This commit is contained in:
2020-08-07 11:40:13 +08:00
parent 9f444ad070
commit eb0d648f6a
5 changed files with 60 additions and 22 deletions

View File

@@ -4,7 +4,7 @@ const install = (Vue, vm) => {
baseUrl: 'https://dmmall.sdbairui.com/api',
loadingText: '努力加载中~',
loadingTime: 800,
// originalData: true
originalData: true
});
// 请求拦截配置Token等参数
@@ -20,12 +20,12 @@ const install = (Vue, vm) => {
// 响应拦截,如配置,每次请求结束都会执行本方法
Vue.prototype.$u.http.interceptor.response = (res) => {
if(parseInt(res.errCode) == 0) {
if(parseInt(res.data.errCode) == 0) {
// res为服务端返回值可能有errCoderesult等字段
// 这里对res.result进行返回将会在this.$u.post(url).then(res => {})的then回调中的res的到
// 如果配置了originalData为true请留意这里的返回值
return res;
} else if(res.errCode == 401) {
return res.data;
} else if(res.data.errCode == 401) {
// 假设201为token失效这里跳转登录
vm.$u.toast('验证失败,请重新登录');
setTimeout(() => {