From fc0c102554f509989dd74b199f298a67f266c3c8 Mon Sep 17 00:00:00 2001 From: inleft <inleft@qq.com> Date: Fri, 25 Feb 2022 12:11:27 +0800 Subject: [PATCH] 虫洞添加,统计代码添加,样式局部调整 --- src/components/group/articleListScorll.vue | 42 ++++++++++++++++++++++++++++++++++-------- 1 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/components/group/articleListScorll.vue b/src/components/group/articleListScorll.vue index 9de3547..47e61cb 100644 --- a/src/components/group/articleListScorll.vue +++ b/src/components/group/articleListScorll.vue @@ -1,10 +1,14 @@ <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 v-for="(temp,index) in data"> + <newArticle v-bind="temp" :index="index"></newArticle> <!-- <box5 v-bind="temp"></box5> --> </div> + <div class="mySecret" v-if="data.length==0"> + <p>空空如也..</p> + </div> + <div v-if="loading && !busy" class="demo-loading-container"> <a-spin /> </div> @@ -63,6 +67,7 @@ }, data() { return { + typeId: "", data: [], loading: false, busy: false, @@ -72,9 +77,29 @@ current: 1, }; }, + 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, + typeId: this.typeId }).then((res) => { this.total = Number(res.data.total) this.pageSize = Number(res.data.size); @@ -83,11 +108,11 @@ }) }, methods: { - onChange(current) { this.current = current; queryBlogArticleList({ - pageNo: this.current + pageNo: current, + typeId: this.typeId }).then((res) => { this.busy = false; this.total = Number(res.data.total) @@ -99,9 +124,10 @@ loadMore() { this.loading = true; this.busy = true; - + queryBlogArticleList({ - pageNo: this.current + 1 + pageNo: this.current + 1, + typeId: this.typeId }).then((res) => { this.total = Number(res.data.total) @@ -109,7 +135,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; -- Gitblit v1.9.1