2024-05-30 18:30:23 +08:00
|
|
|
const baseurl = "http://192.168.110.39:8080"; // 本地
|
|
|
|
// const baseurl = "http://lottery.unipay.test.86698.cn/api"; // 测试
|
2024-05-29 10:42:31 +08:00
|
|
|
// const baseurl = ""; // 正式
|
|
|
|
//统一请求
|
|
|
|
axios.interceptors.request.use((config) => {
|
|
|
|
return config;
|
|
|
|
});
|
|
|
|
|
|
|
|
const req = {
|
|
|
|
//get请求
|
|
|
|
axiosGet(url, params) {
|
|
|
|
const obj = { method: "get", url: baseurl + url, params };
|
|
|
|
var result = axios(obj)
|
|
|
|
.then(function (res) {
|
|
|
|
return res.data;
|
|
|
|
})
|
|
|
|
.catch(function (error) {
|
|
|
|
return;
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
//post请求
|
|
|
|
axiosPost(url, data) {
|
|
|
|
let result = axios({
|
|
|
|
method: "post",
|
|
|
|
url: baseurl + url,
|
|
|
|
data: data,
|
|
|
|
header: {
|
|
|
|
"Content-type": "application/x-www-form-urlencoded"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
return res.data;
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
// return "exception=" + error
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
//put请求
|
|
|
|
axiosPut(url, data) {
|
|
|
|
let result = axios({
|
|
|
|
method: "put",
|
|
|
|
url: baseurl + url,
|
|
|
|
data: data,
|
|
|
|
header: {
|
|
|
|
"Content-type": "application/x-www-form-urlencoded"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
return res.data;
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
alert("服务器错误");
|
|
|
|
return "exception=" + error;
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|