Jelajahi Sumber

验证码登录

natasha 1 tahun lalu
induk
melakukan
20f53b4b97
1 mengubah file dengan 29 tambahan dan 17 penghapusan
  1. 29 17
      src/views/login.vue

+ 29 - 17
src/views/login.vue

@@ -122,7 +122,8 @@ export default {
         },
         time: 60, //获取验证码的时间
         verificationCodeShow: false, //是否已经获取了验证码
-        loading: false
+        loading: false,
+        timer: null
     };
   },
   watch: {
@@ -153,6 +154,14 @@ export default {
                     user_name:this.loginPwdForm.userName,
                     password:this.loginPwdForm.password
                 }
+            }else{
+                data = {
+                    user_type:this.loginCodeForm.type,
+                    user_name:this.loginCodeForm.phone,
+                    password:this.loginCodeForm.code,
+                    is_dynamic_verification_code_login:"true",
+                    dynamic_verification_send_type:"SMS"
+                }
             }
             getLogin(MethodName, data)
             .then((res) => {
@@ -168,6 +177,9 @@ export default {
             })
             .catch(() => {
                 this.loading = false
+                this.verificationCodeShow = false;
+                clearInterval(this.timer);
+                this.time = 60;
             });
           } else {
             return false;
@@ -185,7 +197,7 @@ export default {
         if(this_[time] != 60){
             return
         }
-        let timer;
+        this_.timer = null;
         if (this_.loginCodeForm[phone]) {
             let reg = /^1[3-9]\d{9}$/;
             let result = reg.test(this_.loginCodeForm[phone]);
@@ -194,27 +206,27 @@ export default {
                 return
             }
             this_[flag] = true;
-            timer = setInterval(() => {
+            this_.timer = setInterval(() => {
                 this_[time]--;
                 if (this_[time] == 0) {
                     this_[flag] = false;
-                    clearInterval(timer);
-                    timer = null;
+                    clearInterval(this_.timer);
+                    this_.timer = null;
                     this_[time] = 60;
                 }
             }, 1000);
-            // let MethodName = "user_manager-SendVerificationCode";
-            // let data = {
-            // verification_type: 'EMAIL',
-            // phone_or_email: this_.loginForm.username,
-            // };
-            // getLogin(MethodName, data).then((res) => {
-            // }).catch(()=>{
-            //     this_[flag] = false;
-            //     clearInterval(timer);
-            //     timer = null;
-            //     this_[time] = 60;
-            // });
+            let MethodName = "/OrgServer/LoginControl/SendVerificationCode";
+            let data = {
+                send_type: 'SMS',
+                phone_or_email: this_.loginCodeForm.phone,
+            };
+            getLogin(MethodName, data).then((res) => {
+            }).catch(()=>{
+                this_[flag] = false;
+                clearInterval(this_.timer);
+                this_.timer = null;
+                this_[time] = 60;
+            });
         } else {
             this_.$message.warning('请先输入手机号');
         }