<script setup>
	/**
	 * name：
	 * user：selectDoctor
	 * date：2024年9月24日 16:24:50
	 */
	import {
		ref
	} from 'vue'
	import {
		$api,
		$response,
		$image
	} from '@/api'
	import {
		onShow
	} from '@dcloudio/uni-app'
	import {
		useStore
	} from '@/store'
	const $store = useStore()
	let dqDate = ref('')
	let yytjInfo = ref({}); // 预约信息
	const $props = defineProps({
		date: {
			type: String,
			default: "",
		},
	});

	const mountedAction = () => {
		uni.showLoading({
			title: "加载中",
		});
		yytjInfo.value = $store.getYytjInfo();
		dqDate.value = $props.date ? $props.date : '2024-08-01';
		if (dqDate.value) {
			getdoctorList(); // 获取医生列表
		}
	}
	const doctor_list = ref(false)

	const getdoctorList = async () => {
		// 获取 体检报告列表 
		console.log($store, 'store')
		let obj = {
			"date": dqDate.value
		};
		const response = await $api("DoctorGetList", obj);
		$response(response, () => {
			console.log(response, 'response')
			doctor_list.value = response.data.list;
			uni.hideLoading();
		});
	};
	const config_ref = ref(null)
	const configRef = (e) => {
		if (!config_ref.value) {
			config_ref.value = e
			mountedAction()
		}
	}
	const clickDoctor = (item) => {
		yytjInfo.value.doctor_name = item.name;
		$store.setYytjInfo(yytjInfo.value);
		// 关闭当前页面携带医生名称返回上一个，，并且携带item.name 
		uni.navigateBack({
			delta: 1
		});

	}

	onShow(() => {
		if (!!config_ref.value) {
			mountedAction()
		}
	})
</script>
<template>
	<view>
		<view v-if="!!$store.config">
			<view :ref="configRef"></view>
		</view>
		<view class=" pb-40rpx">
			<view class="h-38rpx bg-#239EA3 pl-20rpx pr-20rpx   box-border">
				<view style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.04);"
					class="pb-80rpx pt-30rpx  rounded-15rpx  bg-#fff">
					<view v-for="(item,index) in doctor_list" :key="index" class="p-10rpx ">
						<view class="flex flex-row text-#8B8B8B text-23rpx  ">
							<image :src="$image(item.head_img)" class="w-170rpx h-226rpx  mr-20rpx "></image>

							<view class="flex-1 flex flex-col flex-justify-start pr-20rpx">
								<view class="text-#0E0E0E text-36rpx">
									{{item.name}}
									<span class="text-26rpx text-#515151 ml-10rpx">{{item.level}}</span>
								</view>
								<view class="mt-33rpx mb-10rpx line-clamp-1">
									{{item.hospital}}:
									<span class="ml-11rpx ">{{item.time}}</span>
								</view>
								<view class="line-clamp-2">
									{{item.desc}}
								</view>
								<view @click="clickDoctor(item)"
									class="ml-a mt-25rpx w-190rpx h-55rpx bg-#239EA3 rounded-33rpx text-#fff text-21rpx  flex  flex-justify-center items-center">
									预约此医生 </view>
							</view>

						</view>
						<view class="w-100% h-1rpx bg-#E6E9E9 mt-15rpx" />

					</view>


				</view>
			</view>
		</view>
	</view>
</template>
<style scoped>


</style>