member.js 3.0 KB

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