|
@@ -18,12 +18,14 @@ service.interceptors.request.use(
|
|
|
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
|
|
|
// get请求映射params参数
|
|
|
if (config.method === 'get' && config.params) {
|
|
|
- // 参数加密
|
|
|
- let encryptParam = doEncrypt(JSON.stringify(config.params))
|
|
|
- // 参数签名
|
|
|
- let paramSign = doSign(JSON.stringify(config.params))
|
|
|
- let result = 'secretData=' + encryptParam + '¶mSign=' + paramSign
|
|
|
- config.params = result
|
|
|
+ if (config.params.toString().indexOf('secretData') !=-1 && config.params.toString().indexOf('paramSign')){
|
|
|
+ // 不是token刷新后执行上次操作,进行参数加密。
|
|
|
+ let encryptParam = doEncrypt(JSON.stringify(config.params))
|
|
|
+ // 参数签名
|
|
|
+ let paramSign = doSign(JSON.stringify(config.params))
|
|
|
+ let result = 'secretData=' + encryptParam + '¶mSign=' + paramSign
|
|
|
+ config.params = result
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put' || config.method === 'delete')) {
|
|
@@ -182,11 +184,13 @@ service.interceptors.response.use(
|
|
|
isRefreshing = true
|
|
|
//调用刷新token的接口
|
|
|
return await Vue.prototype.$axios.post(
|
|
|
- '/refreshToken'
|
|
|
+ '/refreshToken',{}
|
|
|
).then((res) => {
|
|
|
// const { token } = res.data
|
|
|
// 替换token
|
|
|
- sessionStorage.setItem('token', res.data)
|
|
|
+ let tokenStr = doEncrypt(res.data)
|
|
|
+ let sign = doSign(res.data)
|
|
|
+ sessionStorage.setItem('token', tokenStr+'&'+sign)
|
|
|
// Vue.prototype.$axios(error.response.config)
|
|
|
// 重新请求接口 前过期的接口
|
|
|
error.config.headers.Authorization = res.data;
|