|
@@ -25,8 +25,10 @@ export const encryptionFun = (config) => {
|
|
|
|
|
|
// 请求的参数json // 携带的参数json一下,url拼接参数的直接用,没有参数不拼接
|
|
|
const queryJsonData = config.data && Object.keys(config.data).length ?
|
|
|
- decodeURIComponent(JSON.stringify(sortObjectByKey(config.data))) : config.params && Object.keys(config.params).length ?
|
|
|
- decodeURIComponent(qs.stringify(sortObjectByKey(config.params), { allowDots: true }) ): config.url.split('?')?.length>1 ?
|
|
|
+ decodeURIComponent(JSON.stringify(config.data)) :
|
|
|
+ config.params && Object.keys(config.params).length ?
|
|
|
+ decodeURIComponent(qs.stringify(config.params, { allowDots: true }) ) :
|
|
|
+ config.url.split('?')?.length>1 ?
|
|
|
config.url.split('?')[1] : ''
|
|
|
// sha256加密字符串
|
|
|
if (paramsStr) initSign.sign = sha256(queryJsonData + paramsStr)
|
|
@@ -34,13 +36,3 @@ export const encryptionFun = (config) => {
|
|
|
// 请求头加参数initSign,请求头加参数: appId + nonce + timestamp + sign
|
|
|
if (initSign && Object.keys(initSign).length) Object.keys(initSign).forEach(key => { (config).headers[key] = initSign[key] })
|
|
|
}
|
|
|
-
|
|
|
-function sortObjectByKey(obj) {
|
|
|
- return obj
|
|
|
- // return Object.keys(obj)
|
|
|
- // .sort()
|
|
|
- // .reduce((sortedObj, key) => {
|
|
|
- // sortedObj[key] = obj[key];
|
|
|
- // return sortedObj;
|
|
|
- // }, {});
|
|
|
-}
|