listMixin.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. export default {
  2. data() {
  3. return {
  4. pagination: {
  5. total: "",
  6. currentPage: 1,
  7. pageSize: 30,
  8. },
  9. projectFilter: {},
  10. loadMoreText: "加载中...",
  11. };
  12. },
  13. methods: {
  14. initData() {
  15. var pagination = this.pagination;
  16. return this.getProject({
  17. ...this.projectFilter,
  18. pageSize: pagination.pageSize,
  19. currentPage: pagination.currentPage,
  20. }).then((res) => {
  21. // console.log(res)
  22. pagination.total = res.pagination.total;
  23. pagination.currentPage = res.pagination.current;
  24. if (pagination.currentPage * pagination.pageSize >= pagination.total) {
  25. this.loadMoreText = "全部加载完毕";
  26. }
  27. });
  28. },
  29. },
  30. onReachBottom() {
  31. // console.log("onReachBottom");
  32. if (this.projectList.length >= this.pagination.total) {
  33. this.loadMoreText = "没有更多数据了";
  34. return;
  35. }
  36. this.pagination.currentPage++;
  37. this.initData();
  38. },
  39. onPullDownRefresh() {
  40. this.pagination.currentPage = 1;
  41. this.initData().then(() => {
  42. uni.stopPullDownRefresh();
  43. });
  44. },
  45. };