index.js 1.7 KB

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