payment-records.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // pages/payment-records/payment-records.js
  2. import { getHwPaymentDetailsListImpl } from '../../service/impl/hwPaymentDetail.impl'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. list: [], //支付明细列表
  9. pageNo: 1, //页码
  10. isLast: false, //是否为最后一页
  11. },
  12. /**
  13. * 获取支付明细列表
  14. * @pageNo {number} 页码
  15. * @pageSize {number} 页面条数
  16. */
  17. getList(pageNumber?: number) {
  18. let pageNo = pageNumber || this.data.pageNo
  19. getHwPaymentDetailsListImpl({
  20. pageNo,
  21. pageSize: 10
  22. }).then(res => {
  23. if (res.errCode === 0) {
  24. if (pageNo === 1 && res.data.hwPaymentDetailList && res.data.hwPaymentDetailList.length === 0) {
  25. this.setData({
  26. show: true,
  27. isLast: true
  28. })
  29. } else {
  30. pageNo++;
  31. this.setData({
  32. [`list[${pageNo - 2}]`]: res.data.hwPaymentDetailList,
  33. isLast: res.data.isLast,
  34. pageNo
  35. })
  36. }
  37. }
  38. })
  39. },
  40. /**
  41. * 生命周期函数--监听页面加载
  42. */
  43. onLoad: function () {
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function () {
  54. // 获取支付明细列表
  55. this.setData({
  56. list: [],
  57. pageNo: 1,
  58. }, () => {
  59. this.getList()
  60. })
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload: function () {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh: function () {
  76. this.setData({
  77. list: [],
  78. pageNo: 1,
  79. }, () => {
  80. this.getList()
  81. })
  82. },
  83. /**
  84. * 页面上拉触底事件的处理函数
  85. */
  86. onReachBottom: function () {
  87. const isLast = this.data.isLast;
  88. if (isLast) {
  89. // wx.showToast({
  90. // icon: 'none',
  91. // title: '已经是最后一页了',
  92. // })
  93. } else {
  94. this.getList()
  95. }
  96. }
  97. })