<template>
<scroll-view class="orderlist" scroll-y="true" lower-threshold="30" @scrolltolower="scrollLower">
<view class="haha" v-for="(item,index) in dataList" :key="index">{{ item.institutionName }}</view>
<uni-load-more :status="status"></uni-load-more>
</scroll-view>
</template>
<script>
import {getInsList} from '@/api/index.js'
export default {
data() {
return {
numPag: 1, // 第一页
allNum: 0, // 总页数
status: "more", // 加载状态
dataList: {},
timer: null
}
},
onLoad() {
this.getData()
},
methods: {
scrollLower() {
if (this.numPag >= this.allNum) {
this.status = "noMore"
return
} else {
this.status = "loading"
}
this.numPag++
this.timer = setTimeout(() => {
this.getData()
}, 1000)
console.log('我滚动到底部了')
},
getData() {
let param = {
pageNo: this.numPag
}
this.$api.getInsList(param).then((res) => {
if (res.code === 200) {
if (res.data.current !== 1) {
this.dataList = this.dataList.concat(res.data.records)
console.log(this.dataList)
} else {
this.dataList = res.data.records
}
this.numPag = res.data.current
this.allNum = res.data.pages
}
})
}
}
}
</script>
<style>
.orderlist{
height:80vh;border: 1px solid red
}
.haha{height: 370rpx;background: #eee;margin-bottom:10px;}
</style>