This commit is contained in:
2026-09-13 02:28:46 +08:00
parent df5492a48a
commit 42f9530a59
27 changed files with 979 additions and 149 deletions
@@ -2,6 +2,10 @@ import { request } from '../../utils/request'
import { NotificationItem } from '../../types/models'
import { formatDateTime } from '../../utils/format'
import { syncTabBarUnread } from '../../utils/tabbar'
import { logger } from '../../utils/logger'
// 日志模块名
const LOG = 'notification-detail'
Page({
data: {
@@ -12,21 +16,28 @@ Page({
onLoad(query: Record<string, string>) {
const uuid = query.uuid || ''
logger.debug(LOG, 'onLoad, uuid=', uuid)
this.setData({ uuid })
if (uuid) {
this.fetchDetail()
request({ url: `/notification/${uuid}/read`, method: 'POST', showError: false })
.then(() => {
// 标记已读后同步红点:本页不是 tab 页,红点不会自动刷新
syncTabBarUnread(true)
})
.catch(() => {})
if (!uuid) {
logger.warn(LOG, 'onLoad 缺少 uuid 参数')
return
}
this.fetchDetail()
request({ url: `/notification/${uuid}/read`, method: 'POST', showError: false })
.then(() => {
logger.debug(LOG, '标记已读成功')
// 标记已读后同步红点:本页不是 tab 页,红点不会自动刷新
syncTabBarUnread(true)
})
.catch((e: any) => logger.warn(LOG, '标记已读失败, code=', e && e.code))
},
fetchDetail() {
request<NotificationItem>({ url: `/notification/${this.data.uuid}` })
.then((item) => this.setData({ item, time: formatDateTime(item.created_at) }))
.catch(() => {})
.then((item) => {
logger.debug(LOG, '详情加载成功')
this.setData({ item, time: formatDateTime(item.created_at) })
})
.catch((e: any) => logger.warn(LOG, '详情加载失败, code=', e && e.code))
},
})