member.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // pages/member/member.js
  2. const util = require('../../utils/util.js')
  3. const api = require('../../utils/api.js')
  4. const app = getApp()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. tabIndex: 0,
  11. IncomeList: [],
  12. IncomeCount: 99,
  13. IncomeListParams: {
  14. page: 1,
  15. offset: 10
  16. },
  17. IncomeRank: [],
  18. IncomeRankCount: 99,
  19. IncomeRankParams: {
  20. page: 1,
  21. offset: 10
  22. },
  23. mpType: app.globalData.mpType
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. this.getIncomeList()
  30. this.getIncomeRank()
  31. },
  32. getIncomeList: function () {
  33. api.getIncomeList(this.data.IncomeListParams).then(res => {
  34. //
  35. res.data.list.forEach((item, ids) => {
  36. if (this.data.mpType === 'rp') {
  37. item.amount = (item.amount).toFixed(2)
  38. }
  39. item.create_time = util.formatTime(item.create_time, 'yyyy/MM/dd')
  40. })
  41. this.setData({
  42. IncomeList: this.data.IncomeList.concat(res.data.list),
  43. IncomeCount: res.data.count,
  44. IncomeListParams: {
  45. page: ++this.data.IncomeListParams.page,
  46. offset: 10
  47. }
  48. })
  49. })
  50. },
  51. getIncomeRank: function () {
  52. api.memIncomeRank(this.data.IncomeRankParams).then(res => {
  53. if (this.data.mpType === 'rp') {
  54. res.data.list.forEach((item, ids) => {
  55. item.amount = (item.amount || 0).toFixed(2)
  56. })
  57. }
  58. this.setData({
  59. IncomeRank: this.data.IncomeRank.concat(res.data.list),
  60. IncomeRankCount: res.data.count,
  61. IncomeRankParams: {
  62. page: ++this.data.IncomeRankParams.page,
  63. offset: 10
  64. }
  65. })
  66. console.log(this.data.IncomeRank)
  67. })
  68. },
  69. tabChange: function (e) {
  70. this.setData({
  71. tabIndex: e.target.dataset.index
  72. })
  73. },
  74. routeIncome: function (e) {
  75. util.routeTo(`/pages/Incomelog/Incomelog?memid=${e.currentTarget.dataset.memid}`)
  76. },
  77. /**
  78. * 生命周期函数--监听页面初次渲染完成
  79. */
  80. onReady: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面显示
  84. */
  85. onShow: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面隐藏
  89. */
  90. onHide: function () {
  91. },
  92. /**
  93. * 生命周期函数--监听页面卸载
  94. */
  95. onUnload: function () {
  96. },
  97. /**
  98. * 页面相关事件处理函数--监听用户下拉动作
  99. */
  100. onPullDownRefresh: function () {
  101. },
  102. /**
  103. * 页面上拉触底事件的处理函数
  104. */
  105. onReachBottom: function () {
  106. let { tabIndex, IncomeCount, IncomeListParams, IncomeRankCount, IncomeRankParams } = this.data
  107. if (tabIndex) {
  108. if (IncomeRankParams.page * IncomeRankParams.offset < IncomeRankCount + 10) {
  109. this.getIncomeRank()
  110. }
  111. } else {
  112. if (IncomeListParams.page * IncomeListParams.offset < IncomeCount + 10) {
  113. this.getIncomeList()
  114. }
  115. }
  116. }
  117. })