index.js 2.7 KB

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