Browse Source

登录延时

e 5 years ago
parent
commit
b013bdec39
1 changed files with 18 additions and 15 deletions
  1. 18 15
      src/views/login/index.vue

+ 18 - 15
src/views/login/index.vue

@@ -109,21 +109,24 @@ export default {
       })
     },
     handleLogin() {
-      this.$refs.loginForm.validate(valid => {
-        if (valid) {
-          this.loading = true
-          this.$store.dispatch('user/login', this.loginForm).then(() => {
-            /* this.initSystemInfo() */
-            this.$router.push({ path: this.redirect || '/' })
-            this.loading = false
-          }).catch(() => {
-            this.loading = false
-          })
-        } else {
-          console.log('error submit!!')
-          return false
-        }
-      })
+      if (!this.loading) {
+        this.$refs.loginForm.validate(valid => {
+          if (valid) {
+            this.loading = true
+            this.$store.dispatch('user/login', this.loginForm).then(() => {
+              /* this.initSystemInfo() */
+              this.$router.push({ path: this.redirect || '/' })
+              this.loading = false
+            }).catch(() => {
+              setTimeout(() => {
+                this.loading = false
+              }, 3 * 1000)
+            })
+          } else {
+            return false
+          }
+        })
+      }
     }
   }
 }