<template>
	<view class="page">
		<image class="bkg" :src="info.cover?info.cover.url:''"></image>
		<view class="cotainer">
			<view class="hospital">
				<view class="title">{{ info.name }}</view>
				<view class="tag">
					<view class="tag__item" v-if="info.level">{{ info.level }}</view>
					<view class="tag__item" v-if="info.type">{{ info.type }}</view>
				</view>
				<view class="description"> 对接科室{{info.serve_hospital_department_count}}个
					累计咨询量：{{info.serve_hospital_forms_count}} </view>
			</view>
			<view class="department">
				<view class="title">选择科室</view>
				<view class="department-list">
					<view class="department-list-item" :class="department_id==item.id?'department-list-active':''"
						@click="clickDepartment(item)" v-for="item in info.serve_hospital_department">
						<view class="title">
							{{item.name}}
						</view>
						<view class="description">
							累计咨询数量：{{item.serve_hospital_forms_count}}
						</view>
					</view>
				</view>
			</view>
			<u-button ripple shape="circle" :custom-style="orderBtnStyle" :throttle-time="2000"
				@click="goSubmit">下一步</u-button>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderBtnStyle: {
					'background-image': 'linear-gradient(-90deg, #e26165 0%, #c10d12 94%, #c10d12 100%)',
					'font-weight': '500',
					'font-size': '27rpx',
					'color': '#fff',
					'width': '440rpx',
					'height': '80rpx',
					'line-height': '80rpx'
				},
				id: '',
				info: {},
				department_id: '',
				department_name: ''

			};
		},
		mounted() {
			// if (this.$store.state.vuex_location !== 2) {
			// 	this.$store.dispatch('getLocation')
			// }
		},
		onLoad(options) {
			this.id = options.id ? options.id : ''

			this.getDetail()
		},
		methods: {
			async getDetail() {
				const res = await this.$u.api.serveHospitalDetail({
					id: this.id
				})
				this.info = res

			},
			clickDepartment(item) {
				this.department_id = item.id
				this.department_name = item.name
			},
			goSubmit() {
				if(!this.department_id){
					uni.showToast({
						title:'请先选择想要咨询的科室',
						icon:'none',
					})
					return
				}
				this.$u.route({
					url: '/package_sub/pages/ServeForm/ServeForm',
					params: {
						id: this.id,
						department_id: this.department_id,
					}
				})
			}

		},
		computed: {
			token() {
				return this.vuex_token || uni.getStorageSync('lifeData')?.vuex_token
			}
		}
	}
</script>

<style lang="scss">
	.page {
		position: relative;
		background-color: #f5efee;
		height: 100vh;
		padding-bottom: 80rpx;
	}

	.bkg {
		height: 540rpx;
		width: 100vw;
		position: absolute;
	}

	.cotainer {
		padding-top: 460rpx;
	}

	.hospital {
		background-color: #fff;
		border-radius: 10rpx;
		filter: drop-shadow(2.192rpx 4.494rpx 5rpx rgba(33, 32, 32, 0.15));
		// padding-top:460rpx;
		padding: 40rpx;
		margin: 25rpx;
		margin-top: 0;

		.title {
			font-size: 28rpx;
			color: #000000;
			font-weight: bold;
		}

		.tag {
			margin-top: 16rpx;
			display: flex;
			flex-wrap: wrap;

			&__item {
				padding: 5rpx 16rpx;
				font-size: 22rpx;
				line-height: 31rpx;
				font-weight: 500;

				&:nth-child(1) {
					color: #ca2328;
					background-color: #faefef;
				}

				&:nth-child(2) {
					color: #f38628;
					background-color: #fcf3e9;
				}
			}

			.tag__item+.tag__item {
				margin-left: 12rpx;
			}
		}

		.description {
			// max-width: 350rpx;
			width: 100%;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			font-size: 22rpx;
			color: #929196;
			font-weight: 500;
			margin-top: 16rpx;
		}
	}

	.department {
		background-color: #fff;
		border-radius: 10rpx;
		filter: drop-shadow(2.192rpx 4.494rpx 5rpx rgba(33, 32, 32, 0.15));
		// padding-top:460rpx;
		padding: 30rpx 40rpx;
		margin: 25rpx;
		margin-top: 0;
		margin-bottom: 50rpx;

		.title {
			font-size: 28rpx;
			color: #000000;
			font-weight: bold;
			margin-bottom: 30rpx;
		}

		.description {
			// max-width: 350rpx;
			width: 100%;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			font-size: 22rpx;
			color: #929196;
			font-weight: 500;

		}

		&-list {
			display: flex;
			align-items: flex-start;
			justify-content: space-between;
			flex-wrap: wrap;

			&-item {
				width: calc(50% - 15rpx);
				padding: 30rpx;
				padding-right: 10rpx;
				border: 2rpx solid rgba(33, 32, 32, 0.15);
				border-radius: 10rpx;
				margin-bottom: 30rpx;

				.title {
					margin-bottom: 25rpx;
				}
			}

			&-active {
				border: 2rpx solid transparent;
				background-image: url(@/package_sub/static/ServeHospital/active.png);
				background-repeat: no-repeat;
				background-size: 100% 100%;

			}
		}
	}
</style>