|
@@ -9,42 +9,42 @@ $(document).ready(function () {
|
|
|
let referer = scUrlUtil.GetQueryString('referer');
|
|
|
|
|
|
// 载入时先获取相关参数
|
|
|
- $.ajax({
|
|
|
- url: '/captcha',
|
|
|
- type: 'get',
|
|
|
- data: '',
|
|
|
- timeout: 5000,
|
|
|
- error: function() {
|
|
|
- $("#captcha-box").html('验证码加载失败');
|
|
|
- },
|
|
|
- beforeSend: function() {
|
|
|
- $("#captcha-box").html('正在加载验证码');
|
|
|
- },
|
|
|
- success: function(response) {
|
|
|
- $("#captcha-box").html('');
|
|
|
- if (response.success === 0) {
|
|
|
- alert('验证码初始化失败!');
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- initGeetest({
|
|
|
- // 以下配置参数来自服务端 SDK
|
|
|
- gt: response.gt,
|
|
|
- challenge: response.challenge,
|
|
|
- offline: !response.success,
|
|
|
- new_captcha: response.new_captcha,
|
|
|
- width: '100%'
|
|
|
- }, handler);
|
|
|
- }
|
|
|
- });
|
|
|
+ // $.ajax({
|
|
|
+ // url: '/captcha',
|
|
|
+ // type: 'get',
|
|
|
+ // data: '',
|
|
|
+ // timeout: 5000,
|
|
|
+ // error: function() {
|
|
|
+ // $("#captcha-box").html('验证码加载失败');
|
|
|
+ // },
|
|
|
+ // beforeSend: function() {
|
|
|
+ // $("#captcha-box").html('正在加载验证码');
|
|
|
+ // },
|
|
|
+ // success: function(response) {
|
|
|
+ // $("#captcha-box").html('');
|
|
|
+ // if (response.success === 0) {
|
|
|
+ // alert('验证码初始化失败!');
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // initGeetest({
|
|
|
+ // // 以下配置参数来自服务端 SDK
|
|
|
+ // gt: response.gt,
|
|
|
+ // challenge: response.challenge,
|
|
|
+ // offline: !response.success,
|
|
|
+ // new_captcha: response.new_captcha,
|
|
|
+ // width: '100%'
|
|
|
+ // }, handler);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
|
|
|
- const handler = function(captchaObj) {
|
|
|
- captchaObj.appendTo('#captcha-box');
|
|
|
- captchaObj.onSuccess(function () {
|
|
|
- $(".btn-area").slideDown("fast");
|
|
|
- // $('#login').click();
|
|
|
- // captchaObj.getValidate();
|
|
|
- });
|
|
|
+ // const handler = function(captchaObj) {
|
|
|
+ // captchaObj.appendTo('#captcha-box');
|
|
|
+ // captchaObj.onSuccess(function () {
|
|
|
+ // $(".btn-area").slideDown("fast");
|
|
|
+ // // $('#login').click();
|
|
|
+ // // captchaObj.getValidate();
|
|
|
+ // });
|
|
|
|
|
|
$("#login").click(function () {
|
|
|
if (!valid()) {
|
|
@@ -53,14 +53,14 @@ $(document).ready(function () {
|
|
|
if ($('#changeLogin').attr('data-status') === 'user') {
|
|
|
let account = $("#inputEmail").val();
|
|
|
if(/^1[3456789]\d{9}$/.test(account) || /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(account)) {
|
|
|
- login(captchaObj);
|
|
|
+ login();
|
|
|
} else {
|
|
|
$('#emailHelp').text('您输入的 邮箱/手机 格式不对');
|
|
|
}
|
|
|
} else {
|
|
|
let account = $("#mobileLogin").val();
|
|
|
if(/^1[3456789]\d{9}$/.test(account)) {
|
|
|
- login(captchaObj);
|
|
|
+ login();
|
|
|
} else {
|
|
|
$('#phoneHelp').text('您输入的 手机 格式不对');
|
|
|
}
|
|
@@ -142,7 +142,7 @@ $(document).ready(function () {
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
- };
|
|
|
+ // };
|
|
|
|
|
|
$("input").blur(function () {
|
|
|
cleanError();
|
|
@@ -265,73 +265,117 @@ $(document).ready(function () {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
-function login(captchaObj) {
|
|
|
- $('#login').attr('disabled', true);
|
|
|
- let geetest_challenge = $('input[name="geetest_challenge"]').val();
|
|
|
- let geetest_validate = $('input[name="geetest_validate"]').val();
|
|
|
- let geetest_seccode = $('input[name="geetest_seccode"]').val();
|
|
|
+function login() {
|
|
|
+ $.ajax({
|
|
|
+ url: '/captcha?t='+ (new Date()).getTime(),
|
|
|
+ type: 'get',
|
|
|
+ dataType: 'json',
|
|
|
+ timeout: 5000,
|
|
|
+ error: function() {
|
|
|
+ // $("#captcha-box").html('验证码加载失败');
|
|
|
+ },
|
|
|
+ beforeSend: function() {
|
|
|
+ // $("#captcha-box").html('正在加载验证码');
|
|
|
+ },
|
|
|
+ success: function(response) {
|
|
|
+ $("#captcha-box").html('');
|
|
|
+ if (response.success === 0) {
|
|
|
+ alert('验证码初始化失败!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- const postData = {
|
|
|
- geetest_challenge: geetest_challenge,
|
|
|
- geetest_validate: geetest_validate,
|
|
|
- geetest_seccode: geetest_seccode,
|
|
|
- };
|
|
|
- if ($('#changeLogin').attr('data-status') === 'user') {
|
|
|
- let account = $("#inputEmail").val();
|
|
|
- let pw = $("#inputPassword").val();
|
|
|
- postData.account = account;
|
|
|
- postData.pw = pw;
|
|
|
- } else {
|
|
|
- let mobile = $('#mobileLogin').val();
|
|
|
- let code = $("#codeLogin").val();
|
|
|
- postData.mobile = mobile;
|
|
|
- postData.code = code;
|
|
|
- }
|
|
|
+ initGeetest({
|
|
|
+ // 以下配置参数来自服务端 SDK
|
|
|
+ gt: response.gt,
|
|
|
+ challenge: response.challenge,
|
|
|
+ offline: !response.success,
|
|
|
+ new_captcha: response.new_captcha,
|
|
|
+ // width: '100%',
|
|
|
+ product: "bind"
|
|
|
+ }, function (catpchaObj) {
|
|
|
+ catpchaObj.onReady(function () {
|
|
|
+ catpchaObj.verify();
|
|
|
+ }).onClose(function () {
|
|
|
+ }).onSuccess(function () {
|
|
|
+ /* 延迟到动画结束后再alert */
|
|
|
+ var lastUTC = new Date(), duration = 1100;
|
|
|
+ function _alert(msg) {
|
|
|
+ var elapsed = new Date() - lastUTC;
|
|
|
+ if (elapsed >= duration) { return alert(msg) }
|
|
|
+ setTimeout(function () { alert(msg) }, duration - elapsed);
|
|
|
+ }
|
|
|
+ var result = catpchaObj.getValidate();
|
|
|
+ if (!result) {return alert('请完成验证');}
|
|
|
+ $('#login').attr('disabled', true);
|
|
|
+ let geetest_challenge = $('input[name="geetest_challenge"]').val();
|
|
|
+ let geetest_validate = $('input[name="geetest_validate"]').val();
|
|
|
+ let geetest_seccode = $('input[name="geetest_seccode"]').val();
|
|
|
|
|
|
- $.ajax({
|
|
|
- url: '/login',
|
|
|
- type: 'post',
|
|
|
- data: postData,
|
|
|
- success: function (response) {
|
|
|
- if (response.error === 0) {
|
|
|
- // $('#phonepass').modal('hide');
|
|
|
- const url = response.last_page !== null && response.last_page !== undefined && response.last_page !== '' ?
|
|
|
- response.last_page : '/pm';
|
|
|
- if (response.login_ask === 0) {
|
|
|
- location.href = url;
|
|
|
- } else {
|
|
|
- response.compilation_list = response.compilation_list === undefined || response.compilation_list === '' ?
|
|
|
- null : JSON.parse(response.compilation_list);
|
|
|
- if (response.compilation_list === null || response.compilation_list.length <= 0) {
|
|
|
- location.href = url;
|
|
|
- return false;
|
|
|
+ const postData = {
|
|
|
+ geetest_challenge: geetest_challenge,
|
|
|
+ geetest_validate: geetest_validate,
|
|
|
+ geetest_seccode: geetest_seccode,
|
|
|
+ };
|
|
|
+ if ($('#changeLogin').attr('data-status') === 'user') {
|
|
|
+ let account = $("#inputEmail").val();
|
|
|
+ let pw = $("#inputPassword").val();
|
|
|
+ postData.account = account;
|
|
|
+ postData.pw = pw;
|
|
|
+ } else {
|
|
|
+ let mobile = $('#mobileLogin').val();
|
|
|
+ let code = $("#codeLogin").val();
|
|
|
+ postData.mobile = mobile;
|
|
|
+ postData.code = code;
|
|
|
}
|
|
|
- console.log(response.compilation_list);
|
|
|
- setVersion(response.compilation_list);
|
|
|
- $('#ver').modal('show');
|
|
|
- }
|
|
|
- } else if(response.error === 2) {
|
|
|
- // $('#phonepass').modal('hide');
|
|
|
- // captchaObj.reset();
|
|
|
- $('#check_ssoId').val(response.ssoId);
|
|
|
- $('#phone').modal('show');
|
|
|
- $('#login').removeAttr('disabled');
|
|
|
- } else if(response.error === 3) {
|
|
|
- // captchaObj.reset();
|
|
|
- $('#phonepass').modal('show');
|
|
|
- $('#mobileLogin').val(response.data);
|
|
|
- $('#login').removeAttr('disabled');
|
|
|
- } else {
|
|
|
- // $('#phonepass').modal('hide');
|
|
|
- let msg = response.msg !== undefined ? response.msg : '未知错误';
|
|
|
- showError(msg, $("input"));
|
|
|
- $('#login').removeAttr('disabled');
|
|
|
- // captchaObj.reset();
|
|
|
- }
|
|
|
- },
|
|
|
- error: function (result) {
|
|
|
- showError('内部程序错误', null);
|
|
|
- $('#login').removeAttr('disabled');
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url: '/login',
|
|
|
+ type: 'post',
|
|
|
+ data: postData,
|
|
|
+ success: function (response) {
|
|
|
+ if (response.error === 0) {
|
|
|
+ // $('#phonepass').modal('hide');
|
|
|
+ const url = response.last_page !== null && response.last_page !== undefined && response.last_page !== '' ?
|
|
|
+ response.last_page : '/pm';
|
|
|
+ if (response.login_ask === 0) {
|
|
|
+ location.href = url;
|
|
|
+ } else {
|
|
|
+ response.compilation_list = response.compilation_list === undefined || response.compilation_list === '' ?
|
|
|
+ null : JSON.parse(response.compilation_list);
|
|
|
+ if (response.compilation_list === null || response.compilation_list.length <= 0) {
|
|
|
+ location.href = url;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ console.log(response.compilation_list);
|
|
|
+ setVersion(response.compilation_list);
|
|
|
+ $('#ver').modal('show');
|
|
|
+ }
|
|
|
+ } else if(response.error === 2) {
|
|
|
+ // $('#phonepass').modal('hide');
|
|
|
+ // captchaObj.reset();
|
|
|
+ $('#check_ssoId').val(response.ssoId);
|
|
|
+ $('#phone').modal('show');
|
|
|
+ $('#login').removeAttr('disabled');
|
|
|
+ } else if(response.error === 3) {
|
|
|
+ // captchaObj.reset();
|
|
|
+ $('#phonepass').modal('show');
|
|
|
+ $('#mobileLogin').val(response.data);
|
|
|
+ $('#login').removeAttr('disabled');
|
|
|
+ } else {
|
|
|
+ // $('#phonepass').modal('hide');
|
|
|
+ let msg = response.msg !== undefined ? response.msg : '未知错误';
|
|
|
+ showError(msg, $("input"));
|
|
|
+ $('#login').removeAttr('disabled');
|
|
|
+ // captchaObj.reset();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (result) {
|
|
|
+ showError('内部程序错误', null);
|
|
|
+ $('#login').removeAttr('disabled');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
}
|