<template>
	<view>
		<u-navbar title="获奖记录"  >
		</u-navbar>
		<view class="main">
			<view class="winning-box"  v-for="(item,i) in list"  :key="i" >
				<view class="item">
					<view class="title">
						活动：
					</view>
					<view class="value">
						{{item.name}}
					</view>
				</view>
				<view class="item">
					<view class="title">
						奖励：
					</view>
					<view class="value highlight">
						{{item.prize}}
					</view>
				</view>
				<view class="else">
					<view class="state">
					  {{item.status}}
					</view>
					<view class="date">
						{{item.date}}
					</view>
				</view>
			</view>
			
		</view>
		<u-divider  v-if="list.length==recordsTotal"
		 :isnone="!list.length" nonetext="获奖记录为空"  bg-color="#F2F4F4" border-color="#CFD2D5">已经到底了</u-divider>
	</view>
</template>

<script>
	import * as API from '@/apis/pagejs/activity.js'
	
	export default {
		data() {
			return {
				list:[],
				listForm:{
					pageIndex:1,
					
					pageSize:20,
				},
				recordsTotal:0,
			}
		},
		onLoad(op){
		
			this.getList()
		},
		onReachBottom() {
			if (this.list.length < this.recordsTotal) {			
				this.myLoadmore();
			}
		},
		methods: {
			myLoadmore(){
				this.listForm.pageIndex += 1;
				this.getList();
			},
			getList(){
				
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				
				API.myAwards(this.listForm).then((res) => {
					uni.hideLoading();
					this.list = [
						...this.list,
						...res.data.data
					];
					this.recordsTotal = res.data.recordsTotal;
				}).catch(error => {
					uni.showToast({
						title: error,
						icon: "none"
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main{
		padding: 24rpx 32rpx;
		.winning-box{
			padding: 24rpx;
			border-radius: 8px;
			background-color: rgba(255, 255, 255, 1);
			margin-bottom: 24rpx;
			.item{
				display: flex;
				margin-bottom: 16rpx;
				color: rgba(51, 51, 51, 1);
				font-size: 16px;
				font-weight: bold;
				font-family: 'Medium';
				.highlight{
					color:#018BB9;
				}
			}
			.else{
				display: flex;
				color: rgba(119, 119, 119, 1);
				font-size: 12px;
				justify-content: space-between;
				margin-top: 24rpx;
				font-family: 'Regular';
			}
		}
	}

</style>
