|
@@ -1,5 +1,22 @@
|
|
|
const app = getApp();
|
|
|
Page({
|
|
|
+ onShareAppMessage() {
|
|
|
+ const promise = new Promise(resolve => {
|
|
|
+ setTimeout(() => {
|
|
|
+ resolve({
|
|
|
+ title: '用水宝',
|
|
|
+ path: '/homepage/homepage',
|
|
|
+ imageUrl: '/static_file/share_img.png',
|
|
|
+ })
|
|
|
+ }, 500)
|
|
|
+ })
|
|
|
+ return {
|
|
|
+ title: '用水宝',
|
|
|
+ path: '/homepage/homepage',
|
|
|
+ imageUrl: '/static_file/share_img.png',
|
|
|
+ promise
|
|
|
+ }
|
|
|
+ },
|
|
|
data: {
|
|
|
images: {
|
|
|
logo: '/static_file/logo.png',
|
|
@@ -18,9 +35,9 @@ Page({
|
|
|
address: ""
|
|
|
},
|
|
|
//企业地址信息
|
|
|
- enterPriseAddress:"",
|
|
|
+ enterPriseAddress: "",
|
|
|
//企业用户须知
|
|
|
- userNotices:"",
|
|
|
+ userNotices: "",
|
|
|
// 账单信息
|
|
|
billInfo: {
|
|
|
totalAmount: "", // 总计应缴
|
|
@@ -29,40 +46,40 @@ Page({
|
|
|
},
|
|
|
// 功能按钮配置
|
|
|
functionList: [{
|
|
|
- icon: '/static_file/zdlb.png',
|
|
|
- text: '账单列表',
|
|
|
- url: '/pages/zhangdanlist/zhangdanlist'
|
|
|
- },
|
|
|
- {
|
|
|
- icon: '/static_file/jfjl.png',
|
|
|
- text: '缴费记录',
|
|
|
- url: '/pages/jiaofeiList/jiaofeiList'
|
|
|
- },
|
|
|
- // {
|
|
|
- // icon: '/static_file/yhbx.png',
|
|
|
- // text: '用户报修',
|
|
|
- // url: '/pages/baoxiudj/baoxiudj'
|
|
|
- // },
|
|
|
- {
|
|
|
- icon: '/static_file/tzgg.png',
|
|
|
- text: '消息通知',
|
|
|
- url: '/pages/tongzhiList/tongzhiList'
|
|
|
- },
|
|
|
- {
|
|
|
- icon: '/static_file/ckys.png',
|
|
|
- text: '户号绑定',
|
|
|
- url: '/pages/huhaoguanli/huhaoguanli'
|
|
|
- },
|
|
|
- // {
|
|
|
- // icon: '/static_file/yjfk.png',
|
|
|
- // text: '投诉建议',
|
|
|
- // url: '/pages/tousujianyi/tousujianyi'
|
|
|
- // },
|
|
|
- {
|
|
|
- icon: '/static_file/yjfk.png',
|
|
|
- text: '用户须知',
|
|
|
- url: '/pages/usernotice/usernotice'
|
|
|
- }
|
|
|
+ icon: '/static_file/zdlb.png',
|
|
|
+ text: '账单列表',
|
|
|
+ url: '/pages/zhangdanlist/zhangdanlist'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ icon: '/static_file/jfjl.png',
|
|
|
+ text: '缴费记录',
|
|
|
+ url: '/pages/jiaofeiList/jiaofeiList'
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // icon: '/static_file/yhbx.png',
|
|
|
+ // text: '用户报修',
|
|
|
+ // url: '/pages/baoxiudj/baoxiudj'
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ icon: '/static_file/tzgg.png',
|
|
|
+ text: '消息通知',
|
|
|
+ url: '/pages/tongzhiList/tongzhiList'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ icon: '/static_file/ckys.png',
|
|
|
+ text: '户号绑定',
|
|
|
+ url: '/pages/huhaoguanli/huhaoguanli'
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // icon: '/static_file/yjfk.png',
|
|
|
+ // text: '投诉建议',
|
|
|
+ // url: '/pages/tousujianyi/tousujianyi'
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ icon: '/static_file/yjfk.png',
|
|
|
+ text: '用户须知',
|
|
|
+ url: '/pages/usernotice/usernotice'
|
|
|
+ }
|
|
|
],
|
|
|
currentIndex: 0,
|
|
|
noticeList: [],
|
|
@@ -86,7 +103,7 @@ Page({
|
|
|
this.loadPageData();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 检查是否所有户号已解绑
|
|
|
const allAccountsUnbound = wx.getStorageSync('allAccountsUnbound');
|
|
|
if (allAccountsUnbound) {
|
|
@@ -100,9 +117,9 @@ Page({
|
|
|
}
|
|
|
|
|
|
// 检查全局用户信息是否存在
|
|
|
- if (!app.globalData.currentAccountInfo ||
|
|
|
- !app.globalData.currentAccountInfo.usernumber ||
|
|
|
- app.globalData.userWxInfo.currentDsKey === "") {
|
|
|
+ if (!app.globalData.currentAccountInfo ||
|
|
|
+ !app.globalData.currentAccountInfo.usernumber ||
|
|
|
+ app.globalData.userWxInfo.currentDsKey === "") {
|
|
|
wx.redirectTo({
|
|
|
url: '/pages/FirstBangDing/FirstBangDing',
|
|
|
});
|
|
@@ -122,7 +139,7 @@ Page({
|
|
|
wx.request({
|
|
|
url: app.globalData.interfaceUrls.homePageInfo + app.globalData.currentAccountInfo.usernumber,
|
|
|
method: 'GET',
|
|
|
- header: {
|
|
|
+ header: {
|
|
|
'content-type': 'application/json', // 默认值
|
|
|
'token': app.globalData.userWxInfo.token,
|
|
|
'source': "wc",
|
|
@@ -131,7 +148,7 @@ Page({
|
|
|
success(res) {
|
|
|
wx.hideLoading();
|
|
|
let apiReturnData = res.data;
|
|
|
-
|
|
|
+
|
|
|
// 处理轮播通知数据
|
|
|
if (apiReturnData.data && apiReturnData.data.swNotificationAnnouncementDos) {
|
|
|
// 处理日期格式
|
|
@@ -140,30 +157,30 @@ Page({
|
|
|
data.publishtime = data.publishtime.slice(0, 10);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 所有的通知公告
|
|
|
app.globalData.notices = apiReturnData.data.swNotificationAnnouncementDos;
|
|
|
-
|
|
|
+
|
|
|
// 需要轮播的公告
|
|
|
let noticeData = apiReturnData.data.swNotificationAnnouncementDos.filter(data => {
|
|
|
return data.homepageslider == '1';
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 更新轮播通知数据
|
|
|
_this.setData({
|
|
|
noticeList: noticeData,
|
|
|
isScrolling: noticeData && noticeData.length > 0
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 如果有轮播数据,立即开始轮播
|
|
|
if (noticeData && noticeData.length > 0) {
|
|
|
_this.startNoticeScroll();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 该用户所有的消息通知
|
|
|
app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
|
|
|
-
|
|
|
+
|
|
|
// 计算未读消息数
|
|
|
if (app.globalData.userNoticesList) {
|
|
|
const unreadCount = app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length;
|
|
@@ -183,8 +200,8 @@ Page({
|
|
|
accountNumber: apiReturnData.data.usernumber,
|
|
|
address: apiReturnData.data.address
|
|
|
},
|
|
|
- enterPriseAddress:apiReturnData.data.enterPriseAddress,
|
|
|
- userNotices:apiReturnData.data.userNotice
|
|
|
+ enterPriseAddress: apiReturnData.data.enterPriseAddress,
|
|
|
+ userNotices: apiReturnData.data.userNotice
|
|
|
});
|
|
|
},
|
|
|
fail(error) {
|
|
@@ -206,17 +223,17 @@ Page({
|
|
|
this.loadPageData();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 首先检查全局用户信息是否存在,如果没有则跳转到首次绑定页面
|
|
|
- if (!app.globalData.currentAccountInfo ||
|
|
|
- !app.globalData.currentAccountInfo.usernumber ||
|
|
|
- app.globalData.userWxInfo.currentDsKey === "") {
|
|
|
+ if (!app.globalData.currentAccountInfo ||
|
|
|
+ !app.globalData.currentAccountInfo.usernumber ||
|
|
|
+ app.globalData.userWxInfo.currentDsKey === "") {
|
|
|
wx.redirectTo({
|
|
|
url: '/pages/FirstBangDing/FirstBangDing',
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 检查是否需要刷新
|
|
|
const needRefresh = wx.getStorageSync('needRefreshHomepage');
|
|
|
if (needRefresh) {
|
|
@@ -244,13 +261,13 @@ Page({
|
|
|
});
|
|
|
|
|
|
// 检查token和账户信息是否存在
|
|
|
- if (!app.globalData.userWxInfo.token ||
|
|
|
- !app.globalData.currentAccountInfo ||
|
|
|
- !app.globalData.currentAccountInfo.usernumber ||
|
|
|
- !app.globalData.userWxInfo.currentDsKey) {
|
|
|
+ if (!app.globalData.userWxInfo.token ||
|
|
|
+ !app.globalData.currentAccountInfo ||
|
|
|
+ !app.globalData.currentAccountInfo.usernumber ||
|
|
|
+ !app.globalData.userWxInfo.currentDsKey) {
|
|
|
wx.hideLoading();
|
|
|
console.error('缺少必要的账户信息');
|
|
|
-
|
|
|
+
|
|
|
// 尝试从本地存储恢复账户信息
|
|
|
const storedHuHao = wx.getStorageSync('currentHuHao');
|
|
|
if (storedHuHao && storedHuHao.usernumber) {
|
|
@@ -262,14 +279,14 @@ Page({
|
|
|
}, 100);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 如果无法恢复,则跳转到首次绑定页面
|
|
|
wx.redirectTo({
|
|
|
url: '/pages/FirstBangDing/FirstBangDing',
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
wx.request({
|
|
|
url: app.globalData.interfaceUrls.homePageInfo + app.globalData.currentAccountInfo.usernumber,
|
|
|
method: 'GET',
|
|
@@ -282,7 +299,7 @@ Page({
|
|
|
success(res) {
|
|
|
wx.hideLoading();
|
|
|
let apiReturnData = res.data;
|
|
|
-
|
|
|
+
|
|
|
// 处理轮播通知数据
|
|
|
if (apiReturnData.data && apiReturnData.data.swNotificationAnnouncementDos) {
|
|
|
// 处理日期格式
|
|
@@ -291,43 +308,43 @@ Page({
|
|
|
data.publishtime = data.publishtime.slice(0, 10);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 所有的通知公告
|
|
|
app.globalData.notices = apiReturnData.data.swNotificationAnnouncementDos;
|
|
|
-
|
|
|
+
|
|
|
// 需要轮播的公告
|
|
|
let noticeData = apiReturnData.data.swNotificationAnnouncementDos.filter(data => {
|
|
|
return data.homepageslider == '1';
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 更新轮播通知数据
|
|
|
_this.setData({
|
|
|
noticeList: noticeData,
|
|
|
isScrolling: noticeData && noticeData.length > 0
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 如果有轮播数据,立即开始轮播
|
|
|
if (noticeData && noticeData.length > 0) {
|
|
|
_this.startNoticeScroll();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 该用户所有的消息通知
|
|
|
app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
|
|
|
-
|
|
|
+
|
|
|
// 获取用户须知
|
|
|
const userNotices = apiReturnData.data.userNotice || '';
|
|
|
-
|
|
|
+
|
|
|
// 计算未读消息数
|
|
|
- const unreadCount = app.globalData.userNoticesList ?
|
|
|
+ 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: {
|
|
@@ -381,7 +398,7 @@ Page({
|
|
|
...app.globalData.currentAccountInfo,
|
|
|
userNotices: this.data.userNotices
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
// 确保用户须知不为空
|
|
|
if (!this.data.userNotices) {
|
|
|
// 如果为空,尝试重新获取数据
|
|
@@ -470,28 +487,28 @@ Page({
|
|
|
console.log('无轮播通知数据');
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 过滤需要轮播的公告
|
|
|
let data = this.data.noticeList.filter(data => {
|
|
|
return data.homepageslider == '1';
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 如果没有需要轮播的公告,直接返回
|
|
|
if (!data || data.length === 0) {
|
|
|
console.log('没有需要轮播的公告');
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 确保currentIndex在有效范围内
|
|
|
const safeIndex = this.data.currentIndex < data.length ? this.data.currentIndex : 0;
|
|
|
-
|
|
|
+
|
|
|
// 获取当前公告内容和标题
|
|
|
const content = data[safeIndex].scrollingcontent || '';
|
|
|
const title = data[safeIndex].noticetitle || '';
|
|
|
-
|
|
|
+
|
|
|
// 计算滚动时长,基于内容长度
|
|
|
const duration = Math.max(3, (title.length + content.length) * 0.5);
|
|
|
-
|
|
|
+
|
|
|
// 更新数据
|
|
|
this.setData({
|
|
|
currentIndex: safeIndex,
|
|
@@ -519,7 +536,7 @@ Page({
|
|
|
// 加载账户和账单信息
|
|
|
loadAccountInfo: function () {
|
|
|
const accountInfo = app.globalData.currentAccountInfo || {};
|
|
|
-
|
|
|
+
|
|
|
// 检查账户信息是否为空(解绑后返回的情况)
|
|
|
if (!accountInfo || !accountInfo.usernumber) {
|
|
|
// 检查是否已全部解绑
|
|
@@ -533,17 +550,17 @@ Page({
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 尝试请求账户列表,查看是否有其他账户
|
|
|
this.checkAndFetchAccounts();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 检查是否是首次加载
|
|
|
const isFirstLoad = wx.getStorageSync('isFirstLoad') !== 'false';
|
|
|
// 检查是否在户号管理页面切换过账户
|
|
|
const hasUserSwitchedAccount = wx.getStorageSync('hasUserSwitchedAccount') === true;
|
|
|
-
|
|
|
+
|
|
|
if (isFirstLoad && !hasUserSwitchedAccount) {
|
|
|
// 首次加载且未切换过账户,查找并设置默认账户
|
|
|
this.loadDefaultAccount();
|
|
@@ -568,9 +585,9 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
// 检查并获取账户列表
|
|
|
- checkAndFetchAccounts: function() {
|
|
|
+ checkAndFetchAccounts: function () {
|
|
|
if (!app.globalData.userWxInfo.token) {
|
|
|
// 没有token,直接跳转到首次绑定页面
|
|
|
wx.redirectTo({
|
|
@@ -583,7 +600,7 @@ Page({
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
wx.request({
|
|
|
url: app.globalData.interfaceUrls.accountList,
|
|
|
method: 'GET',
|
|
@@ -597,7 +614,7 @@ Page({
|
|
|
if (res.data && res.data.data && res.data.data.length > 0) {
|
|
|
// 找到了账户,设置默认账户
|
|
|
const defaultAccount = res.data.data.find(account => account.defaultAccount === "0") || res.data.data[0];
|
|
|
-
|
|
|
+
|
|
|
// 更新全局账户信息
|
|
|
app.globalData.currentAccountInfo = defaultAccount;
|
|
|
app.globalData.userWxInfo.currentDsKey = defaultAccount.dsKey;
|
|
@@ -607,7 +624,7 @@ Page({
|
|
|
app.globalData.userWxInfo.groupName = defaultAccount.groupName;
|
|
|
// 保存到本地存储
|
|
|
wx.setStorageSync('currentHuHao', defaultAccount);
|
|
|
-
|
|
|
+
|
|
|
// 更新页面数据并加载详细信息
|
|
|
_this.setData({
|
|
|
currentAccountInfo: defaultAccount
|
|
@@ -667,7 +684,7 @@ Page({
|
|
|
_this.setData({
|
|
|
currentAccountInfo: app.globalData.currentAccountInfo || {}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 确保加载页面数据,获取userNotices
|
|
|
_this.loadPageData();
|
|
|
}
|
|
@@ -734,7 +751,7 @@ Page({
|
|
|
enterPriseAddress: res.data.data.enterPriseAddress,
|
|
|
userNotices: res.data.data.userNotice
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 更新全局数据中的用户须知
|
|
|
app.globalData.currentAccountInfo = {
|
|
|
...app.globalData.currentAccountInfo,
|
|
@@ -792,15 +809,15 @@ Page({
|
|
|
|
|
|
// 获取用户须知
|
|
|
const userNotices = apiReturnData.data.userNotice || '';
|
|
|
-
|
|
|
+
|
|
|
// 更新全局数据中的用户须知
|
|
|
app.globalData.currentAccountInfo = {
|
|
|
...app.globalData.currentAccountInfo,
|
|
|
userNotices: userNotices
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
// 更新未读消息数
|
|
|
- const unreadCount = app.globalData.userNoticesList ?
|
|
|
+ const unreadCount = app.globalData.userNoticesList ?
|
|
|
app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length : 0;
|
|
|
|
|
|
// 更新页面数据
|
|
@@ -843,7 +860,7 @@ Page({
|
|
|
showAddressPopup(e) {
|
|
|
const address = e.currentTarget.dataset.address;
|
|
|
if (!address) return;
|
|
|
-
|
|
|
+
|
|
|
wx.showModal({
|
|
|
title: '地址信息',
|
|
|
content: address,
|