提交 cf63674e authored 作者: 刘旭's avatar 刘旭

优化

上级 74cb1d15
......@@ -14,17 +14,17 @@ function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?:
} else {
let pages = getCurrentPages();
let curRoute = pages[pages.length - 1].route;
// if (curRoute != 'pages/login/login') {
// uni.showToast({
// icon: 'none',
// title: '请重新登录',
// success() {
// uni.navigateTo({
// url: '/pages/login/login'
// });
// }
// });
// }
if (curRoute != 'pages/login/login') {
uni.showToast({
icon: 'none',
title: '请重新登录',
success() {
uni.navigateTo({
url: '/pages/login/login',
});
},
});
}
}
uni.request({
url: baseUrl + url,
......@@ -51,23 +51,28 @@ function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?:
});
});
} else {
if (res.error === 'invalid_token') {
uni.clearStorage();
}
console.log(res);
//其余异样
uni.showToast({
title: res.data.msg,
title: res.error,
icon: 'none',
});
reject(res);
}
},
fail(err) {
fail(err: any) {
if (err.error === 'invalid_token') {
uni.clearStorage();
}
uni.hideLoading();
//申请失败
uni.showToast({
title: '连接服务器失败',
icon: 'none',
});
uni.clearStorage();
reject(err);
},
});
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论