|
@@ -5,7 +5,12 @@ import storageUtil from '../util/storageUtil'
|
|
|
export default function ajax (url, data={}, type='GET') {
|
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
- let promise
|
|
|
+ const deptArray = storageUtil.read('dept-array');
|
|
|
+ if(deptArray) {
|
|
|
+ data[ 'dept' + deptArray.length - 1 ] = deptArray[deptArray.length - 1];
|
|
|
+ }
|
|
|
+
|
|
|
+ let promise;
|
|
|
if (type === 'GET') {
|
|
|
let dataStr = ''
|
|
|
Object.keys(data).forEach(key => {
|
|
@@ -14,21 +19,11 @@ export default function ajax (url, data={}, type='GET') {
|
|
|
if (dataStr !== '') {
|
|
|
dataStr = dataStr.substring(0, dataStr.lastIndexOf('&'))
|
|
|
url = url + '?' + dataStr;
|
|
|
- } else {
|
|
|
- url = url;
|
|
|
}
|
|
|
|
|
|
- promise = axios.get(url, {
|
|
|
- headers: {
|
|
|
- 'cipherText': storageUtil.read("userInfo")
|
|
|
- }
|
|
|
- })
|
|
|
+ promise = axios.get(url)
|
|
|
} else {
|
|
|
- promise = axios.post(url, qs.stringify(data), {
|
|
|
- headers: {
|
|
|
- 'cipherText': storageUtil.read("userInfo")
|
|
|
- }
|
|
|
- });
|
|
|
+ promise = axios.post(url, qs.stringify(data));
|
|
|
}
|
|
|
promise.then(function (response) {
|
|
|
resolve(response.data);
|