tongzhiList.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // 通知列表页面的JS文件
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. noticeList: [
  8. {
  9. id: '1',
  10. title: '缴费通知',
  11. content: '由于您没有缴费,为保证正常用水,请您看到通知后到小程序主页进行充值缴费...',
  12. date: '2025-03-10',
  13. type: 'payment',
  14. source: '智慧水务'
  15. },
  16. {
  17. id: '2',
  18. title: '停水通知',
  19. content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
  20. date: '2025-03-08',
  21. type: 'notice',
  22. source: '智慧水务'
  23. },
  24. {
  25. id: '3',
  26. title: '停水通知',
  27. content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
  28. date: '2025-03-08',
  29. type: 'notice',
  30. source: '智慧水务'
  31. },
  32. {
  33. id: '4',
  34. title: '停水通知',
  35. content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
  36. date: '2025-03-08',
  37. type: 'notice',
  38. source: '智慧水务'
  39. },
  40. {
  41. id: '5',
  42. title: '停水通知',
  43. content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
  44. date: '2025-03-08',
  45. type: 'notice',
  46. source: '智慧水务'
  47. },
  48. {
  49. id: '6',
  50. title: '停水通知',
  51. content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
  52. date: '2025-03-08',
  53. type: 'notice',
  54. icon: '/static_file/water_drop_icon.png',
  55. source: '智慧水务'
  56. },
  57. {
  58. id: '7',
  59. title: '停水通知',
  60. content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
  61. date: '2025-03-08',
  62. type: 'notice',
  63. source: '智慧水务'
  64. },
  65. {
  66. id: '8',
  67. title: '停水通知',
  68. content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
  69. date: '2025-03-08',
  70. type: 'notice',
  71. source: '智慧水务'
  72. }
  73. ]
  74. },
  75. // onLoad: function (options) {
  76. // this.getNoticeList();
  77. // },
  78. // getNoticeList: function() {
  79. // wx.request({
  80. // url: 'API地址/notice/list',
  81. // success: (res) => {
  82. // if (res.data && res.data.code === 200) {
  83. // this.setData({
  84. // noticeList: res.data.data
  85. // });
  86. // }
  87. // },
  88. // fail: () => {
  89. // // 网络请求失败时使用默认数据
  90. // console.log('获取通知列表失败,使用默认数据');
  91. // }
  92. // });
  93. // },
  94. /**
  95. * 跳转到通知详情页
  96. */
  97. goToDetail: function (e) {
  98. const id = e.currentTarget.dataset.id;
  99. const notice = this.data.noticeList.find(item => item.id === id);
  100. if (notice) {
  101. // 将通知数据转换为JSON字符串
  102. const noticeStr = JSON.stringify(notice);
  103. // 跳转到详情页并传递完整数据
  104. wx.navigateTo({
  105. url: '/pages/tzxq/tzxq?noticeData=' + encodeURIComponent(noticeStr)
  106. });
  107. } else {
  108. wx.showToast({
  109. title: '未找到通知详情',
  110. icon: 'none'
  111. });
  112. }
  113. },
  114. /**
  115. * 返回上一页
  116. */
  117. goBack: function() {
  118. wx.navigateBack();
  119. },
  120. })