|
@@ -43,7 +43,7 @@ Page({
|
|
},
|
|
},
|
|
{
|
|
{
|
|
icon: '/static_file/tzgg.png',
|
|
icon: '/static_file/tzgg.png',
|
|
- text: '通知公告',
|
|
|
|
|
|
+ text: '消息通知',
|
|
url: '/pages/tongzhiList/tongzhiList'
|
|
url: '/pages/tongzhiList/tongzhiList'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -65,7 +65,8 @@ Page({
|
|
subtitle: '预留入口',
|
|
subtitle: '预留入口',
|
|
imageUrl: '/static_file/background.png'
|
|
imageUrl: '/static_file/background.png'
|
|
},
|
|
},
|
|
- currentAccountInfo: {}
|
|
|
|
|
|
+ currentAccountInfo: {},
|
|
|
|
+ unreadCount: 0
|
|
},
|
|
},
|
|
|
|
|
|
onLoad() {
|
|
onLoad() {
|
|
@@ -89,6 +90,7 @@ Page({
|
|
'!SAAS_LOGIN_TOKEN_!':app.globalData.currentAccountInfo.dsKey
|
|
'!SAAS_LOGIN_TOKEN_!':app.globalData.currentAccountInfo.dsKey
|
|
},
|
|
},
|
|
success (res) {
|
|
success (res) {
|
|
|
|
+ debugger
|
|
wx.hideLoading();
|
|
wx.hideLoading();
|
|
let apiReturnData=res.data;
|
|
let apiReturnData=res.data;
|
|
apiReturnData.data.swNotificationAnnouncementDos.forEach(data=>{
|
|
apiReturnData.data.swNotificationAnnouncementDos.forEach(data=>{
|
|
@@ -96,16 +98,29 @@ Page({
|
|
})
|
|
})
|
|
// 所有的通知公告
|
|
// 所有的通知公告
|
|
app.globalData.notices= apiReturnData.data.swNotificationAnnouncementDos;
|
|
app.globalData.notices= apiReturnData.data.swNotificationAnnouncementDos;
|
|
|
|
+ // 该用户所有的消息通知
|
|
|
|
+ app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
|
|
// 需要轮播的公告
|
|
// 需要轮播的公告
|
|
let data= apiReturnData.data.swNotificationAnnouncementDos.filter(data=>{
|
|
let data= apiReturnData.data.swNotificationAnnouncementDos.filter(data=>{
|
|
return data.homepageslider=='1';
|
|
return data.homepageslider=='1';
|
|
});
|
|
});
|
|
|
|
+ if (app.globalData.userNoticesList) {
|
|
|
|
+ // 假设 userNoticesList 中有一个 isRead 属性表示消息是否已读
|
|
|
|
+ const unreadCount = app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length;
|
|
|
|
+ _this.setData({
|
|
|
|
+ unreadCount: unreadCount
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ _this.setData({
|
|
|
|
+ unreadCount: 0
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
_this.setData({
|
|
_this.setData({
|
|
- billInfo:{
|
|
|
|
- totalAmount:apiReturnData.data.duFees, // 总计应缴
|
|
|
|
- waterUsage:apiReturnData.data.waterConsumption, // 用水量
|
|
|
|
- balance: apiReturnData.data.accountbalance // 账户余额
|
|
|
|
|
|
+ billInfo: {
|
|
|
|
+ totalAmount: apiReturnData.data.duFees ?? 0, // 总计应缴
|
|
|
|
+ waterUsage: apiReturnData.data.waterConsumption ?? 0, // 用水量
|
|
|
|
+ balance: apiReturnData.data.accountbalance ?? 0 // 账户余额
|
|
},
|
|
},
|
|
userInfo:{
|
|
userInfo:{
|
|
name: apiReturnData.data.username,
|
|
name: apiReturnData.data.username,
|
|
@@ -133,6 +148,17 @@ Page({
|
|
wx.removeStorageSync('needRefreshHomepage');
|
|
wx.removeStorageSync('needRefreshHomepage');
|
|
this.loadPageData();
|
|
this.loadPageData();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 从任何页面返回时都获取最新的未读消息数
|
|
|
|
+ this.getUnreadNoticeCount();
|
|
|
|
+
|
|
|
|
+ // 检查是否从户号管理页面返回
|
|
|
|
+ const backFromHuHao = wx.getStorageSync('backFromHuHao');
|
|
|
|
+ if (backFromHuHao) {
|
|
|
|
+ wx.removeStorageSync('backFromHuHao');
|
|
|
|
+ // 从户号管理页面返回时重新加载全部数据
|
|
|
|
+ this.loadHomepageData();
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
loadPageData: function() {
|
|
loadPageData: function() {
|
|
@@ -158,13 +184,14 @@ Page({
|
|
success(res) {
|
|
success(res) {
|
|
wx.hideLoading();
|
|
wx.hideLoading();
|
|
let apiReturnData = res.data;
|
|
let apiReturnData = res.data;
|
|
-
|
|
|
|
|
|
+ // 该用户所有的消息通知
|
|
|
|
+ app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
|
|
// 更新页面数据
|
|
// 更新页面数据
|
|
_this.setData({
|
|
_this.setData({
|
|
billInfo: {
|
|
billInfo: {
|
|
- totalAmount: apiReturnData.data.duFees, // 总计应缴
|
|
|
|
- waterUsage: apiReturnData.data.waterConsumption, // 用水量
|
|
|
|
- balance: apiReturnData.data.accountbalance // 账户余额
|
|
|
|
|
|
+ totalAmount: apiReturnData.data.duFees ?? 0, // 总计应缴
|
|
|
|
+ waterUsage: apiReturnData.data.waterConsumption ?? 0, // 用水量
|
|
|
|
+ balance: apiReturnData.data.accountbalance ?? 0 // 账户余额
|
|
},
|
|
},
|
|
userInfo: {
|
|
userInfo: {
|
|
name: apiReturnData.data.username,
|
|
name: apiReturnData.data.username,
|
|
@@ -403,4 +430,95 @@ Page({
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ // 获取未读消息数量的方法
|
|
|
|
+ getUnreadNoticeCount: function() {
|
|
|
|
+ if (app.globalData.userNoticesList) {
|
|
|
|
+ // 假设 userNoticesList 中有一个 isRead 属性表示消息是否已读
|
|
|
|
+ const unreadCount = app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length;
|
|
|
|
+ this.setData({
|
|
|
|
+ unreadCount: unreadCount
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ this.setData({
|
|
|
|
+ unreadCount: 0
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 新增方法:加载主页全部数据(包括消息通知)
|
|
|
|
+ loadHomepageData: function() {
|
|
|
|
+ const _this = this;
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: '加载中...',
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if(!app.globalData.userWxInfo.token){
|
|
|
|
+ wx.hideLoading();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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) {
|
|
|
|
+ wx.hideLoading();
|
|
|
|
+ if (res.data && res.data.data) {
|
|
|
|
+ let apiReturnData = res.data;
|
|
|
|
+
|
|
|
|
+ // 更新消息通知数据
|
|
|
|
+ apiReturnData.data.swNotificationAnnouncementDos.forEach(data => {
|
|
|
|
+ data.publishtime = data.publishtime.slice(0,10);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 更新全局数据
|
|
|
|
+ app.globalData.notices = apiReturnData.data.swNotificationAnnouncementDos;
|
|
|
|
+ app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
|
|
|
|
+
|
|
|
|
+ // 需要轮播的公告
|
|
|
|
+ let data = apiReturnData.data.swNotificationAnnouncementDos.filter(data => {
|
|
|
|
+ return data.homepageslider == '1';
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 更新未读消息数
|
|
|
|
+ _this.getUnreadNoticeCount();
|
|
|
|
+
|
|
|
|
+ // 更新页面数据
|
|
|
|
+ _this.setData({
|
|
|
|
+ billInfo: {
|
|
|
|
+ totalAmount: apiReturnData.data.duFees ?? 0,
|
|
|
|
+ waterUsage: apiReturnData.data.waterConsumption ?? 0,
|
|
|
|
+ balance: apiReturnData.data.accountbalance ?? 0
|
|
|
|
+ },
|
|
|
|
+ userInfo: {
|
|
|
|
+ name: apiReturnData.data.username,
|
|
|
|
+ accountNumber: apiReturnData.data.usernumber,
|
|
|
|
+ address: apiReturnData.data.address
|
|
|
|
+ },
|
|
|
|
+ noticeList: data,
|
|
|
|
+ isScrolling: true
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 如果有轮播公告,重新开始轮播
|
|
|
|
+ if(data && data.length > 0) {
|
|
|
|
+ _this.startNoticeScroll();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail(error) {
|
|
|
|
+ wx.hideLoading();
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '数据加载失败',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
})
|
|
})
|