...
|
...
|
@@ -13,6 +13,7 @@ var $registerPage = $('.register-page'), |
|
|
$pwdTip1 = $pwdTips.find('#pwd-tip1'),
|
|
|
$errTip = $('#err-tip'),
|
|
|
$registerBtn = $('#register-btn'),
|
|
|
$captchaImageWrap = $('#captcha-img'),
|
|
|
captchaImage = new Captcha('#captcha-img', {checkURI: ''}).init();
|
|
|
|
|
|
var $sendCaptcha = $('#send-captcha'),
|
...
|
...
|
@@ -55,6 +56,10 @@ $pwd.focus(function() { |
|
|
// IE8 placeholder
|
|
|
$('[placeholder]').placeholder();
|
|
|
|
|
|
function showCaptcha() {
|
|
|
$captchaImageWrap.removeClass('hide');
|
|
|
}
|
|
|
|
|
|
// 存储校验信息
|
|
|
validateResult = [
|
|
|
{
|
...
|
...
|
@@ -63,11 +68,6 @@ validateResult = [ |
|
|
status: false // 当前的状态
|
|
|
},
|
|
|
{
|
|
|
id: 'captcha-img',
|
|
|
message: '',
|
|
|
status: false
|
|
|
},
|
|
|
{
|
|
|
id: 'msg-captcha',
|
|
|
message: '',
|
|
|
status: false
|
...
|
...
|
@@ -84,11 +84,6 @@ validateResult = [ |
|
|
}
|
|
|
];
|
|
|
|
|
|
captchaImage.onRefresh(function() {
|
|
|
validateResult[1].message = 'err';
|
|
|
validateResult[1].status = false;
|
|
|
});
|
|
|
|
|
|
// 刷新图形验证码
|
|
|
function refreshPic() {
|
|
|
captchaImage.refresh();
|
...
|
...
|
@@ -96,24 +91,11 @@ function refreshPic() { |
|
|
|
|
|
// 手机号ajax校验
|
|
|
function phoneAjaxFn(page, callback) {
|
|
|
var url,
|
|
|
data;
|
|
|
|
|
|
if (page === 'reg') {
|
|
|
url = '/passport/reg/checkmobile';
|
|
|
data = {
|
|
|
mobile: $pn.val(),
|
|
|
area: $region.text().split('+')[1]
|
|
|
};
|
|
|
} else if (page === 'third') {
|
|
|
url = '/passport/autouserinfo/bindCheck';
|
|
|
data = {
|
|
|
mobile: $pn.val(),
|
|
|
area: $region.text().split('+')[1],
|
|
|
openId: $('#open-id').val(),
|
|
|
sourceType: $('#source-type').val()
|
|
|
};
|
|
|
}
|
|
|
var url = '/passport/reg/checkmobile';
|
|
|
var data = {
|
|
|
mobile: $pn.val(),
|
|
|
area: $region.text().split('+')[1]
|
|
|
};
|
|
|
|
|
|
validateResult[0].message = 'err';
|
|
|
validateResult[0].status = false;
|
...
|
...
|
@@ -138,8 +120,6 @@ function phoneAjaxFn(page, callback) { |
|
|
|
|
|
// 如果手机号发生改变则刷新验证码并且更新状态
|
|
|
refreshPic();
|
|
|
validateResult[1].message = 'err';
|
|
|
validateResult[1].status = false;
|
|
|
}
|
|
|
|
|
|
oldPhone = $pn.val();
|
...
|
...
|
@@ -159,26 +139,10 @@ function phoneAjaxFn(page, callback) { |
|
|
});
|
|
|
}
|
|
|
|
|
|
// 图形验证码ajax校验
|
|
|
function picCaptchaAjaxFn(callback) {
|
|
|
return captchaImage.check().then(function() {
|
|
|
validateResult[1].message = '';
|
|
|
validateResult[1].status = true;
|
|
|
}).fail(function() {
|
|
|
validateResult[1].message = 'err';
|
|
|
validateResult[1].status = false;
|
|
|
}).always(callback);
|
|
|
}
|
|
|
|
|
|
// 短信验证码ajax校验
|
|
|
function msgCaptchaAjaxFn(page, callback) {
|
|
|
var url;
|
|
|
|
|
|
if (page === 'reg') {
|
|
|
url = '/passport/reg/msgcaptcha';
|
|
|
} else if (page === 'third') {
|
|
|
url = '/passport/autouserinfo/checkBindMsg';
|
|
|
}
|
|
|
var url = '/passport/reg/msgcaptcha';
|
|
|
|
|
|
return $.ajax({
|
|
|
type: 'POST',
|
...
|
...
|
@@ -199,14 +163,16 @@ function msgCaptchaAjaxFn(page, callback) { |
|
|
|
|
|
switch (data.code) {
|
|
|
case 200:
|
|
|
validateResult[2].message = '';
|
|
|
validateResult[2].status = true;
|
|
|
validateResult[1].message = '';
|
|
|
validateResult[1].status = true;
|
|
|
return defer.resolve().promise();
|
|
|
case 400:
|
|
|
validateResult[2].message = '短信验证码错误';
|
|
|
validateResult[2].status = false;
|
|
|
return defer.reject().promise();
|
|
|
default:
|
|
|
validateResult[1].message = data.message;
|
|
|
validateResult[1].status = false;
|
|
|
|
|
|
if (data.data && data.data.needCaptcha) {
|
|
|
showCaptcha();
|
|
|
}
|
|
|
return defer.reject().promise();
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -247,59 +213,39 @@ function validateRule(page, $element, callback) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 图形验证码校验
|
|
|
} else if ($element.hasClass('w330')) {
|
|
|
// 并且手机号正确
|
|
|
if (validateResult[0].status) {
|
|
|
return picCaptchaAjaxFn(callback);
|
|
|
|
|
|
} else {
|
|
|
validateResult[1].message = 'err';
|
|
|
validateResult[1].status = false;
|
|
|
return defer.reject().promise();
|
|
|
}
|
|
|
|
|
|
// 短信验证码校验
|
|
|
} else if ($element.hasClass('msg-captcha')) {
|
|
|
if (val === '') {
|
|
|
validateResult[2].message = '请输入短信验证码';
|
|
|
validateResult[2].status = false;
|
|
|
validateResult[1].message = '请输入短信验证码';
|
|
|
validateResult[1].status = false;
|
|
|
return defer.reject().promise();
|
|
|
|
|
|
} else if (val.length <= 3) {
|
|
|
validateResult[2].message = '短信验证码错误';
|
|
|
validateResult[2].status = false;
|
|
|
validateResult[1].message = '验证码错误';
|
|
|
validateResult[1].status = false;
|
|
|
return defer.reject().promise();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 并且图形验证码正确
|
|
|
if (validateResult[1].status) {
|
|
|
return msgCaptchaAjaxFn(page, callback);
|
|
|
} else {
|
|
|
validateResult[2].message = '短信验证码错误';
|
|
|
validateResult[2].status = false;
|
|
|
return defer.reject().promise();
|
|
|
}
|
|
|
return msgCaptchaAjaxFn(page, callback);
|
|
|
}
|
|
|
|
|
|
// 密码校验
|
|
|
} else if ($element.hasClass('pwd')) {
|
|
|
if (val === '') {
|
|
|
validateResult[3].message = '请输入密码';
|
|
|
validateResult[3].status = false;
|
|
|
validateResult[2].message = '请输入密码';
|
|
|
validateResult[2].status = false;
|
|
|
return defer.reject().promise();
|
|
|
} else if (val.length < 6 || val.length > 20) {
|
|
|
validateResult[3].message = '密码只支持6-20位字符';
|
|
|
validateResult[3].status = false;
|
|
|
validateResult[2].message = '密码只支持6-20位字符';
|
|
|
validateResult[2].status = false;
|
|
|
return defer.reject().promise();
|
|
|
} else if (!pwdReg.test($element.val())) {
|
|
|
validateResult[3].message = '密码须字母和数字组合';
|
|
|
validateResult[3].status = false;
|
|
|
validateResult[2].message = '密码须字母和数字组合';
|
|
|
validateResult[2].status = false;
|
|
|
return defer.reject().promise();
|
|
|
} else {
|
|
|
validateResult[3].message = '';
|
|
|
validateResult[3].status = true;
|
|
|
validateResult[2].message = '';
|
|
|
validateResult[2].status = true;
|
|
|
return defer.resolve().promise();
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -507,18 +453,13 @@ exports.init = function(page) { |
|
|
|
|
|
// 点击发送验证码
|
|
|
$sendCaptcha.click(function() {
|
|
|
var t,
|
|
|
url;
|
|
|
var t;
|
|
|
var url = '/passport/reg/sendBindMsg';
|
|
|
|
|
|
if ($(this).hasClass('disable')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (page === 'reg') {
|
|
|
url = '/passport/reg/sendBindMsg';
|
|
|
} else if (page === 'third') {
|
|
|
url = '/passport/autouserinfo/sendBindMsg';
|
|
|
}
|
|
|
|
|
|
// 1.验证图形验证码是否正确
|
|
|
// 2.验证手机号被注册过
|
...
|
...
|
@@ -527,11 +468,6 @@ exports.init = function(page) { |
|
|
showErrTip(); // 显示错误提示
|
|
|
showBorder(); // 显示红色边框
|
|
|
}).then(function() {
|
|
|
return validateRule(page, $('#captcha-img'), function() {
|
|
|
showErrTip(); // 显示错误提示
|
|
|
showBorder(); // 显示红色边框
|
|
|
});
|
|
|
}).then(function() {
|
|
|
return $.ajax({
|
|
|
type: 'POST',
|
|
|
url: url,
|
...
|
...
|
@@ -595,13 +531,7 @@ exports.init = function(page) { |
|
|
|
|
|
// ajax表单提交
|
|
|
$registerBtn.click(function() {
|
|
|
var url;
|
|
|
|
|
|
if (page === 'reg') {
|
|
|
url = '/passport/reg/mobileregister';
|
|
|
} else if (page === 'third') {
|
|
|
url = '/passport/autouserinfo/bindMobile';
|
|
|
}
|
|
|
var url = '/passport/reg/mobileregister';
|
|
|
|
|
|
if ($(this).hasClass('disable')) {
|
|
|
return;
|
...
|
...
|
|