feat: 完善双端演示注册与红娘服务闭环

This commit is contained in:
WorkBuddy
2026-10-21 23:41:47 +08:00
parent afee993626
commit 39a18a50ee
63 changed files with 1298 additions and 217 deletions
+23 -5
View File
@@ -16,6 +16,18 @@ Page({
this.loadNotifications();
},
getTypeText(type) {
return { matchmaker: '红娘服务', appointment: '预约提醒', counseling: '咨询服务', premarital: '婚前辅导', service_location: '服务站服务', match: '匹配提醒', activity: '活动提醒', account: '账号状态', review: '审核通知', local_eligibility: '资格认证', risk: '安全提醒', system: '系统通知' }[type] || '系统通知';
},
openNotification(item) {
const type = item && item.type;
const url = ['matchmaker', 'appointment', 'counseling', 'premarital', 'service_location'].includes(type)
? '/pages/service-history/service-history'
: ['match', 'activity'].includes(type) ? '/pages/fate-center/fate-center' : '/pages/settings/settings';
wx.navigateTo({ url });
},
onShow() {
this.loadUnreadCount();
},
@@ -30,11 +42,12 @@ Page({
{ Authorization: `Bearer ${token}` }
);
if (res) {
const raw = Array.isArray(res) ? res : (res.notifications || res.items || res.records || []);
const isNewPage = this.data.page === 1;
this.setData({
notifications: isNewPage ? res.notifications : [...this.data.notifications, ...res.notifications],
unreadCount: res.unreadCount,
hasMore: res.notifications.length >= 20,
notifications: isNewPage ? raw.map(this.normalizeNotification) : [...this.data.notifications, ...raw.map(this.normalizeNotification)],
unreadCount: res.unreadCount || res.count || 0,
hasMore: raw.length >= 20,
loading: false
});
}
@@ -43,11 +56,15 @@ Page({
}
},
normalizeNotification(item) {
return { ...item, notificationId: item.notificationId || item.id, read: item.read === true || item.readStatus === 'read' };
},
async loadUnreadCount() {
try {
const token = wx.getStorageSync('accessToken');
const res = await api.get('/notifications/unread-count', {}, { Authorization: `Bearer ${token}` });
this.setData({ unreadCount: res?.unreadCount || 0 });
const res = await api.get('/notifications/unread', {}, { Authorization: `Bearer ${token}` });
this.setData({ unreadCount: res?.unreadCount ?? res?.count ?? 0 });
} catch (e) { /* ignore */ }
},
@@ -63,6 +80,7 @@ Page({
unreadCount: Math.max(0, this.data.unreadCount - 1)
});
} catch (err) { /* ignore */ }
this.openNotification(this.data.notifications.find((n) => n.notificationId === notificationId));
},
async onMarkAllRead() {