zhangdanlist.js 3.1 KB

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