|
@@ -8,6 +8,8 @@ var $ = require('yoho-jquery'); |
|
@@ -8,6 +8,8 @@ var $ = require('yoho-jquery'); |
8
|
|
8
|
|
9
|
var regx = require('../common/mail-phone-regx');
|
9
|
var regx = require('../common/mail-phone-regx');
|
10
|
|
10
|
|
|
|
11
|
+var Captcha = require('../../plugins/captcha');
|
|
|
12
|
+
|
11
|
var emailAc = require('../common/ac-email'); // 邮箱自动完成
|
13
|
var emailAc = require('../common/ac-email'); // 邮箱自动完成
|
12
|
|
14
|
|
13
|
var emailReg = regx.emailRegx,
|
15
|
var emailReg = regx.emailRegx,
|
|
@@ -20,24 +22,15 @@ var $cr = $('#country-code-hide'), |
|
@@ -20,24 +22,15 @@ var $cr = $('#country-code-hide'), |
20
|
$cc = $('#country-code'),
|
22
|
$cc = $('#country-code'),
|
21
|
$btn = $('#find-btn'),
|
23
|
$btn = $('#find-btn'),
|
22
|
$accErr = $('#account-err'),
|
24
|
$accErr = $('#account-err'),
|
23
|
- $caErr = $('#captcha-err'),
|
|
|
24
|
caCount = 4, // 验证码位数
|
25
|
caCount = 4, // 验证码位数
|
25
|
hasPh = false,
|
26
|
hasPh = false,
|
26
|
- hasCa = false;
|
27
|
+ captcha = new Captcha('#captcha-img').init();
|
27
|
|
28
|
|
28
|
require('../../simple-header');
|
29
|
require('../../simple-header');
|
29
|
require('yoho-jquery-placeholder');
|
30
|
require('yoho-jquery-placeholder');
|
30
|
|
31
|
|
31
|
-function imgcode() {
|
|
|
32
|
- var time = new Date(),
|
|
|
33
|
- $captchaImg = $('#captcha-img'),
|
|
|
34
|
- captchaImgSrc = $captchaImg.attr('src').split('?')[0];
|
|
|
35
|
-
|
|
|
36
|
- $('#captcha-img').attr('src', captchaImgSrc + '?t=' + time.getTime());
|
|
|
37
|
-}
|
|
|
38
|
-
|
|
|
39
|
function enableBtn() {
|
32
|
function enableBtn() {
|
40
|
- if (hasPh && hasCa) {
|
33
|
+ if (hasPh) {
|
41
|
$btn.removeClass('disable').prop('disabled', false);
|
34
|
$btn.removeClass('disable').prop('disabled', false);
|
42
|
} else {
|
35
|
} else {
|
43
|
$btn.addClass('disable').prop('disabled', true);
|
36
|
$btn.addClass('disable').prop('disabled', true);
|
|
@@ -45,33 +38,27 @@ function enableBtn() { |
|
@@ -45,33 +38,27 @@ function enableBtn() { |
45
|
}
|
38
|
}
|
46
|
|
39
|
|
47
|
function authcode() {
|
40
|
function authcode() {
|
48
|
- if (!hasPh || !hasCa) {
|
|
|
49
|
- enableBtn();
|
|
|
50
|
- return;
|
|
|
51
|
- }
|
|
|
52
|
-
|
|
|
53
|
- $.ajax({
|
41
|
+ return $.ajax({
|
54
|
type: 'POST',
|
42
|
type: 'POST',
|
55
|
url: '/passport/back/authcode',
|
43
|
url: '/passport/back/authcode',
|
56
|
data: {
|
44
|
data: {
|
57
|
- verifyCode: $.trim($ca.val()),
|
45
|
+ verifyCode: captcha.getResults(),
|
58
|
phoneNum: $phoneNum.val(),
|
46
|
phoneNum: $phoneNum.val(),
|
59
|
area: $cr.val()
|
47
|
area: $cr.val()
|
60
|
}
|
48
|
}
|
61
|
|
49
|
|
62
|
}).then(function(data) {
|
50
|
}).then(function(data) {
|
63
|
if (data.code === 200) {
|
51
|
if (data.code === 200) {
|
64
|
- hasCa = true;
|
52
|
+ $('#captcha-value').val(captcha.getResults());
|
|
|
53
|
+ return $.Deferred().resolve().promise(); //eslint-disable-line
|
65
|
} else if (data.code === 402) {
|
54
|
} else if (data.code === 402) {
|
66
|
- hasPh = false;
|
|
|
67
|
- hasCa = true;
|
|
|
68
|
$accErr.removeClass('hide').find('em').text('该账号不存在');
|
55
|
$accErr.removeClass('hide').find('em').text('该账号不存在');
|
69
|
$phoneNum.addClass('error');
|
56
|
$phoneNum.addClass('error');
|
|
|
57
|
+ return $.Deferred().reject().promise();//eslint-disable-line
|
70
|
} else if (data.code === 400) {
|
58
|
} else if (data.code === 400) {
|
71
|
- hasCa = false;
|
|
|
72
|
- imgcode();
|
59
|
+ captcha.showTip();
|
|
|
60
|
+ return $.Deferred().reject().promise();//eslint-disable-line
|
73
|
}
|
61
|
}
|
74
|
- enableBtn();
|
|
|
75
|
});
|
62
|
});
|
76
|
}
|
63
|
}
|
77
|
|
64
|
|
|
@@ -101,7 +88,6 @@ function vaPn(v) { |
|
@@ -101,7 +88,6 @@ function vaPn(v) { |
101
|
pass = false;
|
88
|
pass = false;
|
102
|
}
|
89
|
}
|
103
|
hasPh = pass;
|
90
|
hasPh = pass;
|
104
|
- authcode();
|
|
|
105
|
|
91
|
|
106
|
return {
|
92
|
return {
|
107
|
pass: pass,
|
93
|
pass: pass,
|
|
@@ -109,26 +95,13 @@ function vaPn(v) { |
|
@@ -109,26 +95,13 @@ function vaPn(v) { |
109
|
};
|
95
|
};
|
110
|
}
|
96
|
}
|
111
|
|
97
|
|
112
|
-function vaCa() {
|
|
|
113
|
- var v = $.trim($ca.val());
|
|
|
114
|
-
|
|
|
115
|
- if (v === '' || v.length < caCount) {
|
|
|
116
|
- hasCa = false;
|
|
|
117
|
- enableBtn();
|
|
|
118
|
- return;
|
|
|
119
|
- }
|
|
|
120
|
-
|
|
|
121
|
- hasCa = true;
|
|
|
122
|
-
|
|
|
123
|
- authcode();
|
|
|
124
|
-}
|
|
|
125
|
-
|
|
|
126
|
emailAc($phoneNum, function() {
|
98
|
emailAc($phoneNum, function() {
|
127
|
var pnVa = vaPn($phoneNum.val());
|
99
|
var pnVa = vaPn($phoneNum.val());
|
128
|
|
100
|
|
129
|
if (pnVa.pass) {
|
101
|
if (pnVa.pass) {
|
130
|
$accErr.addClass('hide');
|
102
|
$accErr.addClass('hide');
|
131
|
$phoneNum.removeClass('error');
|
103
|
$phoneNum.removeClass('error');
|
|
|
104
|
+ enableBtn();
|
132
|
} else {
|
105
|
} else {
|
133
|
$accErr.removeClass('hide').find('em').text(pnVa.errTxt);
|
106
|
$accErr.removeClass('hide').find('em').text(pnVa.errTxt);
|
134
|
$phoneNum.addClass('error');
|
107
|
$phoneNum.addClass('error');
|
|
@@ -141,10 +114,6 @@ $ca.attr('maxlength', caCount); |
|
@@ -141,10 +114,6 @@ $ca.attr('maxlength', caCount); |
141
|
// IE8 placeholder
|
114
|
// IE8 placeholder
|
142
|
$('input').placeholder();
|
115
|
$('input').placeholder();
|
143
|
|
116
|
|
144
|
-$('#change-captcha, #captcha-img').on('click', function() {
|
|
|
145
|
- imgcode();
|
|
|
146
|
-});
|
|
|
147
|
-
|
|
|
148
|
$cc.on('click', function(e) {
|
117
|
$cc.on('click', function(e) {
|
149
|
e.stopPropagation();
|
118
|
e.stopPropagation();
|
150
|
if ($ccList.css('style') === 'block') {
|
119
|
if ($ccList.css('style') === 'block') {
|
|
@@ -184,6 +153,8 @@ $(document).click(function() { |
|
@@ -184,6 +153,8 @@ $(document).click(function() { |
184
|
}
|
153
|
}
|
185
|
});
|
154
|
});
|
186
|
|
155
|
|
|
|
156
|
+captcha.refresh();
|
|
|
157
|
+
|
187
|
$phoneNum.keyup(function() {
|
158
|
$phoneNum.keyup(function() {
|
188
|
vaPn($.trim($(this).val()));
|
159
|
vaPn($.trim($(this).val()));
|
189
|
}).focus(function() {
|
160
|
}).focus(function() {
|
|
@@ -193,43 +164,22 @@ $phoneNum.keyup(function() { |
|
@@ -193,43 +164,22 @@ $phoneNum.keyup(function() { |
193
|
$accErr.addClass('hide');
|
164
|
$accErr.addClass('hide');
|
194
|
});
|
165
|
});
|
195
|
|
166
|
|
196
|
-// 验证码在鼠标移开后验证, keyup时不再验证
|
|
|
197
|
-$ca.blur(function() {
|
|
|
198
|
- var errTxt = $.trim($ca.val()) === '' ? '验证码不能为空' : '验证码不正确';
|
|
|
199
|
-
|
|
|
200
|
- if (hasCa) {
|
|
|
201
|
- $caErr.addClass('hide');
|
|
|
202
|
- $ca.removeClass('error');
|
|
|
203
|
- } else {
|
|
|
204
|
- $caErr.removeClass('hide').find('em').text(errTxt);
|
|
|
205
|
- $ca.addClass('error');
|
|
|
206
|
-
|
|
|
207
|
- // 验证码错误则刷新验证码
|
|
|
208
|
- if ($ca.val() < caCount) {
|
|
|
209
|
-
|
|
|
210
|
- // 防止重复刷新验证码
|
|
|
211
|
- imgcode();
|
|
|
212
|
- }
|
|
|
213
|
- }
|
|
|
214
|
-}).focus(function() {
|
|
|
215
|
- $(this).removeClass('error');
|
|
|
216
|
-
|
|
|
217
|
- // focus隐藏错误提示
|
|
|
218
|
- $caErr.addClass('hide');
|
|
|
219
|
-}).keyup(function() {
|
|
|
220
|
- vaCa();
|
|
|
221
|
-});
|
|
|
222
|
-
|
167
|
+// 下一步
|
223
|
$('#find-btn').click(function(e) {
|
168
|
$('#find-btn').click(function(e) {
|
224
|
-
|
|
|
225
|
if (/^[0-9]+$/.test($.trim($phoneNum.val()))) {
|
169
|
if (/^[0-9]+$/.test($.trim($phoneNum.val()))) {
|
226
|
$('#find-form').attr('action', '/passport/back/mobile');
|
170
|
$('#find-form').attr('action', '/passport/back/mobile');
|
227
|
}
|
171
|
}
|
|
|
172
|
+
|
228
|
if ($(this).hasClass('disable')) {
|
173
|
if ($(this).hasClass('disable')) {
|
229
|
return;
|
174
|
return;
|
230
|
}
|
175
|
}
|
231
|
- if (!hasCa || !hasPh) {
|
|
|
232
|
- e.preventDefault();
|
|
|
233
|
- return true;
|
176
|
+
|
|
|
177
|
+ if (hasPh) {
|
|
|
178
|
+ authcode().then(function() {
|
|
|
179
|
+ $('#back-form').submit();
|
|
|
180
|
+ });
|
234
|
}
|
181
|
}
|
|
|
182
|
+
|
|
|
183
|
+ e.preventDefault();
|
|
|
184
|
+ return true;
|
235
|
}); |
185
|
}); |