From 14a0c331b9137ee08c9e8bd9a89745e720e9dbf8 Mon Sep 17 00:00:00 2001 From: wangyi <3432649580@qq.com> Date: Fri, 31 Oct 2025 14:23:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E7=94=A8=E6=88=B7token=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E8=87=B3=E7=99=BB=E5=BD=95=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/http.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/utils/http.js b/utils/http.js index 7249e24..1a1330e 100644 --- a/utils/http.js +++ b/utils/http.js @@ -49,7 +49,7 @@ const httpInterceptor = { if (token) { options.header.token = token } - console.log("最终请求参数:",options) + console.log("最终请求参数:", options) // 避免误用 Authorization 头,后端要求的是 token 头 // if (options.header.Authorization) delete options.header.Authorization return options @@ -75,10 +75,22 @@ export const http = (options) => { loginStore.setLoginInfo("false") console.log("2loginStore.loginInfo", loginStore.loginInfo); - // uni.showToast({ - // title: '请先登录', - // icon: 'none' - // }) + + } + if (result.data.code === 400) { + const userStore = useUserStore() + userStore.clearUserInfo() + uni.showModal({ + title: "登录失效", + content: "点击确定跳转登录页面", + confirmText: "确定", + cancelText: "取消", + success: (res) => { + uni.navigateTo({ + url: '/pages/start/login/login' + }) + }, + }); } resolve(result.data) } else if (result.statusCode === 401) { @@ -87,7 +99,7 @@ export const http = (options) => { memberStore.clearUserInfo() // 提示用户重新登录 uni.navigateTo({ - url: '/pages/login/login' + url: '/pages/start/login/login' }) reject(result) } else {