export default {
  data() {
    return {
      pagination: {
        total: "",
        currentPage: 1,
        pageSize: 30,
      },
      loadMoreText: "加载中...",
    };
  },
  methods: {
    initData() {
      var pagination = this.pagination;
      return this.getProject({
        ...this.projectFilter,
        pageSize: pagination.pageSize,
        currentPage: pagination.currentPage,
      }).then((res) => {
        // console.log(res)
        pagination.total = res.pagination.total;
        pagination.currentPage = res.pagination.current;
        if (pagination.currentPage * pagination.pageSize >= pagination.total) {
          this.loadMoreText = "全部加载完毕";
        }
      });
    },
  },
  onReachBottom() {
    // console.log("onReachBottom");
    if (this.projectList.length >= this.pagination.total) {
      this.loadMoreText = "没有更多数据了";
      return;
    }
    this.pagination.currentPage++;
    this.initData();
  },
  onPullDownRefresh() {
    this.pagination.currentPage = 1;
    this.initData().then(() => {
      uni.stopPullDownRefresh();
    });
  },
};
