|
|
|
@ -39,21 +39,30 @@ const install = (Vue, vm) => {
|
|
|
|
// 响应拦截,如配置,每次请求结束都会执行本方法
|
|
|
|
// 响应拦截,如配置,每次请求结束都会执行本方法
|
|
|
|
Vue.prototype.$u.http.interceptor.response = (res) => {
|
|
|
|
Vue.prototype.$u.http.interceptor.response = (res) => {
|
|
|
|
console.log('res-http', res)
|
|
|
|
console.log('res-http', res)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (res.statusCode === 200) {
|
|
|
|
if (res.statusCode === 200) {
|
|
|
|
|
|
|
|
if (res.data.hasOwnProperty("errcode")) {
|
|
|
|
if (res.data.errcode === 40001) {
|
|
|
|
if (res.data.errcode === 40001) {
|
|
|
|
uni.showToast({
|
|
|
|
uni.showToast({
|
|
|
|
icon: "none",
|
|
|
|
icon: "none",
|
|
|
|
title: "登陆过期,请重新登录"
|
|
|
|
title: "登陆过期,请重新登录"
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
uni.redirectTo({
|
|
|
|
uni.redirectTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}, 1500)
|
|
|
|
}, 1500)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
|
|
icon: "none",
|
|
|
|
|
|
|
|
title: res.data.errmsg
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else
|
|
|
|
return res.data;
|
|
|
|
return res.data;
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
uni.showToast({
|
|
|
|
uni.showToast({
|
|
|
|
icon: "fail",
|
|
|
|
icon: "fail",
|
|
|
|
|