Pārlūkot izejas kodu

feat: 打印状态码

linwenxin 1 gadu atpakaļ
vecāks
revīzija
e2e9cf10a2
2 mainītis faili ar 10 papildinājumiem un 4 dzēšanām
  1. 9 4
      src/common/http/index.js
  2. 1 0
      src/store/modules/user/mutations.js

+ 9 - 4
src/common/http/index.js

@@ -46,12 +46,12 @@ export const $http = (url, method, data, json, loadingBool = false) => {
       }
 
       uni.showToast({
-        title: res.message || 'Error',
+        title: res.message || ('Error_'+res.code),
         icon: 'none',
         duration: 1500
       })
 
-      return Promise.reject(new Error(res.message || 'Error'))
+      return Promise.reject(new Error(res.message || ('Error_'+res.code)))
     } else {
       return res
     }
@@ -162,12 +162,17 @@ export const axios = function(obj = {}) {
         }
         const res = ress.data;
         if (whiteCodes.indexOf(res.code) < 0) {
+          if (res.code === 1001) {
+            goLoginPage()
+            reject(new Error(res.message || ('Error_'+res.code)));
+            return {}
+          }
           uni.showToast({
-            title: res.message || 'Error',
+            title: res.message || ('Error_'+res.code),
             icon: 'none',
             duration: 1500
           })
-          reject(new Error(res.message || 'Error'));
+          reject(new Error(res.message || ('Error_'+res.code)));
         } else {
           resolve(res)
         }

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

@@ -2,6 +2,7 @@ export default {
   //
   set_token: (state, token) => {
     state.token = token
+    state.crossPagePam = (new Date().getTime())
     if (token) {
       uni.setStorageSync('recycle_mobile_token', token)
     } else {