From 2aa506566031eae9a53006119db0cea8c876e6c3 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期一, 01 四月 2024 11:42:23 +0800
Subject: [PATCH] 选择产品信息单位处理

---
 src/common/untils/request.js |   41 ++++++++++++++++++++++++++---------------
 1 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/common/untils/request.js b/src/common/untils/request.js
index 4541c17..e6f2f3e 100644
--- a/src/common/untils/request.js
+++ b/src/common/untils/request.js
@@ -26,9 +26,9 @@
 const getApsPage = () => {
   // 棣栭〉閮ㄧ讲鍦ㄥ悇涓幆澧冪殑绔彛
   const loginPathMap = {
-    prod: `//${window.location.hostname}:9080`,
-    test: `//192.168.20.119:9080`,
-    dev: `//192.168.8.107:8080`
+    prod: `//${window.location.hostname}`,
+    test: `//192.168.20.119:9088`,
+    dev: `//localhost:8080`
   }
   return loginPathMap[environmentType()]
 }
@@ -41,8 +41,8 @@
     // // if (token != undefined) {
     // //   config.headers.Authorization = "Bearer " + token;
     // // }
-    // let token = localStorage.getItem("token")
-    let token = document.cookie.replace(/(?:(?:^|.*;\s*)token\s*=\s*([^;]*).*$)|^.*$/, "$1")
+    let token = localStorage.getItem("token")
+    // let token = document.cookie.replace(/(?:(?:^|.*;\s*)token\s*=\s*([^;]*).*$)|^.*$/, "$1")
     if (isDev) {
       token = token || DEV_TOKEN
     }
@@ -59,7 +59,6 @@
 /* //杩斿洖鐘舵�佸垽鏂�(娣诲姞鍝嶅簲鎷︽埅鍣�) */
 Axios.interceptors.response.use(
   (res) => {
-    console.log("99999", res)
     /* //瀵瑰搷搴旀暟鎹仛浜涗簨 */
     if (res.data.code === 200) {
       return res.data ? res.data : {}
@@ -89,20 +88,32 @@
       // if(window.location.pathname && window.location.pathname !== '/login'){
       //   window.location = window.location.origin+'/login'
       // }
+    } else if ([3003].includes(res.data.code)) {
+      // 姝ょ姸鎬佷笅涓嶅脊鍑篹rror message
+      console.log("3003")
+      return Promise.resolve(res.data)
     } else {
+      if (!res.config.loadingFlag) {
+        Message({
+          // message: res.data.msg==res.data.data?res.data.data:res.data.msg+','+res.data.data,
+          message: res.data.msg,
+          type: "error",
+          duration: 5 * 1000
+        })
+      }
       return res.data ? res.data : {}
     }
   },
   (error) => {
-    // if (error.response.status === 401) {
-    //   if (isDev) {
-    //     alert("JWT澶辨晥,鍗冲皢璺宠浆鑷崇櫥褰曢〉..")
-    //     window.location = getApsPage() + "/login"
-    //   } else {
-    //     //   JWT閴存潈澶辨晥 璺宠浆鍒扮櫥褰曢〉
-    //     window.location = getApsPage() + "/login"
-    //   }
-    // }
+    if (error.response.status === 401) {
+      if (isDev) {
+        alert("JWT澶辨晥,鍗冲皢璺宠浆鑷崇櫥褰曢〉..")
+        window.location = getApsPage() + "/login"
+      } else {
+        //   JWT閴存潈澶辨晥 璺宠浆鍒扮櫥褰曢〉
+        window.location = getApsPage() + "/login"
+      }
+    }
     let { message } = error
     if (message === "Network Error") {
       message = "鍚庣鎺ュ彛杩炴帴寮傚父"

--
Gitblit v1.8.0