listMixin.js 1.2 KB

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