password.js
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* 注册-密码
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
let $ = require('yoho-jquery');
let $pwd = $('#pwd'),
$pwdLint = $('.pwd-lint'),
$pwdLintTxt = $pwdLint.find('.pwd-lint-txt'),
$btnSure = $('#btn-sure');
let api = require('../api');
let tip = require('js/plugin/tip');
let validatePWD = require('../password-check');
let trim = $.trim;
let showErrTip = tip.show;
let sourceType = $('#sourceType').val(),
openId = $('#openId').val(),
phoneNum = $('#phone-num').val(),
areaCode = $('#area-code').val().replace('+', ''),
nickname = $('#nickname').val(),
code = $('#code').val();
function startBind(password) {
$.ajax({
url: '/passport/bind/bindMobile',
type: 'post',
data: {
areaCode: areaCode.replace('+', ''),
phoneNum: phoneNum,
openId: openId,
sourceType: sourceType,
nickname: nickname,
password: password,
code: code
},
success: function(res) {
if (res.code === 200) {
tip.show('登录成功');
setTimeout(function() {
location.href = res.data.refer;
}, 2000);
} else {
tip.show(res.message);
}
},
error: function() {
tip.show('登录失败,请重试!');
}
});
}
api.bindEyesEvt({
status: 'open' // 默认眼睛打开
});
$pwd.bind('input', function() {
let val = $.trim(this.value);
let bool = validatePWD(val, function(res) {
$pwdLint.css({visibility: res.valid ? 'hidden' : 'visible'});
if (!res.valid) {
$pwdLintTxt.text(res.msg);
}
});
$btnSure.toggleClass('disable', !bool);
});
$btnSure.on('touchstart', function() {
let pwd = trim($pwd.val());
if ($btnSure.hasClass('disable')) {
return;
}
if (validatePWD(pwd) === false) {
showErrTip('密码6-20位,请重新输入');
} else {
startBind(pwd);
}
});