<template>
	<view class="page-prebook">
		<view class="title flex">
			<img :src="cssUrl+'ten.svg'">
			{{hospital.hospital_name}} {{hospital.hospital_dept_name}}
		</view>
		<book ref="book" @confirmSubmitEvent="showConfirm" :RegistrationTimeList="RegistrationTimeList" :visitorList="activeVisitors"/>
		<slider-box ref="sliderbox">
			<view class="slider-title PfScMedium">预约信息确认</view>
			<view class="members-box" v-if="needSelectMembers">
				<view class="desc">当前时段余号不足，只能预约2人</view>
				<view class="members">
					<view class="memmbers-item active">
						<img :src="cssUrl+'checkbox_false.svg'" alt="">
						<img :src="cssUrl+'checkbox_true.svg'" alt="">
						上官子涵
					</view>
					<view class="memmbers-item">
						<img :src="cssUrl+'checkbox_false.svg'" alt="">
						<img :src="cssUrl+'checkbox_true.svg'" alt="">
						帅哥
					</view>
					<view class="memmbers-item">
						<img :src="cssUrl+'checkbox_false.svg'" alt="">
						<img :src="cssUrl+'checkbox_true.svg'" alt="">
						发财哥
					</view>
					<view class="memmbers-item">
						<img :src="cssUrl+'checkbox_false.svg'" alt="">
						<img :src="cssUrl+'checkbox_true.svg'" alt="">
						王富贵
					</view>
				</view>
			</view>
			<view class="item member-style" v-else>
				<view class="left">就诊人：</view>
				<view class="right over2 over5">①王鹏  ②张富贵  ③张杨明</view>
			</view>
			<view class="item">
				<view class="left">医生姓名：</view>
				<view class="right">李静</view>
			</view>
			<view class="item">
				<view class="left">就诊医院：</view>
				<view class="right over2 over5">广安门中医医院西单门诊部 中医科</view>
			</view>
			<view class="item">
				<view class="left">看诊时间：</view>
				<view class="right orange">2023.11.12 上午 9:30-10:30</view>
			</view>
			
			<view class="btns-box flex">
				<view class="btn cancel btn1" hover-class="hover" @click="closeConfirm">我再想想</view>
				<view class="primary btn btn1" hover-class="hover" @click="submitConfim">确认预约</view>
			</view>
		</slider-box>
	</view>
</template>

<script>
	import Book from '@/components/bookBox.vue';
	import SliderBox from '@/components/sliderBox.vue';
	export default {
		onLoad(op) {
			uni.setNavigationBarTitle({
				title:'李静医生预约就诊'
			})
		},
		data() {
			return {
				cssUrl:this.cssUrl,
				needSelectMembers:false,
				doctorId:false,
				RegistrationTimeList:[],
				hospitalId:false,
				hospital:false,
				activeVisitors:[]
			}
		},
		components:{
			Book,
			SliderBox
		},
		onShow() {
			var activeVisitors = uni.getStorageSync('active_visitors')
			if(!activeVisitors){
				this.$pop.modelShow('请先选择要预约的就诊人', '/pages/visitors/visitors?type=1')
				return
			}
			this.activeVisitors = JSON.parse(activeVisitors)
			this.hospitalId = uni.getStorageSync('hospital_id')
			this.hospital = uni.getStorageSync('hospital')
			if(!this.hospitalId && this.hospital) {
				this.$pop.modelShow('请先选择要预约的医院', '/pages/index/index')
				return
			}
			this.hospital = JSON.parse(this.hospital)
			this.doctorId = getApp().globalData.doctorId
			this.getAvailabletRegistrationTime()
		},
		methods: {
			tips(){
				uni.showToast({
					title:"成功预约8人",
					mask:true,
					image:this.cssUrl+'gou.svg'
				})
			},
			getAvailabletRegistrationTime() {
				this.$http.req('client/doctor/visit_hospital/days/'+this.hospitalId).then(data=>{
					if(data == -1) return
					data.days = [
						{
							date: "2024-04-16", type: 2, type_text: "上午出诊", weekday: "周一", 
							am: [
								{
									"start": "12:00",
									"end": "12:30",
									"bed_count": 0
								},
								{
									"start": "13:00",
									"end": "14:30",
									"bed_count": 2
								}
							], 
							pm: []
						},
						{
							date: "2024-04-17", type: 5, type_text: "未开放预约", weekday: "周二", am: [], pm: []
						},
						{
							date: "2024-04-18", type: 3, type_text: "全天出诊", weekday: "周三", am: [
								{
									"start": "12:00",
									"end": "12:30",
									"bed_count": 0
								},
								{
									"start": "13:00",
									"end": "14:30",
									"bed_count": 2
								}
							], pm: [
								{
									"start": "12:00",
									"end": "12:30",
									"bed_count": 0
								},
								{
									"start": "13:00",
									"end": "14:30",
									"bed_count": 8
								}
							]
						},
						{
							date: "2024-04-19", type: 4, type_text: "下午出诊", weekday: "周四", am: [], pm: [
								{
									"start": "12:00",
									"end": "12:30",
									"bed_count": 0
								},
								{
									"start": "13:00",
									"end": "14:30",
									"bed_count": 1
								}
							]
						},
						{
							date: "2024-04-20", type: 1, type_text: "全天休息", weekday: "周五", am: [], pm: []
						},
					]

					this.RegistrationTimeList = data.days
					if(this.RegistrationTimeList.length>0) this.$refs.book.dataInit(this.RegistrationTimeList[0])
				});
			},
			closeConfirm() {
				this.$refs.sliderbox.closeConfirm()
			},
			showConfirm(times) {
				console.log(times)
				this.$refs.sliderbox.showConfirm()
			},
			submitConfim(){
				uni.navigateTo({
					url:"/pages/index/index"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page-prebook{
		width: 100%;
		height: 100vh;
		overflow-y: auto;
		background: #F8F8F8;
		.title{
			margin-top: 24rpx;
			align-items: center;
			width: 100%;
			box-sizing: border-box;
			padding: 0 41rpx;
			line-height: 36rpx;
			font-size: 30rpx;
			color: #949699;
			img{
				width: 26rpx;
				height: 26rpx;
				margin-right: 15rpx;
			}
		}
		.slider-title{
			width: 100%;
			text-align: center;
			color: #000000;
			margin-top: 52rpx;
			line-height: 50rpx;
			height: 50rpx;
			font-size: 32rpx;
			letter-spacing: 2rpx;
		}
		.member-style{
			margin-top: 82rpx;
		}
		.item{
			display: flex;
			box-sizing: border-box;
			padding: 0 53rpx;
			min-height: 42rpx;
			line-height: 42rpx;
			font-size: 30rpx;
			margin-bottom: 24rpx;
			.left{
				width: 159rpx;
				flex-shrink: 0;
				color: #999999;
			}
			.right{
				flex-grow: 1;
				color: #242833;
				&.orange{
					color: #FD7100;
				}
			}
		}
		.item:last-of-type{
			margin-bottom: 62rpx;
		}
		.btns-box{
			justify-content: space-between;
			width: 750rpx;
			height: 124rpx;
			padding: 0 50rpx;
			box-sizing: border-box;
			align-items: center;
			background: #FFFFFF;
			margin-bottom: 17rpx;
			box-shadow: 0rpx -2rpx 6rpx 0rpx rgba(181,181,181,0.13);
			margin-top: 62rpx;
		}
		.members-box{
			margin-top: 52rpx;
			padding-left: 60rpx;
			width: 100%;
			box-sizing: border-box;
			.desc{
				height: 50rpx;
				font-size: 30rpx;
				color: #999999;
				line-height: 50rpx;
				letter-spacing: 1rpx;
				margin-bottom: 20rpx;
			}
			.members{
				width: 630rpx;
				min-height: 200rpx;
				max-height: 230rpx;
				overflow-y: auto;
				background: #F7F7F7;
				display: flex;
				justify-content: space-between;
				flex-wrap: wrap;
				padding: 32rpx 40rpx;
				box-sizing: border-box;
				font-size: 28rpx;
				color: #000000;
				line-height: 40rpx;
				margin-bottom: 52rpx;
				row-gap: 50rpx;
				.memmbers-item{
					width: 50%;
					overflow-y: auto;
					display: flex;
					flex-shrink: 0;
					align-items: center;
					word-break: break-all;
					img{
						width: 36rpx;
						height: 36rpx;
						margin-right: 26rpx;
					}
					img:first-of-type{
						display: block;
					}
					img:last-of-type{
						display: none;
					}
					&.active{
						img:first-of-type{
							display: none;
						}
						img:last-of-type{
							display: block;
						}
					}
				}
			}
		}
	}
</style>
