<template>
	<view class="container safe-area-inset-bottom">
		<MessageNotification />
		<!-- 个人介绍 -->
		<view class="card">
			<view class="card_left">
				<view class="name">
					{{doctorList.name}}
				</view>
				<view class="position">
					{{doctorList.title}}  &nbsp; {{doctorList.depart}}
				</view>
				<view class="yard">
					{{doctorList.store}}
				</view>
			</view>
			<image :src="doctorList.avator || '/static/mine/avatar_1.png'" mode=""></image>
		</view>

		<!-- 擅长疾病 -->
		<view class="person">
			<view class="title">
				<text class="iconfont icon-jieshao"></text>
				<text>擅长疾病</text>
			</view>
			<view class="content">
				{{doctorList.good_at || '暂无数据'}}
			</view>
		</view>

		<!-- 个人简介 -->
		<view class="person">
			<view class="title">
				<text class="iconfont icon-jieshao"></text>
				<text>个人简介</text>
			</view>
			<view class="content">
				{{doctorList.intro || '暂无数据'}}
			</view>
		</view>

		<!-- 荣誉著作 -->
		<view class="person">
			<view class="title">
				<text class="iconfont icon-jieshao"></text>
				<text>荣誉著作</text>
			</view>
			<view class="content">
				{{doctorList.intro || '暂无数据'}}
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
import { doctorDetail } from '../../request/api/api'
import { isGuestMode } from '@/common/utils/auth.js';
	export default {
		data() {
			return {
				doctorID: "", // 医生id
				doctorList: {}, // 医生列表
			}
		},
		onLoad(e) {
			// console.log(e,'e');
			this.doctorID = e.id
		},
		methods: {
			// 医生详情
			getDocdetail() {
				doctorDetail({
					method: "post",
					data: {
						doctor_id: this.doctorID,
						store_id: uni.getStorageSync('store_id') || '11001',
					}
				}).then((res) => {
					// console.log(res, 'ress');
					const isGuest = isGuestMode();
					const isNewFormat = isGuest && (res.data.code === 0 || res.data.code === '0');
					const isOldFormat = !isGuest && (res.data.errcode === 0 || res.data.errcode === '0');

					if (isNewFormat || isOldFormat) {
						const responseData = isGuest && res.data.result ? res.data.result : res.data.data;
						this.doctorList = responseData;
						this.id = responseData.id;
						// console.log(this.doctorList, 'list');
					} else {
						const errorMsg = isGuest ? res.data.message : res.data.msg;
						this.$refs.uToast.show({
							title: errorMsg || '获取失败',
							type: 'default',
							icon: false
						})
					}
				})
			}

		},
		mounted() {
			this.getDocdetail()
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 750rpx;
		min-height: 100vh;
		max-height: 100%;
		padding-bottom: env(safe-area-inset-bottom);

		.card {
			width: 750rpx;
			height: 224rpx;
			display: flex;
			justify-content: space-between;
			padding: 0 36rpx;
			align-items: center;

			.card_left {
				width: 400rpx;
				height: 152rpx;
				display: flex;
				flex-direction: column;

				.name {
					height: 56rpx;
					font-size: 40rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #232323;
				}

				.position {
					height: 40rpx;
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
					margin: 16rpx 0;
				}

				.yard {
					height: 40rpx;
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
				}
			}

			image {
				width: 160rpx;
				height: 160rpx;
				border-radius: 50%;
				vertical-align: middle;
			}
		}

		.person {
			width: 750rpx;
			padding: 32rpx;

			.title {
				margin-bottom: 16rpx;

				.iconfont {
					color: #2979FF;
				}

				text {
					height: 44rpx;
					font-size: 32rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #232323;
					margin: 0 16rpx 0 0;
				}
			}

			.content {
				width: 686rpx;
				font-size: 32rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #232323;
				line-height: 46rpx;
			}
		}
	}
</style>
