...
|
...
|
@@ -54,9 +54,15 @@ var $accountInput1 = $('#account1'), |
|
|
},
|
|
|
|
|
|
// 图像验证码
|
|
|
passwordCaptchaImg = new Captcha('.captcha-wrap').init(),
|
|
|
$passwordCaptchaWrap = $('.captcha-wrap'),
|
|
|
passwordCaptchaImg = new Captcha('.captcha-wrap', {checkURI: ''}).init(),
|
|
|
isShowCaptchaImg = false,
|
|
|
getPasswordCaptchaImgVal = function() {
|
|
|
return passwordCaptchaImg.getResults();
|
|
|
if (isShowCaptchaImg) {
|
|
|
return passwordCaptchaImg.getResults();
|
|
|
}
|
|
|
|
|
|
return '';
|
|
|
},
|
|
|
|
|
|
// 短信验证码
|
...
|
...
|
@@ -288,7 +294,12 @@ accountChangeEvent.add(function(type) { |
|
|
}
|
|
|
|
|
|
if (type === AccountLoginData.PasswordLogin.name) {
|
|
|
passwordCaptchaImg.refresh();
|
|
|
if (isShowCaptchaImg) {
|
|
|
$passwordCaptchaWrap.removeClass('hide');
|
|
|
passwordCaptchaImg.refresh();
|
|
|
} else {
|
|
|
$passwordCaptchaWrap.addClass('hide');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (type === AccountLoginData.SMSLogin.name) {
|
...
|
...
|
@@ -448,6 +459,16 @@ function validateAccountPasswordLocal() { |
|
|
return defer.promise();
|
|
|
}
|
|
|
|
|
|
function needCaptcha() {
|
|
|
$.get('/passport/login/account', {
|
|
|
account: $accountInput1.val()
|
|
|
}).then(function(result) {
|
|
|
if (result.data && result.data.needCaptcha) {
|
|
|
showPasswordCaptchaImgPic(); // eslint-disable-line
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function validateAccountSmsLocal() {
|
|
|
var account = currentLogin.getAccountVal(),
|
|
|
err;
|
...
|
...
|
@@ -522,7 +543,17 @@ function validatePasswordLocal() { |
|
|
/** ************************************************************************/
|
|
|
|
|
|
function refreshPasswordCaptchaImg() {
|
|
|
return passwordCaptchaImg.refresh();
|
|
|
if (isShowCaptchaImg) {
|
|
|
return passwordCaptchaImg.refresh();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function validatePasswordCaptchaImg() {
|
|
|
if (isShowCaptchaImg) {
|
|
|
return passwordCaptchaImg.check();
|
|
|
}
|
|
|
|
|
|
return $.Deferred().resolve().promise(); // eslint-disable-line
|
|
|
}
|
|
|
|
|
|
/** ************************************************************************/
|
...
|
...
|
@@ -734,6 +765,7 @@ function getDesktopLoginType() { |
|
|
// 密码验证过程
|
|
|
function validateWithPasswordMode() {
|
|
|
return validateAccount()
|
|
|
.then(validatePasswordCaptchaImg)
|
|
|
.then(validatePasswordLocal);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -856,14 +888,19 @@ function loginAsync() { |
|
|
}
|
|
|
} else {
|
|
|
if (currentLogin.type() === 'password') {
|
|
|
if (res.code === 405) {
|
|
|
if (res.code === 405 || (res.data && res.data.needCaptcha)) {
|
|
|
passwordCaptchaImg.showTip(res.message);
|
|
|
showPasswordCaptchaImgPic(); //eslint-disable-line
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
showPasswordTip(res.message);
|
|
|
$passwordInput.addClass('error').val('');
|
|
|
|
|
|
if (res.data && res.data.needCaptcha) {
|
|
|
showPasswordCaptchaImgPic(); // eslint-disable-line
|
|
|
}
|
|
|
|
|
|
} else if (currentLogin.type() === 'sms') {
|
|
|
showCaptchaSmsTip('短信验证码错误');
|
|
|
$captchaSmsInput.addClass('error').val('');
|
...
|
...
|
@@ -876,6 +913,16 @@ function loginAsync() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
function showPasswordCaptchaImgPic() {
|
|
|
if (isShowCaptchaImg) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
isShowCaptchaImg = true;
|
|
|
$passwordCaptchaWrap.removeClass('hide');
|
|
|
passwordCaptchaImg.refresh();
|
|
|
}
|
|
|
|
|
|
function getReferForLogin() {
|
|
|
var vars = {},
|
|
|
hash,
|
...
|
...
|
@@ -946,7 +993,7 @@ $(document).on('click', function(e) { |
|
|
|
|
|
// 邮箱自动完成后失去焦点:仅进行本地格式验证格式;
|
|
|
mailAc($accountInput1, function() {
|
|
|
return currentLogin.validateAccountLocal();
|
|
|
return currentLogin.validateAccountLocal().then(needCaptcha);
|
|
|
});
|
|
|
|
|
|
// 密码输入框事件
|
...
|
...
|
@@ -1034,13 +1081,13 @@ $PhoneLoginSwitcher.on('click', 'div', function() { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
accountChangeEvent.fire(type);
|
|
|
|
|
|
$this.addClass('selected');
|
|
|
$this.siblings().removeClass('selected');
|
|
|
|
|
|
$(AccountLoginData[type].ele).removeClass('hide');
|
|
|
$(AccountLoginData[type].hideEle).addClass('hide');
|
|
|
|
|
|
accountChangeEvent.fire(type);
|
|
|
});
|
|
|
|
|
|
// 切换登录模式:手机登录和二维码登录
|
...
|
...
|
|