Authored by lore-w

注册逻辑修改

@@ -35,8 +35,8 @@ @@ -35,8 +35,8 @@
35 <span class="pwd-intensity high">高</span> 35 <span class="pwd-intensity high">高</span>
36 </div> 36 </div>
37 <div id="pwd-tips" class="hide pwd-tips"> 37 <div id="pwd-tips" class="hide pwd-tips">
38 - <div class="default" id="pwd-tip1">密码只支持6-20位字符</div>  
39 - <div class="default" id="pwd-tip2">建议由字母、 数字、 符号两种以上组合</div> 38 + <div class="default" id="pwd-tip1"><i></i>密码只支持6-20位字符</div>
  39 + <div class="default" id="pwd-tip2"><i></i>建议由字母、 数字、 符号两种以上组合</div>
40 </div> 40 </div>
41 </li> 41 </li>
42 42
@@ -4,11 +4,13 @@ @@ -4,11 +4,13 @@
4 */ 4 */
5 5
6 var $ = require('yoho.jquery'), 6 var $ = require('yoho.jquery'),
7 - regValidate = require('./mail-phone-regx'); 7 + regValidate = require('./mail-phone-regx'),
  8 + computeComplex = require('./pwd-strength');
8 9
9 var $registerPage = $('.register-page'), 10 var $registerPage = $('.register-page'),
10 $pwdTips = $('#pwd-tips'), 11 $pwdTips = $('#pwd-tips'),
11 - $errTip = $('#err-tip'); 12 + $errTip = $('#err-tip'),
  13 + $registerBtn = $('#register-btn');
12 14
13 var $sendCaptcha = $('#send-captcha'), 15 var $sendCaptcha = $('#send-captcha'),
14 caCount = 4, 16 caCount = 4,
@@ -20,6 +22,10 @@ var $pn = $('#phone-num'), @@ -20,6 +22,10 @@ var $pn = $('#phone-num'),
20 $repwd = $('#repwd'), 22 $repwd = $('#repwd'),
21 $ca = $('#captcha'); 23 $ca = $('#captcha');
22 24
  25 +// 密码强度验证
  26 +var $pwdIntensity = $('.pwd-intensity'),
  27 + $pwdParent = $pwdIntensity.closest('.pwd-intensity-container');
  28 +
23 //signup验证 29 //signup验证
24 var $region = $('#country-code'), 30 var $region = $('#country-code'),
25 $regionSelect = $('#region'); 31 $regionSelect = $('#region');
@@ -293,20 +299,43 @@ function showBorder() { @@ -293,20 +299,43 @@ function showBorder() {
293 $errInput = $('#' + validateResult[i].id); 299 $errInput = $('#' + validateResult[i].id);
294 $errInput.addClass('error'); 300 $errInput.addClass('error');
295 301
  302 + } else {
  303 +
  304 + //去掉红色边框
  305 + $errInput = $('#' + validateResult[i].id);
  306 + $errInput.removeClass('error');
296 } 307 }
297 } 308 }
298 } 309 }
299 310
300 // 失去焦点时开始校验 311 // 失去焦点时开始校验
301 -$registerPage.find('.va').focus(function() { 312 +// Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
  313 +$registerPage.find('.va').keyup(function() {
302 314
303 - // 去掉错误提示,当获得焦点的时候重置message信息  
304 - var index = $(this).parents('li').attr('data-index'); 315 + var j,
  316 + statusLen = 0,
  317 + vLen = validateResult.length;
  318 +
  319 + validateRule($(this), function() {
  320 + showErrTip();
  321 + showBorder(); // 显示红色边框
305 322
306 - validateResult[index].message = ''; 323 + for (j = 0; j < vLen; j++) {
307 324
308 - showErrTip(); // 显示错误提示 325 + if (validateResult[j].status) {
  326 +
  327 + statusLen++;
  328 + }
  329 +
  330 + }
  331 +
  332 + if (statusLen === 4 && $('#agree-terms').is(':checked')) {
  333 + $registerBtn.removeClass('disable');
  334 + } else {
  335 + $registerBtn.addClass('disable');
  336 + }
309 337
  338 + });
310 339
311 }).blur(function() { 340 }).blur(function() {
312 341
@@ -338,4 +367,53 @@ $ca.keyup(function() { @@ -338,4 +367,53 @@ $ca.keyup(function() {
338 } else { 367 } else {
339 $sendCaptcha.addClass('disable'); 368 $sendCaptcha.addClass('disable');
340 } 369 }
  370 +});
  371 +
  372 +$pwd.keyup(function() {
  373 + var pwd = $(this).val(),
  374 + pwdStrength = computeComplex(pwd),
  375 + level = 0;
  376 +
  377 + if (pwdStrength === 0) {
  378 + level = 0;
  379 + } else if (pwdStrength <= 10) {
  380 + level = 1;
  381 + } else if (pwdStrength <= 20) {
  382 + level = 2;
  383 + } else {
  384 + level = 3;
  385 + }
  386 +
  387 + switch (level) {
  388 + case 0:
  389 + $pwdParent.removeClass('red yellow green');
  390 + $pwdIntensity.removeClass('color');
  391 + break;
  392 + case 1:
  393 + $pwdParent.addClass('red').removeClass('yellow green');
  394 + $pwdIntensity.filter('.low').addClass('color');
  395 + $pwdIntensity.filter('.mid,.high').removeClass('color');
  396 + break;
  397 + case 2:
  398 + $pwdParent.addClass('yellow').removeClass('red green');
  399 + $pwdIntensity.filter('.low,.mid').addClass('color');
  400 + $pwdIntensity.filter('.high').removeClass('color');
  401 + break;
  402 + case 3:
  403 + $pwdParent.addClass('green').removeClass('yellow red');
  404 + $pwdIntensity.addClass('color');
  405 + break;
  406 + }
  407 +
  408 + //提示框
  409 + /*if (pwd === '') {
  410 +
  411 + } else {
  412 +
  413 + if (pwd.length < 6 || pwd.length > 20) {
  414 +
  415 + } else {
  416 +
  417 + }
  418 + }*/
341 }); 419 });
@@ -139,6 +139,8 @@ @@ -139,6 +139,8 @@
139 width: 270px; 139 width: 270px;
140 text-align: right; 140 text-align: right;
141 margin-top: 5px; 141 margin-top: 5px;
  142 + height: auto;
  143 + overflow: hidden;
142 144
143 .pwd-intensity { 145 .pwd-intensity {
144 height: 15px; 146 height: 15px;
@@ -166,7 +168,7 @@ @@ -166,7 +168,7 @@
166 168
167 &.green { 169 &.green {
168 .color { 170 .color {
169 - background: #0f0; 171 + background: #3ee392;
170 color: #fff; 172 color: #fff;
171 } 173 }
172 } 174 }
@@ -184,6 +186,7 @@ @@ -184,6 +186,7 @@
184 width: 270px; 186 width: 270px;
185 font-size: 20px; 187 font-size: 20px;
186 font-weight: bold; 188 font-weight: bold;
  189 + background: #ff1901;
187 190
188 &.disable { 191 &.disable {
189 background: #555; 192 background: #555;
@@ -208,6 +211,18 @@ @@ -208,6 +211,18 @@
208 background-color: #ffebeb; 211 background-color: #ffebeb;
209 border: 1px solid #ffbdbe; 212 border: 1px solid #ffbdbe;
210 padding: 0 10px; 213 padding: 0 10px;
  214 +
  215 + b {
  216 + display: block;
  217 + width: 0;
  218 + height: 0;
  219 + border-left: 8px solid transparent;
  220 + border-right: 8px solid transparent;
  221 + border-top: 8px solid #ffebeb;
  222 + position: absolute;
  223 + top: 30px;
  224 + left: 20px;
  225 + }
211 } 226 }
212 } 227 }
213 } 228 }
@@ -55,7 +55,7 @@ class RegisterController extends AbstractAction @@ -55,7 +55,7 @@ class RegisterController extends AbstractAction
55 public function checkmobileAction() 55 public function checkmobileAction()
56 { 56 {
57 $data = array( 57 $data = array(
58 - 'code' => 404 58 + 'code' => 200
59 ); 59 );
60 60
61 $this -> echoJson($data); 61 $this -> echoJson($data);
@@ -65,7 +65,7 @@ class RegisterController extends AbstractAction @@ -65,7 +65,7 @@ class RegisterController extends AbstractAction
65 public function piccaptchaAction() 65 public function piccaptchaAction()
66 { 66 {
67 $data = array( 67 $data = array(
68 - 'code' => 404 68 + 'code' => 200
69 ); 69 );
70 70
71 $this -> echoJson($data); 71 $this -> echoJson($data);
@@ -75,7 +75,7 @@ class RegisterController extends AbstractAction @@ -75,7 +75,7 @@ class RegisterController extends AbstractAction
75 public function msgcaptchaAction() 75 public function msgcaptchaAction()
76 { 76 {
77 $data = array( 77 $data = array(
78 - 'code' => 404 78 + 'code' => 200
79 ); 79 );
80 80
81 $this -> echoJson($data); 81 $this -> echoJson($data);