zhangdanlist.js 2.8 KB

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