index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { getStatisticsInfo, getStatisticsMonth } from "../../../api/admin";
  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. census:{},
  18. list: [],
  19. page: 1,
  20. limit: 15,
  21. dataList:[],
  22. isClose:false
  23. },
  24. /**
  25. * 登录回调
  26. *
  27. */
  28. onLoadFun:function(){
  29. this.getIndex();
  30. this.getList();
  31. },
  32. /**
  33. * 获取订单数据
  34. */
  35. getIndex:function(){
  36. if(this.data.loadend) return;
  37. if(this.data.loading) return;
  38. getStatisticsInfo().then(res=>{
  39. this.setData({ census: res.data });
  40. }).catch(err=>{
  41. return app.Tips({title:err});
  42. });
  43. },
  44. /**
  45. * 获取详细数据
  46. */
  47. getList:function(){
  48. if(this.data.loadend) return;
  49. if(this.data.loading) return;
  50. this.setData({ loading: true, loadTitle:""});
  51. getStatisticsMonth({
  52. page: this.data.page,
  53. limit: this.data.limit
  54. }).then(res=>{
  55. let list = res.data || [];
  56. let loadend = list.length < this.data.limit;
  57. this.data.dataList = app.SplitArray(list, this.data.dataList);
  58. this.setData({
  59. dataList: this.data.dataList,
  60. loadend: loadend,
  61. loading: false,
  62. loadTitle: loadend ? "我也是有底线的" : '加载更多',
  63. page: this.data.page + 1,
  64. });
  65. }).catch(err=>{
  66. this.setData({ loading: false, loadTitle: "加载更多" });
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide: function () {
  73. this.setData({ isClose:true});
  74. },
  75. /**
  76. * 生命周期函数--监听页面显示
  77. */
  78. onShow: function () {
  79. if (app.globalData.isLog && this.data.isClose){
  80. this.setData({ loadend: false, page: 1, dataList:[]});
  81. this.getList();
  82. }
  83. },
  84. /**
  85. * 页面上拉触底事件的处理函数
  86. */
  87. onReachBottom: function () {
  88. this.getList();
  89. },
  90. })