解密有问提
This commit is contained in:
@@ -20,25 +20,28 @@ service.interceptors.request.use(
|
||||
|
||||
config.headers['Authorization'] = token
|
||||
config.headers['device'] = openid
|
||||
config.headers['dataSource'] = 'MP'
|
||||
config.headers['dataSources'] = 'MP'
|
||||
|
||||
if (env === 'production') {
|
||||
// if (env === 'production') {
|
||||
// 生产环境,加密,不输出任何东西
|
||||
// 设置jsessionid和token
|
||||
const JSESSIONID = utils.uuid()
|
||||
config.headers['JSESSIONID'] = JSESSIONID
|
||||
config.headers['token'] = utils.bcrypt(JSESSIONID)
|
||||
if (!notEncrypt && encryptWhite.indexOf(config.url) < 0) {
|
||||
config.headers['token'] = utils.md5Salt(JSESSIONID)
|
||||
// if ( encryptWhite.indexOf(config.url) < 0) {
|
||||
// if (!notEncrypt && encryptWhite.indexOf(config.url) < 0) {
|
||||
// 这是定义在哪的
|
||||
const data = { // 用于存储加密
|
||||
params: '' // 加密后的密文
|
||||
}
|
||||
// 要加密
|
||||
data.params = utils.encrypt(JSON.stringify(config.data))
|
||||
console.log(data.params)
|
||||
config.data = data
|
||||
}
|
||||
} else {
|
||||
// }
|
||||
// } else {
|
||||
console.log('请求路径', config.url, '参数加密前', config.data)
|
||||
}
|
||||
// }
|
||||
|
||||
return config
|
||||
},
|
||||
@@ -57,17 +60,17 @@ service.interceptors.response.use(
|
||||
const res = response.data
|
||||
const env = process.env.NODE_ENV
|
||||
|
||||
if (env === 'production') {
|
||||
// if (env === 'production') {
|
||||
// 生产环境,进行加密解密,不输出日志
|
||||
if (res.encrypt === 1) {
|
||||
// if (res.encrypt === 1) {
|
||||
// 加密的数据,需要解密
|
||||
const dataParam = JSON.parse(utils.decrypt(res.data))
|
||||
res.data = JSON.stringify(dataParam) === '{}' ? null : dataParam
|
||||
}
|
||||
} else {
|
||||
// }
|
||||
// } else {
|
||||
console.log('请求路径', response.config.url, '返回结果未加密', res)
|
||||
console.log('-------------------------------------------')
|
||||
}
|
||||
// }
|
||||
|
||||
uni.hideLoading()
|
||||
if (res.code != 20000) {
|
||||
@@ -77,15 +80,15 @@ service.interceptors.response.use(
|
||||
})
|
||||
if(res.code===42011){
|
||||
console.log(res.code)
|
||||
uni.navigateTo({
|
||||
url:'/pages/login/login',
|
||||
success: () => {
|
||||
console.log('跳转成功')
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
// uni.navigateTo({
|
||||
// url:'/pages/login/login',
|
||||
// success: () => {
|
||||
// console.log('跳转成功')
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// console.log(err)
|
||||
// }
|
||||
// })
|
||||
}
|
||||
}
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user