From 1828c014da918a4f6568ba4ea655dffb9b690a84 Mon Sep 17 00:00:00 2001
From: liyuetong
Date: Wed, 15 Dec 2021 15:39:22 +0800
Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E5=AF=86=E7=A0=81=E5=8A=A0?=
=?UTF-8?q?=E5=AF=86=E8=A7=A3=E5=AF=86--index.js=E7=8E=AF=E5=A2=83?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=8C=BA=E5=88=86?=
=?UTF-8?q?post=E5=92=8Cget=E8=AF=B7=E6=B1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/assets/js/utils/request.js | 48 ++++++++++++++++++++--------------
src/config/index.js | 4 +--
2 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/src/assets/js/utils/request.js b/src/assets/js/utils/request.js
index 3bc7ea034..2b98ee9e9 100644
--- a/src/assets/js/utils/request.js
+++ b/src/assets/js/utils/request.js
@@ -167,28 +167,36 @@ service.interceptors.request.use(
* 请求拦截处理(待添加 判断走统一网关处理)
*/
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) {
config.data = {}
}
if (!!config.data && config.data != null) {
- // let encrypt = AESTools.AESEncrypt(JSON.stringify(config.data), configApp.REQ_PWD)
- 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加密
- config.headers['signature'] = MD5(AESEncrypt(data, masterKey)).toString();
- config.data = { ak, data };
- console.log(config.data);
- if(AESDecrypt(config.data.data, masterKey)){
- console.log(JSON.parse(AESDecrypt(config.data.data, masterKey)));
- }else{
- console.log(AESDecrypt(config.data.data, masterKey));
+ 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加密
+ config.headers['signature'] = MD5(AESEncrypt(data, masterKey)).toString();
+ 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)){
+ console.log(JSON.parse(AESDecrypt(config.data.data, masterKey)));
+ }else{
+ console.log(AESDecrypt(config.data.data, masterKey));
+ }
+ }else if(configApp.API_VERSION == 'v2'){
+ let encrypt = AESEncrypt(JSON.stringify(config.data), configApp.REQ_PWD)
+ config.data = { data: encrypt }
}
// config.data = { data: encrypt }
}
@@ -221,7 +229,7 @@ service.interceptors.request.use(
// 添加请时间戳
let timeStr = new Date().getTime() + ''
config.headers['timeStr'] = timeStr
- config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token'))
+ // config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token'))
return config
},
error => {
@@ -235,7 +243,7 @@ service.interceptors.response.use(
response => {
let res = response.data
if (
- configApp.API_VERSION == 'v2' &&
+ (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])
diff --git a/src/config/index.js b/src/config/index.js
index 9d81cce4f..84f4b77a0 100644
--- a/src/config/index.js
+++ b/src/config/index.js
@@ -48,7 +48,7 @@ switch (process.env.VUE_APP_FLAG) {
API_VERSION = 'v2'
break
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'
assetsUrl = 'https://iagentsales-sr.e-guofu.com:8443/'
// 上传影像地址 挂载共享盘 地址
@@ -58,7 +58,7 @@ switch (process.env.VUE_APP_FLAG) {
zssqUrl = ''
REQ_PWD = '41424344454631323334353637383930'
CACHE_ENCRYP = '41424344454631323334353637383930'
- API_VERSION = 'v2'
+ API_VERSION = 'v3'
break
case 'dat':
apiDomain = ''