修复消息监听角标、历史记录加载与重复订单卡片推送
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user