homepage.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. const app = getApp();
  2. Page({
  3. data: {
  4. images: {
  5. logo:'/static_file/logo.png',
  6. background:'/static_file/background.png',
  7. card:'/static_file/card.png',
  8. tzd:'/static_file/backgrountzdd.png',
  9. phone:'/static_file/phone.png',
  10. yl:'/static_file/background.yl',
  11. jcsfcjtzd:'/static_file/jcsfcjtzd.png',
  12. kapiantubiao:'/static_file/kapiantubiao.png'
  13. },
  14. // 用户信息
  15. userInfo: {
  16. name: "",
  17. accountNumber: "",
  18. address: ""
  19. },
  20. // 账单信息
  21. billInfo: {
  22. totalAmount: 0, // 总计应缴
  23. waterUsage: 0, // 用水量
  24. balance: 0 // 账户余额
  25. },
  26. // 功能按钮配置
  27. functionList: [
  28. {
  29. icon: '/static_file/zdlb.png',
  30. text: '账单列表',
  31. url: '/pages/zhangdanlist/zhangdanlist'
  32. },
  33. {
  34. icon: '/static_file/jfjl.png',
  35. text: '缴费记录',
  36. // url: '/pages/feedback/feedback'
  37. },
  38. {
  39. icon: '/static_file/yhbx.png',
  40. text: '用户报修',
  41. url: '/pages/baoxiudj/baoxiudj'
  42. },
  43. {
  44. icon: '/static_file/tzgg.png',
  45. text: '通知公告',
  46. url: '/pages/tongzhiList/tongzhiList'
  47. },
  48. {
  49. icon: '/static_file/ckys.png',
  50. text: '户号绑定',
  51. url: '/pages/huhaoguanli/huhaoguanli'
  52. },
  53. {
  54. icon: '/static_file/yjfk.png',
  55. text: '投诉建议',
  56. url: '/pages/tousujianyi/tousujianyi'
  57. }
  58. ],
  59. // 活动信息
  60. activity: {
  61. title: '净水器活动',
  62. subtitle: '预留入口',
  63. imageUrl: '/static_file/background.png'
  64. }
  65. },
  66. onLoad() {
  67. let refresh= app.globalData.refresh;
  68. if(refresh==1){
  69. wx.showLoading({
  70. title: '加载中...',
  71. });
  72. if(!app.globalData.userWxInfo.token){
  73. wx.hideLoading();
  74. return;
  75. }
  76. const _this = this;
  77. wx.request({
  78. url: app.globalData.interfaceUrls.homePageInfo+app.globalData.currentAccountInfo.usernumber,
  79. method: 'GET',
  80. header: {
  81. 'content-type': 'application/json', // 默认值
  82. 'token':app.globalData.userWxInfo.token,
  83. 'source':"wc",
  84. '!SAAS_LOGIN_TOKEN_!':app.globalData.currentAccountInfo.dsKey
  85. },
  86. success (res) {
  87. wx.hideLoading();
  88. let apiReturnData=res.data;
  89. _this.setData({
  90. billInfo:{
  91. totalAmount:apiReturnData.data.duFees, // 总计应缴
  92. waterUsage:apiReturnData.data.waterConsumption, // 用水量
  93. balance: apiReturnData.data.accountbalance // 账户余额
  94. },
  95. userInfo:{
  96. name: apiReturnData.data.username,
  97. accountNumber: apiReturnData.data.usernumber,
  98. address: apiReturnData.data.address
  99. },
  100. })
  101. },
  102. fail(error) {
  103. wx.hideLoading()
  104. utils.simleInfo('登录失败,请稍后再试')
  105. }
  106. })
  107. }
  108. },
  109. onShow() {
  110. },
  111. // 切换水表
  112. handleSwitchMeter() {
  113. wx.navigateTo({
  114. url: '/pages/huhaoguanli/huhaoguanli'
  115. })
  116. },
  117. // 充值缴费
  118. handlePayment() {
  119. wx.navigateTo({
  120. // url: '/pages/payment/payment'
  121. })
  122. },
  123. // 功能按钮点击事件
  124. handleFunctionClick(e) {
  125. const index = e.currentTarget.dataset.index
  126. const item = this.data.functionList[index]
  127. if (item && item.url) {
  128. wx.navigateTo({
  129. url: item.url,
  130. fail: function(err) {
  131. console.error('页面跳转失败:', err)
  132. wx.showToast({
  133. title: '功能开发中',
  134. icon: 'none',
  135. duration: 2000
  136. })
  137. }
  138. })
  139. } else {
  140. wx.showToast({
  141. title: '功能开发中',
  142. icon: 'none',
  143. duration: 2000
  144. })
  145. }
  146. },
  147. // 查看账单列表
  148. handleViewBill() {
  149. wx.navigateTo({
  150. // url: '/pages/billList/billList'
  151. })
  152. },
  153. // 查看更多活动
  154. handleMoreActivity() {
  155. wx.navigateTo({
  156. // url: '/pages/activityList/activityList'
  157. })
  158. },
  159. // 跳转到立即缴费页面
  160. goToPayment: function() {
  161. wx.navigateTo({
  162. url: '/pages/lijijiaofei/lijijiaofei',
  163. })
  164. },
  165. // 跳转到通知公告列表页面
  166. goToNoticeList: function() {
  167. wx.navigateTo({
  168. url: '/pages/tongzhiList/tongzhiList'
  169. })
  170. }
  171. })