index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // pages/bill-details/index.js
  2. import { getCommissionInfo } from '../../api/user.js'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. parameter: {
  10. navbar: '1',
  11. return: '1',
  12. title: '账单明细',
  13. color: true,
  14. class: '0'
  15. },
  16. loadTitle: '加载更多',
  17. loading: false,
  18. loadend: false,
  19. page: 1,
  20. limit: 10,
  21. type: 0,
  22. userBillList: []
  23. },
  24. /**
  25. * 授权回调
  26. */
  27. onLoadFun: function () {
  28. this.getUserBillList()
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. this.setData({
  35. type: options.type || 0
  36. })
  37. },
  38. /**
  39. * 获取账户明细
  40. */
  41. getUserBillList: function () {
  42. var that = this
  43. if (that.data.loadend) return
  44. if (that.data.loading) return
  45. that.setData({
  46. loading: true,
  47. loadTitle: ''
  48. })
  49. var data = {
  50. page: that.data.page,
  51. limit: that.data.limit
  52. }
  53. getCommissionInfo(data, that.data.type).then(
  54. function (res) {
  55. var list = res.data,
  56. loadend = list.length < that.data.limit
  57. that.data.userBillList = app.SplitArray(list, that.data.userBillList)
  58. that.setData({
  59. userBillList: that.data.userBillList,
  60. loadend: loadend,
  61. loading: false,
  62. loadTitle: loadend ? '哼😕~我也是有底线的~' : '加载更多',
  63. page: that.data.page + 1
  64. })
  65. },
  66. function (res) {
  67. that.setData({
  68. loading: false,
  69. loadTitle: '加载更多'
  70. })
  71. }
  72. )
  73. },
  74. /**
  75. * 切换导航
  76. */
  77. changeType: function (e) {
  78. this.setData({
  79. type: e.currentTarget.dataset.type,
  80. loadend: false,
  81. page: 1,
  82. userBillList: []
  83. })
  84. this.getUserBillList()
  85. },
  86. /**
  87. * 页面相关事件处理函数--监听用户下拉动作
  88. */
  89. onPullDownRefresh: function () {},
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom: function () {
  94. this.getUserBillList()
  95. }
  96. })