Prechádzať zdrojové kódy

别的系统账号登录时报错处理

chenrui 4 rokov pred
rodič
commit
30ae17e0dd
2 zmenil súbory, kde vykonal 18 pridanie a 19 odobranie
  1. 1 1
      src/store/modules/user.js
  2. 17 18
      src/utils/request.js

+ 1 - 1
src/store/modules/user.js

@@ -41,7 +41,7 @@ const user = {
       return new Promise((resolve, reject) => {
         login(userInfo).then(res => {
           console.log(res, 'login success')
-          if (res.userid) {
+          if (res && res.userid) {
             Vue.ls.set('hasError', 0)
             commit('SET_TOKEN', res.userid)
             commit('SET_NAME', { name: res.userNameCN, welcome: welcome() })

+ 17 - 18
src/utils/request.js

@@ -54,26 +54,25 @@ service.interceptors.request.use(config => {
 
 // response interceptor
 service.interceptors.response.use((response) => {
-  console.log(response, 'responseresponseresponse')
-  if (response.data.status == '-1') {
-    notification.destroy()
-    notification.error({
-      message: '提示',
-      description: response.data.message
-    })
-    setTimeout(function () {
-      store.dispatch('Logout').then(() => {
-        window.location.reload()
+  console.log(response, response.data.status, 'responseresponseresponse')
+  if (window.location.pathname != '/user/login') {
+    if (response.data.status == '900') {
+      notification.destroy()
+      notification.error({
+        message: '提示',
+        description: response.data.message
       })
-    }, 2000)
-  }
-  if ((response.data.status == '900') && window.location.pathname != '/user/login') {
-    notification.destroy()
-    notification.error({
-      message: '提示',
-      description: response.data.message
-    })
+    }
+  } else {
+    if (response.data.status == '500') {
+      notification.destroy()
+      notification.error({
+        message: '提示',
+        description: response.data.message
+      })
+    }
   }
+
   return response.data
 }, err)