index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. */
  25. onLoadFun:function(){
  26. this.getSignMoneList();
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. },
  33. /**
  34. * 获取签到记录列表
  35. */
  36. getSignMoneList:function(){
  37. var that=this;
  38. if(that.data.loading) return;
  39. if(that.data.loadend) return;
  40. that.setData({loading:true,loadtitle:""});
  41. getSignMonthList({ page: that.data.page, limit: that.data.limit }).then(res=>{
  42. var list = res.data;
  43. var loadend = list.length < that.data.limit;
  44. that.data.signList = app.SplitArray(list, that.data.signList);
  45. that.setData({
  46. signList: that.data.signList,
  47. loadend: loadend,
  48. loading: false,
  49. loadtitle: loadend ? "哼😕~我也是底线的~" : "加载更多"
  50. });
  51. }).catch(err=>{
  52. that.setData({ loading: false, loadtitle: '加载更多' });
  53. });
  54. },
  55. /**
  56. * 页面上拉触底事件的处理函数
  57. */
  58. onReachBottom: function () {
  59. this.getSignMoneList();
  60. },
  61. })