index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // pages/my_fans/index.js
  2. import { spreadPeople } from '../../api/user.js';
  3. import util from '../../utils/util.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. parameter: {
  11. 'navbar': '1',
  12. 'return': '1',
  13. 'title': '我的粉丝',
  14. },
  15. loading: false,//是否加载中
  16. loadend: false,//是否加载完毕
  17. loadTitle: '加载更多',//提示语
  18. orderStatus: 0,//订单状态
  19. orderList:[],//订单数组
  20. page: 1,
  21. limit: 10,
  22. loading: false,//是否加载中
  23. loadend: false,//是否加载完毕
  24. },
  25. onLoadFun: function () {
  26. this.getOrderList();
  27. },
  28. /**
  29. * 事件回调
  30. *
  31. */
  32. onChangeFun:function(e){
  33. let opt = e.detail;
  34. let action = opt.action || null;
  35. let value = opt.value != undefined ? opt.value : null;
  36. (action && this[action]) && this[action](value);
  37. },
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. onLoad: function (options) {
  42. },
  43. /**
  44. * 切换类型
  45. */
  46. statusClick: function (e) {
  47. var status = e.currentTarget.dataset.status;
  48. if (status == this.data.orderStatus) return;
  49. this.setData({ orderStatus: status, loadend: false, page: 1, orderList: [] });
  50. this.getOrderList();
  51. },
  52. /**
  53. * 获取订单列表
  54. */
  55. getOrderList: function () {
  56. var that = this;
  57. if (that.data.loadend) return;
  58. if (that.data.loading) return;
  59. that.setData({ loading: true, loadTitle: "" });
  60. spreadPeople({
  61. type: that.data.orderStatus,
  62. page: that.data.page,
  63. limit: that.data.limit,
  64. }).then(res => {
  65. var list = res.data.list || [];
  66. var loadend = list.length < that.data.limit;
  67. that.data.orderList = app.SplitArray(list, that.data.orderList);
  68. that.setData({
  69. orderList: that.data.orderList,
  70. loadend: loadend,
  71. loading: false,
  72. loadTitle: loadend ? "我也是有底线的" : '加载更多',
  73. page: that.data.page + 1,
  74. });
  75. }).catch(err => {
  76. that.setData({ loading: false, loadTitle: "加载更多" });
  77. })
  78. },
  79. /**
  80. * 生命周期函数--监听页面初次渲染完成
  81. */
  82. onReady: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面显示
  86. */
  87. onShow: function () {
  88. },
  89. /**
  90. * 生命周期函数--监听页面隐藏
  91. */
  92. onHide: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面卸载
  96. */
  97. onUnload: function () {
  98. },
  99. /**
  100. * 页面相关事件处理函数--监听用户下拉动作
  101. */
  102. onPullDownRefresh: function () {
  103. },
  104. /**
  105. * 页面上拉触底事件的处理函数
  106. */
  107. onReachBottom: function () {
  108. },
  109. /**
  110. * 用户点击右上角分享
  111. */
  112. onShareAppMessage: function () {
  113. },
  114. /**
  115. * 页面上拉触底事件的处理函数
  116. */
  117. onReachBottom: function () {
  118. this.getOrderList();
  119. }
  120. })