...
|
...
|
@@ -14,6 +14,7 @@ let $account = $('#account'), |
|
|
$ways = $('#retrive-pwd-ways'),
|
|
|
|
|
|
$captcha = $('#js-img-check'),
|
|
|
useVerify = $captcha.data('userverify'), // 170406 是否使用验证
|
|
|
|
|
|
accPass = false,
|
|
|
pwdPass = false;
|
...
|
...
|
@@ -25,14 +26,18 @@ let trim = $.trim; |
|
|
let showErrTip = tip.show;
|
|
|
|
|
|
|
|
|
let validate = new Validate($captcha, {
|
|
|
useREM: {
|
|
|
rootFontSize: 40,
|
|
|
picWidth: 150
|
|
|
}
|
|
|
});
|
|
|
let validate = {};
|
|
|
|
|
|
if (useVerify) {
|
|
|
validate = new Validate($captcha, {
|
|
|
useREM: {
|
|
|
rootFontSize: 40,
|
|
|
picWidth: 150
|
|
|
}
|
|
|
});
|
|
|
|
|
|
validate.init();
|
|
|
validate.init();
|
|
|
}
|
|
|
|
|
|
// 登录按钮状态切换
|
|
|
function switchLoginBtnStatus() {
|
...
|
...
|
@@ -60,6 +65,62 @@ function hideRetrivePanel() { |
|
|
$ways.hide();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 登录校验
|
|
|
*/
|
|
|
function loginAuth(params, acc) {
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/login/auth',
|
|
|
data: params,
|
|
|
success: function(data) {
|
|
|
let res,
|
|
|
LOGI_TYPE;
|
|
|
|
|
|
if (acc.indexOf('@') > 0) {
|
|
|
LOGI_TYPE = 8;
|
|
|
} else {
|
|
|
LOGI_TYPE = 5;
|
|
|
}
|
|
|
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_MY_LOGIN_C',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: window._ChannelVary[window.cookie('_Channel')],
|
|
|
LOGI_TYPE: LOGI_TYPE
|
|
|
})
|
|
|
}, true);
|
|
|
}
|
|
|
validate && validate.type === 2 && validate.refresh();
|
|
|
if (data.code === 200) {
|
|
|
res = data.data;
|
|
|
|
|
|
showErrTip('登录成功');
|
|
|
location.href = res.href;
|
|
|
$loginBtn.text('登录成功');
|
|
|
} else {
|
|
|
if (useVerify && data.captchaShow) {
|
|
|
((data.changeCaptcha && validate.type !== 2) && validate.refresh());
|
|
|
}
|
|
|
|
|
|
showErrTip(data.message);
|
|
|
resetForm();
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
},
|
|
|
error: function() {
|
|
|
showErrTip('网络断开连接啦~');
|
|
|
|
|
|
validate && validate.refresh();
|
|
|
},
|
|
|
complete: function() {
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 密码显示与隐藏
|
|
|
api.bindEyesEvt();
|
|
|
|
...
|
...
|
@@ -95,67 +156,23 @@ $loginBtn.on('touchstart', function() { |
|
|
|
|
|
// 验证账号(数字或者邮箱)和密码合理性
|
|
|
if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
|
|
|
validate.getResults().then((result) => {
|
|
|
$loginBtn.text('正在登录...').addClass('disable');
|
|
|
|
|
|
let params = {
|
|
|
account: acc,
|
|
|
password: pwd
|
|
|
};
|
|
|
|
|
|
$.extend(params, result);
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/login/auth',
|
|
|
data: params,
|
|
|
success: function(data) {
|
|
|
let res,
|
|
|
LOGI_TYPE;
|
|
|
|
|
|
if (acc.indexOf('@') > 0) {
|
|
|
LOGI_TYPE = 8;
|
|
|
} else {
|
|
|
LOGI_TYPE = 5;
|
|
|
}
|
|
|
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_MY_LOGIN_C',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: window._ChannelVary[window.cookie('_Channel')],
|
|
|
LOGI_TYPE: LOGI_TYPE
|
|
|
})
|
|
|
}, true);
|
|
|
}
|
|
|
validate.type === 2 && validate.refresh();
|
|
|
if (data.code === 200) {
|
|
|
res = data.data;
|
|
|
|
|
|
showErrTip('登录成功');
|
|
|
location.href = res.href;
|
|
|
$loginBtn.text('登录成功');
|
|
|
} else {
|
|
|
if (data.captchaShow) {
|
|
|
((data.changeCaptcha && validate.type !== 2) && validate.refresh());
|
|
|
}
|
|
|
|
|
|
showErrTip(data.message);
|
|
|
resetForm();
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
},
|
|
|
error: function() {
|
|
|
showErrTip('网络断开连接啦~');
|
|
|
|
|
|
validate.refresh();
|
|
|
},
|
|
|
complete: function() {
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
}, () => {});
|
|
|
let params = {
|
|
|
account: acc,
|
|
|
password: pwd
|
|
|
};
|
|
|
|
|
|
if (useVerify) {
|
|
|
validate.getResults().then((result) => {
|
|
|
$loginBtn.text('正在登录...').addClass('disable');
|
|
|
|
|
|
$.extend(params, result);
|
|
|
|
|
|
// auth
|
|
|
loginAuth(params, acc);
|
|
|
}, () => {});
|
|
|
} else {
|
|
|
loginAuth(params, acc);
|
|
|
}
|
|
|
} else {
|
|
|
showErrTip('账号或密码有错误,请重新输入');
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
...
|
...
|
|