myRecord.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. chargeList(data).then(res => {
  39. this.setData({
  40. hasNext: res.data.hasNext,
  41. chargeRecordList: res.data.vos
  42. })
  43. })
  44. },
  45. onReachBottom () {
  46. if (this.data.hasNext) {
  47. var _currentPag = this.data.currentPage + 1
  48. this.setData({
  49. currentPage: _currentPag
  50. })
  51. if (this.data.navItemActive == 0) {
  52. this.getChargeList()
  53. }
  54. }
  55. },
  56. /**
  57. * 切换nav
  58. */
  59. handleChangeNav(e) {
  60. var navItemActive = e.currentTarget.dataset.index
  61. this.setData({
  62. navItemActive: navItemActive,
  63. currentPage: 1
  64. })
  65. if (navItemActive == 0) {
  66. this.getChargeList()
  67. }
  68. },
  69. /**
  70. * 生命周期函数--监听页面卸载
  71. */
  72. onUnload() {
  73. },
  74. /**
  75. * 页面相关事件处理函数--监听用户下拉动作
  76. */
  77. onPullDownRefresh() {
  78. },
  79. /**
  80. * 页面上拉触底事件的处理函数
  81. */
  82. onReachBottom() {
  83. },
  84. /**
  85. * 用户点击右上角分享
  86. */
  87. onShareAppMessage() {
  88. }
  89. })