Authored by htoooth

add login

@@ -78,9 +78,9 @@ passport.use(new LocalStrategy({ @@ -78,9 +78,9 @@ passport.use(new LocalStrategy({
78 let accountTimes = _.parseInt(times[1]) || 0; 78 let accountTimes = _.parseInt(times[1]) || 0;
79 let ipTimes = _.parseInt(times[2]) || 0; 79 let ipTimes = _.parseInt(times[2]) || 0;
80 80
81 - if (accountTimes >= Infinity) { 81 + if (accountTimes >= 10) {
82 done({message: '您的账号已被暂时锁定,请稍后再试'}, null); 82 done({message: '您的账号已被暂时锁定,请稍后再试'}, null);
83 - } else if (ipTimes >= Infinity) { 83 + } else if (ipTimes >= 100) {
84 done({message: '您尝试的次数过多,账号已被暂时锁定,请稍后再试'}, null); 84 done({message: '您尝试的次数过多,账号已被暂时锁定,请稍后再试'}, null);
85 } else { 85 } else {
86 return AuthHelper.signin(area, username, password, shoppingKey).then((result) => { 86 return AuthHelper.signin(area, username, password, shoppingKey).then((result) => {
@@ -16,7 +16,7 @@ const config = global.yoho.config; @@ -16,7 +16,7 @@ const config = global.yoho.config;
16 const cache = global.yoho.cache; 16 const cache = global.yoho.cache;
17 const AuthHelper = require('../models/auth-helper'); 17 const AuthHelper = require('../models/auth-helper');
18 const PassportHelper = require('../models/passport-helper'); 18 const PassportHelper = require('../models/passport-helper');
19 -const loginPage = `${config.siteUrl}/signin.html`; 19 +const loginPage = `${config.siteUrl}/signin`;
20 20
21 // 第三方登录回调 21 // 第三方登录回调
22 function doPassportCallback(req, res, user) { 22 function doPassportCallback(req, res, user) {
@@ -122,8 +122,6 @@ const local = { @@ -122,8 +122,6 @@ const local = {
122 qqLogin: helpers.urlFormat('/passport/autosign/qq'), 122 qqLogin: helpers.urlFormat('/passport/autosign/qq'),
123 weiboLogin: helpers.urlFormat('/passport/autosign/sina'), 123 weiboLogin: helpers.urlFormat('/passport/autosign/sina'),
124 alipayLogin: helpers.urlFormat('/passport/autosign/alipay'), 124 alipayLogin: helpers.urlFormat('/passport/autosign/alipay'),
125 - doubanLogin: helpers.urlFormat('/passport/autosign/douban'),  
126 - renrenLogin: helpers.urlFormat('/passport/autosign/renren'),  
127 bindMobile: bindMobile 125 bindMobile: bindMobile
128 }, 126 },
129 module: 'passport', 127 module: 'passport',
@@ -156,11 +154,11 @@ const local = { @@ -156,11 +154,11 @@ const local = {
156 if (refer) { 154 if (refer) {
157 refer = decodeURI(req.cookies.refer); 155 refer = decodeURI(req.cookies.refer);
158 } else { 156 } else {
159 - refer = `${config.siteUrl}/home`; 157 + refer = `${config.siteUrl}`;
160 } 158 }
161 159
162 if (/sign|login/.test(refer)) { 160 if (/sign|login/.test(refer)) {
163 - refer = `${config.siteUrl}/home`; 161 + refer = `${config.siteUrl}`;
164 } 162 }
165 user.session = refer; 163 user.session = refer;
166 user.href = refer; 164 user.href = refer;
@@ -39,14 +39,6 @@ router.get('/login/qq/callback', login.qq.callback); @@ -39,14 +39,6 @@ router.get('/login/qq/callback', login.qq.callback);
39 router.get('/autosign/alipay', login.common.beforeLogin, login.alipay.login); 39 router.get('/autosign/alipay', login.common.beforeLogin, login.alipay.login);
40 router.get('/login/alipay/callback', login.alipay.callback); 40 router.get('/login/alipay/callback', login.alipay.callback);
41 41
42 -// douban登录  
43 -router.get('/autosign/douban', login.common.beforeLogin, login.douban.login);  
44 -router.get('/autosign/doubanback', login.douban.callback);  
45 -  
46 -// renren登录  
47 -router.get('/autosign/renren', login.common.beforeLogin, login.renren.login);  
48 -router.get('/login/renren/callback', login.renren.callback);  
49 -  
50 router.get('/login/account', login.common.needCaptcha); 42 router.get('/login/account', login.common.needCaptcha);
51 43
52 // 第三方登录后绑定 44 // 第三方登录后绑定
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 {{/each}} 12 {{/each}}
13 </select> 13 </select>
14 14
15 - <div id="phone" class="left phone"> 15 + <div id="phone" class="left phone needTip">
16 <span id="country-code" class="country-code">{{countryCode}}</span> 16 <span id="country-code" class="country-code">{{countryCode}}</span>
17 <input id="account" class="account input phone-num va" name="account" value="{{bindMobile}}" 17 <input id="account" class="account input phone-num va" name="account" value="{{bindMobile}}"
18 type="text" 18 type="text"
@@ -21,14 +21,14 @@ @@ -21,14 +21,14 @@
21 </li> 21 </li>
22 22
23 <li class="clearfix"> 23 <li class="clearfix">
24 - <input id="password" class="input password va" name="password" type="password" placeholder="Password" 24 + <input id="password" class="input password va needTip" name="password" type="password"
  25 + placeholder="Password"
25 autocomplete="off" maxlength="20"> 26 autocomplete="off" maxlength="20">
26 - <span id="caps-lock" class="caps-lock hide">大写状态开启</span>  
27 </li> 27 </li>
28 28
29 <li class="clearfix captcha-wrap hide"> 29 <li class="clearfix captcha-wrap hide">
30 30
31 - <input id="captcha" class="input va captcha" type="text" name="captcha" placeholder="图形验证码" 31 + <input id="captcha" class="input va captcha needTip" type="text" name="captcha" placeholder="图形验证码"
32 autocomplete="off" maxlength="4"> 32 autocomplete="off" maxlength="4">
33 33
34 <div class="left captcha-component"> 34 <div class="left captcha-component">
@@ -38,6 +38,11 @@ @@ -38,6 +38,11 @@
38 </li> 38 </li>
39 39
40 <li class="clearfix"> 40 <li class="clearfix">
  41 + <span class="left login-fail-tip hide">
  42 + <span class="'iconfont">&#xe608;</span>
  43 + <em></em>
  44 + </span>
  45 +
41 <a id="login-btn" class="btn login-btn">登录</a> 46 <a id="login-btn" class="btn login-btn">登录</a>
42 </li> 47 </li>
43 48
@@ -55,13 +60,13 @@ @@ -55,13 +60,13 @@
55 <li class="clearfix third-party-login"> 60 <li class="clearfix third-party-login">
56 61
57 <a href="{{weixinLogin}}"> 62 <a href="{{weixinLogin}}">
58 - <span class="iconfont weixin">&#xe622;</span> 63 + <span class="iconfont weixin">&#xe642;</span>
59 </a> 64 </a>
60 <a href="{{qqLogin}}"> 65 <a href="{{qqLogin}}">
61 - <span class="iconfont qq">&#xe626;</span> 66 + <span class="iconfont qq">&#xe641;</span>
62 </a> 67 </a>
63 <a href="{{weiboLogin}}"> 68 <a href="{{weiboLogin}}">
64 - <span class="iconfont weibo">&#xe62e;</span> 69 + <span class="iconfont weibo">&#xe640;</span>
65 </a> 70 </a>
66 <a href="{{alipayLogin}}"> 71 <a href="{{alipayLogin}}">
67 <span class="iconfont alipay">&#xe63f;</span> 72 <span class="iconfont alipay">&#xe63f;</span>
@@ -78,6 +83,11 @@ @@ -78,6 +83,11 @@
78 </span> 83 </span>
79 </li> 84 </li>
80 85
  86 + <div class="tips hide">
  87 + <div class="triangle"></div>
  88 + <div class="rectangle"></div>
  89 + </div>
  90 +
81 </ul> 91 </ul>
82 <input id="country-code-hide" name="countryCode" type="hidden" value="{{countryCode}}"> 92 <input id="country-code-hide" name="countryCode" type="hidden" value="{{countryCode}}">
83 {{/ passport}} 93 {{/ passport}}
@@ -26,9 +26,9 @@ module.exports = { @@ -26,9 +26,9 @@ module.exports = {
26 useOneapm: false, 26 useOneapm: false,
27 useCache: false, 27 useCache: false,
28 memcache: { 28 memcache: {
29 - master: ['192.168.102.163:11213'],  
30 - slave: ['192.168.102.163:11213'],  
31 - session: ['192.168.102.161:11213'], 29 + master: ['192.168.102.222:11213'],
  30 + slave: ['192.168.102.222:11213'],
  31 + session: ['192.168.102.222:11213'],
32 timeout: 1000, 32 timeout: 1000,
33 retries: 0 33 retries: 0
34 }, 34 },
@@ -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: '&#xe601;' 36 unchecked: '&#xe601;'
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 -  
@@ -13,10 +13,10 @@ var $registerPage = $('.register-page'), @@ -13,10 +13,10 @@ var $registerPage = $('.register-page'),
13 $errTip = $('.tips'), 13 $errTip = $('.tips'),
14 $registerBtn = $('#register-btn'); 14 $registerBtn = $('#register-btn');
15 15
16 - // $countDown = $('#count-down'),  
17 - // $successBtn = $('.success-btn'),  
18 - // countDown = 5,  
19 - // clearT; 16 +// $countDown = $('#count-down'),
  17 +// $successBtn = $('.success-btn'),
  18 +// countDown = 5,
  19 +// clearT;
20 20
21 var $sendCaptcha = $('#send-captcha'), 21 var $sendCaptcha = $('#send-captcha'),
22 caCount = 4, 22 caCount = 4,
@@ -289,7 +289,6 @@ function validateRule(page, $element, callback) { @@ -289,7 +289,6 @@ function validateRule(page, $element, callback) {
289 regionCode; 289 regionCode;
290 290
291 291
292 -  
293 // 根据需求http://redmine.yoho.cn/issues/3117改成上边的正则 292 // 根据需求http://redmine.yoho.cn/issues/3117改成上边的正则
294 // 对应的错误提示语也改了,感觉要不了多久就会改回来 293 // 对应的错误提示语也改了,感觉要不了多久就会改回来
295 // pwdReg = /^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/gi; 294 // pwdReg = /^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/gi;
@@ -316,7 +315,7 @@ function validateRule(page, $element, callback) { @@ -316,7 +315,7 @@ function validateRule(page, $element, callback) {
316 } 315 }
317 } 316 }
318 317
319 - // 图形验证码校验 318 + // 图形验证码校验
320 } else if ($element.hasClass('captcha')) { 319 } else if ($element.hasClass('captcha')) {
321 if (val === '') { 320 if (val === '') {
322 validateResult[1].message = '请输入图形验证码'; 321 validateResult[1].message = '请输入图形验证码';
@@ -341,7 +340,7 @@ function validateRule(page, $element, callback) { @@ -341,7 +340,7 @@ function validateRule(page, $element, callback) {
341 340
342 } 341 }
343 342
344 - // 短信验证码校验 343 + // 短信验证码校验
345 } else if ($element.hasClass('msg-captcha')) { 344 } else if ($element.hasClass('msg-captcha')) {
346 345
347 if (val === '') { 346 if (val === '') {
@@ -366,7 +365,7 @@ function validateRule(page, $element, callback) { @@ -366,7 +365,7 @@ function validateRule(page, $element, callback) {
366 } 365 }
367 } 366 }
368 367
369 - // 密码校验 368 + // 密码校验
370 } else if ($element.hasClass('pwd')) { 369 } else if ($element.hasClass('pwd')) {
371 if (val === '') { 370 if (val === '') {
372 validateResult[3].message = '请输入密码'; 371 validateResult[3].message = '请输入密码';
@@ -571,9 +570,9 @@ exports.init = function(page) { @@ -571,9 +570,9 @@ exports.init = function(page) {
571 }).blur(function() { 570 }).blur(function() {
572 571
573 /* validateRule($(this), function() { 572 /* validateRule($(this), function() {
574 - showErrTip();  
575 - showBorder(); // 显示红色边框  
576 - });*/ 573 + showErrTip();
  574 + showBorder(); // 显示红色边框
  575 + });*/
577 }); 576 });
578 577
579 $regionSelect.change(function() { 578 $regionSelect.change(function() {
@@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
22 text-align: center; 22 text-align: center;
23 width: $item-width; 23 width: $item-width;
24 color: $theme-color; 24 color: $theme-color;
  25 + font-weight: bold;
25 } 26 }
26 27
27 .pwd-intensity-container { 28 .pwd-intensity-container {