| | |
| | | //安全请求header |
| | | config.headers['Blade-Requested-With'] = 'BladeHttpRequest' |
| | | //headers判断是否需要 |
| | | const authorization = config.authorization === false |
| | | if (!authorization) { |
| | | config.headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}` |
| | | } |
| | | // const authorization = config.authorization === false |
| | | // if (!authorization) { |
| | | // config.headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}` |
| | | // } |
| | | let authorization = store.state.user.token |
| | | config.headers['Authorization'] = authorization |
| | | // 根据后端要求,post的data为空的话传{} |
| | | if (config.method === 'post') { |
| | | config.data = config.data || {} |
| | |
| | | isErrorShown = true |
| | | showToast('用户令牌不可用,请重新登录'); |
| | | const transmitData = { data: { type: 'tokenExpired' } } |
| | | |
| | | |
| | | wx.miniProgram.reLaunch({url: 'pages/login/index'}) |
| | | wx.miniProgram.postMessage(transmitData) |
| | | uni.postMessage(transmitData) |
| | | |
| | | |
| | | removeToken() |
| | | removeRefreshToken() |
| | | // 重定向到登录页 |
| | |
| | | // message: message, |
| | | // type: status === -2 ? 'warning' : 'error', |
| | | // }) |
| | | showToast(message); |
| | | showToast(message) |
| | | return Promise.reject(new Error(message)) |
| | | } |
| | | return res |
| | |
| | | return Promise.reject(new Error(error)) |
| | | } |
| | | ) |
| | | |
| | | window._request = axios |
| | | export default axios |