Bläddra i källkod

更新 minxin 中的 loginBtn() 方法, 若因图形验证码错误导致登录失败, 不重置已输入的帐号密码信息, 只需要重新输入验证码即可

reghao 2 år sedan
förälder
incheckning
5eb187c436
2 ändrade filer med 13 tillägg och 16 borttagningar
  1. 13 12
      src/assets/js/mixin.js
  2. 0 4
      src/views/login.vue

+ 13 - 12
src/assets/js/mixin.js

@@ -1,7 +1,7 @@
 /**
  * 混入对象,抽取Vue中公共的部分
  */
-import {getPubkey, getCaptchaCode, getVerifyCode, login, logout, register, forgot } from '@/api/account'
+import { getPubkey, getCaptchaCode, getVerifyCode, login, logout, register, forgot } from '@/api/account'
 import { setUserToken, removeAll } from '@/utils/auth'
 import { JSEncrypt } from 'jsencrypt'
 import Vue from 'vue'
@@ -30,7 +30,7 @@ export const userMixin = {
         principal: null,
         verifyCode: null,
         newCredential: null,
-        captchaCode: null,
+        captchaCode: null
       },
       loginDialog: false,
       registerDialog: false,
@@ -161,7 +161,8 @@ export const userMixin = {
         return
       }
 
-      this.userLogin.credential = this.encryptPassword(this.userLogin.credential, this.pubkey, this.pubkeyR)
+      const credential = this.userLogin.credential
+      this.userLogin.credential = this.encryptPassword(credential, this.pubkey, this.pubkeyR)
       // 显示加载效果
       this.isLoading = true
       login(this.userLogin).then(resp => {
@@ -173,25 +174,25 @@ export const userMixin = {
           setUserToken(userToken)
           this.$store.commit('UPDATE_USER_INFO', userInfo)
 
-          // 关闭弹窗并刷新页面
-          this.dialogVisible = false
+          // 刷新当前页面
           this.$router.go(0)
+          this.userLogin = {
+            principal: null,
+            credential: null,
+            captchaCode: null,
+            loginType: 2,
+            plat: 1
+          }
         } else {
           // 登录失败
           this.$message.warning(resp.msg)
+          this.userLogin.credential = credential
         }
       }).catch(error => {
         // 登录请求错误
         this.$message.error(error)
       }).finally(() => {
         this.isLoading = false
-        this.userLogin = {
-          principal: null,
-          credential: null,
-          captchaCode: null,
-          loginType: 2,
-          plat: 1
-        }
       })
     },
     registerBtn() {

+ 0 - 4
src/views/login.vue

@@ -81,10 +81,6 @@ export default {
     }
   },
   methods: {
-    /*login() {
-      this.fetchPubkey()
-      this.dialogVisible = true
-    },*/
     register() {
       this.$router.push('/register')
     },