homepage.js 4.1 KB

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