index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // pages/commission-details/index.js
  2. import {
  3. spreadCommission,
  4. spreadCount
  5. } from '../../api/user.js';
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. parameter: {
  12. 'navbar': '1',
  13. 'return': '1',
  14. 'title': '盈利记录',
  15. 'color': true,
  16. 'class': '0'
  17. },
  18. name: '',
  19. type: 0,
  20. page: 0,
  21. limit: 8,
  22. recordList: [],
  23. recordType: 0,
  24. recordCount: 0,
  25. status: false,
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. this.setData({
  32. type: options.type
  33. });
  34. },
  35. /**
  36. * 生命周期函数--监听页面初次渲染完成
  37. */
  38. onReady: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow: function () {
  44. var type = this.data.type;
  45. if (type == 1) {
  46. this.setData({
  47. 'parameter.title': '提现记录',
  48. name: '提现总额',
  49. recordType: 4
  50. });
  51. } else if (type == 2) {
  52. this.setData({
  53. 'parameter.title': '盈利记录',
  54. name: '盈利记录',
  55. recordType: 3
  56. });
  57. } else {
  58. wx.showToast({
  59. title: '参数错误',
  60. icon: 'none',
  61. duration: 1000,
  62. mask: true,
  63. success: function (res) {
  64. setTimeout(function () {
  65. wx.navigateBack({
  66. delta: 1,
  67. })
  68. }, 1200)
  69. },
  70. });
  71. }
  72. this.getRecordList();
  73. this.getRecordListCount();
  74. },
  75. /**
  76. * 获取余额使用记录
  77. */
  78. getRecordList: function () {
  79. var page = this.data.page;
  80. var limit = this.data.limit;
  81. var status = this.data.status;
  82. var recordType = this.data.recordType;
  83. var recordList = this.data.recordList;
  84. var recordListNew = [];
  85. if (status == true) {
  86. return;
  87. }
  88. var that = this;
  89. spreadCommission(recordType, {
  90. page: page,
  91. limit: limit
  92. }).then(res => {
  93. var len = res.data.length;
  94. var recordListData = res.data;
  95. recordListNew = recordList.concat(recordListData);
  96. that.setData({
  97. status: limit > len,
  98. page: limit + page,
  99. recordList: recordListNew
  100. });
  101. });
  102. },
  103. getRecordListCount: function () {
  104. var that = this;
  105. spreadCount(that.data.recordType).then(res => {
  106. that.setData({
  107. recordCount: res.data.count
  108. });
  109. });
  110. },
  111. /**
  112. * 生命周期函数--监听页面隐藏
  113. */
  114. onHide: function () {
  115. },
  116. /**
  117. * 生命周期函数--监听页面卸载
  118. */
  119. onUnload: function () {
  120. },
  121. /**
  122. * 页面相关事件处理函数--监听用户下拉动作
  123. */
  124. onPullDownRefresh: function () {
  125. },
  126. /**
  127. * 页面上拉触底事件的处理函数
  128. */
  129. onReachBottom: function () {
  130. this.getRecordList();
  131. },
  132. /**
  133. * 用户点击右上角分享
  134. */
  135. onShareAppMessage: function () {
  136. }
  137. })