<template>
	<view class="history">
		<view class="head">
			<view class="back" @tap="$navigateBack()">
				<text class="iconfont icon">&#xe771;</text>
			</view>
			<view class="title">
				打赏记录
			</view>
			<view class="history">

			</view>
		</view>
		<view class="head-placeholder"></view>
		<view class="list">
			<view v-for="item in list" :key="item.id" class="cell">
				<view class="row">
					<view class="label">
						打赏会员：
					</view>
					<view class="value">
						{{item.username}}
					</view>
				</view>
				<view class="row">
					<view class="label">
						打赏金额：
					</view>
					<view class="value">
						{{item.dsMoney}}
					</view>
				</view>
				<view class="row">
					<view class="label">
						打赏日期：
					</view>
					<view class="value">
						{{item.createTime}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import url from "@/common/http/url.js"
	export default {
		data() {
			return {
				list: [],
				page: {
					pageNum: 1,
					pageSize: 10
				}
			}
		},
		mounted() {
			this.page.pageNum = 1;
			this.loadList()
		},
		methods: {
			loadList() {
				this.$http("get", url.store.getRewardHistory, {...this.page}).then(({
					code,
					data,
					msg
				}) => {
					uni.stopPullDownRefresh()
					if (code !== 200) return this.$msg(msg);
					if (data) {
						if (this.page.pageNum === 1) {
							this.list = data.records || [];
						} else {
							this.list = this.list.concat(data.records||[])
						}
					}
				})
			}
		},
		onPullDownRefresh() {
			this.pageNum = 1;
			this.loadList()
		},
		onReachBottom() {
			this.pageNum += 1;
			this.loadList()
		}
	}
</script>

<style scoped lang="scss">
	.history {
		.head {
			position: fixed;
			z-index: 10;
			left: 0;
			top: 0;
			right: 0;
			height: 88upx;
			background: #fff;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			color: #555;

			.back {
				width: 160upx;
				box-sizing: border-box;
				padding: 20upx;

				.icon {
					font-size: 50upx;
				}

				&:active {
					opacity: 0.8;
				}
			}

			.title {
				font-size: 32upx;
				color: #333;
			}

			.history {
				width: 160upx;
				font-size: 28upx;
				box-sizing: border-box;
				padding: 20upx;
				text-align: right;

				&:active {
					opacity: 0.8;
				}
			}
		}

		.head-placeholder {
			width: 100%;
			height: 88upx;
		}
		.list {
			padding: 20upx;
			.cell {
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				align-items: flex-start;
				padding: 20upx;
				border-radius: 12upx;
				background-color: #fff;
				margin-bottom: 20upx;
				font-size: 28upx;
				color: #999;
				.row {
					display: flex;
					flex-direction: row;
					justify-content: flex-start;
					align-items: center;
					padding: 6upx 0;
					.value {
						color: #666;
						font-size: 30upx;
					}
				}
			}
		}
	}
</style>