|
|
@@ -50,39 +50,54 @@ $(document).ready(function () {
|
|
|
if (!valid()) {
|
|
|
return false;
|
|
|
}
|
|
|
- let account = $("#inputEmail").val();
|
|
|
+ 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);
|
|
|
+ } else {
|
|
|
+ $('#emailHelp').text('您输入的 邮箱/手机 格式不对');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let account = $("#mobileLogin").val();
|
|
|
+ if(/^1[3456789]\d{9}$/.test(account)) {
|
|
|
+ login(captchaObj);
|
|
|
+ } else {
|
|
|
+ $('#phoneHelp').text('您输入的 手机 格式不对');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 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);
|
|
|
- // $('#pro_mobile').text(response.data.substr(0, 3) + '****' + response.data.substr(7, 11));
|
|
|
- // }
|
|
|
- // } else if(response.error === 2) {
|
|
|
- // $('#check_ssoId').val(response.ssoId);
|
|
|
- // $('#phone').modal('show');
|
|
|
- // } else {
|
|
|
- // let msg = response.msg !== undefined ? response.msg : '未知错误';
|
|
|
- // showError(msg, $("input"));
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- } else {
|
|
|
- $('#emailHelp').text('您输入的 邮箱/手机 格式不对');
|
|
|
- }
|
|
|
+ // 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);
|
|
|
+ // $('#pro_mobile').text(response.data.substr(0, 3) + '****' + response.data.substr(7, 11));
|
|
|
+ // }
|
|
|
+ // } else if(response.error === 2) {
|
|
|
+ // $('#check_ssoId').val(response.ssoId);
|
|
|
+ // $('#phone').modal('show');
|
|
|
+ // } else {
|
|
|
+ // let msg = response.msg !== undefined ? response.msg : '未知错误';
|
|
|
+ // showError(msg, $("input"));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // });
|
|
|
+ // } else {
|
|
|
+ // $('#emailHelp').text('您输入的 邮箱/手机 格式不对');
|
|
|
+ // }
|
|
|
});
|
|
|
|
|
|
// $('#loginPro').click(function () {
|
|
|
@@ -172,53 +187,111 @@ $(document).ready(function () {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // $("#get-code2").click(function() {
|
|
|
- // const mobile = $("#proMobile").val();
|
|
|
- // if(!validMobile(mobile)){
|
|
|
- // 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'));
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
- // });
|
|
|
+ // 切换登录方式
|
|
|
+ $('#changeLogin').click(function () {
|
|
|
+ if ($(this).attr('data-status') === 'user') {
|
|
|
+ $(this).attr('data-status', 'sms');
|
|
|
+ $('.change-login-p').text('短信登录');
|
|
|
+ $(this).text('账号登录');
|
|
|
+ $('.sms-login-modal').show();
|
|
|
+ $('.user-login-modal').hide();
|
|
|
+ $('.sms-login-modal input').attr('disabled', false);
|
|
|
+ $('.user-login-modal input').attr('disabled', true);
|
|
|
+ } else {
|
|
|
+ $(this).attr('data-status', 'user');
|
|
|
+ $('.change-login-p').text('账号登录');
|
|
|
+ $(this).text('短信登录');
|
|
|
+ $('.sms-login-modal').hide();
|
|
|
+ $('.user-login-modal').show();
|
|
|
+ $('.sms-login-modal input').attr('disabled', true);
|
|
|
+ $('.user-login-modal input').attr('disabled', false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 切换到短信登录
|
|
|
+ $('#changeSmsLogin').click(function () {
|
|
|
+ $('#changeLogin').attr('data-status', 'sms');
|
|
|
+ $('.change-login-p').text('短信登录');
|
|
|
+ $('#changeLogin').text('账号登录');
|
|
|
+ $('.sms-login-modal').show();
|
|
|
+ $('.user-login-modal').hide();
|
|
|
+ $('.sms-login-modal input').attr('disabled', false);
|
|
|
+ $('.user-login-modal input').attr('disabled', true);
|
|
|
+ $('#phonepass').modal('hide');
|
|
|
+ });
|
|
|
+
|
|
|
+ $("#get-code2").click(function() {
|
|
|
+ const mobile = $("#mobileLogin").val();
|
|
|
+ if(!validMobile(mobile, 0)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const btn = $(this);
|
|
|
+ if(!btn.hasClass('disabled')){
|
|
|
+ // 判断该手机号是否已注册通行账号
|
|
|
+ $.ajax({
|
|
|
+ url: '/sms/check/mobile',
|
|
|
+ type: 'post',
|
|
|
+ data: {mobile: mobile},
|
|
|
+ error: function() {
|
|
|
+ $('#phoneHelp').text('号码查询接口出错!');
|
|
|
+ },
|
|
|
+ beforeSend: function() {
|
|
|
+ },
|
|
|
+ success: function(response) {
|
|
|
+ if (response.err === 0) {
|
|
|
+ $.ajax({
|
|
|
+ url: '/sms/code',
|
|
|
+ type: 'post',
|
|
|
+ data: { mobile: mobile, type: 3},
|
|
|
+ error: function() {
|
|
|
+ $('#phoneHelp').text('短信接口出错!');
|
|
|
+ },
|
|
|
+ beforeSend: function() {
|
|
|
+ },
|
|
|
+ success: function(response) {
|
|
|
+ if (response.err === 0) {
|
|
|
+ codeSuccess(btn);
|
|
|
+ } else {
|
|
|
+ $('#phoneHelp').text(response.msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $('#phoneHelp').text(response.msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
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();
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
|
|
|
$.ajax({
|
|
|
url: '/login',
|
|
|
type: 'post',
|
|
|
- data: {
|
|
|
- "account": account,
|
|
|
- "pw": pw,
|
|
|
- "geetest_challenge": geetest_challenge,
|
|
|
- "geetest_validate": geetest_validate,
|
|
|
- "geetest_seccode": geetest_seccode,
|
|
|
- // "code": code,
|
|
|
- },
|
|
|
+ data: postData,
|
|
|
success: function (response) {
|
|
|
if (response.error === 0) {
|
|
|
// $('#phonepass').modal('hide');
|
|
|
@@ -242,8 +315,10 @@ function login(captchaObj) {
|
|
|
captchaObj.reset();
|
|
|
$('#check_ssoId').val(response.ssoId);
|
|
|
$('#phone').modal('show');
|
|
|
- // } else if(response.error === 3) {
|
|
|
- // showValidError(response.msg,$('#smsCode'));
|
|
|
+ } else if(response.error === 3) {
|
|
|
+ captchaObj.reset();
|
|
|
+ $('#phonepass').modal('show');
|
|
|
+ $('#mobileLogin').val(response.data);
|
|
|
} else {
|
|
|
// $('#phonepass').modal('hide');
|
|
|
let msg = response.msg !== undefined ? response.msg : '未知错误';
|
|
|
@@ -286,15 +361,23 @@ function codeSuccess(btn) {
|
|
|
*
|
|
|
* @return {boolean}
|
|
|
*/
|
|
|
-function validMobile(mobile) {
|
|
|
+function validMobile(mobile, status = 1) {
|
|
|
let result = true;
|
|
|
if($.trim(mobile) === ''){
|
|
|
- showValidError('手机号不能为空!',$('#mobile'));
|
|
|
+ if (status === 1) {
|
|
|
+ showValidError('手机号不能为空!',$('#mobile'));
|
|
|
+ } else {
|
|
|
+ $('#phoneHelp').text('手机号不能为空!');
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
- let mobileValid = /^1[3456789]\d{9}$/;
|
|
|
+ let mobileValid = /^1[3456789]\d{9}$/;
|
|
|
if(!mobileValid.test(mobile)){
|
|
|
- showValidError('手机号码格式有误!',$('#mobile'));
|
|
|
+ if (status === 1) {
|
|
|
+ showValidError('手机号码格式有误!',$('#mobile'));
|
|
|
+ } else {
|
|
|
+ $('#phoneHelp').text('手机号码格式有误!');
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
return result;
|
|
|
@@ -331,18 +414,32 @@ function cleanValidError(element) {
|
|
|
*/
|
|
|
function valid() {
|
|
|
let result = true;
|
|
|
- let account = $("#inputEmail").val();
|
|
|
- if (account === undefined || account === '') {
|
|
|
- showError('用户名不能为空!', $("#inputEmail"));
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if ($('#changeLogin').attr('data-status') === 'user') {
|
|
|
+ let account = $("#inputEmail").val();
|
|
|
+ if (account === undefined || account === '') {
|
|
|
+ showError('用户名不能为空!', $("#inputEmail"));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- let password = $("#inputPassword").val();
|
|
|
- if (password === undefined || password === '') {
|
|
|
- showError('密码不能为空!', $("#inputPassword"));
|
|
|
- return false;
|
|
|
+ let password = $("#inputPassword").val();
|
|
|
+ if (password === undefined || password === '') {
|
|
|
+ showError('密码不能为空!', $("#inputPassword"));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let mobile = $('#mobileLogin').val();
|
|
|
+ if (mobile === undefined || mobile === '') {
|
|
|
+ showError('手机号码不能为空!', $("#mobileLogin"));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let code = $('#codeLogin').val();
|
|
|
+ if (code === undefined || code === '') {
|
|
|
+ showError('验证码不能为空!', $("#codeLogin"));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|