payment-records.js 2.0 KB

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