From f60b31044a9a117244e7cd5d51f29b53d425a409 Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Mon, 28 Feb 2022 18:34:47 +0800
Subject: [PATCH] wow.js 加入

---
 src/components/group/articleListScorll.vue |  101 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 79 insertions(+), 22 deletions(-)

diff --git a/src/components/group/articleListScorll.vue b/src/components/group/articleListScorll.vue
index a2f63dd..f93c89e 100644
--- a/src/components/group/articleListScorll.vue
+++ b/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></newArticle>
-				<box5 v-bind="temp"></box5>
+			<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,10 +18,10 @@
 		<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="pageSize" :total="total" />
+					:defaultPageSize="defaultPageSize" :pageSize="pageSize" :total="total" />
 			</div>
 		</a-row>
-		
+
 	</div>
 </template>
 <script>
@@ -24,6 +30,9 @@
 	import babyActicle from '../../assets/baby.htm'
 	import newArticle from "../mini/box-new-article.vue"
 	import shijie from '../../assets/shijie.htm'
+	import {
+		queryBlogArticleList
+	} from '../../api/blogArticle.js'
 
 	var obj1 = {
 		"source": babyActicle,
@@ -58,47 +67,95 @@
 		directives: {
 			infiniteScroll
 		},
+
 		data() {
 			return {
-
+				typeId: "",
 				data: [],
 				loading: false,
 				busy: false,
 				size: "small",
-				total: 500,
-				pageSize: 20,
+				total: 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() {
-			this.data = [obj1, obj2,obj3,obj2];
+			queryBlogArticleList({
+				pageNo: this.current,
+				pageSize:this.pageSize,
+				typeId: this.typeId
+			}).then((res) => {
+				this.total = Number(res.data.total)
+				this.pageSize = Number(res.data.size);
+				this.data = res.data.records;
+				return res
+			})
 		},
 		methods: {
 			onChange(current) {
 				this.current = current;
-				this.data = [obj2, obj3, obj1, obj2];
+				queryBlogArticleList({
+					pageNo: current,
+					pageSize:this.pageSize,
+					typeId: this.typeId
+				}).then((res) => {
+					this.busy = false;
+					this.total = Number(res.data.total)
+					this.pageSize = Number(res.data.size);
+					this.data = res.data.records;
+					return res
+				})
 			},
 			loadMore() {
-				const data = this.data;
 				this.loading = true;
+				this.busy = true;
 
-				this.current += 1;
-				console.log(this.current);
-				console.log(this.busy);
+				queryBlogArticleList({
+					pageNo: this.current + 1,
+					pageSize:this.pageSize,
+					typeId: this.typeId
+				}).then((res) => {
 
-				if (data.length > 3) {
-					this.$message.warning('没有更多了');
-					this.busy = true;
-					this.loading = false;
-					return;
-				}
+					this.total = Number(res.data.total)
+					this.pageSize = Number(res.data.size);
+					this.data = this.data.concat(res.data.records);
+					this.busy = false;
+					if (res.data.records.length == 0) {
+						//this.$message.warning('别滑了,别滑了,到底了..');
+						this.busy = true;
+						this.loading = false;
+						return;
+					} else {
+						this.current += 1;
+					}
 
+					return res
+				})
 
 				setTimeout(function() {
 					this.loading = false;
-				}, 1000);
+				}, 100);
 
-				this.data = data.concat(obj1, obj3, obj2, obj3, obj1);
 
 			},
 		},

--
Gitblit v1.9.1