feat: 迭代
This commit is contained in:
@@ -335,9 +335,14 @@ async function handlePhoneLogin() {
|
||||
setTimeout(() => {
|
||||
uni.switchTab({ url: '/pages/index/index' });
|
||||
}, 500);
|
||||
} catch (e) {
|
||||
} catch (error: any) {
|
||||
uni.hideLoading();
|
||||
console.error(e);
|
||||
console.error('手机号登录失败', error);
|
||||
uni.showToast({
|
||||
title: error.message || '登录失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -83,6 +83,14 @@ export function request<T = any>(options: RequestOptions): Promise<ApiResponse<T
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否有 token,如果没有 token 说明是登录接口返回的 401,直接返回原始错误消息
|
||||
const hasToken = useSellerToken ? uni.getStorageSync('sellerToken') : uni.getStorageSync('token');
|
||||
if (!hasToken) {
|
||||
// 登录接口的 401 错误,直接返回后端的错误消息
|
||||
reject(new Error(responseData.message || '认证失败'));
|
||||
return;
|
||||
}
|
||||
|
||||
// 正常 401 处理,只清除对应账户的 token,不互相干扰
|
||||
if (useSellerToken) {
|
||||
// 商家 token 失效,跳转到商家登录页
|
||||
|
||||
Reference in New Issue
Block a user