seemore-web/js/api.js

140 lines
4.3 KiB
JavaScript

var PATH = 'http://api.seemore.club';
// var PATH = 'http://test.api.seemore.club';
// var PATH = 'http://192.168.10.251:8081';
// var PATH = 'http://192.168.10.252:8081';
function saveContactInfo() {
var affairs = $('.affairs input[type=radio]:checked').val();
var phone = $('#phoneNumber').val();
var params = {
affairs: affairs,
phone: phone
};
$.ajax({
// url: 'http://admin.seemore.club/api/v1/contact/contact',
url: PATH + '/v1/contact/contact',
type: 'POST',
data: JSON.stringify(params),
async: false,
dataType: 'json',
contentType: 'application/json; charset=UTF-8',
success: function (data) {
if (data.c === 200) {
//弹出对话框
$('.dialog').show();
//重置清空处理
$('#phoneNumber').val('');
btn_enable(false);
}
}
})
}
function getCode() {
$('.btn_code').attr('disabled', 'disabled');
$('.btn_code').addClass('off');
var params = {
phoneNumber: $('#phoneNumber').val(),
type: 'REGIST'
}
$.ajax({
url: PATH + '/v1/verification/get',
type: 'POST',
data: JSON.stringify(params),
async: false,
dataType: 'json',
contentType: 'application/json; charset=UTF-8',
success: function (data) {
if (data.c === 200) {
$('.errText').text('');
var count = setInterval(() => {
$('.btn_code').text('重新获取(' + timer + 's)');
timer--;
if (timer < 0) {
clearInterval(count);
timer = 60;
$('.btn_code').removeAttr('disabled');
$('.btn_code').text('获取验证码');
$('.btn_code').removeClass('off');
}
}, 1000);
} else if (data.c === 400) {
$('.errText').text('手机号不能为空');
} else {
$('.btn_code').removeAttr('disabled');
$('.btn_code').removeClass('off');
$('.errText').text(data.m);
}
}
})
}
function inviteRegist(type) {
// console.log(type);
if (vali_Phone() && vali_code() && vali_pwd() && vali_checkInput()) {
$('.btn_regist').text('注册中...');
$('.btn_regist').attr('disabled', 'disabled');
var params = {
username: $('#phoneNumber').val(),
code: $('#code').val(),
inviteId: $('#inviteId').val(),
password: $('#password').val(),
type
};
// console.log(params);
$.ajax({
url: PATH + '/auth/invite',
type: 'POST',
data: JSON.stringify(params),
async: false,
dataType: 'json',
contentType: 'application/json; charset=UTF-8',
success: function (data) {
if (data.c === 200) {
$('#phoneNumber').val('');
$('#code').val('');
$('#password').val('');
$('#dialog_register').show();
$('.btn_regist').text('注册成功');
timer = 60;
$('.btn_code').removeAttr('disabled');
$('.btn_code').text('获取验证码');
$('.btn_code').removeClass('off');
} else {
// $('.btn_regist').removeClass('off');
$('.btn_regist').text('立即注册');
$('.btn_regist').removeAttr('disabled');
$('.errText').text(data.m)
}
}
})
}
}
//包含钻石会员拉新获取结束时间
function get_invite_diamond() {
var endTime = '';
var result = null;
$.ajax({
url: PATH + '/v1/code/conf ',
type: 'POST',
async: false,
dataType: 'json',
contentType: 'application/json; charset=UTF-8',
success: function (data) {
if (data.c === 200) {
$('.invite_diamond').text(data.d.invite_diamond);
endTime = data.d.pull_svip_end_time;
result = data.d
}
}
});
return result
}