优化request
This commit is contained in:
parent
2a85c906dd
commit
01d511b620
|
@ -29,9 +29,13 @@ const request = async (args) => {
|
|||
|
||||
if (typeof rule.auth !== "undefined" && rule.auth === true && !$store.state.user.token) {
|
||||
$store.commit("user/showLoginModal", true);
|
||||
throw "需要登录";
|
||||
return;
|
||||
}
|
||||
|
||||
(rule.showLoading) && uni.showLoading({
|
||||
title: "加载中"
|
||||
});
|
||||
|
||||
const headers = {
|
||||
"XX-Wxapp-AppId": prototype.$config.appId,
|
||||
'XX-Token': $store.state.user.token,
|
||||
|
@ -49,6 +53,14 @@ const request = async (args) => {
|
|||
}
|
||||
});
|
||||
|
||||
(rule.showLoading) && uni.hideLoading();
|
||||
|
||||
if (response.data.code == 10001) {
|
||||
$store.dispatch("user/logout");
|
||||
$store.commit("user/showLoginModal", true);
|
||||
return;
|
||||
}
|
||||
|
||||
return Promise.resolve(response.data);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue