26e543b8
liuqimichale
ajax 统一封装
|
1
2
3
4
5
6
|
import axios from 'axios'
// let _userToken = sessionStorage.getItem('userToken')
// let _url = process.env.API_ROOT
// axios.defaults.baseURL = process.env.API_ROOT
const service = axios.create({
|
26e543b8
liuqimichale
ajax 统一封装
|
7
|
|
7528d5a2
liuqimichale
员工号
|
8
9
|
// https://pay.renniting.cn/ 赤峰
|
c865a00f
liuqimichale
赤峰支付宝支付
|
10
11
12
13
|
// 'http://39.98.58.92:8090'; 赤峰测试环境
|
dc296370
liuqimichale
赤峰测试环境
|
14
15
|
// https://dev.renniting.cn/pay/ 赤峰农行测试环境
|
8ecf38fb
刘淇
在停 聚合 支付
|
16
|
baseURL: 'http://wxzhifu.natapp1.cc', // url = base url + request url
|
e38fe48c
liuqimichale
接口跨域
|
17
|
// withCredentials: true, // send cookies when cross-domain requests
|
6351d1dc
liuqimichale
员工号
|
18
|
timeout: 10000 // request timeout
|
26e543b8
liuqimichale
ajax 统一封装
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
})
service.interceptors.request.use(
config => {
// let token = _userToken
// //let token='298bd7ff-a025-4145-a4a3-554769375b48';
// config.headers['X-Auth-Token'] = token
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
|