article.vue 1.92 KB
<template>
  <LayoutApp :show-back="false" :hideHeader="hideHeader" :no-safe-area="true">
    <ClientOnly>
      <waterFallList
        :listData="articleList"
        :listInfo="listInfo"
        :item-w="344" :gutter-w="18"
        :isLoading="isFetchingArticleList"
        @load-more="loadMore"
      >
      </waterFallList>
    </ClientOnly>

  </LayoutApp>
</template>

<script>
import LayoutApp from '../../components/layout/layout-app';
import {createNamespacedHelpers} from 'vuex';
import waterFallList from './components/waterfall';

const {mapActions, mapState} = createNamespacedHelpers('article/articleList');

export default {
  name: 'articleList',
  components: {
    LayoutApp,
    waterFallList
  },
  props: ['hideHeader'],
  data() {
    return {
      listData: [],
    };
  },
  mounted() {

  },
  activated() {

  },
  computed: {
    ...mapState(['articleList', 'articleListInfo', 'isFetchingArticleList']),
    listInfo() { // 列表基础信息
      if (this.articleListInfo) {
        console.log(this.articleListInfo);
        return {
          lastedTime: this.articleListInfo.lastedTime,
          pageNo: this.articleListInfo.pageNo || 1,
          pageSize: this.articleListInfo.pageSize || 20,
          totalCount: this.articleListInfo.totalCount || 0,
          totalPage: this.articleListInfo.totalPage || 1
        };
      }
    }
  },
  asyncData({store}) {
    return store.dispatch('article/articleList/fetchArticleList', {
      page: 1,
      limit: 20
    });
  },
  methods: {
    ...mapActions(['fetchArticleList']),
    loadMore() {
      if (this.articleListInfo.pageNo < this.articleListInfo.totalPage && !this.isFetchingArticleList) {
        console.log('loadMore');
        this.fetchArticleList({
          page: this.articleListInfo.pageNo + 1,
          limit: 20,
          lastedTime: this.articleListInfo.lastedTime
        });
      }
    }
  },

};
</script>

<style lang="scss" scoped>

</style>