gruopInfo.js 2.7 KB

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