cert.js
2.58 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
/**
* 第三方绑定完善个人信息
* @author: wq
* @date: 2016/1/27
*/
var $ = require('yoho-jquery');
var second = ''; // 倒计时时间
var nopermissionoption = ''; // 倒计时的dom
var sendmessagehtml = ''; // 发送短信的dom
require('../../simple-header');
nopermissionoption = $('#nopermissionmessage').html();
sendmessagehtml = $('.validatewrapper').html();
second = +$('.second').text();
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); // eslint-disable-line
}
});
});
}
/**
* 最终提交表单
*/
function actionSubmit() {
var mobile = '';
var area = '';
var code = '';
var refer = '';
area = $('#area').val();
mobile = $('#mobile').val();
code = $('#validatenum').val();
refer = $('#refer').val();
$.ajax({
type: 'POST',
url: '/passport/cert/certMobile',
data: {
area: area,
mobile: mobile,
code: code,
refer: refer
}
}).then(function(data) {
if (data.code === 200) {
window.location.href = data.data.nextUrl;
} else {
alert(data.message); // eslint-disable-line
}
});
}
/**
* 确定完善信息
* @return {[type]} [description]
*/
function actionConfirm() {
var validatenum = '';
$('#confirmsubmit').on('click', function() {
validatenum = $('#validatenum').val();
if (validatenum === '') {
alert('短信验证码不能为空'); // eslint-disable-line
return;
}
actionSubmit();
});
}
function init() {
sendMessageValidate();
actionConfirm();
$('#sendmessage').click();
circleTime(); // 倒计时
}
init();