<template>
	<view>
		 <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
			<infomation :newList="list"></infomation>
		 </mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
	import infomation from "@/components/infomation/infomation.vue"
	export default {
		mixins:[MescrollMixin],
		components:{
			infomation
		},
		data() {
			return {
				// 列表数据
				list: [],
				downOption: { 
					use: true,
					auto: false
				},
				upOption: {
					page: {
						page: 0,
						size: 10
					},
					noMoreSize: 5, 
					empty: {
						tip: '暂无相关数据'
					}
				},
			}
		},
		methods: {
			downCallback(){
				setTimeout(()=>{
					this.mescroll.resetUpScroll()
				},1500)
			},
			upCallback(mescroll) {
				let params={
					current:mescroll.num,
					size:mescroll.size,
					agencyId:this.$cache.get('agencyId')
				}
				try{
					this.$api.CMS.page(params).then(res=>{
						let data=res.data.records
						let length=data.length
						let total=res.data.total
						mescroll.endBySize(length, total);
						if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
						this.list=this.list.concat(data); //追加新数据
					})
				}catch(e){
					console.log(e);
					mescroll.endErr();
				}
			},
			
		}
	}
</script>

<style>

</style>