...
|
...
|
@@ -33,11 +33,8 @@ |
|
|
|
|
|
var $ = require('yoho-jquery'),
|
|
|
Captcha = require('../../plugins/captcha'),
|
|
|
GeeCaptcha = require('../../plugins/gee-captcha'),
|
|
|
QRCode = require('../../plugins/qrcode');
|
|
|
|
|
|
var needGeeCaptcha = $('.gee-captcha').length;
|
|
|
|
|
|
// 密码输入帐号
|
|
|
var $accountInput1 = $('#account1'),
|
|
|
getAccountVal1 = function() {
|
...
|
...
|
@@ -57,11 +54,9 @@ var $accountInput1 = $('#account1'), |
|
|
},
|
|
|
|
|
|
// 图像验证码
|
|
|
$captchaImgWrapper = $('.captcha-wrap'),
|
|
|
captchaImg = needGeeCaptcha ? new GeeCaptcha('.captcha-wrap').init() : new Captcha('.captcha-wrap').init(),
|
|
|
$showCaptchaImg = true,
|
|
|
getCaptchaImgVal = function() {
|
|
|
return captchaImg.getResults();
|
|
|
passwordCaptchaImg = new Captcha('.captcha-wrap').init(),
|
|
|
getPasswordCaptchaImgVal = function() {
|
|
|
return passwordCaptchaImg.getResults();
|
|
|
},
|
|
|
|
|
|
// 短信验证码
|
...
|
...
|
@@ -273,7 +268,6 @@ 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
|
|
|
hideSmsCaptchaImgTip(); // eslint-disable-line
|
...
|
...
|
@@ -288,21 +282,12 @@ accountChangeEvent.add(function(type) { |
|
|
initQrCode(); // eslint-disable-line
|
|
|
}
|
|
|
|
|
|
// 密码登录的图形验证码
|
|
|
if (type === AccountLoginData.PasswordLogin.name) {
|
|
|
if ($showCaptchaImg) {
|
|
|
$captchaImgWrapper.removeClass('hide');
|
|
|
|
|
|
$.sleep(500).then(function() {
|
|
|
captchaImg.refresh();
|
|
|
});
|
|
|
}
|
|
|
passwordCaptchaImg.refresh();
|
|
|
}
|
|
|
|
|
|
if (type === AccountLoginData.SMSLogin.name) {
|
|
|
if ($showCaptchaImg) {
|
|
|
$captchaImgWrapper.addClass('hide');
|
|
|
}
|
|
|
smsCaptchaImg.refresh();
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -310,7 +295,6 @@ accountChangeEvent.add(function(type) { |
|
|
accountChangeEvent.add(function(type) {
|
|
|
if (type === AccountLoginData.SMSLogin.name) {
|
|
|
$accountInput2.val($accountInput1.val());
|
|
|
refreshSmsCaptchaImg(); // eslint-disable-line
|
|
|
} else {
|
|
|
$accountInput1.val($accountInput2.val());
|
|
|
}
|
...
|
...
|
@@ -387,12 +371,6 @@ function hidePasswordTip() { |
|
|
|
|
|
/** ************************************************************************/
|
|
|
|
|
|
function hideCaptchaImgTip() {
|
|
|
return captchaImg.hide();
|
|
|
}
|
|
|
|
|
|
/** ************************************************************************/
|
|
|
|
|
|
function showCaptchaSmsTip(msg) {
|
|
|
refreshSmsCaptchaEvent.fire();
|
|
|
return errTipShow($captchaSmsTip, $captchaSmsInput, msg);
|
...
|
...
|
@@ -539,22 +517,9 @@ function validatePasswordLocal() { |
|
|
/** ************************************************************************/
|
|
|
/* 图形验证码 */
|
|
|
/** ************************************************************************/
|
|
|
function validateCaptchaImgAsync() {
|
|
|
return captchaImg.check();
|
|
|
}
|
|
|
|
|
|
function validateCaptchaImg() {
|
|
|
// 验证码不可见的时候验证通过
|
|
|
if ($captchaImgWrapper.is(':hidden')) {
|
|
|
return $.Deferred().resolve().promise(); //eslint-disable-line
|
|
|
}
|
|
|
|
|
|
return validateCaptchaImgAsync()
|
|
|
.then(hideCaptchaSmsTip);
|
|
|
}
|
|
|
|
|
|
function refreshPasswordCaptchaImg() {
|
|
|
return captchaImg.refresh();
|
|
|
return passwordCaptchaImg.refresh();
|
|
|
}
|
|
|
|
|
|
/** ************************************************************************/
|
...
|
...
|
@@ -629,6 +594,8 @@ function validateCaptchaSmsAsync() { |
|
|
}
|
|
|
|
|
|
return defer.promise();
|
|
|
}).always(function() {
|
|
|
refreshSmsCaptchaEvent.fire();
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -674,9 +641,7 @@ function validateSmsCaptchaImg() { |
|
|
}
|
|
|
|
|
|
function refreshSmsCaptchaImg() {
|
|
|
$.sleep(500).then(function() {
|
|
|
smsCaptchaImg.refresh();
|
|
|
});
|
|
|
return smsCaptchaImg.refresh();
|
|
|
}
|
|
|
|
|
|
/** ************************************************************************/
|
...
|
...
|
@@ -768,8 +733,7 @@ function getDesktopLoginType() { |
|
|
// 密码验证过程
|
|
|
function validateWithPasswordMode() {
|
|
|
return validateAccount()
|
|
|
.then(validatePasswordLocal)
|
|
|
.then(validateCaptchaImg);
|
|
|
.then(validatePasswordLocal);
|
|
|
}
|
|
|
|
|
|
// 短信验证过程
|
...
|
...
|
@@ -872,7 +836,7 @@ function loginAsync() { |
|
|
areaCode: getAreaCodeVal(),
|
|
|
account: currentLogin.getAccountVal(),
|
|
|
password: currentLogin.creditableToken(),
|
|
|
verifyCode: currentLogin.type() === 'password' ? getCaptchaImgVal() : '',
|
|
|
verifyCode: currentLogin.type() === 'password' ? getPasswordCaptchaImgVal() : '',
|
|
|
isRemember: getRememberMeVal(),
|
|
|
loginType: currentLogin.type()
|
|
|
}
|
...
|
...
|
@@ -887,9 +851,6 @@ function loginAsync() { |
|
|
showPasswordTip(res.message);
|
|
|
$passwordInput.addClass('error').val('');
|
|
|
|
|
|
if (res.data && res.data.needCaptcha) {
|
|
|
showCaptchaImgPic(); // eslint-disable-line
|
|
|
}
|
|
|
} else if (currentLogin.type() === 'sms') {
|
|
|
showCaptchaSmsTip('短信验证码错误');
|
|
|
$captchaSmsInput.addClass('error').val('');
|
...
|
...
|
@@ -900,14 +861,6 @@ function loginAsync() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
function showCaptchaImgPic() {
|
|
|
captchaImg.refresh().then(function() {
|
|
|
$captchaImgWrapper.removeClass('hide');
|
|
|
});
|
|
|
|
|
|
$showCaptchaImg = true;
|
|
|
}
|
|
|
|
|
|
function getReferForLogin() {
|
|
|
var vars = {},
|
|
|
hash,
|
...
|
...
|
@@ -1023,7 +976,7 @@ $captchaSmsBtn.on('click', function() { |
|
|
.then(function() {
|
|
|
disable60sSendSmsBtn();
|
|
|
return sendCaptchaSmsAsync();
|
|
|
});
|
|
|
}).fail(refreshSmsCaptchaImg);
|
|
|
});
|
|
|
|
|
|
// 记住登录状态
|
...
|
...
|
|