index.js 2.4 KB

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