<template>
	<view class="outter">
		<view class="head_title" :style="{height:head_height+'px'}">
			<view @click="navigateBack()" class="title" :style="{height:title_height+'px'}">
				<text class="iconfont .icon-Left"></text>
				我的奖品
			</view>
		</view>

		<scroll-view scroll-with-animation="true" :scroll-top="scroll_top" scroll-y="true" class="body" :style="{height:'calc(100% - '+head_height+'px)'}">
			<view class="theme-title">
				<text class="title">我的奖品</text>
				<image mode="aspectFit" class="title-bg" src="https://www.productronicachina.com.cn/resources/files/0221/67b7dd27b30b7/标题星星.png"></image>
			</view>
			<view class="cont-box">
				<view class="prize-list">
					<view class="list-title">
						<view class="text">路线进度</view>
						<view class="button">继续打卡</view>
					</view>
					<view class="progress">
						<view class="progress-bg">
							<view :style="{width:(current_route/totle_route)*100+'%'}" class="progress-inner"></view>
						</view>
						<view v-for="item in prize_list" :style="{left:(item.route_require/totle_route)*100+'%'}" :class="['item',totle_route>=item.route_require?'active':'']">
							<text class="iconfont .icon-Check"></text>
							<view class="text">已满{{item.route_require}}条</view>
						</view>
					</view>
					<view class="title">
						您目前的奖品
					</view>
					<view class="inner-list">
						<view v-for="item in prize_list" class="list-item">
							<image mode="aspectFill" class="image" :src="item.prize_image"></image>
							<view class="text">
								<view class="name">{{item.prize_name}}</view>
								<view class="route">成功打卡<text class="require">{{item.route_require}}条路线</text>即可获取</view>
								<view class="description">{{item.prize_desc}}</view>
							</view>
							<view class="button">{{getStateName(item.state)}}</view>
						</view>
					</view>
				</view>
				<view class="bottom-text">
					<view style="font-size: 28rpx;margin-bottom: 20rpx;">领取奖品注意事项</view>
					<view style="font-size: 22rpx;line-height: 2;">1.展会期间，每人可领取完成最高线路的对应奖品，每人仅有一次兑奖机会。请谨慎兑奖。</view>
					<view style="font-size: 22rpx;line-height: 2;">2.礼品数量有限，仅限展会期间领取，先到先得，一旦赠完即止。</view>
					<view style="font-size: 22rpx;line-height: 2;">3.点击【可领取奖品】至展会现场礼品发放处【展位号待定】进行奖品核销与兑换。</view>
					<view style="font-size: 22rpx;line-height: 2;">4.满9条路线的观众兑奖完成后，可将名片投入礼品发放处【展位号待定】抽奖箱，获奖结果将于展后公布。</view>
					<view style="font-size: 22rpx;line-height: 2;">如有其他疑问，可至展会现场礼品发放处询问主办工作人员。</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				head_height:0,
				title_height:0,
				totle_route:9,
				current_route:6,
				prize_list:[
					{
						prize_name:'手机支架或降噪眼罩（随机）',
						prize_desc:'① 公文包或斜挎包（随机）<br/>② 有机会抽取大奖',
						prize_image:'',
						route_require:2,
						//
						state:'0'
					},
					{
						prize_name:'露营杯',
						prize_desc:'',
						prize_image:'',
						route_require:5,
						//
						state:'2'
					},
				]
			};
		},
		methods: {
			getSafeHeight(){
				let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
				this.head_height = menuButtonInfo.bottom + 15
				this.title_height = menuButtonInfo.height
			},
			/**
			 * 根据状态代码获取文本
			 * @param {String} code 状态代码
			 */
			getStateName(code){
				switch (code){
					case '0':
						return '不可领取'
						break
					case '1':
						return '待领取奖品'
						break
					case '2':
						return '可领取奖品'
						break
					case '3':
						return '已领取奖品'
						break
					default:
						break;
				}
			}
		},
		onLoad() {
			this.getSafeHeight()
		}
	}
</script>

<style lang="scss">
.outter{
	height: 100%;
	position: relative;
	.head_title{
		width: 100%;
		background: linear-gradient( 270deg, #332968 9%, #435797 44%, #382E73 92%), rgba(0,0,0,0.2);
		padding-bottom: 15px;
		display: flex;
		align-items: flex-end;
		padding-left: 28rpx;
		.title{
			display: flex;
			align-items: center;
			color: white;
			font-size: 32rpx;
			.iconfont{
				font-size: 36rpx;
				margin-right: 8rpx;
			}
		}
	}
	.body{
		overflow: hidden;
		overflow-y: auto;
		background: linear-gradient( 180deg, #015A92 0%, #56A3E9 24%, #106591 98%);
		.cont-box{
			border-radius: 20rpx;
			margin: 30rpx;
			background-color: #EEEEEE;
			.prize-list{
				border-radius: 20rpx;
				background-color: white;
				padding: 36rpx 44rpx 30rpx;
				.inner-list{
					.list-item{
						padding: 20rpx 30rpx;
						background-color: #FAFAFA;
						border-radius: 20rpx;
						display: flex;
						.image{
							width: 128rpx;
							height: 128rpx;
						}
						.text{
							flex: 1;
							margin-left: 20rpx;
							margin-right: 60rpx;
							.name{
								font-size: 26rpx;
								margin-bottom: 10rpx;
							}
							.route{
								font-size: 18rpx;
								line-height: 1.8;
								.require{
									color: #015A92;
								}
							}
							.description{
								font-size: 18rpx;
								line-height: 1.8;
							}
						}
						.button{
							width: 128rpx;
							height: 48rpx;
							border-radius: 6rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							color: white;
							font-size: 16rpx;
							font-weight: bold;
							background-color: #94A3B8;
						}
					}
				}
				.title{
					font-size: 24rpx;
					margin-bottom: 31rpx;
				}
				.progress{
					position: relative;
					height: 24rpx;
					width: 94%;
					margin-top: 24rpx;
					margin-bottom: 90rpx;
					display: flex;
					align-items: center;
					.item{
						position: relative;
						top:0;
						transform: translateX();
						background-color: white;
						position: absolute;
						height: 24rpx;
						width: 24rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						border-radius: 12rpx;
						border: 1rpx solid #E57519;
						&.active{
							background-color: #E57519;
						}
						.iconfont{
							color: white;
							font-size: 18rpx;
						}
						.text{
							position: absolute;
							bottom: -40rpx;
							font-size: 20rpx;
							width: 100rpx;
							left: 50%;
							text-align: center;
							transform: translateX(-50%);
						}
					}
					.progress-bg{
						width: 100%;
						height: 9rpx;
						background-color: #D9CC9D;
						border-radius: 10rpx;
						.progress-inner{
							height: 100%;
							width: 50%;
							background-color: #E57519;
							border-radius: 10rpx;
						}
					}
				}
				.list-title{
					display: flex;
					justify-content: space-between;
					align-items: center;
					.text{
						font-size: 24rpx;
					}
					.button{
						font-size: 18rpx;
						padding: 10rpx 20rpx;
						background-color: #4085C7;
						border-radius: 40rpx;
						font-weight: bold;
						color: white;
					}
				}
			}
			.bottom-text{
				padding: 36rpx 44rpx 30rpx;
			}
		}
		.theme-title{
			margin-top: 54rpx;
			margin-bottom: 32rpx;
			position: relative;
			height: 130rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			.title{
				color: white;
				font-size: 55rpx;
				font-weight: bold;
			}
			.title-bg{
				position: absolute;
				left: 0;
				top: 0;
				height: 100%;
			}

		}
	}
}
</style>
