|
|
@@ -1,8 +1,8 @@
|
|
|
import axios from 'axios'
|
|
|
-import { MessageBox, Message } from 'element-ui'
|
|
|
+import {MessageBox, Message} from 'element-ui'
|
|
|
import store from '@/store'
|
|
|
-import { getToken } from '@/utils/auth'
|
|
|
-import { aesEncrypt_HmacSha256 } from './encryption/utils.js'
|
|
|
+import {getToken} from '@/utils/auth'
|
|
|
+import {aesEncrypt_HmacSha256} from './encryption/utils.js'
|
|
|
import * as queryString from 'query-string'
|
|
|
import moment from 'moment'
|
|
|
|
|
|
@@ -44,7 +44,11 @@ service.interceptors.request.use(
|
|
|
} else if (config.method === 'post' || config.method === 'put') {
|
|
|
paramsObject = config.data
|
|
|
Object.keys(paramsObject).forEach(key => {
|
|
|
- const item = paramsObject[key]
|
|
|
+ var item = paramsObject[key]
|
|
|
+ if (item === null || item === undefined) {
|
|
|
+ debugger
|
|
|
+ paramsObject[key] = ''
|
|
|
+ }
|
|
|
if (typeOf(item) === 'object' || typeOf(item) === 'array') {
|
|
|
paramsObject[key] = JSON.stringify(item)
|
|
|
}
|
|
|
@@ -54,6 +58,7 @@ service.interceptors.request.use(
|
|
|
const queryString1 = queryString.stringify(paramsObject)
|
|
|
console.log('queryString1===', queryString1)
|
|
|
const queryString2 = encodeURIComponent(queryString1).replace('+', '%20').replace('*', '%2A').replace('%7E', '~')
|
|
|
+ console.log('queryString2===', queryString2)
|
|
|
config.headers['signature'] = aesEncrypt_HmacSha256(queryString2, key)
|
|
|
config.headers['timestamp'] = moment().format('YYYY-MM-DD HH:mm:ss') // 格式化输出
|
|
|
|