// 通知列表页面的JS文件 Page({ /** * 页面的初始数据 */ data: { noticeList: [ { id: '1', title: '缴费通知', content: '由于您没有缴费,为保证正常用水,请您看到通知后到小程序主页进行充值缴费...', date: '2025-03-10', type: 'payment', source: '智慧水务' }, { id: '2', title: '停水通知', content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...', date: '2025-03-08', type: 'notice', source: '智慧水务' }, { id: '3', title: '停水通知', content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...', date: '2025-03-08', type: 'notice', source: '智慧水务' }, { id: '4', title: '停水通知', content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...', date: '2025-03-08', type: 'notice', source: '智慧水务' }, { id: '5', title: '停水通知', content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...', date: '2025-03-08', type: 'notice', source: '智慧水务' }, { id: '6', title: '停水通知', content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...', date: '2025-03-08', type: 'notice', icon: '/static_file/water_drop_icon.png', source: '智慧水务' }, { id: '7', title: '停水通知', content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...', date: '2025-03-08', type: 'notice', source: '智慧水务' }, { id: '8', title: '停水通知', content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...', date: '2025-03-08', type: 'notice', source: '智慧水务' } ] }, // onLoad: function (options) { // this.getNoticeList(); // }, // getNoticeList: function() { // wx.request({ // url: 'API地址/notice/list', // success: (res) => { // if (res.data && res.data.code === 200) { // this.setData({ // noticeList: res.data.data // }); // } // }, // fail: () => { // // 网络请求失败时使用默认数据 // console.log('获取通知列表失败,使用默认数据'); // } // }); // }, /** * 跳转到通知详情页 */ goToDetail: function (e) { const id = e.currentTarget.dataset.id; const notice = this.data.noticeList.find(item => item.id === id); if (notice) { // 将通知数据转换为JSON字符串 const noticeStr = JSON.stringify(notice); // 跳转到详情页并传递完整数据 wx.navigateTo({ url: '/pages/tzxq/tzxq?noticeData=' + encodeURIComponent(noticeStr) }); } else { wx.showToast({ title: '未找到通知详情', icon: 'none' }); } }, /** * 返回上一页 */ goBack: function() { wx.navigateBack(); }, })