<template>
	<view class="container">
		<VNavigationBar background-color="rgba(0,0,0,0)" title-color="#333" title="提交预约"></VNavigationBar>
		<view class="body">
			<view class="carInfo">
				<view class="cardInfoHeader">
					<view class="carInfoLeftTop">
						<image class="carInfoLeftTopIcon" src="../../static/icons/order-icon10.png" mode="widthFix">
						</image>
						车辆信息
					</view>
					<view class="carInfoRightTop">
						<uni-icons type="compose" color="#0174F6"></uni-icons> 修改信息
					</view>
				</view>
				<view class="cardInfoBody">
					<view class="cardInfoBody_content">
						<view class="carForm">
							<view class="carForm_num">鲁A 781NB</view>
							<view class="carForm_carName">车辆持有人：位数好</view>
							<view class="carForm_carPhone">持有人电话：13111111111</view>
						</view>
						<image class="carImg" src="" mode="aspectFill"></image>
					</view>
					<view class="cardInfoBody_footer">
						<view class="nj">
							年检时间：<text class="date">2024年</text>
							<image class="cardInfoBody_footerIcon" src="../../static/icons/icon2.png" mode="aspectFit">
							</image>
						</view>
						<view class="bx">
							保险时间：<text class="date">2024年</text>
							<image class="cardInfoBody_footerIcon" src="../../static/icons/icon2.png" mode="aspectFit">
							</image>
						</view>
					</view>
				</view>
			</view>
			<view class="baseInfo">
				<view class="formItem">
					<view class="formItem_content">
						<view class="label">姓名</view>
						<input class="formItemInput" placeholder="请输入姓名" type="text" />
					</view>

				</view>
				<view class="formItem">
					<view class="formItem_content">
						<view class="label">联系电话</view>
						<input class="formItemInput" placeholder="请输入姓名" type="text" />
					</view>
				</view>
				<view class="formItem">
					<picker mode="selector" :range="['汽车维修']" @change="">
						<view class="formItem_content">
							<view class="label">预约项目</view>
							<input disabled class="formItemInput" placeholder="请选择预约项目" type="text" />
							<image class="formItemBtn" src="../../static/icons/homeInfoMore.png" mode="aspectFit">
							</image>
						</view>
					</picker>
				</view>
			</view>

			<view class="dateCard">
				<view class="cardTitle">预约时间</view>
				<view class="datePicker">
					<view v-for="(date, index) in dateList" :key="date.date" class="dateItem"
						:class="{active: chooseDate === date.date, disabled: date.disabled}"
						@click="chooseDateFun(date)">
						<text>{{date.date}}</text>
						<text>{{date.title}}</text>
						<image v-if="chooseDate === date.date" class="activeIcon" src="../../static/icons/order-icon11.png" mode="aspectFit"></image>
					</view>
				</view>
				<view class="timerPicker">
					<view v-for="(time, index) in timeList" :key="index" class="timeItem"
						:class="{active: chooseTime === time.time, disabled: time.disabled}"
						@click="chooseTimeFun(time)">
						<text>{{time.time}}</text>
						<image v-if="chooseTime === time.time" class="activeIcon" src="../../static/icons/order-icon11.png" mode="aspectFit"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="footer">
			<view class="footerBtn" @click="submit">提交预约</view>
		</view>
	</view>
</template>

<script>
	import VNavigationBar from '@/components/VNavigationBar.vue'

	export default {
		components: {
			VNavigationBar,
		},
		data() {
			return {
				dateList: [{
					date: '06-05',
					title: '周四',
					disabled: true
				}, {
					date: '06-06',
					title: '周四',
					disabled: false
				}, {
					date: '06-07',
					title: '周四',
					disabled: false
				}, {
					date: '06-08',
					title: '周四',
					disabled: false
				}, {
					date: '06-09',
					title: '周四',
					disabled: false
				}, ],
				chooseDate: '06-06',
				chooseTime: '13:00',
				timeList: [{
						time: '11:00',
						disabled: false
					},
					{
						time: '13:00',
						disabled: false
					},
					{
						time: '15:00',
						disabled: false
					},
					{
						time: '16:30',
						disabled: false
					},
					{
						time: '18:00',
						disabled: false
					},
					{
						time: '15:00',
						disabled: false
					},
				]
			};
		},
		methods: {
			chooseTimeFun(time) {
				if (time.disabled) {
					return
				}
				this.chooseTime = time.time
			},
			chooseDateFun(date) {
				if (date.disabled) {
					return
				}
				this.chooseDate = date.date
			},
			submit() {
				uni.redirectTo({
					url: '/pages/myReservation/reservationSuccess'
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.container {
		height: 100%;
		display: flex;
		flex-direction: column;

		background: linear-gradient(180deg, #C1DEFF 0%, rgba(193, 222, 255, 0) 100%);
		background-size: 100% 500rpx;
		background-repeat: no-repeat;

	}

	.body {
		flex: 1;
		height: 0;
		overflow: auto;
		background: linear-gradient(180deg, rgba(193, 222, 255, 0) 0%, #F3F5F7 50%, #F3F5F7 100%);

		.carInfo {
			margin: 20rpx 32rpx 30rpx;
			background: #022B9A;
			box-shadow: 0rpx 8rpx 16rpx 0rpx rgba(10, 54, 104, 0.1);
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			overflow: hidden;

			.cardInfoHeader {
				display: flex;
				align-items: stretch;
			}

			.carInfoLeftTop {
				display: flex;
				align-items: center;
				column-gap: 10rpx;
				padding: 20rpx;
				color: #fff;

				.carInfoLeftTopIcon {
					width: 36rpx;
				}
			}

			.carInfoRightTop {
				flex: 1;
				width: 0;
				background-color: #fff;
				text-align: right;
				padding-right: 20rpx;

				display: flex;
				align-items: center;
				justify-content: flex-end;
				border: 10rpx;
				clip-path: polygon(20rpx 0, 100% 0, 100% 0, 100% 100%, 100% 100%, 0 100%, 10rpx 10rpx);
			}

			.cardInfoBody {
				padding: 30rpx;
				background-color: #fff;
				border-radius: 16rpx 0rpx 0 0;
			}

			.cardInfoBody_content {
				display: flex;
				align-items: stretch;
				column-gap: 32rpx;
				padding-bottom: 20rpx;
				border-bottom: 1rpx dashed #858BA0;

				.carForm {
					padding: 10rpx 0;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					font-weight: 500;
					font-size: 28rpx;
					color: #858BA0;
					flex: 1;
					width: 0;
				}

				.carForm_num {
					font-weight: bold;
					font-size: 36rpx;
					color: #333333;
				}

				.carImg {
					width: 240rpx;
					height: 150rpx;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					background-color: #efefef;
				}
			}

			.cardInfoBody_footer {
				display: flex;
				align-items: center;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
				padding-top: 20rpx;

				.nj {
					border-right: 1rpx solid #ddd;
					margin-right: 20rpx;
				}

				.nj,
				.bx {
					flex: 1;
					width: 0;

					display: flex;
					align-items: center;
					column-gap: 10rpx;
				}

				.date {
					color: #0174F6;
				}

				.cardInfoBody_footerIcon {
					width: 28rpx;
					height: 28rpx;
				}
			}
		}

		.baseInfo {
			margin: 20rpx 32rpx 30rpx;
			background: #FFFFFF;
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			padding: 0 30rpx;
			font-weight: 500;
			font-size: 28rpx;
			color: #333333;

			.formItem {
				padding: 40rpx 0;
				border-bottom: 1rpx solid #EEEEEE;

				&:last-child {
					border: none;
				}
			}

			.formItem_content {
				display: flex;
				align-items: center;
				column-gap: 10rpx;
			}

			.formItemInput {
				flex: 1;
				width: 0;
				text-align: right;
			}

			.formItemBtn {
				width: 24rpx;
				height: 24rpx;
			}
		}

		.dateCard {
			margin: 20rpx 32rpx 30rpx;
			padding: 22rpx 30rpx;
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;

			.cardTitle {
				font-weight: bold;
				font-size: 28rpx;
				color: #333333;
			}

			.datePicker {
				display: flex;
				column-gap: 20rpx;
				overflow: auto;
				padding: 30rpx 0;
				border-bottom: 1rpx solid #EEEEEE;

				.dateItem {
					padding: 20rpx 40rpx;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					border: 1rpx solid rgba(0, 0, 0, 0.1);

					font-size: 24rpx;
					color: #666666;

					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					flex-shrink: 0;
				}
			}

			.timerPicker {
				display: grid;
				grid-template-columns: 1fr 1fr 1fr;
				gap: 20rpx;
				padding-top: 30rpx;
				.timeItem {
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					border: 1rpx solid rgba(0, 0, 0, 0.1);
					padding: 30rpx 0;
					text-align: center;

				}
			}

			.timeItem,
			.dateItem {
				position: relative;
				overflow: hidden;
				&.active {
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					border: 2rpx solid #0174F6;
					color: #0174F6;
				}

				&.disabled {
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					border: 1rpx solid rgba(0,0,0,0.1);
					color: rgba(51,51,51,0.4);
				}
				.activeIcon {
					position: absolute;
					right: 0;
					top: 0;
					width: 36rpx;
					height: 24rpx;
				}
			}
		}
	}

	.footer {
		background: #FFFFFF;
		padding: 12rpx 0;
		padding-bottom: calc(12rpx + env(safe-area-inset-bottom));

		.footerBtn {
			width: 80%;
			margin: 0 auto;
			padding: 22rpx 0;
			background: #0174F6;
			border-radius: 38rpx 38rpx 38rpx 38rpx;

			display: flex;
			align-items: center;
			justify-content: center;

			font-weight: bold;
			font-size: 32rpx;
			color: #FFFFFF;
		}
	}
</style>