update:提示词
This commit is contained in:
parent
0f7e7467d9
commit
efae461f9d
@ -143,6 +143,7 @@ function request({
|
||||
// 如果后端在 Response Headers 下发新的 token,就替换本地 token
|
||||
const tokenUpdated = tryUpdateAccessTokenFromResponseHeaders(res);
|
||||
const statusCode = res && res.data && res.data.statusCode ? res.data.statusCode : 0;
|
||||
const errors = res && res.data && res.data.errors ? res.data.errors : null;
|
||||
const payload = res && res.data !== undefined ? res.data : null;
|
||||
|
||||
// ── 401 未授权:尝试刷新Token ──
|
||||
@ -201,28 +202,28 @@ function request({
|
||||
|
||||
// ── 403 禁止访问 ──
|
||||
if (statusCode === 403) {
|
||||
wx.showToast({ title: '无访问权限', icon: 'none' });
|
||||
wx.showToast({ title: errors, icon: 'none' });
|
||||
reject(new Error('Forbidden'));
|
||||
return;
|
||||
}
|
||||
|
||||
// ── 404 资源不存在 ───────────────────────────────────────────
|
||||
if (statusCode === 404) {
|
||||
wx.showToast({ title: '请求资源不存在', icon: 'none' });
|
||||
wx.showToast({ title: errors || '请求资源不存在', icon: 'none' });
|
||||
reject(new Error('Not Found'));
|
||||
return;
|
||||
}
|
||||
|
||||
// ── 5xx 服务端错误 ───────────────────────────────────────────
|
||||
if (statusCode >= 500) {
|
||||
wx.showToast({ title: '服务器异常,请稍后重试', icon: 'none' });
|
||||
wx.showToast({ title: errors || '服务器异常,请稍后重试', icon: 'none' });
|
||||
reject(new Error(`Server Error: ${statusCode}`));
|
||||
return;
|
||||
}
|
||||
|
||||
// ── 其他非 2xx ───────────────────────────────────────────────
|
||||
if (statusCode !== 0 && (statusCode < 200 || statusCode >= 300)) {
|
||||
wx.showToast({ title: `请求失败(${statusCode})`, icon: 'none' });
|
||||
wx.showToast({ title: errors || `请求失败(${statusCode})`, icon: 'none' });
|
||||
reject(new Error(`HTTP Error: ${statusCode}`));
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user