inleft
2022-02-28 f60b31044a9a117244e7cd5d51f29b53d425a409
src/components/group/articleListScorll.vue
@@ -1,10 +1,16 @@
<template>
   <div>
      <div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" :infinite-scroll-distance="10">
         <div v-for="temp in data">
            <newArticle v-bind="temp"></newArticle>
         <div class="mySecret" v-if="data.length==0">
            <p>空空如也..</p>
         </div>
         <div v-for="(temp,index) in data" >
            <newArticle v-bind="temp" :index="index"></newArticle>
            <!-- <box5 v-bind="temp"></box5> -->
         </div>
         <div v-if="loading && !busy" class="demo-loading-container">
            <a-spin />
         </div>
@@ -12,7 +18,7 @@
      <a-row type="flex" justify="center">
         <div style="position:fixed;bottom: 10px;" id="dddadf">
            <a-pagination @change="onChange" :showQuickJumper="true" :size="size" v-model="current"
               :defaultPageSize="10" :pageSize="pageSize" :total="total" />
               :defaultPageSize="defaultPageSize" :pageSize="pageSize" :total="total" />
         </div>
      </a-row>
@@ -61,20 +67,43 @@
      directives: {
         infiniteScroll
      },
      data() {
         return {
            typeId: "",
            data: [],
            loading: false,
            busy: false,
            size: "small",
            total: 1,
            pageSize: 1,
            pageSize: 10,
            current: 1,
            defaultPageSize:10
         };
      },
      watch: {
         '$route'(to, from) {
            if ("articleList" === to.name) {
               this.typeId = this.$route.query.typeId;
            }
         },
         typeId: function(newValue, oldValue) {
            this.busy = true;
            this.$message.info('loading', 0.3);
            this.onChange(1);
         },
      },
      activated() {
         window.addEventListener('scroll', this);
      },
      deactivated() {
         window.removeEventListener('scroll', this);
      },
      beforeMount() {
         queryBlogArticleList({
            pageNo: this.current
            pageNo: this.current,
            pageSize:this.pageSize,
            typeId: this.typeId
         }).then((res) => {
            this.total = Number(res.data.total)
            this.pageSize = Number(res.data.size);
@@ -83,11 +112,12 @@
         })
      },
      methods: {
         onChange(current) {
            this.current = current;
            queryBlogArticleList({
               pageNo: this.current
               pageNo: current,
               pageSize:this.pageSize,
               typeId: this.typeId
            }).then((res) => {
               this.busy = false;
               this.total = Number(res.data.total)
@@ -99,9 +129,11 @@
         loadMore() {
            this.loading = true;
            this.busy = true;
            queryBlogArticleList({
               pageNo: this.current + 1
               pageNo: this.current + 1,
               pageSize:this.pageSize,
               typeId: this.typeId
            }).then((res) => {
               this.total = Number(res.data.total)
@@ -109,7 +141,7 @@
               this.data = this.data.concat(res.data.records);
               this.busy = false;
               if (res.data.records.length == 0) {
                  this.$message.warning('别滑了,别滑了,到底了..');
                  //this.$message.warning('别滑了,别滑了,到底了..');
                  this.busy = true;
                  this.loading = false;
                  return;