zhangdanlist.js 3.1 KB

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