<template>
	<view class="pages">
		<view class="" :style="{height: navHeight+'px' }"></view>
		<view class="navbar-box">
			<u-navbar title="选择区域" :safeAreaInsetTop="true" @leftClick="leftClick" :titleStyle="{color:'#fff'}" leftIconColor="#fff" bgColor="#EF1818"></u-navbar>
		</view>
		<view class="page-wrap">
			<view class="base-info">
				<view class="name">{{pageData.performName}}</view>
				<view class="time u-flex">
					<view class="title">{{pageData.day|checkDate}}</view>
					<text>{{pageData.performTimeStart}} - {{pageData.performTimeEnd}}</text>
				</view>
			</view>
			<view class="position-wrap u-flex u-row-center">
				<view class="u-flex item" :class="{active:positionIndex==index}" :style="{color:positionIndex==index?'#fff':item.seatColor,borderColor:item.seatColor,backgroundColor:positionIndex==index?item.seatColor:'#fff'}" @click="positionClick(index)" v-for="(item,index) in positionArr" :key="index">
					<!-- <image class="icon" :src="item.icon" ></image> -->
					<text style="margin-right: 5px;">{{item.seatTypeName}}</text>
					<text>¥ {{item.salePrice}}</text>
				</view>
			</view>
			<image class="position-img" :src="positionData.seatImg" mode="widthFix"></image>
			<view class="btn" @click="book">确定区域</view>
		</view>
	</view>
</template>

<script>
	import { systemInfo } from "@/mixin.js";
	export default {
		mixins: [systemInfo],
		data() {
			return {
				staticUrl:this.$commonConfig.staticUrl,
				params:{
					performId:'',
				},
				positionData:{},
				positionArr:[],
				positionIndex:0,
				pageData:{},
			}
		},
		onShow() {
			
		},
		onLoad(page) {
			// console.log('page',page);
			this.pageData = page;
			this.getSystemInfo();
			this.getPositionData();
		},
		methods: {
			leftClick(e){
				let pages = getCurrentPages();
				if(pages.length==1){
					uni.$u.route('/pages/index/index')
				}else{
					uni.navigateBack()
				};
			},
			getPositionData(){
				let params ={
					performId:this.pageData.performId,
					goodsId:this.pageData.goodsId,
					auditoriumId:this.pageData.auditoriumId,
					performTimeId:this.pageData.performTimeId,
				}
				this.$u.api.selectRegion(params).then(res=>{
					// console.log('getPositionData',res.data);
					this.positionData =  res.data;
					this.positionArr = res.data.regionPriceList;
				}).catch(err=>{
					console.log('getPositionData',err);
				})
			},
			book(){
				if(this.positionArr.length<1){
					uni.toast('还没有座位信息')
					return
				}
				let seatType = this.positionArr[this.positionIndex];
				let params ={
					performId:this.pageData.performId,
					goodsId:this.pageData.goodsId,
					auditoriumId:this.pageData.auditoriumId,
					performTimeId:this.pageData.performTimeId,
					seatTypeId:seatType.seatTypeId,
					salePrice:seatType.salePrice
				}
				// params.price = this.positionArr[this.positionIndex].price;
				// params.positionName = this.positionArr[this.positionIndex].positionName;
				uni.$u.route('pages/bookticket',params)
			},
			positionClick(index){
				this.positionIndex = index;
			}

		}
	}
</script>
<style>
page{
	background-color: #F7F7F9;
}
</style>
<style lang="scss" scoped>
.page-wrap{
	padding-top: 36rpx;
}
.base-info{
	background: #FFFFFF;
	box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(221,221,221,0.4);
	border-radius: 16rpx;
	padding: 38rpx 28rpx;
	margin-bottom: 54rpx;
	.name{
		font-size: 28rpx;
		font-weight: bold;
		color: #2D2D2D;
		line-height: 42rpx;
		margin-bottom: 24rpx;
	}
	.time{
		font-size: 24rpx;
		font-weight: 400;
		color: #7F7F7F;
		.title{
			font-size: 24rpx;
			font-weight: 500;
			color: #F01414;
			margin-right: 26rpx;
		}
	}
}
.position-wrap{
	margin-bottom: 80rpx;
	.item{
		padding: 20rpx 24rpx 14rpx;
		border-radius: 8rpx;
		border: 2rpx solid #D9D9D9;
		margin: 0 24rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #EF1D1E;
		.icon{
			display: block;
			width: 36rpx;
			height: 36rpx;
			margin-right: 20rpx;
		}
		&.active{
			border-color: #EF1D1E;
		}
	}
}
.position-img{
	width: 100%;
	margin-bottom: 40rpx;
}
.btn{
	height: 92rpx;
	line-height: 92rpx;
	background: linear-gradient(90deg, #FF7878 0%, #ED0000 100%);
	border-radius: 46rpx;
	text-align: center;
	font-size: 28rpx;
	font-weight: 400;
	color: #FFFFFF;
}
</style>