<template>
	<view class="u-content">
		<!-- #ifdef MP-WEIXIN -->
		<u-navbar title-color="#000000"  :is-back="true" title="投票须知"></u-navbar>
		<!-- #endif -->
		 <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
			<u-parse :html="content" ></u-parse>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				downOption:{
					use:false,
					auto:false
				},
				content:'',
				list: [] // 数据列表
			}
		},
		methods: {
			downCallback(){
				setTimeout(()=>{
					this.mescroll.resetUpScroll();
				},1000)
			},
			upCallback(mescroll) {
				try {
					let params={
						title:'投票须知',
						activeId:this.vuex_active_setting.defaultActiveId,
						current:mescroll.num,
						size:mescroll.size,
					}
					this.$api.notice.list(params).then(res => {
						let data = res.data.data.records
						let total = res.data.data.total
						mescroll.endBySize(data.length, total);
						if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
						this.list = this.list.concat(data); //追加新数据
						this.content = decodeURIComponent(this.list[0].content)
					}).catch(err=>{
						console.log(err);
					})
				} catch (e) {
					console.error(e);
					this.mescroll.endErr()
				}
			}
		}
	}
</script>

<style >
	page{
		background-color: #FFFFFF;
	}
	
	.u-content {
		padding: 30rpx;
		line-height: 50rpx;
		color: #505050;
	}
</style>