zhouna 4 лет назад
Родитель
Сommit
9f70b1aa5e
1 измененных файлов с 20 добавлено и 8 удалено
  1. 20 8
      src/js/index.js

+ 20 - 8
src/js/index.js

@@ -18,9 +18,9 @@ const hideLogo = getUrlArgObject("hideLg");
 const modalDom = `
       <p class="tips"><img src=${WarningIcon} /><span>为确保账号安全,请及时修改初始密码</span></p>
       <div class="modalAction">
-        <p><span class="label"><i>*</i>原密码:</span><input type="password" placeholder="请输入原密码" class="oldword" id="oldWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="oldWaring warning"><img src=${warnIcon} /><b>原密码错误</b></p></p>
-        <p><span class="label"><i>*</i>新密码:</span><input type="password" disabled placeholder="请输入新密码" class="newword" id="newWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="newword warning"><img src=${warnIcon} /><b>密码最多12位</b></p></p>
-        <p><span class="label"><i>*</i>确认新密码:</span><input type="password" disabled placeholder="请输入确认新密码" class="sureword" id="sureWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="sureword warning"><img src=${warnIcon} /><b>两次密码输入不一致</b></p></p>
+        <p><span class="label"><i>*</i>原密码:</span><input type="password" readonly placeholder="请输入原密码" class="oldword" id="oldWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="oldWaring warning"><img src=${warnIcon} /><b>原密码错误</b></p></p>
+        <p><span class="label"><i>*</i>新密码:</span><input type="password" readonly placeholder="请输入新密码" class="newword" id="newWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="newword warning"><img src=${warnIcon} /><b>密码最多12位</b></p></p>
+        <p><span class="label"><i>*</i>确认新密码:</span><input type="password" readonly placeholder="请输入确认新密码" class="sureword" id="sureWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="sureword warning"><img src=${warnIcon} /><b>两次密码输入不一致</b></p></p>
       </div>
     `;
 const psdChecker = `<div class="psd-checkbox">
@@ -122,16 +122,17 @@ function hideDropdown(){//关闭下拉
 
 //绑定输入框事件
 function bindModalEvent(){
-    /*$(".modalAction input[ autocomplete='off']").off("focus").on("focus",function(){
-        $(this).attr("type","password")
+    $(".modalAction input").off("click").on("click",function(){
+          $(this).removeAttr("readonly").focus()
+    })
+    $(".modalAction input").off("blur").on("blur",function(){
+        $(this).attr("readonly",true)
     })
-    $(".modalAction input[ autocomplete='off']").off("blur").on("blur",function(){
-        $(this).attr("type","text")
-    })*/
   $(".modalAction .eye").off("click").on("click",function(){
       switchPwd($(this))
   })
   $("#oldWord").off("input").on("input",function(){
+      switchToPsd($(this));
     const text = $(this).val();
     $(".oldWaring.warning,.newword.warning").hide();
     verifyPsdPart();
@@ -140,6 +141,7 @@ function bindModalEvent(){
     }
   });
   $("#newWord").off("input").on("input",function(){
+      switchToPsd($(this));
       let text = $(this).val();
       const checker = $(".alertModal .psd-checkbox");
       if(/[\u4e00-\u9fa5]/g.test(text)){
@@ -170,6 +172,7 @@ function bindModalEvent(){
       }
   })
     $("#sureWord").off("input").on("input",function(){
+        switchToPsd($(this));
         const text = $(this).val();
         $(".sureword.warning").hide();
         if(/[\u4e00-\u9fa5]/g.test(text)){
@@ -189,6 +192,15 @@ function bindModalEvent(){
     })
 }
 
+function switchToPsd(dom){
+    if(!dom.val()){
+        dom.attr("readonly",true)
+        setTimeout(function () {
+            dom.removeAttr("readonly").focus()
+        })
+    }
+}
+
 //验证新密码规则
 function verifyPsd(text){
     let pass = true;