随机密码加密解密--index.js环境配置修改,区分post和get请求

This commit is contained in:
liyuetong
2021-12-15 15:39:22 +08:00
committed by li.yuetong
parent 7a4515eb17
commit d6fdb8534b
2 changed files with 9 additions and 5 deletions

View File

@@ -169,7 +169,7 @@ service.interceptors.request.use(
* 请求拦截处理(待添加 判断走统一网关处理) * 请求拦截处理(待添加 判断走统一网关处理)
*/ */
console.log(config) console.log(config)
if (config.url && /api\/$/.test(config.url.split(configApp.API_VERSION)[0]) && configApp.API_VERSION == 'v2') { 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) { if (!config.data || config.data == null) {
config.data = {} config.data = {}
} }
@@ -185,6 +185,10 @@ service.interceptors.request.use(
// 验证数据完整性MD5 // 验证数据完整性MD5
// 数据完整性MD5需要进行二次AES加密 // 数据完整性MD5需要进行二次AES加密
config.headers['signature'] = MD5(AESEncrypt(data, masterKey)).toString(); config.headers['signature'] = MD5(AESEncrypt(data, masterKey)).toString();
if(config.method == 'get'){
config.headers['ak'] = ak
config.headers['data'] = data
}
config.data = { ak, data }; config.data = { ak, data };
console.log(config.data); console.log(config.data);
if(AESDecrypt(config.data.data, masterKey)){ if(AESDecrypt(config.data.data, masterKey)){
@@ -226,7 +230,7 @@ service.interceptors.request.use(
// 添加请时间戳 // 添加请时间戳
let timeStr = new Date().getTime() + '' let timeStr = new Date().getTime() + ''
config.headers['timeStr'] = timeStr config.headers['timeStr'] = timeStr
config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token')) // config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token'))
return config return config
}, },
error => { error => {
@@ -240,7 +244,7 @@ service.interceptors.response.use(
response => { response => {
let res = response.data let res = response.data
if ( if (
configApp.API_VERSION == 'v2' && (configApp.API_VERSION == 'v2' || configApp.API_VERSION == 'v3') &&
response.config.url && response.config.url &&
response.headers['content-type'].match(/application\/json/) && response.headers['content-type'].match(/application\/json/) &&
/api\/$/.test(response.config.url.split(configApp.API_VERSION)[0]) /api\/$/.test(response.config.url.split(configApp.API_VERSION)[0])

View File

@@ -47,7 +47,7 @@ switch (process.env.VUE_APP_FLAG) {
API_VERSION = 'v2' API_VERSION = 'v2'
break break
case 'prd': case 'prd':
apiDomain = 'https://iagentsales.e-guofu.com/api/v2' apiDomain = 'https://iagentsales.e-guofu.com/api/v3'
imgDomain = 'https://iagentsales-ud.e-guofu.com:8553/updown' imgDomain = 'https://iagentsales-ud.e-guofu.com:8553/updown'
assetsUrl = 'https://iagentsales-sr.e-guofu.com:8443/' assetsUrl = 'https://iagentsales-sr.e-guofu.com:8443/'
// 上传影像地址 挂载共享盘 地址 // 上传影像地址 挂载共享盘 地址
@@ -57,7 +57,7 @@ switch (process.env.VUE_APP_FLAG) {
zssqUrl = '' zssqUrl = ''
REQ_PWD = '41424344454631323334353637383930' REQ_PWD = '41424344454631323334353637383930'
CACHE_ENCRYP = '41424344454631323334353637383930' CACHE_ENCRYP = '41424344454631323334353637383930'
API_VERSION = 'v2' API_VERSION = 'v3'
break break
case 'dat': case 'dat':
apiDomain = '' apiDomain = ''