<template>
	<view class="ctime_main">
		<view class="zhouli">
			<WeeklyCalendar v-if="weekList" :dataInfo="weekList" :selectedTime="selectedTime"
				@selectDate="selectDateFunc" @selectTime="selectTimeFunc" />
		</view>
		<view class="dateitem" v-if="orderInfo">
			<view
				style="background-color: #f7f7f7; padding: 20rpx; font-size: 30rpx; border-radius: 20rpx;color: #333;">
				<view>{{orderInfo.name}}</view>
				<view
					style="background-color: #f1f1f1;padding: 20rpx 30rpx; margin-top: 10rpx;border-radius: 14rpx;font-size: 28rpx;">
					<view v-if=" orderInfo.buy_info.nmr_list && orderInfo.buy_info.nmr_list.length>0">
						<view v-for="(item1,index1) in orderInfo.buy_info.nmr_list">
							{{item1.name}}
						</view>
					</view>
					<view style="margin-top: 10rpx;">体检日期</view>
				</view>

			</view>
		</view>
		<view class="pb-100rpx">
			<view  
				class="text-#fff text-32rpx rounded-45rpx bg-#239EA3 mt-40rpx ma w-520rpx h-90rpx flex flex-items-center flex-justify-center">
				确定
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {
		$image,
		$api,
		$response
	} from "@/api";
	import {
		onShow
	} from "@dcloudio/uni-app";
	import WeeklyCalendar from '@/common/WeeklyCalendar.vue';
	let weekList = ref(null);
	const GetDayPlanListFunc = async () => {
		uni.showLoading();
		let data = {
			hospital: orderInfo.value.hospital_id,
			person_id: orderInfo.value.person_id,
			date: selectedDate.value,
			use_type: orderInfo.value.type,
			checkup_type_id: orderInfo.value.checkup_type_id,
			amount: orderInfo.value.true_price,
		}
		const response = await $api("GetDayPlanList", data);
		uni.hideLoading();
		$response(response, () => {
			weekList.value = response.data
		});
	};
	let selectedTime = ref(null);
	let orderInfo = ref(null)
	const GetOrderInfo = async () => {
		uni.showLoading();
		const response = await $api("GetOrderDetail", {
			id: 38
		});
		uni.hideLoading();
		$response(response, () => {
			orderInfo.value = response.data.info
			selectedTime.value = orderInfo.value.appointment_time
			selectedDate.value = orderInfo.value.appointment_date
			GetDayPlanListFunc()

		});
	}

	//weekly子组件点击了日期
	let selectedDate = ref(null);
	const selectDateFunc = (date) => {
		selectedDate.value = date
		GetDayPlanListFunc();
	}
	//weekly子组件点击了时间
	let SelectedPlanId = ref(null)
	const selectTimeFunc = (timeinfo) => {
		selectedTime.value = timeinfo.time
		SelectedPlanId.value = timeinfo.id
	}
	onShow(() => {
		GetOrderInfo()
	});
</script>

<style scoped>
	.ctime_main {
		padding: 20rpx;
	}

	.zhouli {
		padding: 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
	}

	.dateitem {
		padding: 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
		margin-top: 20rpx;
	}
</style>