index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import {
  2. getStatisticsInfo,
  3. getStatisticsMonth
  4. } from "../../../api/admin";
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. parameter: {
  12. 'navbar': '1',
  13. 'return': '1',
  14. 'title': '订单统计',
  15. 'color': false
  16. },
  17. loading: false, //是否加载中
  18. loadend: false, //是否加载完毕
  19. loadTitle: '加载更多', //提示语
  20. census: {},
  21. list: [],
  22. page: 1,
  23. limit: 15,
  24. dataList: [],
  25. isClose: false
  26. },
  27. /**
  28. * 登录回调
  29. */
  30. onLoadFun: function () {
  31. this.getIndex();
  32. this.getList();
  33. },
  34. /**
  35. * 获取订单数据
  36. */
  37. getIndex: function () {
  38. if (this.data.loadend) return;
  39. if (this.data.loading) return;
  40. getStatisticsInfo().then(res => {
  41. this.setData({
  42. census: res.data
  43. });
  44. }).catch(err => {
  45. return app.Tips({
  46. title: err
  47. });
  48. });
  49. },
  50. /**
  51. * 获取详细数据
  52. */
  53. getList: function () {
  54. if (this.data.loadend) return;
  55. if (this.data.loading) return;
  56. this.setData({
  57. loading: true,
  58. loadTitle: ""
  59. });
  60. getStatisticsMonth({
  61. page: this.data.page,
  62. limit: this.data.limit
  63. }).then(res => {
  64. let list = res.data || [];
  65. let loadend = list.length < this.data.limit;
  66. this.data.dataList = app.SplitArray(list, this.data.dataList);
  67. this.setData({
  68. dataList: this.data.dataList,
  69. loadend: loadend,
  70. loading: false,
  71. loadTitle: loadend ? "我也是有底线的" : '加载更多',
  72. page: this.data.page + 1,
  73. });
  74. }).catch(err => {
  75. this.setData({
  76. loading: false,
  77. loadTitle: "加载更多"
  78. });
  79. })
  80. },
  81. /**
  82. * 生命周期函数--监听页面隐藏
  83. */
  84. onHide: function () {
  85. this.setData({
  86. isClose: true
  87. });
  88. },
  89. /**
  90. * 生命周期函数--监听页面显示
  91. */
  92. onShow: function () {
  93. if (app.globalData.isLog && this.data.isClose) {
  94. this.setData({
  95. loadend: false,
  96. page: 1,
  97. dataList: []
  98. });
  99. this.getList();
  100. }
  101. },
  102. /**
  103. * 页面上拉触底事件的处理函数
  104. */
  105. onReachBottom: function () {
  106. this.getList();
  107. },
  108. })