homepage.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. debugger;
  68. let refresh= app.globalData.refresh;
  69. if(refresh==1){
  70. wx.showLoading({
  71. title: '加载中...',
  72. });
  73. if(!app.globalData.userWxInfo.token){
  74. wx.hideLoading();
  75. return;
  76. }
  77. const _this = this;
  78. debugger;
  79. wx.request({
  80. url: app.globalData.interfaceUrls.homePageInfo+app.globalData.currentAccountInfo.usernumber,
  81. method: 'GET',
  82. header: {
  83. 'content-type': 'application/json', // 默认值
  84. 'token':app.globalData.userWxInfo.token,
  85. 'source':"wc",
  86. '!SAAS_LOGIN_TOKEN_!':app.globalData.currentAccountInfo.dsKey
  87. },
  88. success (res) {
  89. wx.hideLoading();
  90. let apiReturnData=res.data;
  91. debugger;
  92. _this.setData({
  93. billInfo:{
  94. totalAmount:apiReturnData.data.duFees, // 总计应缴
  95. waterUsage:apiReturnData.data.waterConsumption, // 用水量
  96. balance: apiReturnData.data.accountbalance // 账户余额
  97. },
  98. userInfo:{
  99. name: apiReturnData.data.username,
  100. accountNumber: apiReturnData.data.usernumber,
  101. address: apiReturnData.data.address
  102. },
  103. })
  104. },
  105. fail(error) {
  106. wx.hideLoading()
  107. utils.simleInfo('登录失败,请稍后再试')
  108. }
  109. })
  110. }
  111. },
  112. onShow() {
  113. },
  114. // 切换水表
  115. handleSwitchMeter() {
  116. wx.navigateTo({
  117. // url: '/pages/meterList/meterList'
  118. })
  119. },
  120. // 充值缴费
  121. handlePayment() {
  122. wx.navigateTo({
  123. // url: '/pages/payment/payment'
  124. })
  125. },
  126. // 功能按钮点击事件
  127. handleFunctionClick(e) {
  128. const index = e.currentTarget.dataset.index
  129. const item = this.data.functionList[index]
  130. if (item && item.url) {
  131. wx.navigateTo({
  132. url: item.url,
  133. fail: function(err) {
  134. console.error('页面跳转失败:', err)
  135. wx.showToast({
  136. title: '功能开发中',
  137. icon: 'none',
  138. duration: 2000
  139. })
  140. }
  141. })
  142. } else {
  143. wx.showToast({
  144. title: '功能开发中',
  145. icon: 'none',
  146. duration: 2000
  147. })
  148. }
  149. },
  150. // 查看账单列表
  151. handleViewBill() {
  152. wx.navigateTo({
  153. // url: '/pages/billList/billList'
  154. })
  155. },
  156. // 查看更多活动
  157. handleMoreActivity() {
  158. wx.navigateTo({
  159. // url: '/pages/activityList/activityList'
  160. })
  161. },
  162. // 跳转到立即缴费页面
  163. goToPayment: function() {
  164. wx.navigateTo({
  165. url: '/pages/lijijiaofei/lijijiaofei',
  166. })
  167. },
  168. // 跳转到通知公告列表页面
  169. goToNoticeList: function() {
  170. wx.navigateTo({
  171. url: '/pages/tongzhiList/tongzhiList'
  172. })
  173. }
  174. })