beta
This commit is contained in:
parent
bcd986e3f7
commit
44500afd3f
2 changed files with 41 additions and 15 deletions
|
@ -24,19 +24,13 @@ const request = (options) => {
|
|||
success: (res) => {
|
||||
// 处理业务错误
|
||||
if (res.data.code !== 0) {
|
||||
// token过期,尝试刷新
|
||||
if (res.statusCode === 401) {
|
||||
refreshToken().then(() => {
|
||||
// 刷新token后重试请求
|
||||
request(options).then(resolve).catch(reject);
|
||||
}).catch((err) => {
|
||||
// 刷新失败,需要重新登录
|
||||
// token过期,直接清除并跳转登录
|
||||
if (res.statusCode === 401) {
|
||||
wx.removeStorageSync('token');
|
||||
wx.removeStorageSync('openid');
|
||||
reject(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
reject(new Error('登录已过期,请重新登录'));
|
||||
return;
|
||||
}
|
||||
reject(new Error(res.data.message || '请求失败'));
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue