listMixin.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. if(pagination.total == 0) {
  27. this.loadMoreText = '暂无数据'
  28. }
  29. });
  30. },
  31. },
  32. onReachBottom() {
  33. // console.log("onReachBottom");
  34. if (this.projectList.length >= this.pagination.total) {
  35. this.loadMoreText = "没有更多数据了";
  36. return;
  37. }
  38. this.pagination.currentPage++;
  39. this.initData();
  40. },
  41. onPullDownRefresh() {
  42. this.pagination.currentPage = 1;
  43. this.initData().then(() => {
  44. uni.stopPullDownRefresh();
  45. });
  46. },
  47. };