<template>
	<view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view class="context">
				<u-cell-group>
					<u-cell v-for="item in list" :key="item.id" isLink :title="item.title" @click="routeInfo(item)"></u-cell>
				</u-cell-group>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import { getMessagePage } from '@/api/index.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				list: []
			}
		},
		methods: {
			routeInfo(item) {
				this.navigateTo('/pages/notice/info/info?item='+JSON.stringify(item))
			},
			async getList(pageNum) {
				const res = await getMessagePage(pageNum, 15, {})
				if(res.success) {
					this.mescroll.endBySize(res.data.list.length, parseInt(res.data.total));
					if (pageNum == 1) this.list = []; //如果是第一页需手动制空列表
					this.list = this.list.concat(res.data.list);
				} else {
					this.mescroll.endErr();
				}
			},
			upCallback(page) {
				this.getList(page.num)
			},
		}
	}
</script>

<style lang="scss">
	.context {
		background-color: #fff;
	}
</style>