|
@ -33,10 +33,23 @@ const instance = axios.create({ |
|
|
*/ |
|
|
*/ |
|
|
instance.interceptors.request.use((config) => { |
|
|
instance.interceptors.request.use((config) => { |
|
|
const { method, params, url } = 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
|
|
|
// 附带鉴权的token
|
|
|
const headers : any = { |
|
|
const headers : any = { |
|
|
token: getAccessToken(), |
|
|
token: getAccessToken(), |
|
|
'Authorization': 'Bearer ' + getAccessToken() |
|
|
'Authorization': 'Bearer ' + getAccessToken(), |
|
|
|
|
|
"Referer1":currentRoute |
|
|
} |
|
|
} |
|
|
if (uni.getStorageSync('openId')) { |
|
|
if (uni.getStorageSync('openId')) { |
|
|
headers['openId'] = uni.getStorageSync('openId') |
|
|
headers['openId'] = uni.getStorageSync('openId') |
|
|