|
@@ -4,6 +4,7 @@ |
|
@@ -4,6 +4,7 @@ |
4
|
* @date: 2015/12/11
|
4
|
* @date: 2015/12/11
|
5
|
*/
|
5
|
*/
|
6
|
var $ = require('yoho-jquery');
|
6
|
var $ = require('yoho-jquery');
|
|
|
7
|
+var EventProxy = require('../common/eventproxy');
|
7
|
|
8
|
|
8
|
var $account = $('#account'),
|
9
|
var $account = $('#account'),
|
9
|
$password = $('#password'),
|
10
|
$password = $('#password'),
|
|
@@ -11,11 +12,8 @@ var $account = $('#account'), |
|
@@ -11,11 +12,8 @@ var $account = $('#account'), |
11
|
$login = $('#login-btn'),
|
12
|
$login = $('#login-btn'),
|
12
|
$phone = $('#phone');
|
13
|
$phone = $('#phone');
|
13
|
|
14
|
|
14
|
-var $accountTip = $phone.siblings('.err-tip'),
|
|
|
15
|
- $passwordTip = $password.siblings('.err-tip'),
|
|
|
16
|
- $captchaTip = $captcha.siblings('.err-tip'),
|
|
|
17
|
- $loginTip = $login.siblings('.login-fail-tip'),
|
|
|
18
|
- $capsLock = $('#caps-lock');
|
15
|
+var $loginTip = $login.siblings('.login-fail-tip'),
|
|
|
16
|
+ ep = new EventProxy();
|
19
|
|
17
|
|
20
|
var $countryCodeEm = $('#country-code'),
|
18
|
var $countryCodeEm = $('#country-code'),
|
21
|
$countryList = $('#country-list');
|
19
|
$countryList = $('#country-list');
|
|
@@ -38,70 +36,74 @@ var checkbox = { |
|
@@ -38,70 +36,74 @@ var checkbox = { |
38
|
unchecked: ''
|
36
|
unchecked: ''
|
39
|
};
|
37
|
};
|
40
|
|
38
|
|
41
|
-var authing = false;
|
|
|
42
|
-
|
|
|
43
|
var emailAcTime;
|
39
|
var emailAcTime;
|
44
|
|
40
|
|
45
|
-var ERR_ACCOUNT_EMPTY = '请输入账号';
|
41
|
+var $errTip = $('.tips');
|
|
|
42
|
+var $errMsg = $errTip.find('.rectangle');
|
46
|
|
43
|
|
47
|
$captcha = $captchaWrap.find('#captcha');
|
44
|
$captcha = $captchaWrap.find('#captcha');
|
48
|
-$captchaTip = $captchaWrap.find('.err-tip');
|
|
|
49
|
|
45
|
|
50
|
require('../../plugins/tips');
|
46
|
require('../../plugins/tips');
|
51
|
require('yoho-jquery-placeholder');
|
47
|
require('yoho-jquery-placeholder');
|
52
|
|
48
|
|
|
|
49
|
+function errTip(ele, msg) {
|
|
|
50
|
+ var topLeft = ele.offset();
|
|
|
51
|
+
|
|
|
52
|
+ $errMsg.text(msg);
|
|
|
53
|
+ return $errTip.css({
|
|
|
54
|
+ top: topLeft.top + ele.height() - 2,
|
|
|
55
|
+ left: topLeft.left,
|
|
|
56
|
+ width: ele.width() + 2,
|
|
|
57
|
+ height: ele.height
|
|
|
58
|
+ }).removeClass('hide');
|
|
|
59
|
+}
|
|
|
60
|
+
|
|
|
61
|
+
|
53
|
// 验证账户名
|
62
|
// 验证账户名
|
54
|
-function validateAccount() {
|
|
|
55
|
- var pass = false,
|
|
|
56
|
- account = $.trim($account.val()),
|
|
|
57
|
- countryCode = $countryCodeEm.val(),
|
|
|
58
|
- err;
|
63
|
+function validateAccountLocal() {
|
|
|
64
|
+ var account = $.trim($account.val()),
|
|
|
65
|
+ countryCode = $countryCodeEm.val();
|
59
|
|
66
|
|
60
|
if (account !== '') {
|
67
|
if (account !== '') {
|
61
|
if (/^[0-9]+$/.test(account)) {
|
68
|
if (/^[0-9]+$/.test(account)) {
|
|
|
69
|
+ // 不是11位
|
|
|
70
|
+ if (account.length !== 11) {
|
|
|
71
|
+ ep.emit('phone', false);
|
|
|
72
|
+ errTip($phone, '手机号码不正确,请重新输入');
|
|
|
73
|
+ return false;
|
|
|
74
|
+ }
|
62
|
|
75
|
|
63
|
// 如果是纯数字,则作为手机号码处理
|
76
|
// 如果是纯数字,则作为手机号码处理
|
64
|
if (countryCode !== '+86' ||
|
77
|
if (countryCode !== '+86' ||
|
65
|
mailPhoneRegx.phoneRegx[countryCode].test(account)) {
|
78
|
mailPhoneRegx.phoneRegx[countryCode].test(account)) {
|
66
|
- pass = true;
|
79
|
+ ep.emit('phone', true);
|
|
|
80
|
+ return true;
|
67
|
} else {
|
81
|
} else {
|
68
|
- pass = false;
|
|
|
69
|
- err = '手机号码不正确,请重新输入';
|
82
|
+ ep.emit('phone', false);
|
|
|
83
|
+ errTip($phone, '手机号码不正确,请重新输入');
|
|
|
84
|
+ return false;
|
70
|
}
|
85
|
}
|
71
|
} else {
|
86
|
} else {
|
|
|
87
|
+
|
|
|
88
|
+ // 邮箱验证
|
72
|
if (mailPhoneRegx.emailRegx.test(account)) {
|
89
|
if (mailPhoneRegx.emailRegx.test(account)) {
|
73
|
- pass = true;
|
90
|
+ ep.emit('phone', true);
|
|
|
91
|
+ return true;
|
74
|
} else {
|
92
|
} else {
|
75
|
- pass = false;
|
|
|
76
|
- err = '邮箱格式不正确,请重新输入';
|
93
|
+ ep.emit('phone', false);
|
|
|
94
|
+ errTip($phone, '邮箱格式不正确,请重新输入');
|
|
|
95
|
+ return false;
|
77
|
}
|
96
|
}
|
78
|
}
|
97
|
}
|
79
|
|
98
|
|
80
|
-
|
|
|
81
|
} else {
|
99
|
} else {
|
82
|
- err = ERR_ACCOUNT_EMPTY;
|
100
|
+ ep.emit('phone', false);
|
|
|
101
|
+ errTip($phone, '请输入账号');
|
|
|
102
|
+ return false;
|
83
|
}
|
103
|
}
|
84
|
-
|
|
|
85
|
- if (pass) {
|
|
|
86
|
- $accountTip.addClass('hide');
|
|
|
87
|
- } else {
|
|
|
88
|
- $accountTip.removeClass('hide').children('em').text(err);
|
|
|
89
|
- }
|
|
|
90
|
-
|
|
|
91
|
- return pass;
|
|
|
92
|
}
|
104
|
}
|
93
|
|
105
|
|
94
|
-function disableTips() {
|
|
|
95
|
- 'use strict';
|
|
|
96
|
- $phone.tips('hide');
|
|
|
97
|
-}
|
|
|
98
|
-
|
|
|
99
|
-function enableTips() {
|
|
|
100
|
- 'use strict';
|
|
|
101
|
- $phone.tips('show', '× 账号不存在');
|
|
|
102
|
-}
|
|
|
103
|
-
|
|
|
104
|
-function tryUser() {
|
106
|
+function validateAccountAsync() {
|
105
|
return $.ajax({
|
107
|
return $.ajax({
|
106
|
type: 'POST',
|
108
|
type: 'POST',
|
107
|
url: '/passport/login/user',
|
109
|
url: '/passport/login/user',
|
|
@@ -109,179 +111,150 @@ function tryUser() { |
|
@@ -109,179 +111,150 @@ function tryUser() { |
109
|
phoneNum: $account.val(),
|
111
|
phoneNum: $account.val(),
|
110
|
area: $countryCodeEm.val().replace('+', '')
|
112
|
area: $countryCodeEm.val().replace('+', '')
|
111
|
}
|
113
|
}
|
112
|
-
|
|
|
113
|
}).then(function(data) {
|
114
|
}).then(function(data) {
|
114
|
if (data.code && data.code === 200) {
|
115
|
if (data.code && data.code === 200) {
|
115
|
- authing = false;
|
|
|
116
|
- disableTips();
|
116
|
+ ep.emit('phone', true);
|
|
|
117
|
+ return true;
|
117
|
} else {
|
118
|
} else {
|
118
|
- enableTips();
|
|
|
119
|
- authing = true;
|
119
|
+ ep.emit('phone', false);
|
|
|
120
|
+ errTip($phone, '账号不存在');
|
|
|
121
|
+ return false;
|
120
|
}
|
122
|
}
|
121
|
});
|
123
|
});
|
122
|
}
|
124
|
}
|
123
|
|
125
|
|
|
|
126
|
+function validateAccount() {
|
|
|
127
|
+ var defer = $.Deferred(); // eslint-disable-line
|
124
|
|
128
|
|
125
|
-// 验证密码
|
|
|
126
|
-function validatePassword() {
|
|
|
127
|
- var pass = false,
|
|
|
128
|
- password = $.trim($password.val()),
|
|
|
129
|
- err;
|
|
|
130
|
-
|
|
|
131
|
- if (password !== '') {
|
|
|
132
|
- if (password.length < 6) {
|
|
|
133
|
- err = '请输入长度为6-20字符的密码';
|
|
|
134
|
- } else {
|
|
|
135
|
- pass = true;
|
|
|
136
|
- }
|
129
|
+ if (validateAccountLocal()) {
|
|
|
130
|
+ validateAccountAsync().then(function(result) {
|
|
|
131
|
+ defer.resolve(result);
|
|
|
132
|
+ });
|
137
|
} else {
|
133
|
} else {
|
138
|
- err = '请输入密码';
|
134
|
+ defer.resolve(false);
|
139
|
}
|
135
|
}
|
140
|
|
136
|
|
141
|
- if (pass) {
|
|
|
142
|
- $passwordTip.addClass('hide');
|
|
|
143
|
- } else {
|
|
|
144
|
- $passwordTip.removeClass('hide').children('em').text(err);
|
|
|
145
|
- }
|
|
|
146
|
- return pass;
|
137
|
+ return defer.promise();
|
147
|
}
|
138
|
}
|
148
|
|
139
|
|
149
|
-// 验证验证码
|
|
|
150
|
-function validateCaptcha() {
|
|
|
151
|
- var pass = false,
|
|
|
152
|
- captcha = $.trim($captcha.val()),
|
|
|
153
|
- err;
|
|
|
154
|
-
|
|
|
155
|
- // 验证码不可见的时候不验证
|
|
|
156
|
- if ($captchaWrap.is(':hidden')) {
|
|
|
157
|
- return true;
|
|
|
158
|
- }
|
|
|
159
|
-
|
|
|
160
|
- if (captcha !== '') {
|
|
|
161
|
- if (captcha.length !== 4) {
|
|
|
162
|
- err = '请输入长度为4字符的验证码';
|
140
|
+// 验证密码
|
|
|
141
|
+function validatePasswordLocal() {
|
|
|
142
|
+ var password = $.trim($password.val());
|
|
|
143
|
+ var length = password.length;
|
|
|
144
|
+
|
|
|
145
|
+ if (length !== 0) {
|
|
|
146
|
+ if (length < 6) {
|
|
|
147
|
+ ep.emit('password', false);
|
|
|
148
|
+ errTip($password, '请输入长度为6-20字符的密码');
|
|
|
149
|
+ return false;
|
163
|
} else {
|
150
|
} else {
|
164
|
- pass = true;
|
151
|
+ ep.emit('password', true);
|
|
|
152
|
+ return true;
|
165
|
}
|
153
|
}
|
166
|
} else {
|
154
|
} else {
|
167
|
- err = '请输入验证码';
|
155
|
+ errTip($password, '请输入密码');
|
|
|
156
|
+ ep.emit('password', false);
|
|
|
157
|
+ return false;
|
168
|
}
|
158
|
}
|
169
|
-
|
|
|
170
|
- if (pass) {
|
|
|
171
|
- $captchaTip.addClass('hide');
|
|
|
172
|
- } else {
|
|
|
173
|
- $captchaTip.removeClass('hide').children('em').text(err);
|
|
|
174
|
- }
|
|
|
175
|
- return pass;
|
|
|
176
|
}
|
159
|
}
|
177
|
|
160
|
|
178
|
-// 验证
|
|
|
179
|
-function validate() {
|
|
|
180
|
- var pass = true,
|
|
|
181
|
- account = $.trim($account.val()),
|
|
|
182
|
- password = $.trim($password.val());
|
|
|
183
|
-
|
|
|
184
|
- if (account !== '') {
|
|
|
185
|
- pass = validateAccount() && validatePassword() && validateCaptcha();
|
|
|
186
|
- } else {
|
|
|
187
|
- pass = false;
|
|
|
188
|
-
|
|
|
189
|
- if (password === '') {
|
161
|
+// 验证验证码
|
|
|
162
|
+function validateCaptchaLocal() {
|
|
|
163
|
+ var captcha = $.trim($captcha.val());
|
|
|
164
|
+ var length = captcha.length;
|
190
|
|
165
|
|
191
|
- // 账户名和密码都为空的情况下点击登陆,只在账户输入框后显示错误提示
|
|
|
192
|
- $accountTip.addClass('both-error').removeClass('hide').children('em').text('请输入账户名和密码');
|
|
|
193
|
- $passwordTip.addClass('hide');
|
|
|
194
|
- } else {
|
|
|
195
|
- $accountTip.removeClass('hide').children('em').text(ERR_ACCOUNT_EMPTY);
|
|
|
196
|
- }
|
166
|
+ if ($captchaWrap.hasClass('hide')) {
|
|
|
167
|
+ ep.emit('captcha', true);
|
|
|
168
|
+ return;
|
197
|
}
|
169
|
}
|
198
|
|
170
|
|
199
|
- return pass;
|
171
|
+ switch (length) {
|
|
|
172
|
+ case 0:
|
|
|
173
|
+ errTip($captcha, '请输入验证码');
|
|
|
174
|
+ ep.emit('captcha', false);
|
|
|
175
|
+ break;
|
|
|
176
|
+ case 4:
|
|
|
177
|
+ ep.emit('captcha', true);
|
|
|
178
|
+ break;
|
|
|
179
|
+ default:
|
|
|
180
|
+ errTip($captcha, '请输入长度为4字符的验证码');
|
|
|
181
|
+ ep.emit('captcha', false);
|
|
|
182
|
+ break;
|
|
|
183
|
+ }
|
200
|
}
|
184
|
}
|
201
|
|
185
|
|
202
|
// 密码错误次数,超过三次显示验证码
|
186
|
// 密码错误次数,超过三次显示验证码
|
203
|
-function vaAccountErrTimes() {
|
187
|
+function showAccountErrTimes() {
|
|
|
188
|
+ $captchaWrap.removeClass('hide');
|
204
|
$captchaImg.attr('src', captchaUrl + $.now());
|
189
|
$captchaImg.attr('src', captchaUrl + $.now());
|
205
|
$captcha.val('');
|
190
|
$captcha.val('');
|
206
|
- $captchaWrap.removeClass('hide');
|
|
|
207
|
}
|
191
|
}
|
208
|
|
192
|
|
209
|
// 登录
|
193
|
// 登录
|
210
|
function login() {
|
194
|
function login() {
|
211
|
- var pass = validate();
|
|
|
212
|
-
|
|
|
213
|
- if (pass && authing === false) {
|
|
|
214
|
- authing = true;
|
|
|
215
|
-
|
|
|
216
|
- $.ajax({
|
|
|
217
|
- url: '/passport/login/auth',
|
|
|
218
|
- type: 'POST',
|
|
|
219
|
- data: {
|
|
|
220
|
- areaCode: $countryCodeEm.val().replace('+', ''),
|
|
|
221
|
- account: $.trim($account.val()),
|
|
|
222
|
- password: $.trim($password.val()),
|
|
|
223
|
- captcha: $.trim($captcha.val()),
|
|
|
224
|
- isRemember: $remember.hasClass('checked') ? true : false
|
|
|
225
|
- },
|
|
|
226
|
- success: function(res) {
|
|
|
227
|
- if (res.code === 200) {
|
|
|
228
|
- if (res.data) {
|
|
|
229
|
-
|
|
|
230
|
- // 防止data.data为undefined时下行语句执行出错而导致脚本不能走到complete去处理authing
|
|
|
231
|
- location.href = res.data.session;
|
|
|
232
|
- }
|
195
|
+ $.ajax({
|
|
|
196
|
+ url: '/passport/login/auth',
|
|
|
197
|
+ type: 'POST',
|
|
|
198
|
+ data: {
|
|
|
199
|
+ areaCode: $countryCodeEm.val().replace('+', ''),
|
|
|
200
|
+ account: $.trim($account.val()),
|
|
|
201
|
+ password: $.trim($password.val()),
|
|
|
202
|
+ captcha: $.trim($captcha.val()),
|
|
|
203
|
+ isRemember: $remember.hasClass('checked') ? true : false
|
|
|
204
|
+ },
|
|
|
205
|
+ success: function(res) {
|
|
|
206
|
+ if (res.code === 200) {
|
|
|
207
|
+ if (res.data) {
|
|
|
208
|
+
|
|
|
209
|
+ // 防止data.data为undefined时下行语句执行出错而导致脚本不能走到complete去处理authing
|
|
|
210
|
+ location.href = res.data.session;
|
|
|
211
|
+ }
|
|
|
212
|
+ } else {
|
|
|
213
|
+ if (res.data.errorType === 'captcha') {
|
|
|
214
|
+ $captcha.val('');
|
233
|
} else {
|
215
|
} else {
|
234
|
- if (res.data.errorType === 'captcha') {
|
|
|
235
|
- $captchaTip.removeClass('hide').children('em').html(res.message);
|
|
|
236
|
- $captcha.val('');
|
|
|
237
|
- } else {
|
|
|
238
|
- $loginTip.removeClass('hide').children('em').html(res.message);
|
|
|
239
|
- $password.val('');
|
|
|
240
|
- }
|
|
|
241
|
-
|
|
|
242
|
- // 验证错误次数
|
|
|
243
|
- if (res.data && res.data.needCaptcha) {
|
|
|
244
|
- vaAccountErrTimes();
|
|
|
245
|
- }
|
216
|
+ $loginTip.removeClass('hide').children('em').html(res.message);
|
|
|
217
|
+ $password.val('');
|
|
|
218
|
+ }
|
|
|
219
|
+
|
|
|
220
|
+ // 验证错误次数
|
|
|
221
|
+ if (res.data && res.data.needCaptcha) {
|
|
|
222
|
+ showAccountErrTimes();
|
246
|
}
|
223
|
}
|
247
|
- },
|
|
|
248
|
- complete: function() {
|
|
|
249
|
- authing = false;
|
|
|
250
|
}
|
224
|
}
|
251
|
- });
|
|
|
252
|
- }
|
225
|
+ }
|
|
|
226
|
+ });
|
253
|
}
|
227
|
}
|
254
|
|
228
|
|
255
|
mailAc($account, function() {
|
229
|
mailAc($account, function() {
|
256
|
-
|
|
|
257
|
- if (validateAccount()) {
|
|
|
258
|
-
|
|
|
259
|
- tryUser().then(function() {
|
|
|
260
|
-
|
|
|
261
|
- return $.ajax({
|
|
|
262
|
- url: '/passport/login/account',
|
|
|
263
|
- type: 'GET',
|
|
|
264
|
- data: {
|
|
|
265
|
- account: $.trim($account.val())
|
|
|
266
|
- }
|
|
|
267
|
- });
|
|
|
268
|
- }).then(function(res) {
|
|
|
269
|
- 'use strict';
|
|
|
270
|
- if (res.data && res.data.needCaptcha) {
|
|
|
271
|
- vaAccountErrTimes();
|
230
|
+ function validateUser() {
|
|
|
231
|
+ return $.ajax({
|
|
|
232
|
+ url: '/passport/login/account',
|
|
|
233
|
+ type: 'GET',
|
|
|
234
|
+ data: {
|
|
|
235
|
+ account: $.trim($account.val())
|
272
|
}
|
236
|
}
|
273
|
});
|
237
|
});
|
274
|
}
|
238
|
}
|
275
|
-});
|
|
|
276
|
|
239
|
|
277
|
-$account.on('keyup', function() {
|
|
|
278
|
- 'use strict';
|
|
|
279
|
- var value = $.trim($(this).val());
|
240
|
+ $.when(validateAccount()).then(function(result) {
|
|
|
241
|
+ if (result) {
|
|
|
242
|
+ return $.when(validateUser());
|
|
|
243
|
+ } else {
|
|
|
244
|
+ return $.when(false);
|
|
|
245
|
+ }
|
|
|
246
|
+ }).then(function(res) {
|
|
|
247
|
+ if (!res) {
|
|
|
248
|
+ return;
|
|
|
249
|
+ }
|
280
|
|
250
|
|
281
|
- if (value.length === 0) {
|
|
|
282
|
- disableTips();
|
|
|
283
|
- }
|
|
|
284
|
-}).on('focus', function() {
|
251
|
+ if (res.data && res.data.needCaptcha) {
|
|
|
252
|
+ showAccountErrTimes();
|
|
|
253
|
+ }
|
|
|
254
|
+ });
|
|
|
255
|
+});
|
|
|
256
|
+
|
|
|
257
|
+$account.on('focus', function() {
|
285
|
$phone.addClass('focus');
|
258
|
$phone.addClass('focus');
|
286
|
}).on('blur', function() {
|
259
|
}).on('blur', function() {
|
287
|
$phone.removeClass('focus');
|
260
|
$phone.removeClass('focus');
|
|
@@ -290,32 +263,16 @@ $account.on('keyup', function() { |
|
@@ -290,32 +263,16 @@ $account.on('keyup', function() { |
290
|
$('[placeholder]').placeholder();
|
263
|
$('[placeholder]').placeholder();
|
291
|
|
264
|
|
292
|
$countryList.change(function() {
|
265
|
$countryList.change(function() {
|
293
|
- 'use strict';
|
|
|
294
|
var $this = $(this);
|
266
|
var $this = $(this);
|
295
|
|
267
|
|
296
|
$countryCodeEm.text($this.val());
|
268
|
$countryCodeEm.text($this.val());
|
297
|
-
|
|
|
298
|
});
|
269
|
});
|
299
|
|
270
|
|
300
|
// 密码
|
271
|
// 密码
|
301
|
$password.on('blur', function() {
|
272
|
$password.on('blur', function() {
|
302
|
$password.removeClass('focus');
|
273
|
$password.removeClass('focus');
|
303
|
-
|
|
|
304
|
- validatePassword();
|
|
|
305
|
- if ($capsLock.hasClass('hide')) {
|
|
|
306
|
- return;
|
|
|
307
|
- }
|
|
|
308
|
-
|
|
|
309
|
- $capsLock.addClass('hide');
|
|
|
310
|
-}).on('keypress', function(e) {
|
|
|
311
|
- var code = e.which;
|
|
|
312
|
-
|
|
|
313
|
- // CapsLock检测
|
|
|
314
|
- if (code >= 65 && code <= 90) {
|
|
|
315
|
- $capsLock.removeClass('hide');
|
|
|
316
|
- return;
|
|
|
317
|
- }
|
|
|
318
|
- $capsLock.addClass('hide');
|
274
|
+ validatePasswordLocal();
|
|
|
275
|
+ $captcha.trigger('blur');
|
319
|
}).on('focus', function() {
|
276
|
}).on('focus', function() {
|
320
|
$password.addClass('focus');
|
277
|
$password.addClass('focus');
|
321
|
});
|
278
|
});
|
|
@@ -323,7 +280,7 @@ $password.on('blur', function() { |
|
@@ -323,7 +280,7 @@ $password.on('blur', function() { |
323
|
// 验证码
|
280
|
// 验证码
|
324
|
$captcha.on('blur', function() {
|
281
|
$captcha.on('blur', function() {
|
325
|
$captcha.removeClass('focus');
|
282
|
$captcha.removeClass('focus');
|
326
|
- validateCaptcha();
|
283
|
+ validateCaptchaLocal();
|
327
|
}).on('focus', function() {
|
284
|
}).on('focus', function() {
|
328
|
$captcha.addClass('focus');
|
285
|
$captcha.addClass('focus');
|
329
|
});
|
286
|
});
|
|
@@ -360,8 +317,46 @@ $captchaWrap.on('click', '.change-captcha, .captcha-img', function() { |
|
@@ -360,8 +317,46 @@ $captchaWrap.on('click', '.change-captcha, .captcha-img', function() { |
360
|
$captchaImg.attr('src', captchaUrl + $.now());
|
317
|
$captchaImg.attr('src', captchaUrl + $.now());
|
361
|
});
|
318
|
});
|
362
|
|
319
|
|
|
|
320
|
+// 初始:只带账户名的页面,密码输入获得焦点
|
|
|
321
|
+if (($account.val() !== '' || $account.val() === $account.attr('placeholder')) &&
|
|
|
322
|
+ $password.val() === '') {
|
|
|
323
|
+ $password.focus();
|
|
|
324
|
+}
|
|
|
325
|
+
|
|
|
326
|
+ep.tail('phone', 'password', 'captcha', function(phoneAuth, passwordAuth, captchaAuth) {
|
|
|
327
|
+ if (phoneAuth && passwordAuth && captchaAuth) {
|
|
|
328
|
+ $login.removeClass('auth_ok');
|
|
|
329
|
+ } else {
|
|
|
330
|
+ $login.addClass('auth_ok');
|
|
|
331
|
+ }
|
|
|
332
|
+});
|
|
|
333
|
+
|
|
|
334
|
+ep.on('phone', function(auth) {
|
|
|
335
|
+ if (auth) {
|
|
|
336
|
+ $errTip.addClass('hide');
|
|
|
337
|
+ }
|
|
|
338
|
+});
|
|
|
339
|
+
|
|
|
340
|
+ep.on('password', function(auth) {
|
|
|
341
|
+ if (auth) {
|
|
|
342
|
+ $errTip.addClass('hide');
|
|
|
343
|
+ }
|
|
|
344
|
+});
|
|
|
345
|
+
|
|
|
346
|
+ep.on('captcha', function(auth) {
|
|
|
347
|
+ if (auth && !$captchaWrap.hasClass('hide')) {
|
|
|
348
|
+ $errTip.addClass('hide');
|
|
|
349
|
+ }
|
|
|
350
|
+});
|
|
|
351
|
+
|
363
|
// 登录
|
352
|
// 登录
|
364
|
-$login.on('click', login);
|
353
|
+$login.on('click', function() {
|
|
|
354
|
+ if ($login.hasClass('auth_ok')) {
|
|
|
355
|
+ return;
|
|
|
356
|
+ }
|
|
|
357
|
+
|
|
|
358
|
+ login();
|
|
|
359
|
+});
|
365
|
|
360
|
|
366
|
// Enter登录
|
361
|
// Enter登录
|
367
|
$('input.va').on('keypress', function(e) {
|
362
|
$('input.va').on('keypress', function(e) {
|
|
@@ -370,9 +365,3 @@ $('input.va').on('keypress', function(e) { |
|
@@ -370,9 +365,3 @@ $('input.va').on('keypress', function(e) { |
370
|
}
|
365
|
}
|
371
|
});
|
366
|
});
|
372
|
|
367
|
|
373
|
-// 初始:只带账户名的页面,密码输入获得焦点
|
|
|
374
|
-if (($account.val() !== '' || $account.val() === $account.attr('placeholder')) &&
|
|
|
375
|
- $password.val() === '') {
|
|
|
376
|
- $password.focus();
|
|
|
377
|
-}
|
|
|
378
|
- |
|
|