fix: 移动端通知已读状态无法持久化
根因:
handleCardTap 中 try { await markNotificationRead(); item.is_read = true } catch {}
静默吞噬了 API 错误。PUT /notifications/{id}/read 调用失败时,本地 is_read
仍被设为 true,红点消失。下次进入页面重新拉取,服务端仍为未读状态。
修复:
- API 失败时保留 is_read = false,不更新本地状态
- 弹出Toast提示用户下拉刷新重试
- 失败时 return 阻止跳转,避免用户误以为已处理
This commit is contained in:
@ -102,7 +102,13 @@ function formatTime(t) {
|
|||||||
|
|
||||||
async function handleCardTap(item) {
|
async function handleCardTap(item) {
|
||||||
if (!item.is_read) {
|
if (!item.is_read) {
|
||||||
try { await markNotificationRead(item.id); item.is_read = true; } catch {}
|
try {
|
||||||
|
await markNotificationRead(item.id);
|
||||||
|
item.is_read = true;
|
||||||
|
} catch {
|
||||||
|
uni.showToast({ title: "标记已读失败,请下拉刷新重试", icon: "none", duration: 2000 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 🚀 优先使用 product_serial_number,兜底从 content 中解析
|
// 🚀 优先使用 product_serial_number,兜底从 content 中解析
|
||||||
let sn = item.product_serial_number || "";
|
let sn = item.product_serial_number || "";
|
||||||
|
|||||||
Reference in New Issue
Block a user