Переглянути джерело

登录验证码等待逻辑修改

zhangjie 3 роки тому
батько
коміт
d780f0f461

+ 16 - 2
src/modules/base/components/ResetPwd.vue

@@ -120,6 +120,13 @@ export default {
   },
   mixins: [fetchSmsMixins],
   data() {
+    const equalToOldPswd = (rule, value, callback) => {
+      if (value === this.modalForm.oldPassword) {
+        callback(new Error("新旧密码不可以相同"));
+      } else {
+        callback();
+      }
+    };
     const equalToPswd = (rule, value, callback) => {
       if (value !== this.modalForm.password) {
         callback(new Error("两次输入的密码不一致"));
@@ -137,12 +144,18 @@ export default {
         code: smscode,
         mobileNumber: phone,
         oldPassword: password,
-        password,
+        password: [
+          ...password,
+          {
+            validator: equalToOldPswd,
+            trigger: "change"
+          }
+        ],
         rePassword: [
           ...password,
           {
             validator: equalToPswd,
-            trigger: "blur"
+            trigger: "change"
           }
         ]
       }
@@ -175,6 +188,7 @@ export default {
     },
     cancel() {
       this.modalIsShow = false;
+      this.$emit("cancel");
     },
     open() {
       this.modalIsShow = true;

+ 11 - 7
src/modules/login/fetchSmsMixins.js

@@ -23,7 +23,8 @@ export default {
       isFetchingCode: false,
       codeContent: "获取验证码",
       codeWaitingTime,
-      time: codeWaitingTime
+      time: codeWaitingTime,
+      setT: null
     };
   },
   methods: {
@@ -53,7 +54,7 @@ export default {
       if (!this.isFetchingCode) return;
       this.codeContent = "倒计时" + this.time + "s";
       const circleTime = time => {
-        let t = setInterval(() => {
+        this.setT = setInterval(() => {
           if (time > 1) {
             time--;
             let expire = new Date().getTime() + time * 1000;
@@ -67,15 +68,18 @@ export default {
             );
             this.codeContent = "倒计时" + time + "s";
           } else {
-            this.time = this.codeWaitingTime;
-            wstorage.remove(this.nameWaitTime);
-            this.codeContent = "获取验证码";
-            this.isFetchingCode = false;
-            clearInterval(t);
+            this.clearSetContent();
           }
         }, 1e3);
       };
       circleTime(this.time);
+    },
+    clearSetContent() {
+      this.time = this.codeWaitingTime;
+      wstorage.remove(this.nameWaitTime);
+      this.codeContent = "获取验证码";
+      this.isFetchingCode = false;
+      clearInterval(this.setT);
     }
   }
 };

+ 5 - 1
src/modules/login/views/Login.vue

@@ -68,7 +68,11 @@
     </div>
 
     <!-- 修改密码 -->
-    <reset-pwd :user-info="userInfo" ref="ResetPwd"></reset-pwd>
+    <reset-pwd
+      :user-info="userInfo"
+      ref="ResetPwd"
+      @cancel="clearSetContent"
+    ></reset-pwd>
   </div>
 </template>