|
|
@ -2,7 +2,8 @@ |
|
|
|
import { H5_API, WX_API,httpPrefix } from '@/config/site.config.js'; |
|
|
|
|
|
|
|
import { refreshToken } from './utils' |
|
|
|
|
|
|
|
import md5 from 'js-md5' |
|
|
|
let secretKey = '22d90e09d1374f0f9e4accd07d333e55' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -27,7 +28,13 @@ module.exports = (vm) => { |
|
|
|
config.data = config.data || {} |
|
|
|
// 根据custom参数中配置的是否需要token,添加对应的请求头
|
|
|
|
console.log('--------------') |
|
|
|
console.log(config) |
|
|
|
config.data['timestamp'] = Date.now() |
|
|
|
let jsonString = JSON.stringify(config.data) |
|
|
|
let strSecretKey = jsonString + secretKey |
|
|
|
let hash = md5(strSecretKey) |
|
|
|
config.header['Signature'] = hash |
|
|
|
config.data = jsonString |
|
|
|
console.log(config.data) |
|
|
|
let token = vm.$store.state.user.vuex_loginInfo.accessToken |
|
|
|
if(token) { |
|
|
|
config.header.Authorization = 'Bearer ' + token |
|
|
@ -36,6 +43,8 @@ module.exports = (vm) => { |
|
|
|
if(noToken&&config.header.Authorization) { |
|
|
|
delete config.header.Authorization |
|
|
|
} |
|
|
|
console.log('config') |
|
|
|
console.log(config) |
|
|
|
return config |
|
|
|
}, config => { // 可使用async await 做异步操作
|
|
|
|
return Promise.reject(config) |
|
|
|