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