Pārlūkot izejas kodu

报404跳转到登录页

HW 3 gadi atpakaļ
vecāks
revīzija
394766aa97
1 mainītis faili ar 7 papildinājumiem un 3 dzēšanām
  1. 7 3
      src/utils/servers/interceptors.js

+ 7 - 3
src/utils/servers/interceptors.js

@@ -7,17 +7,21 @@ const customInterceptor = (chain) => {
   const requestParams = chain.requestParams
 
   return chain.proceed(requestParams).then(res => {
-    // console.log(res,'proceed')
+    // console.log(res.statusCode,'proceed')
     // 只要请求成功,不管返回什么状态码,都走这个回调
     if (res.statusCode === HTTP_STATUS.NOT_FOUND) {
+      Taro.setStorageSync("token", "");
+      Taro.setStorageSync('userInfor', "");
+      pageToLogin()
+      // TODO 根据自身业务修改
       return {
         error: [
           {
-            message:'请求资源不存在,请重试',
+            message:'请求资源不存在,请重新登录',
             start: 404
           }
         ]
-      }
+      };
 
     } else if (res.statusCode === HTTP_STATUS.SERVER_ERROR) {
       return {