Incomelog.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // pages/Incomelog/Incomelog.js
  2. import api from '../../utils/api.js'
  3. import util from '../../utils/util.js'
  4. const app = getApp()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. IncomeParams: {},
  11. IncomeLog: [],
  12. IncomeLogCount: 99,
  13. mpType: app.globalData.mpType
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function(opt) {
  19. this.setData({
  20. IncomeParams: {
  21. page: 1,
  22. offset: 10,
  23. tmem_id: opt.memid
  24. }
  25. })
  26. this.getIncomeLog()
  27. },
  28. getIncomeLog: function() {
  29. api.getMemIncomeList(this.data.IncomeParams).then(res => {
  30. res.data.list.forEach((item, ids) => {
  31. item.amount = (item.amount || 0).toFixed(2)
  32. item.create_time = util.formatTime(item.create_time, 'yyyy/MM/dd')
  33. })
  34. this.setData({
  35. IncomeLog: this.data.IncomeLog.concat(res.data.list),
  36. IncomeLogCount: res.data.count
  37. })
  38. })
  39. },
  40. /**
  41. * 生命周期函数--监听页面初次渲染完成
  42. */
  43. onReady: function () {
  44. },
  45. /**
  46. * 生命周期函数--监听页面显示
  47. */
  48. onShow: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面隐藏
  52. */
  53. onHide: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面卸载
  57. */
  58. onUnload: function () {
  59. },
  60. /**
  61. * 页面相关事件处理函数--监听用户下拉动作
  62. */
  63. onPullDownRefresh: function () {
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom: function() {
  69. if (this.data.IncomeLogCount <= this.data.IncomeLog.length) {
  70. return false
  71. }
  72. this.data.IncomeParams.page = ++this.data.IncomeParams.page
  73. this.setData({
  74. IncomeParams: this.data.IncomeParams
  75. })
  76. this.getIncomeLog()
  77. }
  78. })