0c49c87e
liuqimichale
微信公众号 初始化
|
1
2
3
4
|
import axios from 'axios'
// let _url = process.env.API_ROOT
// axios.defaults.baseURL = process.env.API_ROOT
|
eae77c58
刘淇
江阴领取优惠券
|
5
|
|
0c49c87e
liuqimichale
微信公众号 初始化
|
6
|
const service = axios.create({
|
92e91fa6
刘淇
江阴领取优惠券调接口
|
7
8
|
// baseURL:'https://bus.jycrtc.com/',
// baseURL:process.env.VUE_APP_URL,
|
331018f3
刘淇
江阴领取优惠券调接口
|
9
|
// baseURL:'',
|
0c49c87e
liuqimichale
微信公众号 初始化
|
10
|
// withCredentials: true, // send cookies when cross-domain requests
|
eae77c58
刘淇
江阴领取优惠券
|
11
|
timeout: 6000, // request timeout
|
331018f3
刘淇
江阴领取优惠券调接口
|
12
13
14
15
16
17
18
19
|
// withCredentials: false,
// crossDomain: true,
xhrFields: {
withCredentials: false
},
|
eae77c58
刘淇
江阴领取优惠券
|
20
|
headers:{
|
92e91fa6
刘淇
江阴领取优惠券调接口
|
21
22
|
'Access-Control-Allow-Origin':'*'
//'Content-Type':'application/x-www-form-urlencoded'
|
eae77c58
刘淇
江阴领取优惠券
|
23
|
}
|
0c49c87e
liuqimichale
微信公众号 初始化
|
24
25
26
|
})
service.interceptors.request.use(
|
eae77c58
刘淇
江阴领取优惠券
|
27
|
|
0c49c87e
liuqimichale
微信公众号 初始化
|
28
|
config => {
|
331018f3
刘淇
江阴领取优惠券调接口
|
29
30
31
|
// if (process.env.NODE_ENV === 'production'){
// if(config.requestBase=='VUE_APP_URL'){
// config.baseURL='https://bus.jycrtc.com/';
|
92e91fa6
刘淇
江阴领取优惠券调接口
|
32
|
//
|
331018f3
刘淇
江阴领取优惠券调接口
|
33
34
35
|
// }else if(config.requestBase=='VUE_APP_URL_TWO'){
// config.baseURL='https://pay.jycrtc.com/';
// }
|
92e91fa6
刘淇
江阴领取优惠券调接口
|
36
|
// }
|
eae77c58
刘淇
江阴领取优惠券
|
37
|
|
331018f3
刘淇
江阴领取优惠券调接口
|
38
|
|
0c49c87e
liuqimichale
微信公众号 初始化
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
return config
},
error => {
// do something with request error
console.log(error) // for debug
return Promise.reject(error)
}
)
// response interceptor
service.interceptors.response.use(
response => {
const res = response.data
// if the custom code is not 20000, it is judged as an error.
if (res.code != '8888') {
return res
} else {
return res
}
},
error => {
console.log('err' + error) // for debug
return Promise.reject(error)
}
)
export default service
|