Browse Source

报404跳转到登录页

HW 3 years ago
parent
commit
394766aa97
1 changed files with 7 additions and 3 deletions
  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
   const requestParams = chain.requestParams
 
 
   return chain.proceed(requestParams).then(res => {
   return chain.proceed(requestParams).then(res => {
-    // console.log(res,'proceed')
+    // console.log(res.statusCode,'proceed')
     // 只要请求成功,不管返回什么状态码,都走这个回调
     // 只要请求成功,不管返回什么状态码,都走这个回调
     if (res.statusCode === HTTP_STATUS.NOT_FOUND) {
     if (res.statusCode === HTTP_STATUS.NOT_FOUND) {
+      Taro.setStorageSync("token", "");
+      Taro.setStorageSync('userInfor', "");
+      pageToLogin()
+      // TODO 根据自身业务修改
       return {
       return {
         error: [
         error: [
           {
           {
-            message:'请求资源不存在,请重试',
+            message:'请求资源不存在,请重新登录',
             start: 404
             start: 404
           }
           }
         ]
         ]
-      }
+      };
 
 
     } else if (res.statusCode === HTTP_STATUS.SERVER_ERROR) {
     } else if (res.statusCode === HTTP_STATUS.SERVER_ERROR) {
       return {
       return {