fans.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. if (res.data.code == 0) {
  80. let rushList = that.data.order.concat(res.data.data);
  81. that.setData({
  82. order: rushList,
  83. hide_tip: true,
  84. no_order: 0
  85. });
  86. wx.hideLoading();
  87. } else {
  88. that.setData({
  89. isHideLoadMore: true
  90. })
  91. wx.hideLoading();
  92. return false;
  93. }
  94. }
  95. })
  96. },
  97. /**
  98. * 监控输入框
  99. */
  100. bindSearchChange: function (e) {
  101. this.setData({
  102. searchKey: e.detail.value
  103. });
  104. },
  105. /**
  106. * 搜索
  107. */
  108. searchByKey: function () {
  109. page = 1;
  110. this.setData({
  111. order: [],
  112. no_order: 0,
  113. page: 1
  114. });
  115. this.data.queryData.memberNickName = this.data.searchKey;
  116. this.getData();
  117. },
  118. /**
  119. * 取消
  120. */
  121. cancel: function () {
  122. page = 1;
  123. this.setData({
  124. searchKey: "",
  125. order: []
  126. });
  127. this.data.queryData.memberNickName = null;
  128. this.getData();
  129. },
  130. /**
  131. * 获取更多
  132. */
  133. getMore: function () {
  134. if (this.data.no_order == 1) return false;
  135. this.data.page += 1;
  136. this.getData();
  137. this.setData({
  138. isHideLoadMore: false
  139. })
  140. }
  141. })