<template>
	<view class="content">
		<view class="bg"></view>
		<view class="cont">
			<view class="hos-box">
				<view class="left">
					<image :src="hospital.imgUrl" mode="aspectFit"></image>
				</view>
				<view class="right">
					<view class="hos-name-box">
						<view class="hos-name">
							{{hospital.hospitalName}}
						</view>
					</view>
					<view class="hos-desc-box">
						{{hospital.hospitalType}}
					</view>
					<view class="hos-address-box" @click="goMap()">
						<view class="address-left">
							<view class="address one-t">{{hospital.address}}</view>
						</view>
						<view class="address-right">
							<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_arrow_r.png"></image>
						</view>
					</view>
				</view>
				
			</view>
			<view class="desc-box">
				<view class="title-box">
					<view class="line"></view>
					<view class="title">医院介绍</view>
				</view>
				<view class="desc" >
					{{hospital.descs}}
				</view>
			</view>
			<view class="doctor-box">
				<view class="title-box">
					<view class="line"></view>
					<view class="title">医院专家</view>
				</view>
				<view class="doctors" v-if="doctors.length>0">
					<view class="doctor" @click="navTo('/pages/doctor/doctorDetails?doctorId='+item.doctorId)" v-for="(item,index) in doctors">
						<view class="item">
							<image mode="aspectFill" class="doc-img" :src="item.avatar" ></image>
							<view class="right"> 
								<view class="doc-box">
									<view class="doc-name">
										{{item.doctorName}}
									</view>
									<view class="doc-position">{{item.position}}</view>
								</view>
								<view class="hospital">
									{{item.hospitalName}} {{item.deptName}}
								</view>
								<view class="doc-spec">
									<view class="title">擅长:</view>
									<view class="spec ellipsis">{{item.speciality}}</view>
								</view>
								<view class="doc-ping">
									<view class="ping">好评率:{{item.pingStar}}%</view>
									<view class="count">咨询量:{{item.orderNumber}}</view>
								</view>
								<view class="doc-price">
									<view class="left">￥
										<text v-for="(price,index) in item.prices">
											{{price.price.toFixed(2)}} <text v-if="index==0">/</text>
										</text>
									</view>
									<view class="btns">
										<view class="btn">
											咨询医生
										</view>
									</view>
								</view>
							</view>
							
						</view>
						
					</view>
				</view>
				 
			</view>
		</view>
	</view>
</template>
<script>
	import {getHospitalById} from '@/api/hospital.js'
	import {getDoctorList} from '@/api/doctor.js'
	export default {
		data() {
			return {
				hospitalId:null,
				hospital:null,
				doctors:[]
			}
		},
		onLoad(options) {
			this.hospitalId=options.hospitalId;
			this.getHospitalById();
			this.getDoctorList();
		},
		methods: {
			goMap(){
				uni.openLocation({
					latitude: parseFloat(this.hospital.lat),
					longitude: parseFloat(this.hospital.lng),
					scale:18,
					name:this.hospital.hospitalName,
					address:this.hospital.address,
					success:()=> {
						console.log('导航success');
					}
				});
			},
			getHospitalById() {
				//联网加载数据
				var that = this;
				var data = {
					hospitalId: this.hospitalId
				};
				getHospitalById(data).then(res => {
					if(res.code==200){
						this.hospital=res.data;
					}else{
						uni.showToast({
							icon:'none',
							title: "请求失败",
						});
					}
				});
			},
			getDoctorList() {
				//联网加载数据
				var that = this;
				var data = {
					hospitalId: this.hospitalId,
					pageNum: 1,
					pageSize: 10
				};
				getDoctorList(data).then(res => {
					if(res.code==200){
						res.data.list.forEach(function(value,index,array){
							value.prices=JSON.parse(value.priceJson)
						});
						this.doctors=res.data.list;
					}else{
						uni.showToast({
							icon:'none',
							title: "请求失败",
						});
					}
				});
			},
			navTo(url){
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>
<style scoped lang="scss">
	.content{
		height: 100%;
		position: relative;
		.bg{
			width: 100%;
			height:280rpx;
			background-color: #2583EB;
			background: linear-gradient(#2583EB, #2EDAD4);
			border-radius: 0rpx 0rpx 100rpx 100rpx;
			position: fixed;
			// z-index: 1;
		}
		.cont{
			top:50rpx;
			position: relative;
			padding: 0rpx 20rpx;
			z-index: 999;
			width: 100%;
			display: flex;
			flex-direction: column;
			.hos-box{
				margin-bottom: 20rpx;
				padding: 30rpx;
				box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
				background-color: #fff;
				border-radius: 15rpx;
				display: flex;
				align-items: center;
				justify-content: flex-start;
				.left{
					width: 190upx;
					height: 190upx;
					border-radius: 8upx;
					image{
						width: 190upx;
						height: 190upx;
					}
				}
				.right{
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					margin-left: 20rpx;
					height:190upx;
					width: calc(100% - 210rpx);
					.hos-name-box{
						display: flex;
						align-items: center;
						justify-content: flex-start;
						.hos-name{
							font-size: 32rpx;
							font-weight: bold;
						}
					}
					.hos-desc-box{
						display: flex;
						align-items: center;
						justify-content: flex-start;
						font-size: 28upx;
						font-family: PingFang SC;
						color: #2d2b36;
						 
					}
					.hos-address-box{
						display: flex;
						align-items: center;
						justify-content: flex-start;
					 
						.address-left{
							width: calc(100% - 30rpx);
							display: flex;
							align-items: center;
							justify-content: flex-start;
							.address{
								font-size: 28upx;
								font-family: PingFang SC;
								color: #9a9a9c;
							}
						}
						.address-right{
							image{
								width: 30upx;
								height: 30upx;
							}
							
						}
						
					}
				}
				
			}
			.desc-box{
				margin-bottom: 20rpx;
				padding: 15rpx;
				box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
				background-color: #fff;
				border-radius: 15rpx;
				.title-box{
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: flex-start;
					.title{
						font-size: 32upx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #111111;
					}
					.line{
						margin-right: 15rpx;
						height: 30rpx;
						width: 6rpx;
						background-color: #2583EB;
						
					}
					 
				}
				.desc{
					margin-top: 15rpx;
					font-size: 28upx;
					font-family: PingFang SC;
					color: #111;
				}
			}
			.doctor-box{
				margin-bottom: 20rpx;
				padding: 15rpx;
				box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
				background-color: #fff;
				border-radius: 15rpx;
				.title-box{
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: flex-start;
					.title{
						font-size: 32upx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #111111;
					}
					.line{
						margin-right: 15rpx;
						height: 30rpx;
						width: 6rpx;
						background-color: #2583EB;
						
					}
					 
				}
				.doctors{
					margin-top: 15rpx;
					width: 100%;
					padding: 20rpx 0rpx;
					box-sizing: border-box;
					display: flex;
					flex-direction: column;
					align-items: flex-start;
					justify-content: flex-start;
					.doctor{
						width: 100%;
						margin-bottom: 15rpx;
						background: #f9f8fe;
						padding: 15rpx;
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						justify-content: flex-start;
						&:last-child{
							margin-bottom: 0rpx;
						}
						.item{
							width: 100%;
							display: flex;
							align-items: flex-start;
							justify-content: flex-start;
							.doc-img{
								width:80rpx;
								height:80rpx;
								border-radius: 50%;
							}
							.right{
								width: calc(100% - 100rpx); 
								margin-left: 20rpx;
								display: flex;
								flex-direction: column;
								align-items: flex-start;
								justify-content: flex-start;
								.doc-box{
									display: flex;
									align-items: center;
									justify-content: space-between;
									.doc-name{
										font-size: 28upx;
										font-family: PingFang SC;
										font-weight: bold;
										color: #111111;
										
									}
									.doc-position{
										margin-left: 50rpx;
										font-size: 26upx;
										font-family: PingFang SC;
										color: #2d2b36;
									}
								}
								.hospital{
									margin-top: 10rpx;
									font-size: 24upx;
									font-family: PingFang SC;
									color: #9a9a9c;
								}
								.doc-spec{
									width: 100%;
									display: flex;
									align-items: center;
									justify-content: flex-start;
									margin-top: 15rpx;
									.title{
										min-width: 55rpx;
										font-size: 24upx;
										font-family: PingFang SC;
										color: #2d2b36;
									}
									.spec{
										margin-left: 10rpx;
										font-size: 24upx;
										font-family: PingFang SC;
										color: #9a9a9c;
									}
								}
								.doc-ping{
									margin-top: 15rpx;
									display: flex;
									align-items: center;
									justify-content: flex-start;
									.ping{
										font-size: 24upx;
										font-family: PingFang SC;
										color: #2d2b36;
									}
									.count{
										margin-left: 10rpx;
										font-size: 24upx;
										font-family: PingFang SC;
										color: #9a9a9c;
									}
								}
								.doc-price{
									width: 100%;
									margin-top: 15rpx;
									display: flex;
									align-items: center;
									justify-content: space-between;
									.left{
										flex: 1;
										font-size: 32upx;
										font-family: PingFang SC;
										color: #2583EB;
									}
									.btns{
										margin-right: 10rpx;
										.btn{
											display: flex;
											align-items: center;
											justify-content: center;
											border: 2rpx solid #2583EB;
											padding: 15rpx 30rpx;
											border-radius: 30rpx;
											font-size: 24upx;
											font-family: PingFang SC;
											color: #2583EB;
										}
										
									
									}
								}
								
							}
						}
						
					}
					
				}
				 
			}
		}
	}
	 
</style>
