listMixin.js 1.1 KB

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