<template>
	<view>
		<u-navbar title="获奖名单" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
		<view class="list">
			<view v-for="(item,index) in list" :key="index" class="list-view">
				<view class="award">
					<view class="award-avatar">
						<image :src="item.avatar" mode=""></image>
					</view>
					<view class="award-nickNames">
						<view class="nickName"><text>{{item.nickName}}</text>
							<view v-if="item.awardName == '一等奖'" class="awardName">
								<image src="../../static/activity/one.png" mode="">
								</image>
								<text style="color: #FFD225;">{{item.awardName}}</text>
							</view>
							<view v-else-if="item.awardName == '二等奖'" class="awardName">
								<image src="../../static/activity/two.png" mode="">
								</image>
								<text style="color: #94CBEC;">{{item.awardName}}</text>
							</view>
							<view v-else-if="item.awardName == '三等奖'" class="awardName">
								<image src="../../static/activity/three.png" mode=""></image>
								<text style="color: #F2B47A;">{{item.awardName}}</text>
							</view>
						</view>
						<view style="line-height: 46rpx; color: #666666;">中奖码：{{item.code}}</view>
						<view style="line-height: 46rpx; color: #666666;">{{item.prizeTitle}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import env from '../../config/env.js'
	import $http from '@/utils/request.js'
	export default {
		data() {
			return {
				list: [],
				marketingId: '',
				total: '',
			}
		},
		onLoad(opthios) {
			this.marketingId = opthios.id
			this.pageList()
		},
		methods: {
			pageList() {
				this.pageNum = 1
				this.list = []
				this.getList()
			},
			getList() {
				uni.showLoading({
					title: '加载中'
				});
				this.loading = true
				$http.post(`/api/v1/mp/user/marketing/hit/prize/list`, {
					marketingId: this.marketingId,
				}).then(res => {
					console.log(res);
					uni.hideLoading();
					this.loading = false
					if (res.code == 0) {
						res.rows.forEach(item => {
							let prizePicUrlArr = item.prizePicUrl.split(',')
							item.prizePicUrl = env.filePublic + prizePicUrlArr[0] + '?imageView2/2/w/170'
							item.avatar = env.filePublic + item.avatar + '?imageView2/2/w/170'
						})
						this.total = res.total
						this.list = this.list.concat(res.rows)
					}
				}).catch(() => {
					uni.hideLoading();
					this.loading = false
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.list {

		&-view {
			padding: 10rpx 30rpx;

			.award {
				border-radius: 22rpx;
				width: 100%;
				height: 108px;
				background-color: #fff;
				overflow: hidden;

				&-avatar {
					float: left;
					padding: 50rpx 32rpx;

					image {
						height: 100rpx;
						width: 100rpx;
						border-radius: 100rpx;
					}
				}

				&-nickNames {
					float: left;
					padding: 30rpx 0;

					.nickName {
						line-height: 60rpx;
						font-size: 30rpx;

						.awardName {
							display: inline-block;
							image {
								width: 40rpx;
								height: 36rpx;
								margin-left: 30rpx;
								vertical-align: -10%;
							}
							text {
								display: inline-block;
								font-size: 26rpx;
								line-height: 26rpx;
							}
						}

					}
				}
			}
		}
		// 设置ios刘海屏底部横线安全区域
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}
</style>
