integral.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // pages/my/integral/integral.js
  2. const App = getApp()
  3. const util = require('../../../utils/util')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. queryParams: {
  10. page: 1,
  11. limit: 10
  12. },
  13. list: [],
  14. page: {
  15. total: null,
  16. currPage: null,
  17. totalPage: null,
  18. },
  19. nodata: util.nodata(),
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad(options) {
  25. console.log(options)
  26. this.setData({
  27. memberId: options.id
  28. })
  29. this.getIntegral(options.id)
  30. },
  31. /**
  32. * 生命周期函数--监听页面初次渲染完成
  33. */
  34. onReady() {
  35. },
  36. /**
  37. * 生命周期函数--监听页面显示
  38. */
  39. onShow() {
  40. },
  41. getIntegral(id) {
  42. if (this.data.queryParams.page > 1) {
  43. if (this.data.page.currPage == this.data.page.totalPage) {
  44. wx.showToast({
  45. icon: 'none',
  46. title: '没有更多哦~',
  47. })
  48. return false
  49. }
  50. }
  51. wx.showLoading({
  52. title: '努力加载中...',
  53. })
  54. App._get('expert/pointsRecordPage', {
  55. ...this.data.queryParams,
  56. memberId: id || this.data.memberId
  57. }, res => {
  58. if (res.code === 0) {
  59. this.setData({
  60. list: [...this.data.list, ...res.page.list],
  61. page: {
  62. total: res.page.totalCount,
  63. currPage: res.page.currPage,
  64. totalPage: res.page.totalPage
  65. }
  66. })
  67. }
  68. }, err => {}, complete => {
  69. setTimeout(() => {
  70. wx.hideLoading()
  71. }, 500)
  72. })
  73. },
  74. /**
  75. * 生命周期函数--监听页面隐藏
  76. */
  77. onHide() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面卸载
  81. */
  82. onUnload() {
  83. },
  84. /**
  85. * 页面相关事件处理函数--监听用户下拉动作
  86. */
  87. onPullDownRefresh() {
  88. this.setData({
  89. queryParams: {
  90. page: 1,
  91. limit: 10
  92. },
  93. list: []
  94. })
  95. this.getIntegral()
  96. setTimeout(() => {
  97. wx.stopPullDownRefresh()
  98. }, 300)
  99. },
  100. /**
  101. * 页面上拉触底事件的处理函数
  102. */
  103. onReachBottom() {
  104. this.setData({
  105. queryParams: {
  106. page: ++this.data.queryParams.page,
  107. limit: 10
  108. }
  109. })
  110. this.getIntegral()
  111. },
  112. /**
  113. * 用户点击右上角分享
  114. */
  115. onShareAppMessage() {
  116. }
  117. })