index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // pages/promoter-order/index.js
  2. import { spreadOrder } 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. loading: false,//是否加载中
  17. loadend: false,//是否加载完毕
  18. loadTitle: '加载更多',//提示语
  19. page: 1,
  20. limit: 5,
  21. recordList: [],
  22. recordCount: 0,
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. },
  29. /**
  30. * 生命周期函数--监听页面初次渲染完成
  31. */
  32. onReady: function () {
  33. },
  34. /**
  35. * 生命周期函数--监听页面显示
  36. */
  37. onShow: function () {
  38. this.getRecordOrderList();
  39. },
  40. getRecordOrderList: function () {
  41. var that = this;
  42. if (that.data.loadend) return;
  43. if (that.data.loading) return;
  44. that.setData({ loading: true, loadTitle: "" });
  45. var page = that.data.page;
  46. var limit = that.data.limit;
  47. spreadOrder({ page: page, limit: limit }).then(res=>{
  48. var list = res.data.list || [];
  49. var loadend = list.length < that.data.limit;
  50. var recordList = that.data.recordList;
  51. recordList = recordList.concat(res.data.list);
  52. that.setData({
  53. recordList: recordList,
  54. loadend: loadend,
  55. loading: false,
  56. loadTitle: loadend ? "我也是有底线的" : '加载更多',
  57. page: that.data.page + 1,
  58. recordCount: res.data.count
  59. });
  60. }).catch(function(){
  61. that.setData({ loading: false, loadTitle: "加载更多" });
  62. })
  63. },
  64. /**
  65. * 生命周期函数--监听页面隐藏
  66. */
  67. onHide: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面卸载
  71. */
  72. onUnload: function () {
  73. },
  74. /**
  75. * 页面相关事件处理函数--监听用户下拉动作
  76. */
  77. onPullDownRefresh: function () {
  78. },
  79. /**
  80. * 页面上拉触底事件的处理函数
  81. */
  82. onReachBottom: function () {
  83. this.getRecordOrderList();
  84. },
  85. /**
  86. * 用户点击右上角分享
  87. */
  88. onShareAppMessage: function () {
  89. }
  90. })