|
@@ -1,8 +1,8 @@
|
|
|
import axios from 'axios'
|
|
import axios from 'axios'
|
|
|
-import { MessageBox, Message } from 'element-ui'
|
|
|
|
|
|
|
+import {MessageBox, Message} from 'element-ui'
|
|
|
import store from '@/store'
|
|
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 * as queryString from 'query-string'
|
|
|
import moment from 'moment'
|
|
import moment from 'moment'
|
|
|
|
|
|
|
@@ -12,6 +12,25 @@ const service = axios.create({
|
|
|
// withCredentials: true, // send cookies when cross-domain requests
|
|
// withCredentials: true, // send cookies when cross-domain requests
|
|
|
timeout: 600000 // request timeout
|
|
timeout: 600000 // request timeout
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+function typeOf(obj) {
|
|
|
|
|
+ const toString = Object.prototype.toString
|
|
|
|
|
+ const map = {
|
|
|
|
|
+ '[object Boolean]': 'boolean',
|
|
|
|
|
+ '[object Number]': 'number',
|
|
|
|
|
+ '[object String]': 'string',
|
|
|
|
|
+ '[object Function]': 'function',
|
|
|
|
|
+ '[object Array]': 'array',
|
|
|
|
|
+ '[object Date]': 'date',
|
|
|
|
|
+ '[object RegExp]': 'regExp',
|
|
|
|
|
+ '[object Undefined]': 'undefined',
|
|
|
|
|
+ '[object Null]': 'null',
|
|
|
|
|
+ '[object Object]': 'object',
|
|
|
|
|
+ '[object Blob]': 'blob'
|
|
|
|
|
+ }
|
|
|
|
|
+ return map[toString.call(obj)]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const key = 's#e@5f98H*^his%t'
|
|
const key = 's#e@5f98H*^his%t'
|
|
|
// request interceptor
|
|
// request interceptor
|
|
|
service.interceptors.request.use(
|
|
service.interceptors.request.use(
|
|
@@ -20,11 +39,16 @@ service.interceptors.request.use(
|
|
|
config.headers['Authorization'] = getToken()
|
|
config.headers['Authorization'] = getToken()
|
|
|
}
|
|
}
|
|
|
var paramsObject = ''
|
|
var paramsObject = ''
|
|
|
- debugger
|
|
|
|
|
if (config.method === 'get' || config.method === 'delete') {
|
|
if (config.method === 'get' || config.method === 'delete') {
|
|
|
paramsObject = config.params
|
|
paramsObject = config.params
|
|
|
} else if (config.method === 'post' || config.method === 'put') {
|
|
} else if (config.method === 'post' || config.method === 'put') {
|
|
|
paramsObject = config.data
|
|
paramsObject = config.data
|
|
|
|
|
+ Object.keys(paramsObject).forEach(key => {
|
|
|
|
|
+ const item = paramsObject[key]
|
|
|
|
|
+ if (typeOf(item) === 'object' || typeOf(item) === 'array') {
|
|
|
|
|
+ paramsObject[key] = JSON.stringify(item)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
const queryString1 = queryString.stringify(paramsObject)
|
|
const queryString1 = queryString.stringify(paramsObject)
|
|
|
const queryString2 = encodeURIComponent(queryString1).replace('+', '%20').replace('*', '%2A').replace('%7E', '~')
|
|
const queryString2 = encodeURIComponent(queryString1).replace('+', '%20').replace('*', '%2A').replace('%7E', '~')
|