From 80368e7d4c3fdf248e8a90f4cf5967702b6900cc Mon Sep 17 00:00:00 2001 From: ljlong_2630 Date: Thu, 22 Aug 2024 16:56:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dapp=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=9C=AA=E7=94=9F=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/http.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/api/http.ts b/src/api/http.ts index 30e8a39..466a9f9 100644 --- a/src/api/http.ts +++ b/src/api/http.ts @@ -33,10 +33,23 @@ const instance = axios.create({ */ instance.interceptors.request.use((config) => { const { method, params, url } = config + // 获取当前页面路由 + let pages = getCurrentPages(); // 获取所有页面栈的实例数组 + let currentPage = pages[pages.length - 1]; // 获取最后一个页面的实例 + console.log(currentPage) + let currentRoute='' + if(currentPage){ + currentRoute = currentPage.route; // 获取当前页面的路由 + if (currentRoute.endsWith('/index')) { + currentRoute = currentRoute.slice(0, -'/index'.length); + } + } + // 附带鉴权的token const headers : any = { token: getAccessToken(), - 'Authorization': 'Bearer ' + getAccessToken() + 'Authorization': 'Bearer ' + getAccessToken(), + "Referer1":currentRoute } if (uni.getStorageSync('openId')) { headers['openId'] = uni.getStorageSync('openId')