...
|
...
|
@@ -4,7 +4,7 @@ |
|
|
* @date: 2015/9/30
|
|
|
*/
|
|
|
var $ = require('yoho-jquery');
|
|
|
var ImgCheck = require('plugin/img-check');
|
|
|
var Validate = require('plugin/validata');
|
|
|
|
|
|
var $account = $('#account'),
|
|
|
$pwd = $('#pwd'),
|
...
|
...
|
@@ -25,7 +25,7 @@ var trim = $.trim; |
|
|
var showErrTip = tip.show;
|
|
|
|
|
|
|
|
|
var imgCheck = new ImgCheck($captcha, {
|
|
|
var validate = new Validate($captcha, {
|
|
|
useREM: {
|
|
|
rootFontSize: 40,
|
|
|
picWidth: 150
|
...
|
...
|
@@ -33,7 +33,7 @@ var imgCheck = new ImgCheck($captcha, { |
|
|
});
|
|
|
|
|
|
if ($captcha.data('init') != null) { //eslint-disable-line
|
|
|
imgCheck.init();
|
|
|
validate.init();
|
|
|
}
|
|
|
|
|
|
// 登录按钮状态切换
|
...
|
...
|
@@ -89,86 +89,86 @@ $pwd.bind('input', function() { |
|
|
|
|
|
// Login
|
|
|
$loginBtn.on('touchstart', function() {
|
|
|
var acc = trim($account.val()),
|
|
|
pwd = trim($pwd.val()),
|
|
|
captcha = null;
|
|
|
|
|
|
if ($loginBtn.hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// if (imgCheck.atWorking) {
|
|
|
captcha = imgCheck.getResults();
|
|
|
|
|
|
// if (captcha === '0000') {
|
|
|
// return tip.show(' 请将图片旋转到正确方向');
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
$loginBtn.text('正在登录...').addClass('disable');
|
|
|
let acc = trim($account.val()),
|
|
|
pwd = trim($pwd.val());
|
|
|
|
|
|
// 验证账号(数字或者邮箱)和密码合理性
|
|
|
if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
|
|
|
let data = {
|
|
|
account: acc,
|
|
|
password: pwd,
|
|
|
yohobuy: $('#yohobuy').val()
|
|
|
};
|
|
|
|
|
|
if (imgCheck.atWorking) {
|
|
|
$.extend(data, {captcha});
|
|
|
let validResult = validate.getResults();
|
|
|
|
|
|
if (typeof validResult === 'string') {
|
|
|
if (validResult === '0000') {
|
|
|
return tip.show(' 请将图片旋转到正确方向');
|
|
|
}
|
|
|
validResult = Promise.resolve({captcha: validResult});
|
|
|
}
|
|
|
validResult.then((captcha) => {
|
|
|
$loginBtn.text('正在登录...').addClass('disable');
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/login/auth',
|
|
|
data,
|
|
|
success: function(data) { //eslint-disable-line
|
|
|
var res,
|
|
|
LOGI_TYPE;
|
|
|
|
|
|
if (acc.indexOf('@') > 0) {
|
|
|
LOGI_TYPE = 8;
|
|
|
} else {
|
|
|
LOGI_TYPE = 5;
|
|
|
}
|
|
|
let data = {
|
|
|
account: acc,
|
|
|
password: pwd,
|
|
|
yohobuy: $('#yohobuy').val()
|
|
|
};
|
|
|
|
|
|
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);
|
|
|
}
|
|
|
if (validate.atWorking) {
|
|
|
$.extend(data, captcha);
|
|
|
}
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
res = data.data;
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/passport/login/auth',
|
|
|
data,
|
|
|
success: function(data) { //eslint-disable-line
|
|
|
var res,
|
|
|
LOGI_TYPE;
|
|
|
|
|
|
if (acc.indexOf('@') > 0) {
|
|
|
LOGI_TYPE = 8;
|
|
|
} else {
|
|
|
LOGI_TYPE = 5;
|
|
|
}
|
|
|
|
|
|
showErrTip('登录成功');
|
|
|
location.href = res.href;
|
|
|
$loginBtn.text('登录成功').off();
|
|
|
} else {
|
|
|
if (data.captchaShow) {
|
|
|
imgCheck.atWorking ? (data.changeCaptcha && imgCheck.refresh()) : imgCheck.init();
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
showErrTip(data.message);
|
|
|
resetForm();
|
|
|
}
|
|
|
if (data.code === 200) {
|
|
|
res = data.data;
|
|
|
|
|
|
return data;
|
|
|
},
|
|
|
error: function() {
|
|
|
showErrTip('网络断开连接啦~');
|
|
|
showErrTip('登录成功');
|
|
|
location.href = res.href;
|
|
|
$loginBtn.text('登录成功').off();
|
|
|
} else {
|
|
|
if (data.captchaShow) {
|
|
|
validate.atWorking ? ((data.changeCaptcha || validate.type === 2) && validate.refresh()) : validate.init();
|
|
|
}
|
|
|
|
|
|
imgCheck.atWorking && imgCheck.refresh();
|
|
|
},
|
|
|
complete: function() {
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
showErrTip(data.message);
|
|
|
resetForm();
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
},
|
|
|
error: function() {
|
|
|
showErrTip('网络断开连接啦~');
|
|
|
|
|
|
validate.atWorking && validate.refresh();
|
|
|
},
|
|
|
complete: function() {
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
}, () => {});
|
|
|
} else {
|
|
|
showErrTip('账号或密码有错误,请重新输入');
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
...
|
...
|
|