index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // pages/promoter-list/index.js
  2. import { spreadPeople } 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. total:0,
  17. totalLevel:0,
  18. teamCount: 0,
  19. page: 1,
  20. limit: 20,
  21. keyword:'',
  22. sort:'',
  23. grade:0,
  24. status: false,
  25. recordList:[],
  26. },
  27. onLoadFun:function(e){
  28. this.userSpreadNewList();
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. },
  35. /**
  36. * 生命周期函数--监听页面初次渲染完成
  37. */
  38. onReady: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow: function () {
  44. if(this.data.is_show) this.userSpreadNewList();
  45. },
  46. setSort: function (e) {
  47. var that = this;
  48. that.setData({
  49. sort: e.currentTarget.dataset.sort,
  50. page: 1,
  51. limit: 20,
  52. status: false,
  53. recordList: [],
  54. });
  55. that.userSpreadNewList();
  56. },
  57. setKeyword: function (e) {
  58. this.setData({ keyword: e.detail.value });
  59. },
  60. setRecordList: function () {
  61. this.setData({
  62. page: 1,
  63. limit: 20,
  64. status: false,
  65. recordList: [],
  66. });
  67. this.userSpreadNewList();
  68. },
  69. setType:function(e){
  70. if (this.data.grade != e.currentTarget.dataset.grade) {
  71. this.setData({
  72. grade: e.currentTarget.dataset.grade,
  73. page: 1,
  74. limit: 20,
  75. keyword: '',
  76. sort: '',
  77. status: false,
  78. recordList: [],
  79. });
  80. this.userSpreadNewList();
  81. }
  82. },
  83. userSpreadNewList: function () {
  84. var that = this;
  85. var page = that.data.page;
  86. var limit = that.data.limit;
  87. var status = that.data.status;
  88. var keyword = that.data.keyword;
  89. var sort = that.data.sort;
  90. var grade = that.data.grade;
  91. var recordList = that.data.recordList;
  92. var recordListNew = [];
  93. if (status == true) return;
  94. spreadPeople({
  95. page: page,
  96. limit: limit,
  97. keyword: keyword,
  98. grade: grade,
  99. sort: sort,
  100. }).then(res=>{
  101. var len = res.data.list.length;
  102. var recordListData = res.data.list;
  103. recordListNew = recordList.concat(recordListData);
  104. that.setData({
  105. total: res.data.total,
  106. totalLevel: res.data.totalLevel,
  107. teamCount: Number(res.data.total) + Number(res.data.totalLevel),
  108. status: limit > len,
  109. page: page + 1,
  110. recordList: recordListNew
  111. });
  112. });
  113. },
  114. /**
  115. * 生命周期函数--监听页面隐藏
  116. */
  117. onHide: function () {
  118. this.setData({is_show:true});
  119. },
  120. /**
  121. * 生命周期函数--监听页面卸载
  122. */
  123. onUnload: function () {
  124. },
  125. /**
  126. * 页面相关事件处理函数--监听用户下拉动作
  127. */
  128. onPullDownRefresh: function () {
  129. },
  130. /**
  131. * 页面上拉触底事件的处理函数
  132. */
  133. onReachBottom: function () {
  134. this.userSpreadNewList();
  135. }
  136. })