homepage.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. _this.setData({
  92. billInfo:{
  93. totalAmount:apiReturnData.data.duFees, // 总计应缴
  94. waterUsage:apiReturnData.data.waterConsumption, // 用水量
  95. balance: apiReturnData.data.accountbalance // 账户余额
  96. },
  97. userInfo:{
  98. name: apiReturnData.data.username,
  99. accountNumber: apiReturnData.data.usernumber,
  100. address: apiReturnData.data.address
  101. },
  102. })
  103. },
  104. fail(error) {
  105. wx.hideLoading()
  106. utils.simleInfo('登录失败,请稍后再试')
  107. }
  108. })
  109. }
  110. },
  111. onShow() {
  112. },
  113. // 切换水表
  114. handleSwitchMeter() {
  115. wx.navigateTo({
  116. // url: '/pages/meterList/meterList'
  117. })
  118. },
  119. // 充值缴费
  120. handlePayment() {
  121. wx.navigateTo({
  122. // url: '/pages/payment/payment'
  123. })
  124. },
  125. // 功能按钮点击事件
  126. handleFunctionClick(e) {
  127. const index = e.currentTarget.dataset.index
  128. const item = this.data.functionList[index]
  129. if (item && item.url) {
  130. wx.navigateTo({
  131. url: item.url,
  132. fail: function(err) {
  133. console.error('页面跳转失败:', err)
  134. wx.showToast({
  135. title: '功能开发中',
  136. icon: 'none',
  137. duration: 2000
  138. })
  139. }
  140. })
  141. } else {
  142. wx.showToast({
  143. title: '功能开发中',
  144. icon: 'none',
  145. duration: 2000
  146. })
  147. }
  148. },
  149. // 查看账单列表
  150. handleViewBill() {
  151. wx.navigateTo({
  152. // url: '/pages/billList/billList'
  153. })
  154. },
  155. // 查看更多活动
  156. handleMoreActivity() {
  157. wx.navigateTo({
  158. // url: '/pages/activityList/activityList'
  159. })
  160. },
  161. // 跳转到立即缴费页面
  162. goToPayment: function() {
  163. wx.navigateTo({
  164. url: '/pages/lijijiaofei/lijijiaofei',
  165. })
  166. },
  167. // 跳转到通知公告列表页面
  168. goToNoticeList: function() {
  169. wx.navigateTo({
  170. url: '/pages/tongzhiList/tongzhiList'
  171. })
  172. }
  173. })