goodsDetails.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. var app = getApp();
  2. var util = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. currentTab: 0,
  9. pageSize: 10,
  10. navList: [{
  11. name: "全部",
  12. status: "-1"
  13. }, {
  14. name: "待结算",
  15. status: "0"
  16. }, {
  17. name: "已结算",
  18. status: "1"
  19. }, {
  20. name: "已失效",
  21. status: "2"
  22. }],
  23. list: [],
  24. loadText: "加载中...",
  25. info: {},
  26. noData: 0,
  27. loadMore: true,
  28. stateArr: ["待结算", "已结算", "已失效"]
  29. },
  30. page: 1,
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad: function (options) {
  35. wx.setNavigationBarTitle({
  36. title: '推广收益',
  37. })
  38. this.getInfo();
  39. this.getData();
  40. },
  41. getInfo: function () {
  42. wx.showLoading();
  43. var token = wx.getStorageSync('token');
  44. let that = this;
  45. app.util.request({
  46. url: 'entry/wxapp/user',
  47. data: {
  48. controller: 'distribution.get_commission_info',
  49. token: token
  50. },
  51. dataType: 'json',
  52. success: function (res) {
  53. wx.hideLoading();
  54. if (res.data.code == 0) {
  55. // Todo
  56. that.setData({ info: res.data.data })
  57. } else {
  58. wx.showModal({
  59. title: '提示',
  60. content: res.data.msg,
  61. showCancel: false,
  62. success(res) {
  63. if (res.confirm) {
  64. console.log('用户点击确定')
  65. wx.reLaunch({
  66. url: '/lionfish_comshop/pages/user/me',
  67. })
  68. }
  69. }
  70. })
  71. }
  72. }
  73. })
  74. },
  75. getData: function(){
  76. let that = this;
  77. let token = wx.getStorageSync('token');
  78. let currentTab = this.data.currentTab;
  79. let state = this.data.navList[currentTab].status;
  80. wx.showLoading();
  81. app.util.request({
  82. 'url': 'entry/wxapp/index',
  83. 'data': {
  84. controller: 'distribution.listorder_list',
  85. token: token,
  86. state: state,
  87. page: this.page
  88. },
  89. dataType: 'json',
  90. success: function (res) {
  91. if (res.data.code == 0) {
  92. let h = {};
  93. let list = res.data.data;
  94. if (list.length < 6) h.noMore = true;
  95. let oldList = that.data.list;
  96. list = oldList.concat(list);
  97. that.page++;
  98. that.setData({ list, ...h })
  99. } else {
  100. // 无数据
  101. if (that.page == 1) that.setData({ noData: 1 })
  102. that.setData({ loadMore: false, noMore: false, loadText: "没有更多记录了~" })
  103. }
  104. wx.hideLoading();
  105. }
  106. })
  107. },
  108. getCurrentList: function () {
  109. if (!this.data.loadMore) return false;
  110. this.getData();
  111. this.setData({
  112. isHideLoadMore: false
  113. })
  114. },
  115. onReachBottom: function () {
  116. this.getCurrentList();
  117. },
  118. bindChange: function (t) {
  119. this.page = 1;
  120. this.setData({
  121. // currentTab: 1 * t.detail.current,
  122. currentTab: t,
  123. list: [],
  124. noData: 0,
  125. loadMore: true,
  126. loadText: "加载中..."
  127. }, () => {
  128. console.log('我变啦');
  129. this.getData();
  130. });
  131. },
  132. /**
  133. * 切换导航
  134. */
  135. switchNav: function (e) {
  136. const that = this;
  137. if (this.data.currentTab === 1 * e.target.dataset.current) return false;
  138. let currentTab = 1 * e.target.dataset.current;
  139. this.setData({
  140. currentTab
  141. },()=>{
  142. that.bindChange(currentTab)
  143. });
  144. },
  145. handleTipDialog: function(){
  146. this.setData({
  147. showTipDialog: !this.data.showTipDialog
  148. })
  149. }
  150. })