|
|
@@ -1,23 +1,15 @@
|
|
|
// 导入axios
|
|
|
import axios from 'axios';
|
|
|
-import cookie from 'js-cookie';
|
|
|
import store from '@/store'
|
|
|
import Vue from 'vue'
|
|
|
|
|
|
|
|
|
// 进行一些全局配置
|
|
|
// 公共路由(网络请求地址)
|
|
|
-// axios.defaults.baseURL = process.env.API_URL;
|
|
|
-// axios.defaults.baseURL = 'http://192.168.100.8:3000';
|
|
|
-axios.defaults.baseURL = 'http://127.0.0.1:3000/'; // 本地
|
|
|
+// axios.defaults.baseURL = process.env.API_DEV_URL; // 后台地址
|
|
|
+axios.defaults.baseURL = process.env.API_PRO_URL; // 本地后台地址
|
|
|
// 请求响应超时时间
|
|
|
axios.defaults.timeout = 5000;
|
|
|
-// 设置请求头
|
|
|
-// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
|
-
|
|
|
-// 设置请求超时
|
|
|
-axios.defaults.timeout = 5000 //设置超时时间为5s```
|
|
|
-
|
|
|
// 设置post请求方式请求头
|
|
|
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
|
|
|
// 请求拦截器
|
|
|
@@ -106,12 +98,10 @@ axios.interceptors.response.use(
|
|
|
export default {
|
|
|
get: function(path = '', data = {}) {
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
- const token = cookie.get('token')
|
|
|
axios.get(path, {
|
|
|
params: data,
|
|
|
headers:{
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
- 'Authorization': token || ''
|
|
|
}
|
|
|
})
|
|
|
.then(function(response) {
|
|
|
@@ -124,11 +114,9 @@ export default {
|
|
|
},
|
|
|
post: function(path = '', data = {}) {
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
- const token = cookie.get('token')
|
|
|
axios.post(path, data, {
|
|
|
headers:{
|
|
|
'Content-Type': 'application/json',
|
|
|
- // 'Authorization': token || ''
|
|
|
}
|
|
|
})
|
|
|
.then(function(response) {
|
|
|
@@ -150,12 +138,10 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
.then(function(response) {
|
|
|
- console.log(`response`, response)
|
|
|
console.log('========上传成功=====')
|
|
|
resolve(response.data);
|
|
|
})
|
|
|
.catch(function(error) {
|
|
|
- console.log(`error upload====`, error)
|
|
|
reject(error);
|
|
|
});
|
|
|
});
|