|
@@ -149,15 +149,15 @@ Page({
|
|
|
this.loadPageData();
|
|
|
}
|
|
|
|
|
|
- // 从任何页面返回时都获取最新的未读消息数
|
|
|
- this.getUnreadNoticeCount();
|
|
|
-
|
|
|
// 检查是否从户号管理页面返回
|
|
|
const backFromHuHao = wx.getStorageSync('backFromHuHao');
|
|
|
if (backFromHuHao) {
|
|
|
wx.removeStorageSync('backFromHuHao');
|
|
|
// 从户号管理页面返回时重新加载全部数据
|
|
|
this.loadHomepageData();
|
|
|
+ } else {
|
|
|
+ // 即使不是从户号管理页面返回,也更新未读消息数
|
|
|
+ this.getUnreadNoticeCount();
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -433,11 +433,29 @@ Page({
|
|
|
|
|
|
// 获取未读消息数量的方法
|
|
|
getUnreadNoticeCount: function() {
|
|
|
- if (app.globalData.userNoticesList) {
|
|
|
- // 假设 userNoticesList 中有一个 isRead 属性表示消息是否已读
|
|
|
- const unreadCount = app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length;
|
|
|
- this.setData({
|
|
|
- unreadCount: unreadCount
|
|
|
+ const _this = this;
|
|
|
+ // 从服务器获取最新的消息通知数据
|
|
|
+ if (app.globalData.userWxInfo.token && app.globalData.currentAccountInfo) {
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.interfaceUrls.homePageInfo + app.globalData.currentAccountInfo.usernumber,
|
|
|
+ method: 'GET',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/json',
|
|
|
+ 'token': app.globalData.userWxInfo.token,
|
|
|
+ 'source': "wc",
|
|
|
+ '!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ if (res.data && res.data.data) {
|
|
|
+ // 更新全局的用户通知列表
|
|
|
+ app.globalData.userNoticesList = res.data.data.sysNotifyAnnounceUserDos;
|
|
|
+ // 计算未读消息数量
|
|
|
+ const unreadCount = app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length;
|
|
|
+ _this.setData({
|
|
|
+ unreadCount: unreadCount
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
} else {
|
|
|
this.setData({
|