From bccdb8f81c07c8a9cdcd6838173dfd1c73c98d90 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期四, 26 二月 2026 16:05:30 +0800
Subject: [PATCH] #

---
 config/request.js |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/config/request.js b/config/request.js
index 9a8beab..f21af74 100644
--- a/config/request.js
+++ b/config/request.js
@@ -9,7 +9,7 @@
 			settings = {
 				ip: '127.0.0.1',
 				port: '8080',
-				project: 'jshdasrs'
+				project: 'wms'
 			};
 			// uni.setStorageSync('app_settings', settings);
 		}
@@ -34,13 +34,9 @@
 			});
 		}
 
-		// 鏍规嵁custom鍙傛暟涓厤缃殑鏄惁闇�瑕乼oken锛屾坊鍔犲搴旂殑璇锋眰澶�
-		// 榛樿鎴栨樉寮� auth 涓� true 鏃舵坊鍔� token
-		if (config?.custom?.auth !== false) {
-			const token = uni.getStorageSync('token');
-			if (token) {
-				config.header.token = token;
-			}
+		const token = uni.getStorageSync('token');
+		if (token) {
+			config.header.token = token;
 		}
 		return config
 	}, config => { // 鍙娇鐢╝sync await 鍋氬紓姝ユ搷浣�
@@ -60,9 +56,16 @@
 		const custom = response.config?.custom || {}
 
 		if (data.code !== 200) {
-			// 濡傛灉娌℃湁鏄惧紡瀹氫箟custom鐨則oast鍙傛暟涓篺alse鐨勮瘽锛岄粯璁ゅ鎶ラ敊杩涜toast寮瑰嚭鎻愮ず
-			if (custom.toast !== false) {
-				uni.$u.toast(data.msg || data.message || '璇锋眰澶辫触')
+			if (data.code === 401 || data.code === 403) {
+				vm.$showToast({ type: 'error', message: data.msg || data.message || '璇烽噸鏂扮櫥褰�' })
+				setTimeout(() => {
+					uni.reLaunch({ url: '/pages/login/login' })
+				}, 1000)
+			} else {
+				// 濡傛灉娌℃湁鏄惧紡瀹氫箟custom鐨則oast鍙傛暟涓篺alse鐨勮瘽锛岄粯璁ゅ鎶ラ敊杩涜toast寮瑰嚭鎻愮ず
+				if (custom.toast !== false) {
+					vm.$showToast({ type: 'error', message: data.msg || data.message || '璇锋眰澶辫触' })
+				}
 			}
 
 			// 濡傛灉闇�瑕乧atch杩斿洖锛屽垯杩涜reject
@@ -70,7 +73,7 @@
 				return Promise.reject(data)
 			} else {
 				// 鍚﹀垯杩斿洖涓�涓猵ending涓殑promise锛岃姹備笉浼氳繘鍏atch涓�
-				return new Promise(() => {})
+				return new Promise(() => { })
 			}
 		}
 		// 鏍规嵁绀轰緥锛岃繑鍥炰笟鍔℃暟鎹�
@@ -81,6 +84,17 @@
 		if (hideLoading === false || hideLoading === undefined) {
 			uni.hideLoading();
 		}
+
+		if (response.statusCode === 401 || response.statusCode === 403) {
+			vm.$showToast({ type: 'error', message: '璇烽噸鏂扮櫥褰�' })
+			setTimeout(() => {
+				uni.reLaunch({ url: '/pages/login/login' })
+			}, 1000)
+		} else {
+			const errMsg = response.data?.msg || response.data?.message || '璇锋眰澶辫触';
+			vm.$showToast({ type: 'error', message: errMsg })
+		}
+
 		return Promise.reject(response)
 	})
 }
\ No newline at end of file

--
Gitblit v1.9.1