修复消息监听角标、历史记录加载与重复订单卡片推送

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-06-24 04:17:33 +08:00
parent 53548b6a61
commit 29b8f303b3
4 changed files with 360 additions and 128 deletions

View File

@@ -32,14 +32,34 @@ Page({
this.renderConversations(content);
}
};
this._onUnreadChanged = (data) => {
const unreadTotal = data?.unreadTotal ?? app.globalData.messageManager?.unreadTotal ?? 0;
if (app.globalData.messageManager) {
app.globalData.messageManager.unreadTotal = unreadTotal;
}
if (app.emitEvent) {
app.emitEvent('tabBarBadgeChanged', {
badgeText: unreadTotal > 0 ? String(unreadTotal) : '',
});
}
if (this.data.currentUser) {
this.loadConversations();
}
};
app.on('conversationsUpdated', this._onGlobalConvUpdated);
app.on('unreadCountChanged', this._onGlobalConvUpdated);
app.on('unreadCountChanged', this._onUnreadChanged);
},
onUnload() {
if (this._onGlobalConvUpdated) {
app.off('conversationsUpdated', this._onGlobalConvUpdated);
app.off('unreadCountChanged', this._onGlobalConvUpdated);
}
if (this._onUnreadChanged) {
app.off('unreadCountChanged', this._onUnreadChanged);
}
if (this.conversationsUpdatedListener && wx.goEasy?.im) {
wx.goEasy.im.off(wx.GoEasy.IM_EVENT.CONVERSATIONS_UPDATED, this.conversationsUpdatedListener);
this.conversationsUpdatedListener = null;
}
},
@@ -55,11 +75,7 @@ Page({
this.checkPermissionAndAutoConnect();
},
// ❌ 原版注释保留:删除所有清理逻辑,监听器永久存活
onHide() {},
onUnload() {},
// ========== 鉴权检查 ==========
async checkPermissionAndAutoConnect() {
const seq = ++this._permissionSeq;
let quanxian;