<template>
	<view>
		<!-- #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">
			<view @click="jump(item)" class="card" v-for="(item,index) in list" :key="index">
				<view class="card-left">
					<view class="title">
						<text v-if="item.heatType=='HEAT_VALUE_EXCHANGE'">热力值兑换</text>
						<text v-if="item.heatType=='HEAT_VALUE_SEND'">热力值赠送</text>
					</view>

					<view class="time">
						<text>{{item.createTime}}</text>
					</view>
				</view>

				<view class="card-right">
					<view class="center">
						<image src="/static/icon/remen.png" style="width: 36rpx;height: 36rpx;margin-right: 6rpx;">
						</image>
					</view>
					<view class="center padding-top-10">
						<text v-if="item.heatType=='HEAT_VALUE_EXCHANGE'"
							class="center reduce">{{item.voteCount}}</text>
						<text v-if="item.heatType=='HEAT_VALUE_SEND'" class="center plus">{{item.voteCount}}</text>
					</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: {
			jump(item) {
				if (this.$isNotEmpty(item.activeProductId)) {
					uni.navigateTo({
						url: '/pages/activity/activityDetail?id=' + item.activeProductId
					})
				}
			},
			downCallback() {
				setTimeout(() => {
					this.mescroll.resetUpScroll();
				}, 1000)
			},
			upCallback(mescroll) {
				try {
					let params = {
						phone: this.vuex_phone || '-1',
						current: mescroll.num,
						size: mescroll.size,
					}
					this.$api.heatrecord.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;
		display: flex;
		justify-content: space-between;

		.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 {
			display: flex;
		}
	}
</style>
