myRecord.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // pages/myRecord/myRecord.js
  2. import { chargeList } from "../../api/my";
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. navItemActive: 0,
  9. chargeRecordList: [],
  10. destoryRecordList: [],
  11. currentPage: 1,
  12. hasNext: false
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad(options) {
  18. },
  19. /**
  20. * 生命周期函数--监听页面初次渲染完成
  21. */
  22. onReady() {
  23. },
  24. /**
  25. * 生命周期函数--监听页面显示
  26. */
  27. onShow() {
  28. this.setData({
  29. navItemActive: 0
  30. })
  31. this.getChargeList()
  32. },
  33. // 获取充值记录
  34. getChargeList () {
  35. var data = {
  36. currentPage: this.data.currentPage
  37. }
  38. wx.showLoading({
  39. title: '加载中...',
  40. mask: true
  41. })
  42. chargeList(data).then(res => {
  43. wx.hideLoading()
  44. this.setData({
  45. hasNext: res.data.hasNext,
  46. chargeRecordList: res.data.vos
  47. })
  48. }).catch(e => {
  49. wx.hideLoading()
  50. wx.showModal({
  51. content: e,
  52. confirmColor: '#333',
  53. showCancel: false
  54. })
  55. })
  56. },
  57. onReachBottom () {
  58. if (this.data.hasNext) {
  59. var _currentPag = this.data.currentPage + 1
  60. this.setData({
  61. currentPage: _currentPag
  62. })
  63. if (this.data.navItemActive == 0) {
  64. this.getChargeList()
  65. }
  66. }
  67. },
  68. /**
  69. * 切换nav
  70. */
  71. handleChangeNav(e) {
  72. var navItemActive = e.currentTarget.dataset.index
  73. this.setData({
  74. navItemActive: navItemActive,
  75. currentPage: 1
  76. })
  77. if (navItemActive == 0) {
  78. this.getChargeList()
  79. }
  80. },
  81. /**
  82. * 生命周期函数--监听页面卸载
  83. */
  84. onUnload() {
  85. },
  86. /**
  87. * 页面相关事件处理函数--监听用户下拉动作
  88. */
  89. onPullDownRefresh() {
  90. },
  91. /**
  92. * 页面上拉触底事件的处理函数
  93. */
  94. onReachBottom() {
  95. },
  96. /**
  97. * 用户点击右上角分享
  98. */
  99. onShareAppMessage() {
  100. }
  101. })