<template>
|
<div class="fade">
|
<div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" :infinite-scroll-distance="10">
|
<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="loading-container">
|
<a-spin />
|
</div>
|
</div>
|
<a-row type="flex" justify="center">
|
<div style="position:fixed;bottom: 10px;">
|
<a-pagination @change="onChange" :showQuickJumper="true" :size="size" v-model="current"
|
:defaultPageSize="defaultPageSize" :pageSize="pageSize" :total="total" />
|
</div>
|
</a-row>
|
|
</div>
|
</template>
|
<script>
|
import infiniteScroll from 'vue-infinite-scroll';
|
import box5 from "../mini/box5-article.vue"
|
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'
|
|
|
|
export default {
|
components: {
|
box5,
|
newArticle
|
},
|
directives: {
|
infiniteScroll
|
},
|
|
data() {
|
return {
|
typeId: "",
|
data: [],
|
loading: false,
|
busy: false,
|
size: "small",
|
total: 1,
|
pageSize: 6,
|
current: 1,
|
defaultPageSize: 10
|
};
|
},
|
created() {
|
this.typeId = this.$route.query.typeId;
|
},
|
watch: {
|
'$route'(to, from) {
|
if ("articleList" === to.name || "home" === to.name) {
|
this.typeId = this.$route.query.typeId;
|
}
|
},
|
typeId: function(newValue, oldValue) {
|
//有条件不刷新
|
// if (newValue == undefined || oldValue == "") {
|
// return
|
// }
|
|
this.busy = true;
|
this.$message.info('loading', 0.3);
|
this.onChange(1);
|
},
|
},
|
activated() {
|
this.busy = false;
|
window.addEventListener('scroll', this);
|
},
|
deactivated() {
|
this.busy = true;
|
window.removeEventListener('scroll', this);
|
},
|
methods: {
|
onChange(current) {
|
this.current = current;
|
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() {
|
this.loading = true;
|
this.busy = true;
|
|
queryBlogArticleList({
|
pageNo: this.current + 1,
|
pageSize: this.pageSize,
|
typeId: this.typeId
|
}).then((res) => {
|
|
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;
|
}, 100);
|
|
|
},
|
},
|
};
|
</script>
|
<style>
|
.loading-container {
|
position: absolute;
|
bottom: 40px;
|
width: 100%;
|
text-align: center;
|
}
|
</style>
|