gruopInfo.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. distributeInfo: {},
  10. list: [],
  11. stateName: ["未结算", "已结算", "已取消"],
  12. typeName: { commiss: "订单分佣", tuijian: "推荐下级奖励" },
  13. noData: 0,
  14. tip: '加载中',
  15. isHideLoadMore: true
  16. },
  17. page: 1,
  18. hasMore: true,
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. let that = this;
  24. status.setGroupInfo().then((groupInfo) => {
  25. let owner_name = groupInfo && groupInfo.owner_name || '团长';
  26. wx.setNavigationBarTitle({
  27. title: `${owner_name}分销`,
  28. })
  29. that.setData({ groupInfo })
  30. });
  31. if (!util.check_login()) {
  32. wx.reLaunch({
  33. url: '/lionfish_comshop/pages/user/me',
  34. })
  35. }
  36. wx.showLoading();
  37. this.getList();
  38. },
  39. getData(){
  40. var token = wx.getStorageSync('token');
  41. var that = this;
  42. app.util.request({
  43. 'url': 'entry/wxapp/user',
  44. 'data': {
  45. controller: 'community.get_head_distribute_info',
  46. token: token
  47. },
  48. dataType: 'json',
  49. success: function (res) {
  50. wx.hideLoading();
  51. if (res.data.code == 0) {
  52. that.setData({
  53. distributeInfo: res.data.data
  54. })
  55. } else {
  56. wx.reLaunch({
  57. url: '/lionfish_comshop/pages/user/me',
  58. })
  59. }
  60. }
  61. })
  62. },
  63. getList() {
  64. var token = wx.getStorageSync('token');
  65. var that = this;
  66. if(!that.hasMore) { return; }
  67. this.setData({ isHideLoadMore: false })
  68. app.util.request({
  69. 'url': 'entry/wxapp/user',
  70. 'data': {
  71. controller: 'community.get_head_distribute_order',
  72. token: token,
  73. page: that.page,
  74. type: '',
  75. level: ''
  76. },
  77. dataType: 'json',
  78. success: function (res) {
  79. if (res.data.code == 0) {
  80. let oldList = that.data.list;
  81. let list = oldList.concat(res.data.data);
  82. that.setData({ list, isHideLoadMore: true })
  83. } else {
  84. if (that.data.list.length==0 && that.page==1) that.setData({ noData: 1 })
  85. that.hasMore = false;
  86. }
  87. }
  88. })
  89. },
  90. /**
  91. * 生命周期函数--监听页面显示
  92. */
  93. onShow: function () {
  94. this.getData();
  95. console.log(this.page)
  96. },
  97. /**
  98. * 页面相关事件处理函数--监听用户下拉动作
  99. */
  100. onPullDownRefresh: function () {
  101. },
  102. /**
  103. * 页面上拉触底事件的处理函数
  104. */
  105. onReachBottom: function () {
  106. this.page++;
  107. this.getList();
  108. }
  109. })