...
|
...
|
@@ -69,6 +69,12 @@ var $accountInput1 = $('#account1'), |
|
|
getCaptchaSmsTokenVal = function() { // 短信登录凭证
|
|
|
return $.trim($captchaSmsTokenHideInput.val());
|
|
|
},
|
|
|
$smsCaptchaImgWrapper = $('.sms-captcha-img-wrap'),
|
|
|
$smsCaptchaImgInput = $smsCaptchaImgWrapper.find('#sms-captcha-input'),
|
|
|
$smsCaptchaImgPic = $smsCaptchaImgWrapper.find('#sms-captcha-img'),
|
|
|
getSmsCaptchaImgVal = function() { // 短信登录图形验证码
|
|
|
return $.trim($smsCaptchaImgInput.val());
|
|
|
},
|
|
|
|
|
|
// 区域选择
|
|
|
$countryCodeInput = $('#country-code-hide'),
|
...
|
...
|
@@ -101,6 +107,7 @@ var $accountTip1 = $accountInput1.siblings('.err-tip'), |
|
|
$passwordTip = $passwordInput.siblings('.err-tip'),
|
|
|
$captchaImgTip = $captchaImgInput.siblings('.err-tip'),
|
|
|
$captchaSmsTip = $captchaSmsInput.siblings('.err-tip'),
|
|
|
$smsCaptchaImgTip = $smsCaptchaImgInput.siblings('.err-tip'),
|
|
|
$capsLock = $('#caps-lock');
|
|
|
|
|
|
var mailPhoneRegx = require('../common/mail-phone-regx'), // 邮箱格式验证
|
...
|
...
|
@@ -109,6 +116,9 @@ var mailPhoneRegx = require('../common/mail-phone-regx'), // 邮箱格式验证 |
|
|
// 图像验证码URL
|
|
|
var CAPTCHA_IMG_URL = '/passport/imagesNode?t=';
|
|
|
|
|
|
// 刷新手机短信图形验证码
|
|
|
var refreshSmsImgCallBack = $.Callbacks(); // eslint-disable-line
|
|
|
|
|
|
// 记住我符号
|
|
|
var checkboxSymbol = {
|
|
|
checked: '',
|
...
|
...
|
@@ -253,30 +263,34 @@ accountChangeEvent.add(function(type) { |
|
|
|
|
|
// 重置状态
|
|
|
accountChangeEvent.add(function(type) {
|
|
|
//hideAccountTip1(); // eslint-disable-line
|
|
|
//hideAccountTip2(); // eslint-disable-line
|
|
|
//hideCaptchaImgTip(); // eslint-disable-line
|
|
|
//hideCaptchaSmsTip(); // eslint-disable-line
|
|
|
//hidePasswordTip(); // eslint-disable-line
|
|
|
//
|
|
|
//$passwordInput.val('');
|
|
|
//$captchaImgInput.val('');
|
|
|
//$captchaSmsInput.val('');
|
|
|
//$captchaSmsTokenHideInput.val('');
|
|
|
//
|
|
|
//if (type === AccountLoginData.QRCodeLogin.name) {
|
|
|
// $qrCodeOverLayer.empty();
|
|
|
// initQrCode(); // eslint-disable-line
|
|
|
//}
|
|
|
hideAccountTip1(); // eslint-disable-line
|
|
|
hideAccountTip2(); // eslint-disable-line
|
|
|
hideCaptchaImgTip(); // eslint-disable-line
|
|
|
hideCaptchaSmsTip(); // eslint-disable-line
|
|
|
hidePasswordTip(); // eslint-disable-line
|
|
|
hideSmsCaptchaImgTip(); // eslint-disable-line
|
|
|
|
|
|
$passwordInput.val('');
|
|
|
$captchaImgInput.val('');
|
|
|
|
|
|
$captchaSmsInput.val('');
|
|
|
$smsCaptchaImgInput.val('');
|
|
|
$captchaSmsTokenHideInput.val('');
|
|
|
|
|
|
if (type === AccountLoginData.QRCodeLogin.name) {
|
|
|
$qrCodeOverLayer.empty();
|
|
|
initQrCode(); // eslint-disable-line
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 保留已输入的帐号信息
|
|
|
accountChangeEvent.add(function(type) {
|
|
|
//if (type === AccountLoginData.SMSLogin.name) {
|
|
|
// $accountInput2.val($accountInput1.val());
|
|
|
//} else {
|
|
|
// $accountInput1.val($accountInput2.val());
|
|
|
//}
|
|
|
if (type === AccountLoginData.SMSLogin.name) {
|
|
|
$accountInput2.val($accountInput1.val());
|
|
|
$smsCaptchaImgPic.attr('src', CAPTCHA_IMG_URL + $.now());
|
|
|
} else {
|
|
|
$accountInput1.val($accountInput2.val());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
desktopTipShowOnce.add(function() {
|
...
|
...
|
@@ -287,6 +301,10 @@ mobileTipShowOnce.add(function() { |
|
|
$deviceTips.removeClass('hide');
|
|
|
});
|
|
|
|
|
|
refreshSmsImgCallBack.add(function() {
|
|
|
$smsCaptchaImgPic.attr('src', CAPTCHA_IMG_URL + $.now());
|
|
|
});
|
|
|
|
|
|
/** ************************************************************************/
|
|
|
/* 加载自定义库 */
|
|
|
/** ************************************************************************/
|
...
|
...
|
@@ -321,6 +339,7 @@ function hideAccountTip1() { |
|
|
}
|
|
|
|
|
|
function showAccountTip2(msg) {
|
|
|
refreshSmsImgCallBack.fire();
|
|
|
return errTipShow($accountTip2, $accountInput2, msg);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -351,6 +370,7 @@ function hideCaptchaImgTip() { |
|
|
/** ************************************************************************/
|
|
|
|
|
|
function showCaptchaSmsTip(msg) {
|
|
|
refreshSmsImgCallBack.fire();
|
|
|
return errTipShow($captchaSmsTip, $captchaSmsInput, msg);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -360,6 +380,17 @@ function hideCaptchaSmsTip() { |
|
|
|
|
|
/** ************************************************************************/
|
|
|
|
|
|
function showSmsCaptchaImgTip(msg) {
|
|
|
refreshSmsImgCallBack.fire();
|
|
|
return errTipShow($smsCaptchaImgTip, $smsCaptchaImgInput, msg);
|
|
|
}
|
|
|
|
|
|
function hideSmsCaptchaImgTip() {
|
|
|
return errTipHide($smsCaptchaImgTip, $smsCaptchaImgInput);
|
|
|
}
|
|
|
|
|
|
/** ************************************************************************/
|
|
|
|
|
|
function showQrCodeFailTip(msg) {
|
|
|
hideQrCodeTip(); // eslint-disable-line
|
|
|
$qrCodeOverLayer.addClass('qrcode-overlay-fail');
|
...
|
...
|
@@ -654,6 +685,70 @@ function sendCaptchaSmsAsync() { |
|
|
}
|
|
|
|
|
|
/** ************************************************************************/
|
|
|
/* 短信验证图形验证 */
|
|
|
/** ************************************************************************/
|
|
|
|
|
|
function smsCaptchaImgLocal() {
|
|
|
var captcha = getSmsCaptchaImgVal(),
|
|
|
err;
|
|
|
|
|
|
var defer = $.Deferred(); // eslint-disable-line
|
|
|
|
|
|
if (captcha !== '') {
|
|
|
if (captcha.length !== 4) {
|
|
|
err = '请输入长度为4字符的验证码';
|
|
|
|
|
|
defer.reject();
|
|
|
} else {
|
|
|
|
|
|
defer.resolve();
|
|
|
}
|
|
|
} else {
|
|
|
err = '请输入验证码';
|
|
|
|
|
|
defer.reject();
|
|
|
}
|
|
|
|
|
|
if (defer.state() === 'resolved') {
|
|
|
hideSmsCaptchaImgTip();
|
|
|
} else {
|
|
|
showSmsCaptchaImgTip(err);
|
|
|
}
|
|
|
|
|
|
return defer.promise();
|
|
|
}
|
|
|
|
|
|
function smsCaptchaImgAsync() {
|
|
|
return $.ajax({
|
|
|
url: '/passport/captcha/img',
|
|
|
type: 'POST',
|
|
|
data: {
|
|
|
verifyCode: getSmsCaptchaImgVal()
|
|
|
}
|
|
|
}).then(function(result) {
|
|
|
var defer = $.Deferred(); // eslint-disable-line
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
hideSmsCaptchaImgTip();
|
|
|
|
|
|
defer.resolve();
|
|
|
} else {
|
|
|
showSmsCaptchaImgTip('验证码不正确');
|
|
|
|
|
|
defer.reject();
|
|
|
}
|
|
|
|
|
|
return defer.promise();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function validateSmsCaptchaImg() {
|
|
|
smsCaptchaImgLocal()
|
|
|
.then(smsCaptchaImgAsync)
|
|
|
.then(hideSmsCaptchaImgTip);
|
|
|
}
|
|
|
|
|
|
/** ************************************************************************/
|
|
|
/* 二维码验证 */
|
|
|
/** ************************************************************************/
|
|
|
|
...
|
...
|
@@ -753,8 +848,8 @@ function validateWithPasswordMode() { |
|
|
// 短信验证过程
|
|
|
function validateWithSmsMode() {
|
|
|
return validateAccount()
|
|
|
.then(validateCaptchaSms)
|
|
|
.then(validateCaptchaImg);
|
|
|
.then(validateSmsCaptchaImg)
|
|
|
.then(validateCaptchaSms);
|
|
|
}
|
|
|
|
|
|
/** ************************************************************************/
|
...
|
...
|
@@ -800,7 +895,8 @@ function prePasswordLoginWithValidate() { |
|
|
function preSmsLoginWithValidate() {
|
|
|
return (function() {
|
|
|
var account = currentLogin.getAccountVal(),
|
|
|
password = getCaptchaSmsVal();
|
|
|
password = getCaptchaSmsVal(),
|
|
|
smsImg = getSmsCaptchaImgVal();
|
|
|
|
|
|
var defer = $.Deferred(); // eslint-disable-line
|
|
|
|
...
|
...
|
@@ -810,6 +906,12 @@ function preSmsLoginWithValidate() { |
|
|
defer.reject();
|
|
|
}
|
|
|
|
|
|
if (smsImg === '') {
|
|
|
showSmsCaptchaImgTip('请输入图形证码');
|
|
|
|
|
|
defer.reject();
|
|
|
}
|
|
|
|
|
|
if (password === '') {
|
|
|
showCaptchaSmsTip('请输入短信验证码');
|
|
|
|
...
|
...
|
@@ -844,7 +946,7 @@ function loginAsync() { |
|
|
areaCode: getAreaCodeVal(),
|
|
|
account: currentLogin.getAccountVal(),
|
|
|
password: currentLogin.creditableToken(),
|
|
|
captcha: getCaptchaImgVal(),
|
|
|
captcha: currentLogin.type() === 'password' ? getCaptchaImgVal() : getSmsCaptchaImgVal(),
|
|
|
isRemember: getRememberMeVal(),
|
|
|
loginType: currentLogin.type()
|
|
|
}
|
...
|
...
|
@@ -871,7 +973,6 @@ function loginAsync() { |
|
|
} else if (currentLogin.type() === 'sms') {
|
|
|
showCaptchaSmsTip('短信验证码错误');
|
|
|
$captchaSmsInput.addClass('error').val('');
|
|
|
|
|
|
} else if (currentLogin.type() === 'qrcode') {
|
|
|
showQrCodeFailTip(QR_CODE_ERR.fail);
|
|
|
}
|
...
|
...
|
@@ -891,27 +992,6 @@ function showCaptchaImgPic() { |
|
|
$captchaImgWrapper.removeClass('hide');
|
|
|
}
|
|
|
|
|
|
// 检查有效用户,超过三次会有验证操作进行
|
|
|
function authUntilThreeTimesAsync() {
|
|
|
return $.ajax({
|
|
|
url: '/passport/login/account',
|
|
|
type: 'GET',
|
|
|
data: {
|
|
|
account: currentLogin.getAccountVal()
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
var defer = $.Deferred(); // eslint-disable-line
|
|
|
|
|
|
if (res.data && res.data.needCaptcha) {
|
|
|
defer.resolve();
|
|
|
} else {
|
|
|
defer.reject();
|
|
|
}
|
|
|
|
|
|
return defer.promise();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 设置 refer 信息
|
|
|
function setRefer() {
|
|
|
var refer = queryString().refer || '', // eslint-disable-line
|
...
|
...
|
@@ -973,17 +1053,6 @@ mailAc($accountInput1, function() { |
|
|
return currentLogin.validateAccountLocal();
|
|
|
});
|
|
|
|
|
|
// 短信下手机输入框失去焦点:
|
|
|
// 1. 本地验证格式;2.服务器检查用户是否注册;3.始终检查验证用户次数
|
|
|
$accountInput2.on('blur', function() {
|
|
|
return currentLogin.validateAccountLocal().then(function() {
|
|
|
return currentLogin.validateAccountAsync()
|
|
|
.always(function() {
|
|
|
return authUntilThreeTimesAsync().then(showCaptchaImgPic);
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 密码输入框事件
|
|
|
$passwordInput.on('blur', function() {
|
|
|
validatePasswordLocal();
|
...
|
...
|
@@ -1007,6 +1076,19 @@ $passwordInput.on('blur', function() { |
|
|
// 图像验证码输入框事件
|
|
|
$captchaImgInput.on('blur', validateCaptchaImg);
|
|
|
|
|
|
|
|
|
/** ************************************************************************/
|
|
|
|
|
|
// 短信下手机输入框失去焦点:本地验证格式
|
|
|
$accountInput2.on('blur', function() {
|
|
|
return currentLogin.validateAccountLocal();
|
|
|
});
|
|
|
|
|
|
// 图形验证码失去焦点验证
|
|
|
$smsCaptchaImgInput.on('blur', function() {
|
|
|
validateSmsCaptchaImg();
|
|
|
});
|
|
|
|
|
|
// sms验证码输入框事件
|
|
|
$captchaSmsInput.on('blur', validateCaptchaSms);
|
|
|
|
...
|
...
|
@@ -1049,6 +1131,11 @@ $captchaImgWrapper.on('click', '.change-captcha, .captcha-img', function() { |
|
|
$captchaImgPic.attr('src', CAPTCHA_IMG_URL + $.now());
|
|
|
});
|
|
|
|
|
|
// 刷新短信图形验证码
|
|
|
$smsCaptchaImgWrapper.on('click', '.change-captcha, .captcha-img', function() {
|
|
|
$smsCaptchaImgPic.attr('src', CAPTCHA_IMG_URL + $.now());
|
|
|
});
|
|
|
|
|
|
// 切换登录模式:密码登录和短信登录
|
|
|
$PhoneLoginSwitcher.on('click', 'div', function() {
|
|
|
var $this = $(this),
|
...
|
...
|
@@ -1073,38 +1160,34 @@ $deviceSwitcher.on('click', function() { |
|
|
$parent = $this.parent(),
|
|
|
type = $parent.data('type');
|
|
|
|
|
|
// 二维码登录
|
|
|
//$deviceTips.addClass('hide'); // 提示一直隐藏
|
|
|
//
|
|
|
//$(deviceLoginData[type].ele).removeClass('hide');
|
|
|
//$(deviceLoginData[type].hideEle).addClass('hide');
|
|
|
//
|
|
|
//$parent.data('type', deviceLoginData[type].dataType);
|
|
|
//$parent.find('#device-tip').html(deviceLoginData[type].tipText);
|
|
|
//
|
|
|
//$this.removeClass(deviceLoginData[type].removeClass)
|
|
|
// .addClass(deviceLoginData[type].bgClass);
|
|
|
// end 二维码登录结束
|
|
|
$deviceTips.addClass('hide'); // 提示一直隐藏
|
|
|
|
|
|
$(deviceLoginData[type].ele).removeClass('hide');
|
|
|
$(deviceLoginData[type].hideEle).addClass('hide');
|
|
|
|
|
|
$parent.data('type', deviceLoginData[type].dataType);
|
|
|
$parent.find('#device-tip').html(deviceLoginData[type].tipText);
|
|
|
|
|
|
$this.removeClass(deviceLoginData[type].removeClass)
|
|
|
.addClass(deviceLoginData[type].bgClass);
|
|
|
|
|
|
if (type === 'DesktopLogin') {
|
|
|
//desktopTipShowOnce.fire();
|
|
|
desktopTipShowOnce.fire();
|
|
|
|
|
|
// 还原桌面登录方式
|
|
|
accountChangeEvent.fire(getDesktopLoginType());
|
|
|
|
|
|
//stopPollingQrCodeTimer();
|
|
|
stopPollingQrCodeTimer();
|
|
|
} else {
|
|
|
mobileTipShowOnce.fire();
|
|
|
|
|
|
accountChangeEvent.fire('QRCodeLogin');
|
|
|
|
|
|
refreshQrCodeAsync().then(pollingThisQrCodeStatusAsync);
|
|
|
}
|
|
|
//} else {
|
|
|
// mobileTipShowOnce.fire();
|
|
|
//
|
|
|
// accountChangeEvent.fire('QRCodeLogin');
|
|
|
//
|
|
|
// refreshQrCodeAsync().then(pollingThisQrCodeStatusAsync);
|
|
|
//}
|
|
|
});
|
|
|
|
|
|
// 鼠标移动到上面
|
|
|
// 鼠标移动到二维码上面
|
|
|
$qrCodeHoverPanel.hover(function() {
|
|
|
$qrCodeContainer.stop(false, true).animate({left: '-=65'}, {
|
|
|
complete: function() {
|
...
|
...
|
|