...
|
...
|
@@ -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, {
|
|
|
let validate = {};
|
|
|
|
|
|
if (useVerify) {
|
|
|
validate = new Validate($captcha, {
|
|
|
useREM: {
|
|
|
rootFontSize: 40,
|
|
|
picWidth: 150
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
validate.init();
|
|
|
validate.init();
|
|
|
}
|
|
|
|
|
|
// 登录按钮状态切换
|
|
|
function switchLoginBtnStatus() {
|
...
|
...
|
@@ -60,51 +65,10 @@ function hideRetrivePanel() { |
|
|
$ways.hide();
|
|
|
}
|
|
|
|
|
|
// 密码显示与隐藏
|
|
|
api.bindEyesEvt();
|
|
|
|
|
|
// 清空账号输入框
|
|
|
api.bindClearEvt();
|
|
|
|
|
|
$account.bind('input', function() {
|
|
|
if (trim($account.val()) !== '') {
|
|
|
accPass = true;
|
|
|
} else {
|
|
|
accPass = false;
|
|
|
}
|
|
|
switchLoginBtnStatus();
|
|
|
});
|
|
|
|
|
|
$pwd.bind('input', function() {
|
|
|
if (trim($pwd.val()) === '') {
|
|
|
pwdPass = false;
|
|
|
} else {
|
|
|
pwdPass = true;
|
|
|
}
|
|
|
switchLoginBtnStatus();
|
|
|
});
|
|
|
|
|
|
|
|
|
// Login
|
|
|
$loginBtn.on('touchstart', function() {
|
|
|
if ($loginBtn.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
let acc = trim($account.val()),
|
|
|
pwd = trim($pwd.val());
|
|
|
|
|
|
// 验证账号(数字或者邮箱)和密码合理性
|
|
|
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);
|
|
|
|
|
|
/**
|
|
|
* 登录校验
|
|
|
*/
|
|
|
function loginAuth(params, acc) {
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/login/auth',
|
...
|
...
|
@@ -128,7 +92,7 @@ $loginBtn.on('touchstart', function() { |
|
|
})
|
|
|
}, true);
|
|
|
}
|
|
|
validate.type === 2 && validate.refresh();
|
|
|
validate && validate.type === 2 && validate.refresh();
|
|
|
if (data.code === 200) {
|
|
|
res = data.data;
|
|
|
|
...
|
...
|
@@ -136,7 +100,7 @@ $loginBtn.on('touchstart', function() { |
|
|
location.href = res.href;
|
|
|
$loginBtn.text('登录成功');
|
|
|
} else {
|
|
|
if (data.captchaShow) {
|
|
|
if (useVerify && data.captchaShow) {
|
|
|
((data.changeCaptcha && validate.type !== 2) && validate.refresh());
|
|
|
}
|
|
|
|
...
|
...
|
@@ -149,14 +113,67 @@ $loginBtn.on('touchstart', function() { |
|
|
error: function() {
|
|
|
showErrTip('网络断开连接啦~');
|
|
|
|
|
|
validate.refresh();
|
|
|
validate && validate.refresh();
|
|
|
},
|
|
|
complete: function() {
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 密码显示与隐藏
|
|
|
api.bindEyesEvt();
|
|
|
|
|
|
// 清空账号输入框
|
|
|
api.bindClearEvt();
|
|
|
|
|
|
$account.bind('input', function() {
|
|
|
if (trim($account.val()) !== '') {
|
|
|
accPass = true;
|
|
|
} else {
|
|
|
accPass = false;
|
|
|
}
|
|
|
switchLoginBtnStatus();
|
|
|
});
|
|
|
|
|
|
$pwd.bind('input', function() {
|
|
|
if (trim($pwd.val()) === '') {
|
|
|
pwdPass = false;
|
|
|
} else {
|
|
|
pwdPass = true;
|
|
|
}
|
|
|
switchLoginBtnStatus();
|
|
|
});
|
|
|
|
|
|
|
|
|
// Login
|
|
|
$loginBtn.on('touchstart', function() {
|
|
|
if ($loginBtn.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
let acc = trim($account.val()),
|
|
|
pwd = trim($pwd.val());
|
|
|
|
|
|
// 验证账号(数字或者邮箱)和密码合理性
|
|
|
if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
|
|
|
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');
|
|
|
}
|
...
|
...
|
|