一、页面到底监听
//监听滑动到底段
onReachBottom() {
},
二、自动加载
<template>
<view>
<uni-nav-bar left-text="返回" right-text="退出系统"
backgroundColor="#d3233b" color="#ffffff" title="睿智法务"
@clickRight="exitLogin" @clickLeft="clickLeft" fixed="true"></uni-nav-bar>
<uni-list ref="list">
<uni-list-item v-for="article in articleList" :title="article.title" :thumb="fileServer+article.imgurl"
thumbSize="lg" :clickable="true" @click="click(article.id,article.title)"></uni-list-item>
<uni-load-more status="loading"
v-show="show"></uni-load-more>
</uni-list>
</view>
</template>
<script>
export default{
data(){
return{
pageSize:10,
pageIndex:1,
articleList:[],
cid:'',
fileServer:'http://localhost:8060',
show:false,
}
},
//监听滑动到底段
onReachBottom() {
this.show = true
this.pageIndex++
this.getAll()
},
onLoad(options) {
this.cid = options.cid
this.getAll()
},
methods:{
click(id,title){
uni.redirectTo({
url:'./content?id='+id +'&title='+title +'&cid='+this.cid
})
},
getAll(){
uni.request({
url:'http://localhost:8070/news/article/list/'+ this.cid +'/'+this.pageIndex + '/' + this.pageSize,
success: (res) =>{
this.show = false
if(this.articleList == null){
this.articleList = res.data.data
}else{
var list = res.data.data
if(list != null){
for (var i = 0; i < list.length; i++) {
this.articleList.push(list[i])
}
}
}
}
})
},
clickLeft(){
uni.redirectTo({
url:'../main/main'
})
},
exitLogin(){
uni.redirectTo({
url:'../login/login'
})
},
}
}
</script>
<style>
.uni-button{
margin-right: 10rpx;
margin-left: 10rpx;
}
</style>