Authored by 陈轩

账户设置密码有货: 第三⽅绑定流程新⽤户输⼊新密码

@@ -10,8 +10,14 @@ @@ -10,8 +10,14 @@
10 您以后还可以使手机号+密码的形式登录有货哦! 10 您以后还可以使手机号+密码的形式登录有货哦!
11 </div> 11 </div>
12 {{/if}} 12 {{/if}}
13 - <div class="input-container row has-eye">  
14 - <input id="pwd" class="input pwd" type="text" placeholder="请输入密码" autocomplete="off" maxlength="20"> 13 + <div class="row">
  14 + <div class="input-container row has-eye">
  15 + <input id="pwd" class="input pwd" type="text" placeholder="请输入密码" autocomplete="off" maxlength="20">
  16 + </div>
  17 + <div class="pwd-lint">
  18 + <i class="iconfont icon-tip">&#xE61A;</i>
  19 + <span class="pwd-lint-txt">由字母、数字组合,不能包含特殊字符</span>
  20 + </div>
15 </div> 21 </div>
16 <span id="btn-sure" class="btn btn-sure disable row">确定</span> 22 <span id="btn-sure" class="btn btn-sure disable row">确定</span>
17 </div> 23 </div>
@@ -6,10 +6,13 @@ @@ -6,10 +6,13 @@
6 var $ = require('yoho-jquery'); 6 var $ = require('yoho-jquery');
7 7
8 var $pwd = $('#pwd'), 8 var $pwd = $('#pwd'),
  9 + $pwdLint = $('.pwd-lint'),
  10 + $pwdLintTxt = $pwdLint.find('.pwd-lint-txt'),
9 $btnSure = $('#btn-sure'); 11 $btnSure = $('#btn-sure');
10 12
11 var api = require('../api'); 13 var api = require('../api');
12 var tip = require('../../plugin/tip'); 14 var tip = require('../../plugin/tip');
  15 +var validatePWD = require('../password-check');
13 16
14 var trim = $.trim; 17 var trim = $.trim;
15 var showErrTip = tip.show; 18 var showErrTip = tip.show;
@@ -53,11 +56,16 @@ api.bindEyesEvt({ @@ -53,11 +56,16 @@ api.bindEyesEvt({
53 }); 56 });
54 57
55 $pwd.bind('input', function() { 58 $pwd.bind('input', function() {
56 - if (trim($pwd.val()) === '') {  
57 - $btnSure.addClass('disable');  
58 - } else {  
59 - $btnSure.removeClass('disable');  
60 - } 59 + var val = $.trim(this.value);
  60 + var bool = validatePWD(val, function(res) {
  61 + $pwdLint.css({visibility: res.valid ? 'hidden' : 'visible'});
  62 +
  63 + if (!res.valid) {
  64 + $pwdLintTxt.text(res.msg);
  65 + }
  66 + });
  67 +
  68 + $btnSure.toggleClass('disable', !bool);
61 }); 69 });
62 70
63 $btnSure.on('touchstart', function() { 71 $btnSure.on('touchstart', function() {
@@ -67,7 +75,7 @@ $btnSure.on('touchstart', function() { @@ -67,7 +75,7 @@ $btnSure.on('touchstart', function() {
67 return; 75 return;
68 } 76 }
69 77
70 - if (api.pwdValidate(pwd) === false) { 78 + if (validatePWD(pwd) === false) {
71 showErrTip('密码6-20位,请重新输入'); 79 showErrTip('密码6-20位,请重新输入');
72 } else { 80 } else {
73 startBind(pwd); 81 startBind(pwd);