payment-details.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // pages/payment-details/payment-details.js
  2. import {
  3. pointsDetail,
  4. getMoneyDetail
  5. } from '../../services/index.js'
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. list: [],
  12. title: {
  13. integral: '积分明细',
  14. wallet: '收支明细'
  15. },
  16. isLast: false,
  17. pageNo: 1
  18. },
  19. /**
  20. * 获取积分明细
  21. *
  22. */
  23. integral(pageNo = this.data.pageNo) {
  24. let params = {
  25. user_id: wx.getStorageSync('user_id'),
  26. user_token: wx.getStorageSync('user_token'),
  27. member_id: wx.getStorageSync('member_id'),
  28. pageNo
  29. }
  30. pointsDetail(params).then(res => {
  31. if (res.errcode === 0) {
  32. if (res.data.pointsList && res.data.pointsList.length) {
  33. pageNo++;
  34. this.setData({
  35. isLast: res.data.isLast,
  36. list: [...this.data.list, ...res.data.pointsList],
  37. pageNo,
  38. })
  39. }
  40. }
  41. })
  42. },
  43. /**
  44. * 获取支付明细
  45. */
  46. wallet(pageNo = this.data.pageNo) {
  47. let params = {
  48. user_id: wx.getStorageSync('user_id'),
  49. user_token: wx.getStorageSync('user_token'),
  50. member_id: wx.getStorageSync('member_id'),
  51. pageNo
  52. }
  53. getMoneyDetail(params).then(res => {
  54. if (res.errcode === 0) {
  55. if (res.data.mpMoneyDetailAPIList && res.data.mpMoneyDetailAPIList.length) {
  56. pageNo++;
  57. this.setData({
  58. isLast: res.data.isLast,
  59. list: [...this.data.list, ...res.data.mpMoneyDetailAPIList],
  60. pageNo,
  61. })
  62. }
  63. }
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面加载
  68. */
  69. onLoad: function(options) {
  70. /*
  71. @integral 积分
  72. @wallet 钱包
  73. */
  74. if (options.type) {
  75. wx.setNavigationBarTitle({
  76. title: this.data.title[options.type],
  77. })
  78. this.setData({
  79. type: options.type
  80. })
  81. // 获取页面列表
  82. this[options.type]();
  83. }
  84. },
  85. /**
  86. * 生命周期函数--监听页面初次渲染完成
  87. */
  88. onReady: function() {
  89. },
  90. /**
  91. * 生命周期函数--监听页面显示
  92. */
  93. onShow: function() {
  94. },
  95. /**
  96. * 生命周期函数--监听页面隐藏
  97. */
  98. onHide: function() {
  99. },
  100. /**
  101. * 生命周期函数--监听页面卸载
  102. */
  103. onUnload: function() {
  104. },
  105. /**
  106. * 页面相关事件处理函数--监听用户下拉动作
  107. */
  108. onPullDownRefresh: function() {
  109. },
  110. /**
  111. * 页面上拉触底事件的处理函数
  112. */
  113. onReachBottom: function() {
  114. const isLast = this.data.isLast;
  115. if (isLast) {
  116. } else {
  117. this[this.data.type]();
  118. }
  119. },
  120. })