import { request } from '../../utils/request' import { NotificationItem } from '../../types/models' import { formatDateTime } from '../../utils/format' import { syncTabBarUnread } from '../../utils/tabbar' Page({ data: { uuid: '', item: {} as NotificationItem, time: '', }, onLoad(query: Record) { const uuid = query.uuid || '' this.setData({ uuid }) if (uuid) { this.fetchDetail() request({ url: `/notification/${uuid}/read`, method: 'POST', showError: false }) .then(() => { // 标记已读后同步红点:本页不是 tab 页,红点不会自动刷新 syncTabBarUnread(true) }) .catch(() => {}) } }, fetchDetail() { request({ url: `/notification/${this.data.uuid}` }) .then((item) => this.setData({ item, time: formatDateTime(item.created_at) })) .catch(() => {}) }, })