headlist.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. var app = getApp();
  2. var util = require('../../utils/util.js');
  3. var status = require('../../utils/index.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. list: [],
  10. noData: 0,
  11. tip: '加载中',
  12. isHideLoadMore: true,
  13. level: '',
  14. groupInfo: {
  15. owner_name: '团长'
  16. }
  17. },
  18. page: 1,
  19. hasMore: true,
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. let level = options.level || '';
  25. this.setData({ level });
  26. let that = this;
  27. status.setGroupInfo().then((groupInfo) => {
  28. let owner_name = groupInfo && groupInfo.owner_name || '团长';
  29. wx.setNavigationBarTitle({
  30. title: `${owner_name}列表`,
  31. })
  32. that.setData({ groupInfo })
  33. });
  34. if (!util.check_login()) {
  35. wx.redirectTo({
  36. url: '/lionfish_comshop/pages/user/me',
  37. })
  38. }
  39. wx.showLoading();
  40. this.getList();
  41. },
  42. /**
  43. * 生命周期函数--监听页面显示
  44. */
  45. onShow: function () {
  46. },
  47. getList() {
  48. var token = wx.getStorageSync('token');
  49. var that = this;
  50. if (!that.hasMore) { return; }
  51. this.setData({ isHideLoadMore: false })
  52. app.util.request({
  53. 'url': 'entry/wxapp/user',
  54. 'data': {
  55. controller: 'community.get_head_child_headlist',
  56. token: token,
  57. page: that.page,
  58. level: that.data.level
  59. },
  60. dataType: 'json',
  61. success: function (res) {
  62. wx.hideLoading();
  63. if (res.data.code == 0) {
  64. let oldList = that.data.list;
  65. let list = oldList.concat(res.data.data);
  66. that.setData({ list, isHideLoadMore: true })
  67. } else {
  68. if (that.data.list.length == 0 && that.page == 1) that.setData({ noData: 1 })
  69. that.hasMore = false;
  70. }
  71. }
  72. })
  73. },
  74. /**
  75. * 页面相关事件处理函数--监听用户下拉动作
  76. */
  77. onPullDownRefresh: function () {
  78. },
  79. /**
  80. * 页面上拉触底事件的处理函数
  81. */
  82. onReachBottom: function () {
  83. this.page++;
  84. this.getList();
  85. }
  86. })