member.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. var page = 1;
  2. var app = getApp();
  3. var util = require('../../utils/util.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. queryData: {
  10. createTime: null,
  11. communityId: null,
  12. order: [],
  13. page: page,
  14. pageSize: 20
  15. },
  16. searchKey: "",
  17. containerHeight: 0,
  18. showLoadMore: false,
  19. no_order: 0,
  20. page: 1,
  21. hide_tip: true,
  22. order: [],
  23. tip: '正在加载',
  24. levelName: ['', '1级粉丝', '2级粉丝', '3级粉丝']
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. var sysInfo = wx.getSystemInfoSync();
  31. this.setData({
  32. containerHeight: sysInfo.windowHeight - Math.round(sysInfo.windowWidth / 375 * 125)
  33. });
  34. page = 1;
  35. this.data.queryData.communityId = app.globalData.disUserInfo.communityId;
  36. this.data.queryData.createTime = null;
  37. wx.setNavigationBarTitle({
  38. title: '我的粉丝',
  39. })
  40. this.getData();
  41. },
  42. /**
  43. * 生命周期函数--监听页面显示
  44. */
  45. onShow: function () {
  46. var is_show_on = this.data.is_show_on;
  47. if (is_show_on > 0) {
  48. this.setData({
  49. page: 1,
  50. order: []
  51. })
  52. this.getData();
  53. } else {
  54. this.setData({
  55. is_show_on: is_show_on + 1
  56. })
  57. }
  58. },
  59. /**
  60. * 获取数据
  61. */
  62. getData: function () {
  63. wx.showLoading({
  64. title: "加载中...",
  65. mask: true
  66. });
  67. this.setData({
  68. isHideLoadMore: true
  69. })
  70. this.data.no_order = 1
  71. let that = this;
  72. var token = wx.getStorageSync('token');
  73. app.util.request({
  74. 'url': 'entry/wxapp/index',
  75. 'data': {
  76. controller: 'distribution.get_head_child_headlist',
  77. keyword: that.data.searchKey,
  78. token: token,
  79. page: that.data.page
  80. },
  81. dataType: 'json',
  82. success: function (res) {
  83. if (res.data.code == 0) {
  84. let rushList = that.data.order.concat(res.data.data);
  85. that.setData({
  86. order: rushList,
  87. hide_tip: true,
  88. no_order: 0
  89. });
  90. wx.hideLoading();
  91. } else {
  92. that.setData({
  93. isHideLoadMore: true
  94. })
  95. wx.hideLoading();
  96. return false;
  97. }
  98. }
  99. })
  100. },
  101. /**
  102. * 监控输入框
  103. */
  104. bindSearchChange: function (e) {
  105. this.setData({
  106. searchKey: e.detail.value
  107. });
  108. },
  109. /**
  110. * 搜索
  111. */
  112. searchByKey: function () {
  113. page = 1;
  114. this.setData({
  115. order: [],
  116. no_order: 0,
  117. page: 1
  118. });
  119. this.data.queryData.memberNickName = this.data.searchKey;
  120. this.getData();
  121. },
  122. /**
  123. * 取消
  124. */
  125. cancel: function () {
  126. page = 1;
  127. this.setData({
  128. searchKey: "",
  129. order: []
  130. });
  131. this.data.queryData.memberNickName = null;
  132. this.getData();
  133. },
  134. /**
  135. * 获取更多
  136. */
  137. getMore: function () {
  138. if (this.data.no_order == 1) return false;
  139. this.data.page += 1;
  140. this.getData();
  141. this.setData({
  142. isHideLoadMore: false
  143. })
  144. }
  145. })