pullUpRefresh.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { debounce } from "lodash";
  2. export default {
  3. data() {
  4. return {
  5. listData: [],
  6. finished: false, // 是否已经到最低
  7. loadStatus: "loadmore",
  8. isThrottled : false,
  9. }
  10. },
  11. methods: {
  12. async handleLoadData(){
  13. this.loadStatus = "loading"
  14. const rows = await this.getList();
  15. this.listData = this.listData.concat(rows);
  16. this.loadStatus = "loadmore"
  17. if(rows.length < this.queryParams.pageSize){
  18. this.finished = true;
  19. }
  20. },
  21. resetData: debounce(function() {
  22. this.queryParams.pageNum = 1;
  23. this.listData = [];
  24. this.finished = false;
  25. this.loadStatus = "loadmore";
  26. this.handleLoadData(); // 实际加载数据
  27. this.getOtherData && this.getOtherData();
  28. }, 100),
  29. // resetData(){
  30. // this.queryParams.pageNum = 1;
  31. // this.listData = [];
  32. // this.finished = false;
  33. // this.loadStatus = "loadmore";
  34. // this.handleLoadData();
  35. // },
  36. handleReachBottom(){
  37. if (this.finished) return;
  38. this.queryParams.pageNum += 1;
  39. this.handleLoadData();
  40. },
  41. },
  42. onReachBottom() {
  43. this.handleReachBottom();
  44. }
  45. }