<template>
	<view>
		<mescroll-body-diy ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback"
			@up="upCallback">
			<view class="card" v-for="(item,index) in list" :key="index">
				<view class="card-top">
					<view>少儿普法课堂</view>
					<view class="flex">
						<image src="/static/icon/remen.png" style="width: 36rpx;height: 36rpx;margin-right: 6rpx;">
						</image>
						<text class="center">+10</text>
					</view>
				</view>

				<view class="card-bottom">
					<view class="center">2021-11-09 09:13:38</view>
					<view class="center">移动积分 -1000</view>
				</view>
			</view>
		</mescroll-body-diy>
	</view>
</template>

<script>
	import MescrollBodyDiy from "@/uni_modules/mescroll-uni/components/mescroll-diy/xinlang/mescroll-body.vue";
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		components: {
			MescrollBodyDiy,
		},
		data() {
			return {
				downOption: {
					auto: false
				},
				top: 0,
				list: []
			}
		},
		methods: {
			downCallback() {
				setTimeout(() => {
					this.mescroll.resetUpScroll();
				}, 1000)
			},
			upCallback(mescroll) {
				try {
					let params = {
						current: mescroll.num,
						size: mescroll.size,
					}
					this.$api.help.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); //追加新数据
					})
				} catch (e) {
					console.error(e);
					this.mescroll.endErr()
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		background-color: #FFFFFF;
		margin: 20rpx 0;
		padding: 35rpx;

		.card-top {
			display: flex;
			justify-content: space-between;
			color: #353535;
			font-size: 32rpx;
			margin-bottom: 20rpx;
			font-family: PingFang-SC-Bold;
		}

		.card-bottom {
			display: flex;
			justify-content: space-between;
			margin-top: 20rpx;
			color: #999999;
			font-size: 26rpx;
			font-weight: 400;
		}
	}
</style>
