|
@@ -19,6 +19,8 @@ Page({
|
|
|
},
|
|
|
//企业地址信息
|
|
|
enterPriseAddress:"",
|
|
|
+ //企业用户须知
|
|
|
+ userNotices:"",
|
|
|
// 账单信息
|
|
|
billInfo: {
|
|
|
totalAmount: "", // 总计应缴
|
|
@@ -313,16 +315,21 @@ Page({
|
|
|
// 该用户所有的消息通知
|
|
|
app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
|
|
|
|
|
|
+ // 获取用户须知
|
|
|
+ const userNotices = apiReturnData.data.userNotice || '';
|
|
|
+
|
|
|
// 计算未读消息数
|
|
|
- if (app.globalData.userNoticesList) {
|
|
|
- const unreadCount = app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length;
|
|
|
- _this.setData({
|
|
|
- unreadCount: unreadCount
|
|
|
- });
|
|
|
- }
|
|
|
+ const unreadCount = app.globalData.userNoticesList ?
|
|
|
+ app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length : 0;
|
|
|
|
|
|
- // 更新页面数据
|
|
|
+ // 更新全局数据中的用户须知
|
|
|
+ app.globalData.currentAccountInfo = {
|
|
|
+ ...app.globalData.currentAccountInfo,
|
|
|
+ userNotices: userNotices
|
|
|
+ };
|
|
|
+
|
|
|
_this.setData({
|
|
|
+ unreadCount: unreadCount,
|
|
|
billInfo: {
|
|
|
totalAmount: apiReturnData.data.duFees ?? 0, // 总计应缴
|
|
|
waterUsage: apiReturnData.data.waterConsumption ?? 0, // 用水量
|
|
@@ -333,7 +340,8 @@ Page({
|
|
|
accountNumber: apiReturnData.data.usernumber,
|
|
|
address: apiReturnData.data.address
|
|
|
},
|
|
|
- enterPriseAddress:apiReturnData.data.enterPriseAddress
|
|
|
+ enterPriseAddress: apiReturnData.data.enterPriseAddress,
|
|
|
+ userNotices: userNotices
|
|
|
});
|
|
|
},
|
|
|
fail(error) {
|
|
@@ -373,6 +381,27 @@ Page({
|
|
|
...app.globalData.currentAccountInfo,
|
|
|
userNotices: this.data.userNotices
|
|
|
};
|
|
|
+
|
|
|
+ // 确保用户须知不为空
|
|
|
+ if (!this.data.userNotices) {
|
|
|
+ // 如果为空,尝试重新获取数据
|
|
|
+ this.loadPageData();
|
|
|
+ // 延迟跳转,等待数据加载完成
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: item.url,
|
|
|
+ fail: function (err) {
|
|
|
+ console.error('页面跳转失败:', err)
|
|
|
+ wx.showToast({
|
|
|
+ title: '功能开发中',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, 500);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: item.url,
|
|
@@ -522,7 +551,7 @@ Page({
|
|
|
wx.setStorageSync('isFirstLoad', 'false');
|
|
|
} else {
|
|
|
if (!isFirstLoad && hasUserSwitchedAccount) {
|
|
|
- // 未切换过账户,查找并设置默认账户
|
|
|
+ // 用户在户号管理中切换过账户,需要重新加载数据
|
|
|
this.loadDefaultAccount();
|
|
|
} else {
|
|
|
// 非首次加载或已在户号管理中切换过账户,直接使用当前账户
|
|
@@ -533,6 +562,8 @@ Page({
|
|
|
// 如果是从户号管理页面切换了账户,需要清除该标记
|
|
|
if (hasUserSwitchedAccount) {
|
|
|
wx.removeStorageSync('hasUserSwitchedAccount');
|
|
|
+ // 从户号管理页面返回时,确保加载最新数据
|
|
|
+ this.loadHomepageData();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -622,7 +653,6 @@ Page({
|
|
|
if (res.data && res.data.data) {
|
|
|
// 查找 defaultAccount 为 0 的账户
|
|
|
const defaultAccount = res.data.data.find(account => account.defaultAccount === "0");
|
|
|
- debugger
|
|
|
if (defaultAccount) {
|
|
|
// 设置为当前账户
|
|
|
app.globalData.currentAccountInfo = defaultAccount;
|
|
@@ -637,6 +667,9 @@ Page({
|
|
|
_this.setData({
|
|
|
currentAccountInfo: app.globalData.currentAccountInfo || {}
|
|
|
});
|
|
|
+
|
|
|
+ // 确保加载页面数据,获取userNotices
|
|
|
+ _this.loadPageData();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -698,8 +731,15 @@ Page({
|
|
|
const unreadCount = app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length;
|
|
|
_this.setData({
|
|
|
unreadCount: unreadCount,
|
|
|
- enterPriseAddress:res.data.enterPriseAddress
|
|
|
+ enterPriseAddress: res.data.data.enterPriseAddress,
|
|
|
+ userNotices: res.data.data.userNotice
|
|
|
});
|
|
|
+
|
|
|
+ // 更新全局数据中的用户须知
|
|
|
+ app.globalData.currentAccountInfo = {
|
|
|
+ ...app.globalData.currentAccountInfo,
|
|
|
+ userNotices: res.data.data.userNotice
|
|
|
+ };
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -750,8 +790,18 @@ Page({
|
|
|
return data.homepageslider == '1';
|
|
|
});
|
|
|
|
|
|
+ // 获取用户须知
|
|
|
+ const userNotices = apiReturnData.data.userNotice || '';
|
|
|
+
|
|
|
+ // 更新全局数据中的用户须知
|
|
|
+ app.globalData.currentAccountInfo = {
|
|
|
+ ...app.globalData.currentAccountInfo,
|
|
|
+ userNotices: userNotices
|
|
|
+ };
|
|
|
+
|
|
|
// 更新未读消息数
|
|
|
- _this.getUnreadNoticeCount();
|
|
|
+ const unreadCount = app.globalData.userNoticesList ?
|
|
|
+ app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length : 0;
|
|
|
|
|
|
// 更新页面数据
|
|
|
_this.setData({
|
|
@@ -765,9 +815,11 @@ Page({
|
|
|
accountNumber: apiReturnData.data.usernumber,
|
|
|
address: apiReturnData.data.address
|
|
|
},
|
|
|
- enterPriseAddress:apiReturnData.data.enterPriseAddress,
|
|
|
+ enterPriseAddress: apiReturnData.data.enterPriseAddress,
|
|
|
+ userNotices: userNotices,
|
|
|
noticeList: data,
|
|
|
- isScrolling: true
|
|
|
+ isScrolling: true,
|
|
|
+ unreadCount: unreadCount
|
|
|
});
|
|
|
|
|
|
// 如果有轮播公告,重新开始轮播
|