| | |
| | | // 请求拦截器 |
| | | uni.$u.http.interceptors.request.use((config) => { |
| | | const Headtoken = vm.$store.state.token |
| | | uni.showLoading({ title: '加载中' }); |
| | | // 判断有无token,有则加入请求头中 |
| | | if (Headtoken) { |
| | | config.header['token'] = Headtoken; |
| | |
| | | |
| | | // 响应拦截器 |
| | | uni.$u.http.interceptors.response.use((response) => { |
| | | uni.hideLoading(); |
| | | if (response.data.code === 5113) { |
| | | uni.navigateTo({ |
| | | uni.switchTab({ |
| | | url: '/pages/index/index' |
| | | }); |
| | | return |
| | | return |
| | | } |
| | | if (response.data.code !== 200) { |
| | | uni.showToast({ |
| | | title: response.data.message, |
| | | icon: "none", |
| | | duration: 2000 |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | return response.data |
| | | }, (response) => { |
| | | return Promise.reject(response) |