|
@@ -3,17 +3,18 @@ import sysConfig from '@/config' //引入配置文件
|
|
import store from "../store/index"
|
|
import store from "../store/index"
|
|
import qs from "qs"
|
|
import qs from "qs"
|
|
|
|
|
|
-// console.log(process.env.NODE_ENV)
|
|
|
|
|
|
|
|
axios.defaults.baseURL = sysConfig.baseUrl //设置请求时间
|
|
axios.defaults.baseURL = sysConfig.baseUrl //设置请求时间
|
|
axios.defaults.timeout = sysConfig.timeout //设置请求超时时间
|
|
axios.defaults.timeout = sysConfig.timeout //设置请求超时时间
|
|
const ContentType = sysConfig.ContentType
|
|
const ContentType = sysConfig.ContentType
|
|
|
|
|
|
-//axios.defaults.headers["Content-Type"] = "application/json";
|
|
|
|
// axios.defaults.withCredentials = true
|
|
// axios.defaults.withCredentials = true
|
|
axios.defaults.headers = { 'Content-Type': 'application/json; charset=utf-8' };
|
|
axios.defaults.headers = { 'Content-Type': 'application/json; charset=utf-8' };
|
|
-
|
|
|
|
-// axios.defaults.headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
|
|
|
|
+axios.defaults.paramsSerializer = {
|
|
|
|
+ serialize: function(params) {
|
|
|
|
+ return qs.stringify(params, { allowDots: true })
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
/** 请求发送前拦截,用于配置求情内容,如headers参数等 */
|
|
/** 请求发送前拦截,用于配置求情内容,如headers参数等 */
|
|
@@ -31,29 +32,29 @@ function error1(res) {
|
|
if (res.status == 408 || res.status == 401) { // 需要重新登录
|
|
if (res.status == 408 || res.status == 401) { // 需要重新登录
|
|
store.commit('setPcToken', "");
|
|
store.commit('setPcToken', "");
|
|
console.log(res.data);
|
|
console.log(res.data);
|
|
- // window.xm.showToast({
|
|
|
|
- // message:res.data
|
|
|
|
- // })
|
|
|
|
|
|
+ window.xm.showToast({
|
|
|
|
+ message: res.data
|
|
|
|
+ })
|
|
} else if (res.status === 404) {
|
|
} else if (res.status === 404) {
|
|
console.log("404,路径找不到:" + res.data.path);
|
|
console.log("404,路径找不到:" + res.data.path);
|
|
- // window.xm.showToast({
|
|
|
|
- // message:"404,路径找不到:"+res.data.path
|
|
|
|
- // })
|
|
|
|
|
|
+ window.xm.showToast({
|
|
|
|
+ message: "404,路径找不到:" + res.data.path
|
|
|
|
+ })
|
|
} else if (res.status === 503) {
|
|
} else if (res.status === 503) {
|
|
console.log("服务不可用");
|
|
console.log("服务不可用");
|
|
- // window.xm.showToast({
|
|
|
|
- // message:"服务不可用"
|
|
|
|
- // })
|
|
|
|
|
|
+ window.xm.showToast({
|
|
|
|
+ message: "服务不可用"
|
|
|
|
+ })
|
|
} else if (res.status === 504) {
|
|
} else if (res.status === 504) {
|
|
console.log("网络连接错误");
|
|
console.log("网络连接错误");
|
|
- // window.xm.showToast({
|
|
|
|
- // message:"网络连接错误"
|
|
|
|
- // })
|
|
|
|
|
|
+ window.xm.showToast({
|
|
|
|
+ message: "网络连接错误"
|
|
|
|
+ })
|
|
} else {
|
|
} else {
|
|
console.log(res.data);
|
|
console.log(res.data);
|
|
- // window.xm.showToast({
|
|
|
|
- // message:res.data
|
|
|
|
- // })
|
|
|
|
|
|
+ window.xm.showToast({
|
|
|
|
+ message: res.data
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -114,16 +115,9 @@ var http = {
|
|
url: url,
|
|
url: url,
|
|
method: 'post',
|
|
method: 'post',
|
|
data: data,
|
|
data: data,
|
|
- // params: params,
|
|
|
|
params: qs.stringify(params),
|
|
params: qs.stringify(params),
|
|
config: config
|
|
config: config
|
|
}).then((response) => {
|
|
}).then((response) => {
|
|
- //if(response.data && response.data.statusCode !== 200){
|
|
|
|
- // error(response.data);
|
|
|
|
- // reject(response.data)
|
|
|
|
- // }
|
|
|
|
- // resolve(response.data);
|
|
|
|
-
|
|
|
|
resolve(response);
|
|
resolve(response);
|
|
}).catch((error) => {
|
|
}).catch((error) => {
|
|
reject(error)
|
|
reject(error)
|