index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { getSignMonthList } from '../../api/user.js'
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. parameter: {
  9. navbar: '1',
  10. return: '1',
  11. title: '签到记录',
  12. color: false
  13. },
  14. loading: false,
  15. loadend: false,
  16. loadtitle: '加载更多',
  17. page: 1,
  18. limit: 8,
  19. signList: []
  20. },
  21. /**
  22. * 授权回调
  23. */
  24. onLoadFun: function () {
  25. this.getSignMoneList()
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {},
  31. /**
  32. * 获取签到记录列表
  33. */
  34. getSignMoneList: function () {
  35. var that = this
  36. if (that.data.loading) return
  37. if (that.data.loadend) return
  38. that.setData({
  39. loading: true,
  40. loadtitle: ''
  41. })
  42. getSignMonthList({
  43. page: that.data.page,
  44. limit: that.data.limit
  45. })
  46. .then(res => {
  47. var list = res.data
  48. var loadend = list.length < that.data.limit
  49. that.data.signList = app.SplitArray(list, that.data.signList)
  50. that.setData({
  51. signList: that.data.signList,
  52. loadend: loadend,
  53. loading: false,
  54. loadtitle: loadend ? '哼😕~我也是底线的~' : '加载更多'
  55. })
  56. })
  57. .catch(err => {
  58. that.setData({
  59. loading: false,
  60. loadtitle: '加载更多'
  61. })
  62. })
  63. },
  64. /**
  65. * 页面上拉触底事件的处理函数
  66. */
  67. onReachBottom: function () {
  68. this.getSignMoneList()
  69. }
  70. })