import $ajax from 'axios' $ajax.defaults.withCredentials = true; $ajax.interceptors.response.use( (response)=> { // 对响应数据做点什么 // 显示 console.log("添加响应拦截器", response) if (response.data.resultCode == 1999){ // localStorage.setItem("userIsLogin", "true") window.location.reload(); } else if (response.data.resultCode == 2000 && localStorage.getItem("resultCode") == "true"){ localStorage.removeItem("resultCode") location.href = window.location.origin + "/weixin/dist/index.html#/" } if (response.data.data == null){ Vue.$vux.toast.text(response.data.errorMessage, 'bottom') } else if (response.data.data.errorCode && response.data.data.errorCode != 0){ Vue.$vux.toast.text(response.data.errorMessage, 'bottom') // response.config.url } return response.data.data; }, function (error) { // 对响应错误做点什么 Vue.$vux.toast.text("服务器异常!", 'bottom') return Promise.reject(error); });