|
|
@@ -8,47 +8,122 @@
|
|
|
$(document).ready(function () {
|
|
|
let referer = scUrlUtil.GetQueryString('referer');
|
|
|
|
|
|
- $("#login").click(function () {
|
|
|
- if (!valid()) {
|
|
|
- return false;
|
|
|
+ // 载入时先获取相关参数
|
|
|
+ $.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);
|
|
|
}
|
|
|
- let account = $("#inputEmail").val();
|
|
|
- let pw = $("#inputPassword").val();
|
|
|
+ });
|
|
|
|
|
|
- $.ajax({
|
|
|
- url: '/login',
|
|
|
- type: 'post',
|
|
|
- data: {"account": account, "pw": pw},
|
|
|
- success: function (response) {
|
|
|
- if (response.error === 0) {
|
|
|
- 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 handler = function(captchaObj) {
|
|
|
+ captchaObj.appendTo('#captcha-box');
|
|
|
+ captchaObj.onSuccess(function () {
|
|
|
+ $(".btn-area").slideDown("fast");
|
|
|
+ $('#login').click();
|
|
|
+ captchaObj.getValidate();
|
|
|
+ });
|
|
|
+
|
|
|
+ $("#login").click(function () {
|
|
|
+ if (!valid()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let account = $("#inputEmail").val();
|
|
|
+ let pw = $("#inputPassword").val();
|
|
|
+
|
|
|
+ // 判断输入的邮箱/手机是否格式正确
|
|
|
+ if(/^1[3456789]\d{9}$/.test(account) || /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(account)) {
|
|
|
+ // 先判断是否是专业版用户,是的话弹出短信验证
|
|
|
+ $.ajax({
|
|
|
+ url: '/accountIsPro',
|
|
|
+ type: 'post',
|
|
|
+ async: true,
|
|
|
+ data: {"account": account, "pw": pw},
|
|
|
+ success: function (response) {
|
|
|
+ if (response.error === 0) {
|
|
|
+ const ispro = response.result;
|
|
|
+ if (!ispro) {
|
|
|
+ login(captchaObj);
|
|
|
+ } else {
|
|
|
+ $('#phonepass').modal('show');
|
|
|
+ $('#proMobile').val(response.data);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let msg = response.msg !== undefined ? response.msg : '未知错误';
|
|
|
+ showError(msg, $("input"));
|
|
|
}
|
|
|
- console.log(response.compilation_list);
|
|
|
- setVersion(response.compilation_list);
|
|
|
- $('#ver').modal('show');
|
|
|
}
|
|
|
- } else if(response.error === 2) {
|
|
|
- $('#check_ssoId').val(response.ssoId);
|
|
|
- $('#phone').modal('show');
|
|
|
- } else {
|
|
|
- let msg = response.msg !== undefined ? response.msg : '未知错误';
|
|
|
- showError(msg, $("input"));
|
|
|
- }
|
|
|
- },
|
|
|
- error: function (result) {
|
|
|
- showError('内部程序错误', null);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $('#emailHelp').text('您输入的 邮箱/手机 格式不对');
|
|
|
}
|
|
|
});
|
|
|
- });
|
|
|
+
|
|
|
+ $('#loginPro').click(function () {
|
|
|
+ if ($('#smsCode').val() === '') {
|
|
|
+ showValidError('请输入验证码',$('#smsCode'));
|
|
|
+ } else {
|
|
|
+ login(captchaObj);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#check-code').click(function () {
|
|
|
+ const mobile = $("#mobile").val();
|
|
|
+ const ssoId = $("#check_ssoId").val();
|
|
|
+ const code = $("#code").val();
|
|
|
+ if(!validMobile(mobile)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(ssoId === undefined || ssoId === '') {
|
|
|
+ showValidError('账号有误!', $('#code'));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if($.trim(code) === '') {
|
|
|
+ showValidError('验证码不能为空!', $('#code'));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ url: '/sms/mobile',
|
|
|
+ type: 'post',
|
|
|
+ data: {ssoId: ssoId, mobile: mobile, code: code},
|
|
|
+ error: function() {
|
|
|
+ showValidError('接口出错!',$('#code'));
|
|
|
+ },
|
|
|
+ beforeSend: function() {
|
|
|
+ },
|
|
|
+ success: function(response) {
|
|
|
+ if (response.err === 0) {
|
|
|
+ $("#login").click();
|
|
|
+ $('#phone').modal('hide');
|
|
|
+ } else {
|
|
|
+ showValidError(response.msg,$('#code'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
$("input").blur(function () {
|
|
|
cleanError();
|
|
|
@@ -86,43 +161,90 @@ $(document).ready(function () {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- $('#check-code').click(function () {
|
|
|
- const mobile = $("#mobile").val();
|
|
|
- const ssoId = $("#check_ssoId").val();
|
|
|
- const code = $("#code").val();
|
|
|
- if(!validMobile(mobile)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if(ssoId === undefined || ssoId === '') {
|
|
|
- showValidError('账号有误!', $('#code'));
|
|
|
+ $("#get-code2").click(function() {
|
|
|
+ const mobile = $("#proMobile").val();
|
|
|
+ if(!validMobile(mobile)){
|
|
|
return false;
|
|
|
}
|
|
|
- if($.trim(code) === '') {
|
|
|
- showValidError('验证码不能为空!', $('#code'));
|
|
|
- return false;
|
|
|
+ const btn = $(this);
|
|
|
+ if(!btn.hasClass('disabled')){
|
|
|
+ $.ajax({
|
|
|
+ url: '/sms/code',
|
|
|
+ type: 'post',
|
|
|
+ data: { mobile: mobile, type: 3},
|
|
|
+ error: function() {
|
|
|
+ showValidError('短信接口出错!',$('#smsCode'));
|
|
|
+ },
|
|
|
+ beforeSend: function() {
|
|
|
+ },
|
|
|
+ success: function(response) {
|
|
|
+ if (response.err === 0) {
|
|
|
+ codeSuccess(btn);
|
|
|
+ } else {
|
|
|
+ showValidError(response.msg,$('#smsCode'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- $.ajax({
|
|
|
- url: '/sms/mobile',
|
|
|
- type: 'post',
|
|
|
- data: {ssoId: ssoId, mobile: mobile, code: code},
|
|
|
- error: function() {
|
|
|
- showValidError('接口出错!',$('#code'));
|
|
|
- },
|
|
|
- beforeSend: function() {
|
|
|
- },
|
|
|
- success: function(response) {
|
|
|
- if (response.err === 0) {
|
|
|
- $("#login").click();
|
|
|
- $('#phone').modal('hide');
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+function login(captchaObj) {
|
|
|
+ let account = $("#inputEmail").val();
|
|
|
+ let pw = $("#inputPassword").val();
|
|
|
+ let geetest_challenge = $('input[name="geetest_challenge"]').val();
|
|
|
+ let geetest_validate = $('input[name="geetest_validate"]').val();
|
|
|
+ let geetest_seccode = $('input[name="geetest_seccode"]').val();
|
|
|
+ let code = $("#smsCode").val();
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url: '/login',
|
|
|
+ type: 'post',
|
|
|
+ data: {
|
|
|
+ "account": account,
|
|
|
+ "pw": pw,
|
|
|
+ "geetest_challenge": geetest_challenge,
|
|
|
+ "geetest_validate": geetest_validate,
|
|
|
+ "geetest_seccode": geetest_seccode,
|
|
|
+ "code": code,
|
|
|
+ },
|
|
|
+ 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 {
|
|
|
- showValidError(response.msg,$('#code'));
|
|
|
+ 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');
|
|
|
+ } else if(response.error === 3) {
|
|
|
+ showValidError(response.msg,$('#smsCode'));
|
|
|
+ } else {
|
|
|
+ $('#phonepass').modal('hide');
|
|
|
+ let msg = response.msg !== undefined ? response.msg : '未知错误';
|
|
|
+ showError(msg, $("input"));
|
|
|
+ captchaObj.reset();
|
|
|
}
|
|
|
- })
|
|
|
-
|
|
|
+ },
|
|
|
+ error: function (result) {
|
|
|
+ showError('内部程序错误', null);
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
-});
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* 获取成功后的操作
|
|
|
@@ -224,7 +346,7 @@ function showError(msg, element) {
|
|
|
if (element !== null) {
|
|
|
element.parent().addClass('has-danger');
|
|
|
}
|
|
|
- $("#message").text(msg);
|
|
|
+ $("#message").html(msg);
|
|
|
$("#error-tips").show("fast");
|
|
|
}
|
|
|
|
|
|
@@ -261,4 +383,4 @@ function setVersion(versionData) {
|
|
|
html += tmpHtml;
|
|
|
}
|
|
|
$("#version-area").html(html);
|
|
|
-}
|
|
|
+}
|