<template>
	<view class="exchangePrize">
		<!-- 表单 -->
		<view class="form">
			<uni-forms :modelValue="formData" >
				<uni-forms-item  name="type" v-if="istype">
					<view class="selectType">
						<picker mode="selector" :value="formData.type" :range='typeSelect'
							@change="bindTypeChange">
							<view class="uni-input" >
								<text v-if="formData.type==''||formData.type==null"
									style="color: #999999 ;">请选择配送方式</text>
								<text v-if="formData.type!=''">{{formData.type}}</text>
							</view>
							<image src="/static/icon/right.png"
								style="width: 14rpx;height: 24rpx;position: absolute;top:20rpx;right: 30rpx;"></image>
						</picker>
					</view>
				</uni-forms-item>
				<uni-forms-item  name="name" v-if="formData.type!=''||isVerification==true">
					<uni-easyinput type="text" v-model="formData.name" placeholder="填写联系人" />
				</uni-forms-item>
				<uni-forms-item  name="phone" v-if="formData.type!=''||isVerification==true">
					<uni-easyinput type="number" v-model="formData.phone" placeholder="填写联系电话" />
				</uni-forms-item>
				<uni-forms-item  name="region" v-if="formData.type=='快递配送'">
					<uni-easyinput type="text" v-model="formData.region" placeholder="所在地区" />
				</uni-forms-item>
				<uni-forms-item  name="region" v-if="formData.type=='快递配送'">
					<uni-easyinput type="text" v-model="formData.region" placeholder="详细地址" />
				</uni-forms-item>
				<uni-forms-item  name="region" v-if="formData.type=='到店自提'||isVerification==true">
					<view class="selectType">
						<picker mode="selector" :value="formData.region" :range='regionSelect'
							@change="bindregionChange">
							<view class="uni-input" >
								<text v-if="formData.region==''||formData.region==null"
									style="color: #999999 ;">请选择门店</text>
								<text v-if="formData.region!=''">{{formData.region}}</text>
							</view>
							<image src="/static/icon/right.png"
								style="width: 14rpx;height: 24rpx;position: absolute;top:20rpx;right: 30rpx;"></image>
						</picker>
					</view>
				</uni-forms-item>
			</uni-forms>
		</view>
		
		<!-- 奖品信息 -->
		<view class="msg">
			<view class="title">
				<text>奖品信息</text>
			</view>
			<view class="shopCard">
				<image  src="/static/icon/Kudosbg.png"></image>
				<view style="margin-left: 24rpx;">
					<text class="name">端午佳节五香肉粽子，仅限前</text>
					<text class="tag">礼盒装 </text>
				</view>
			</view>
			<view class="shopNumber">
				<text>件数</text>
				<text>1件</text>
			</view>
		</view>
		
		<!-- 兑换按钮 -->
		<view class="bottombtn" @click="goExDetail">
			<view class="btnitem" >
				<text>确认兑换</text>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data(){
			return{
				//产品
				id:'',
				// 是否核销
				isVerification:false,
				// 表单数据
				formData:{
					type:'',
					phone:'',
					name:'',
					region:'',
					address:'',
				},
				// 配送方式
				typeSelect:['快递配送','到店自提'],
				// 是否显示配送方式
				istype:true,
				// 选择门店
				regionSelect:['第一门店','第二门店','第三门店','第四门店']
			}
		},
		
		onLoad(o) {
			if(o.id){
				this.id = o.id
				this.getProductDetail()
			}
			
			
		},
		
		methods:{
			getProductDetail(){
				this.$api.product.getProductDetail({
					product_id:this.id
				}).then(res=>{
					console.log(res,'------->res');
				})
			},
			
			// 选择快递方式
			bindTypeChange:function(e){
				if(e.detail.value==0){
					this.formData.type='快递配送'
				}else{
					this.formData.type='到店自提'
				}
			},
			// 跳转兑换详情
			goExDetail(){
				uni.navigateTo({
					url:'/pages/my/prize/exchangeDetail'
				})
			},
			// 选择门店
			bindregionChange:function(e){
				this.formData.region=this.regionSelect[e.detail.value]
			},
		}
	}
</script>

<style lang="scss" scoped>
	$pageColor:#F9F9F9;
	$bgColor:#FFFFFF;
	@mixin flexlayout {
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.exchangePrize{
		height: 100%;
		background:$bgColor ;
	}
	::v-deep .uni-forms-item{
		margin-bottom: 24rpx;
	}
	::v-deep .uni-forms-item__content{
		font-size: 30rpx;
		border: 2rpx solid #EAEAEA;
		padding:18rpx 0;
		border-radius: 8rpx;
		background-color: #fff;
	}
	::v-deep .is-input-border{
		border: none;
	}
	.form{
		background:$pageColor ;
		width: 750rpx;
		padding:24rpx 30rpx 12rpx 30rpx;
		box-sizing: border-box;
		.selectType{
			width: 690rpx;
			height: 68rpx;
			background: #FFFFFF;
			display: flex;
			align-items:center;
			padding-left: 20rpx; 
			box-sizing: border-box;
			position: relative;
		}
	}
	.msg{
		width: 750rpx;
		height: 700rpx;
		background:$bgColor;
		border-radius: 12rpx 12rpx 0px 0px;
		padding:32rpx 30rpx;
		.title{
			margin-bottom: 24rpx;
			text{
				font-size: 32rpx;
				font-family: PingFang-SC-Bold, PingFang-SC;
				font-weight: bold;
				color: #080F18;
			}
		}
		.shopCard{
			margin-top: 28rpx;
			width: 694rpx;
			height: 164rpx;
			background: #F4F5F6;
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			image{
				width: 132rpx;
				height: 132rpx; 
				margin-left: 16rpx;
				display: inline-block;
				border-radius: 10rpx;
			}
			.name{
				font-size: 28rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #080F18;
				display: block;
			}
			.tag{
				font-size: 24rpx;
				font-family: PingFang-SC-Medium, PingFang-SC;
				font-weight: 500;
				color: #666666;
			}
		}
		.shopNumber{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 25rpx;
			text{
				font-size: 26rpx;
				font-family: PingFang-SC-Medium, PingFang-SC;
				font-weight: 500;
				color: #000000;
			}
		}
	}
	.bottombtn{
		width: 690rpx;
		height: 92rpx;
		background: linear-gradient(270deg, #FF6200 0%, #FF9342 100%);	
		border-radius: 12rpx;
		margin-left: 30rpx;
		position: fixed;
		bottom: 72rpx;
		@include flexlayout();
		.btnitem{
			@include flexlayout();
			text{
				font-size: 30rpx;
				font-family: PingFang-SC-Bold, PingFang-SC;
				font-weight: bold;
				color: $bgColor;
			}
		}
	}
</style>