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')