From b731144a5a4048066be3dcf05c0a20c0daf0db11 Mon Sep 17 00:00:00 2001 From: duxingchen Date: Wed, 12 Aug 2026 12:15:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E5=8A=A8=E7=AB=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=B7=B2=E8=AF=BB=E7=8A=B6=E6=80=81=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: handleCardTap 中 try { await markNotificationRead(); item.is_read = true } catch {} 静默吞噬了 API 错误。PUT /notifications/{id}/read 调用失败时,本地 is_read 仍被设为 true,红点消失。下次进入页面重新拉取,服务端仍为未读状态。 修复: - API 失败时保留 is_read = false,不更新本地状态 - 弹出Toast提示用户下拉刷新重试 - 失败时 return 阻止跳转,避免用户误以为已处理 --- track-uniapp/src/pages/notify/index.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/track-uniapp/src/pages/notify/index.vue b/track-uniapp/src/pages/notify/index.vue index 9092b8e..e2292bd 100644 --- a/track-uniapp/src/pages/notify/index.vue +++ b/track-uniapp/src/pages/notify/index.vue @@ -102,7 +102,13 @@ function formatTime(t) { async function handleCardTap(item) { 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 中解析 let sn = item.product_serial_number || "";