<template>
	<view>
		<!-- #ifdef MP-WEIXIN -->
		<view class="navbar">
			<u-navbar title-color="#000000" :is-back="true" title="我的作品"></u-navbar>
		</view>
		<!-- #endif -->
		<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback"
			@up="upCallback">
			<view class="card" @click="goDetail(item)" v-for="(item,index) in list" :key="index">
				<view class="card-left" style="width: 75%;">
					<view class="title text-cut-1 flex" style="justify-content: flex-start;">{{item.productTitle}}</view>
					<view class="center time flex" style="justify-content: flex-start;">
						<text>{{item.createTime}}</text>
					</view>
				</view>

				<view class="card-right" style="width: 25%;">
					<view class="center">
						<image style="height: 52rpx;width: 90rpx;"   :src="item.helpGoods.imgUrl"></image>
					</view>
					<view class="center margin-left-20">x {{item.voteCount}}</view>
				</view>
			</view>
		</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: {
					auto: false
				},
				top: 0,
				list: []
			}
		},
		methods: {
			goDetail(item){
				let params={
					isCustomBack:false,
					id:item.productId
				}
				uni.navigateTo({
					url:"/pages/activity/activityDetail"+this.$u.queryParams(params)
				})
			},
			downCallback() {
				setTimeout(() => {
					this.mescroll.resetUpScroll();
				}, 1000)
			},
			upCallback(mescroll) {
				try {
					let params = {
						userId: this.vuex_userId,
						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;
		justify-content: space-between;
		display: flex;

		.card-left {
			.title {
				color: #353535;
				font-size: 32rpx;
				margin-bottom: 20rpx;
				font-family: PingFang-SC-Bold;
			}

			.time {
				margin-top: 20rpx;
				color: #999999;
				font-size: 26rpx;
				font-weight: 400;
			}
		}

		.card-right {
			justify-content: flex-end;
			display: flex;
		}
	}
</style>
