接口封装处理

main
limingtao 11 months ago
parent 432d6959af
commit 9e85ccfb80
  1. 4
      common/globalJs/request.js

@ -67,13 +67,15 @@ class Request {
if (_this.resInterceptors && typeof _this.resInterceptors === 'function') { if (_this.resInterceptors && typeof _this.resInterceptors === 'function') {
let resInterceptors = _this.resInterceptors(res); let resInterceptors = _this.resInterceptors(res);
// console.log('resInterceptors-----------------',resInterceptors) // console.log('resInterceptors-----------------',resInterceptors)
if(resInterceptors.statusCode == 400 || resInterceptors.data.code == 403){ if(resInterceptors.statusCode == 401 || resInterceptors.data.code == 403){
$.toast('登录信息已过期,请重新登录') $.toast('登录信息已过期,请重新登录')
$.removeData('token') $.removeData('token')
setTimeout(() => { setTimeout(() => {
$.openNew('/pages/logIn/logIn') $.openNew('/pages/logIn/logIn')
},1500) },1500)
return return
}else if(resInterceptors.statusCode != 200){
$.toast(resInterceptors.data.message)
} }
if (!resInterceptors && resInterceptors != '') { if (!resInterceptors && resInterceptors != '') {
reject('返回值已被您拦截!'); reject('返回值已被您拦截!');

Loading…
Cancel
Save