linwenxin il y a 1 mois
Parent
commit
4d6c0a2dfe
2 fichiers modifiés avec 11 ajouts et 1 suppressions
  1. 10 0
      src/common/http/index.js
  2. 1 1
      src/store/modules/user/index.js

+ 10 - 0
src/common/http/index.js

@@ -59,6 +59,10 @@ export const $http = (url, method, data, json, loadingBool = false, isExecute =
       if (~res.message.indexOf('USERPAYING')) {
         return Promise.reject(new Error(res.message || 'Error'))
       }
+      if (res.code === 4440) {
+        location.reload()
+        return {}
+      }
       if (res.code === 1001) {
         webLogin(true)
         return {}
@@ -266,6 +270,12 @@ export const axios = function (obj = {}) {
             return {}
           }
 
+          if (res.code === 4440) {
+            location.reload()
+            reject(new Error(res.message || 'Error'))
+            return {}
+          }
+
           if (res.message || res.code) {
             uni.showToast({
               title: res.message || 'Error',

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

@@ -25,7 +25,7 @@ function getQueryVariable(variable) {
 
 const state = {
   openId: getQueryVariable('openId') || getStorage('openId') || '',
-  token: getQueryVariable('x-token') || getStorage('token') || '',
+  token: getStorage('token') || getQueryVariable('x-token') || '',
   name: getQueryVariable('username') || getStorage('name') || '',
   avatar: getQueryVariable('useravatar') || getStorage('avatar') || '',
   userId: getQueryVariable('userId') || getStorage('userId') || '',