bind-info.js
3.57 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/**
* 第三方绑定完善个人信息
* @author: wq
* @date: 2016/1/27
*/
var $ = require('yoho-jquery');
var dovalidate = false; // 校验验证码的标识
var isvalidatecode = false; // 是否验证成功的标识
var isvalidatepwd = false; // 密码验证是否通过的标识
var second = ''; // 倒计时时间
var nopermissionoption = ''; // 倒计时的dom
var sendmessagehtml = ''; // 发送短信的dom
var $pwd,
$pwdParent,
$pwdTip1,
$pwdIntensity;
require('../../simple-header');
nopermissionoption = $('#nopermissionmessage').html();
sendmessagehtml = $('.validatewrapper').html();
second = +$('.second').text();
function gettype(str, i) {
if (str.charCodeAt(i) >= 48 && str.charCodeAt(i) <= 57) {
return 1;
} else if (str.charCodeAt(i) >= 97 && str.charCodeAt(i) <= 122) {
return 2;
} else if (str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 90) {
return 3;
}
return 4;
}
function isregular(cur, pre, type) {
var curCode = cur.charCodeAt(0);
var preCode = pre.charCodeAt(0);
if (curCode - preCode === 0) {
return true;
}
if (type !== 4 && (curCode - preCode === 1 || curCode - preCode === -1)) {
return true;
}
return false;
}
function getcomplex(curType, preType) {
if (preType === 0 || curType === preType) {
return 0;
} else if (curType === 4 || preType === 4) {
return 2;
} else {
return 1;
}
}
function changeSecond() {
second -= 1;
if (second < 0) {
second = 60;
$('.validatewrapper').html(sendmessagehtml);
return;
} else {
$('.second').text(second);
window.setTimeout(changeSecond, 1000);
}
}
/**
* 启动倒计时
* @return {[type]} [description]
*/
function circleTime() {
$('.validatewrapper').html(nopermissionoption);
window.setTimeout(changeSecond, 1000);
}
function sendMessageValidate() {
var mobile = '';
var area = '';
$(document).on('click', '#sendmessage', function() {
circleTime();
mobile = $('#mobile').val();
area = $('#area').val();
$.ajax({
type: 'POST',
url: '/passport/cert/sendCertMsg',
data: {
mobile: mobile,
area: area
}
}).then(function(data) {
if (data.code !== 200) {
alert(data.message);
}
});
});
}
/**
* 最终提交表单
*/
function actionSubmit() {
var mobile = '';
var area = '';
var code = '';
area = $('#area').val();
mobile = $('#mobile').val();
code = $('#validatenum').val();
$.ajax({
type: 'POST',
url: '/passport/cert/certMobile',
data: {
area: area,
mobile: mobile,
code: code
}
}).then(function(data) {
if (data.code === 200) {
window.location.href = data.data.nextUrl;
} else {
alert(data.message);
}
});
}
/**
* 确定完善信息
* @return {[type]} [description]
*/
function actionConfirm() {
var validatenum = '';
$('#confirmsubmit').on('click', function() {
validatenum = $('#validatenum').val();
if (validatenum === '') {
alert('短信验证码不能为空');
return;
}
if (isvalidatecode === false) {
alert('请输入正确的验证码');
return;
}
actionSubmit();
});
}
function init() {
circleTime(); // 倒计时
sendMessageValidate();
codeValidate();
actionConfirm();
}
init();