zhangdanlist.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. const app = getApp();
  2. Page({
  3. data: {
  4. images: {
  5. background: '/static_file/background.png',
  6. water: '/static_file/water.png'
  7. },
  8. userInfo: {
  9. name: app.globalData.currentAccountInfo.username,
  10. id: app.globalData.currentAccountInfo.usernumber,
  11. address: app.globalData.currentAccountInfo.address
  12. },
  13. showKeyboard: false,
  14. selectedAmount: null,
  15. customAmount: '',
  16. inputFocus: false,
  17. address: '',
  18. billList: [],
  19. // 是否可以开票
  20. isInvoic:false,
  21. },
  22. onLoad: function(options) {
  23. debugger;
  24. // 确保图片资源正确加载
  25. this.setData({
  26. images: {
  27. background: '/static_file/background.png',
  28. water: '/static_file/water.png'
  29. },
  30. isInvoic: app.globalData.waterCompanys.filter(data=>data.id==app.globalData.currentAccountInfo.dsKey)[0].swCompanyInfo.supportonlineinvoice=="1"
  31. });
  32. // 获取账单列表
  33. this.getBillList();
  34. },
  35. getBillList:function(){
  36. const _this = this;
  37. wx.showLoading({
  38. title: '获取中...',
  39. mask: true,
  40. });
  41. debugger;
  42. wx.request({
  43. url: app.globalData.interfaceUrls.billList,
  44. method: 'POST',
  45. data: {
  46. accountNum: app.globalData.currentAccountInfo.usernumber,
  47. year: new Date().getFullYear()
  48. },
  49. header: {
  50. 'content-type': 'application/json', // 默认值
  51. 'token':app.globalData.userWxInfo.token,
  52. 'source':"wc",
  53. '!SAAS_LOGIN_TOKEN_!':app.globalData.currentAccountInfo.dsKey
  54. },
  55. success (res) {
  56. wx.hideLoading();
  57. let apiReturnData=res.data;
  58. debugger;
  59. _this.setData({
  60. billList:apiReturnData.data,
  61. })
  62. },
  63. fail(error) {
  64. wx.hideLoading()
  65. utils.simleInfo('登录失败,请稍后再试')
  66. }
  67. });
  68. },
  69. // 返回上一页
  70. goBack: function() {
  71. wx.navigateBack();
  72. },
  73. // 点击开发票按钮
  74. openInvoice: function(e) {
  75. const index = e.currentTarget.dataset.index;
  76. const bill = this.data.billList[index];
  77. wx.showToast({
  78. title: '开发票功能开发中',
  79. icon: 'none'
  80. });
  81. },
  82. // 切换到首页
  83. goToHome: function() {
  84. wx.switchTab({
  85. url: '/pages/homepage/homepage',
  86. });
  87. },
  88. // 切换到我的页面
  89. goToMine: function() {
  90. wx.switchTab({
  91. url: '/pages/mine/mine',
  92. });
  93. },
  94. navigateToHome() {
  95. wx.switchTab({
  96. url: '/pages/index/index'
  97. })
  98. },
  99. navigateToMine() {
  100. wx.switchTab({
  101. url: '/pages/mine/mine'
  102. })
  103. },
  104. // 跳转到账单详情页面
  105. goToBillDetail: function(e) {
  106. const bill = e.currentTarget.dataset.bill;
  107. wx.navigateTo({
  108. url: '/pages/zhangdanxiangqing/zdxiangqing?billInfo=' + JSON.stringify(bill)
  109. });
  110. },
  111. // 获取发票
  112. getInvoice: function(e) {
  113. wx.showToast({
  114. title: '暂不支持!',
  115. icon: 'none'
  116. });
  117. return;
  118. // 阻止事件冒泡,避免触发goToBillDetail
  119. e.stopPropagation();
  120. const bill = e.currentTarget.dataset.bill;
  121. wx.navigateTo({
  122. url: '/pages/invoice/invoice?billInfo=' + JSON.stringify(bill)
  123. });
  124. }
  125. })