myRecord.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // pages/myRecord/myRecord.js
  2. import { chargeList, getExaminationOrderList } 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. onShow() {
  18. this.setData({
  19. navItemActive: 0
  20. })
  21. this.getChargeList()
  22. },
  23. // 获取充值记录
  24. getChargeList () {
  25. var data = {
  26. currentPage: this.data.currentPage
  27. }
  28. wx.showLoading({
  29. title: '加载中...',
  30. mask: true
  31. })
  32. chargeList(data).then(res => {
  33. wx.hideLoading()
  34. this.setData({
  35. hasNext: res.data.hasNext,
  36. chargeRecordList: res.data.vos
  37. })
  38. }).catch(e => {
  39. wx.hideLoading()
  40. wx.showModal({
  41. content: e,
  42. confirmColor: '#333',
  43. showCancel: false
  44. })
  45. })
  46. },
  47. // 获取核销记录
  48. getExaminationOrderListFn () {
  49. var data = {
  50. currentPage: this.data.currentPage
  51. }
  52. wx.showLoading({
  53. title: '加载中...',
  54. mask: true
  55. })
  56. getExaminationOrderList(data).then(res => {
  57. wx.hideLoading()
  58. this.setData({
  59. hasNext: res.data.hasNext,
  60. destoryRecordList: res.data.vos
  61. })
  62. }).catch(e => {
  63. wx.hideLoading()
  64. wx.showModal({
  65. content: e,
  66. confirmColor: '#333',
  67. showCancel: false
  68. })
  69. })
  70. },
  71. onReachBottom () {
  72. if (this.data.hasNext) {
  73. var _currentPag = this.data.currentPage + 1
  74. this.setData({
  75. currentPage: _currentPag
  76. })
  77. if (this.data.navItemActive == 0) {
  78. this.getChargeList()
  79. } else {
  80. this.getExaminationOrderListFn()
  81. }
  82. }
  83. },
  84. /**
  85. * 切换nav
  86. */
  87. handleChangeNav(e) {
  88. var navItemActive = e.currentTarget.dataset.index
  89. this.setData({
  90. navItemActive: navItemActive,
  91. currentPage: 1,
  92. hasNext: false
  93. })
  94. if (navItemActive == 0) {
  95. this.getChargeList()
  96. } else {
  97. this.getExaminationOrderListFn()
  98. }
  99. }
  100. })