mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-21 04:16:44 +08:00
国富金掌柜隐私政策无法读取问题处理
This commit is contained in:
@@ -158,49 +158,49 @@ service.interceptors.request.use(
|
||||
})
|
||||
}
|
||||
let masterKey
|
||||
if(configApp.API_VERSION == 'v3'){
|
||||
if (configApp.API_VERSION == 'v3') {
|
||||
// 生成本次请求随机密钥
|
||||
if (!window.localStorage.getItem('masterKey')) {
|
||||
masterKey = randomString();
|
||||
window.localStorage.setItem('masterKey',masterKey)
|
||||
window.localStorage.setItem('masterKey', masterKey)
|
||||
} else {
|
||||
masterKey = window.localStorage.getItem('masterKey')
|
||||
}
|
||||
}
|
||||
// token 不存在初始化处理
|
||||
let token = CacheUtils.getLocItem('token')
|
||||
// token 不存在初始化处理
|
||||
let token = CacheUtils.getLocItem('token')
|
||||
/**
|
||||
* 请求拦截处理(待添加 判断走统一网关处理)
|
||||
*/
|
||||
// console.log(config)
|
||||
if (config.url && /api\/$/.test(config.url.split(configApp.API_VERSION)[0]) && (configApp.API_VERSION == 'v2' || configApp.API_VERSION == 'v3')) {
|
||||
if (config.url && /api\/$/.test(config.url.split(configApp.API_VERSION)[0]) && (configApp.API_VERSION == 'v2' || configApp.API_VERSION == 'v3')) {
|
||||
if (!config.data || config.data == null) {
|
||||
config.data = {}
|
||||
}
|
||||
|
||||
if (!!config.data && config.data != null) {
|
||||
if(configApp.API_VERSION == 'v3'){
|
||||
if (configApp.API_VERSION == 'v3') {
|
||||
// console.log('随机密钥:' + masterKey);
|
||||
// RSA加密随机密钥
|
||||
let ak = RSAEncrypt(masterKey, publicKey);
|
||||
// console.log('加密后的masterKey:' + ak);
|
||||
// 随机密钥加密data
|
||||
let data = AESEncrypt(JSON.stringify(config.data), masterKey);
|
||||
// console.log('MD5值:' + MD5(AESEncrypt(data, masterKey)).toString());
|
||||
// 验证数据完整性MD5
|
||||
// 数据完整性MD5需要进行二次AES加密
|
||||
// 验证数据完整性SHA256
|
||||
// 数据完整性SHA256需要进行二次AES加密
|
||||
config.headers['signature'] = SHA256(AESEncrypt(data, masterKey)).toString();
|
||||
if(config.method == 'get'){
|
||||
if (config.method == 'get') {
|
||||
config.headers['ak'] = ak
|
||||
config.headers['data'] = data
|
||||
}
|
||||
config.data = { ak, data };
|
||||
// console.log(config.data);
|
||||
if(AESDecrypt(config.data.data, masterKey)){
|
||||
if (AESDecrypt(config.data.data, masterKey)) {
|
||||
// console.log(JSON.parse(AESDecrypt(config.data.data, masterKey)));
|
||||
}else{
|
||||
} else {
|
||||
// console.log(AESDecrypt(config.data.data, masterKey));
|
||||
}
|
||||
}else if(configApp.API_VERSION == 'v2'){
|
||||
} else if (configApp.API_VERSION == 'v2') {
|
||||
config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token'))
|
||||
let encrypt = AESEncryptV2(JSON.stringify(config.data), configApp.REQ_PWD)
|
||||
config.data = { data: encrypt }
|
||||
@@ -217,18 +217,21 @@ service.interceptors.request.use(
|
||||
// eslint-disable-next-line no-undef
|
||||
let u = navigator.userAgent;
|
||||
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //判断是否是 android终端
|
||||
if(isAndroid){
|
||||
if (isAndroid) {
|
||||
// setTimeout(() => {
|
||||
console.log(window.Android.getToken(),'Android获取token')
|
||||
if (window.location.hash !== '#/my/privacyPolicy') {
|
||||
console.log(window.Android.getToken(), 'Android获取token')
|
||||
CacheUtils.setLocItem('token', window.Android.getToken())
|
||||
}
|
||||
// }, 1000)
|
||||
}else{
|
||||
const res = await EWebBridge.webCallAppInJs('getToken')
|
||||
CacheUtils.setLocItem('token', JSON.parse(res).token)
|
||||
} else {
|
||||
if (window.location.hash !== '#/my/privacyPolicy') {
|
||||
const res = await EWebBridge.webCallAppInJs('getToken')
|
||||
CacheUtils.setLocItem('token', JSON.parse(res).token)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.headers['token'] = CacheUtils.getLocItem('token')
|
||||
// 添加请时间戳
|
||||
let timeStr = new Date().getTime() + ''
|
||||
@@ -246,14 +249,14 @@ service.interceptors.response.use(
|
||||
response => {
|
||||
let res = response.data
|
||||
if (
|
||||
(configApp.API_VERSION == 'v2' || configApp.API_VERSION == 'v3') &&
|
||||
(configApp.API_VERSION == 'v2' || configApp.API_VERSION == 'v3') &&
|
||||
response.config.url &&
|
||||
response.headers['content-type'].match(/application\/json/) &&
|
||||
/api\/$/.test(response.config.url.split(configApp.API_VERSION)[0])
|
||||
) {
|
||||
if (res.response) {
|
||||
if(configApp.API_VERSION == 'v3'){
|
||||
// 正常情況返回必有response 节点
|
||||
if (configApp.API_VERSION == 'v3') {
|
||||
// 正常情況返回必有response 节点
|
||||
// 返回结果的随机密钥
|
||||
let masterKey;
|
||||
if (!window.localStorage.getItem('masterKey')) {
|
||||
@@ -266,11 +269,11 @@ service.interceptors.response.use(
|
||||
// console.log(JSON.parse(AESDecrypt(response.data.response, masterKey)))
|
||||
// 使用随机密钥解密返回结果data
|
||||
res = JSON.parse(AESDecrypt(res.response, masterKey))
|
||||
}else if(configApp.API_VERSION == 'v2'){
|
||||
} else if (configApp.API_VERSION == 'v2') {
|
||||
// 使用固定密钥解密返回结果data
|
||||
res = JSON.parse(AESDecryptV2(res.response, configApp.REQ_PWD))
|
||||
// console.log(res,'JSON.parse(AESDecrypt(res.response, configApp.REQ_PWD))')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +283,7 @@ service.interceptors.response.use(
|
||||
if (res.code == 10001 || res.code == 10002) {
|
||||
var ua = window.navigator.userAgent.toLowerCase();
|
||||
//通过正则表达式匹配ua中是否含有MicroMessenger字符串, 在微信
|
||||
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
|
||||
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
|
||||
Dialog.alert({
|
||||
title: '提示',
|
||||
confirmButtonText: '退出',
|
||||
@@ -288,7 +291,7 @@ service.interceptors.response.use(
|
||||
}).then(() => {
|
||||
window.close();
|
||||
WeixinJSBridge.call('closeWindow');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
//在app
|
||||
Dialog.confirm({
|
||||
@@ -300,7 +303,7 @@ service.interceptors.response.use(
|
||||
flag: 'login'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//Toast.fail(res.msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user