| | |
| | | * 响应拦截
|
| | | * @param {Object} http
|
| | | */ |
| | | import { coustomLogin, wxEmpower } from '@/util/api/index'
|
| | | module.exports = (vm) => {
|
| | | uni.$u.http.interceptors.response.use((response) => {
|
| | | /* 对响应成功做点什么 可使用async await 做异步操作*/
|
| | | const data = response.data
|
| | | // 自定义参数
|
| | | const custom = response.config?.custom
|
| | | if (data.code !== 200) { // 服务端返回的状态码不等于200,则reject() |
| | | uni.$u.toast(data.message) |
| | | if (data.code === 5112) { |
| | | // 未登录、登录失效 |
| | | uni.reLaunch({ |
| | | url: '/pages/index/index' |
| | | }) |
| | | } |
| | | return Promise.reject(data)
|
| | | } |
| | | // const custom = response.config?.custom
|
| | | // if (data.code !== 200) { // 服务端返回的状态码不等于200,则reject() |
| | | // uni.$u.toast(data.message) |
| | | // if (data.code === 401) { |
| | | // // console.log('未登录、登录失效'); |
| | | // // 未登录、登录失效 |
| | | // uni.reLaunch({ |
| | | // url: '/pages/login/login' |
| | | // }) |
| | | // } |
| | | // return Promise.reject(data)
|
| | | // } |
| | | // console.log(data.data);
|
| | | return data.data || {}
|
| | | }, (response) => {
|