<template>
	<view class="app">
		<image src="../../static/pages/wenzhenbanner.png" mode="" class="banner"></image>
		<view class="card">
			<view class="topbar">
				<view class="item" @tap='goimagetextConsultation'>
					<image src="../../static/pagesB/tuwen.png" mode=""></image>
					<view class="text">
						图文问诊
					</view>
				</view>
				<view class="item" @tap='gomedicine'>
					<image src="../../static/pagesB/zhuanjia.png" mode=""></image>
					<view class="text">
						专家问诊
					</view>
				</view>
			</view>
			<view class="title">
				专家信息栏
			</view>
			<u-tabs :list="hospitalDepartmentList" :current="tabcurrent" @change="tabchange" active-color='#26A888'
				:show-bar='false'></u-tabs>
			<view class="list" v-if="HospitalPersonlist">
				<view class="item" @tap="godoctordetails" v-for="item in HospitalPersonlist">
					<image v-if="item.personPictureUrl" :src="baseurl+item.personPictureUrl" mode=""></image>
					<image v-else src="@/static/docHead.png" mode=""></image>
					<view class="name">
						{{item.personName}}
					</view>
					<view class="position">
						{{ item.academicTitle=='CHIEF_PHYSICIAN'?'主任医师':''}}
						{{ item.academicTitle=='DEPUTY_CHIEF_PHYSICIAN'?'副主任医师':''}}
						{{ item.academicTitle=='ATTENDING_DOCTOR'?'主治医师':''}}
						{{ item.academicTitle=='PHYSICIAN'?'医师':''}}
						{{ item.academicTitle=='HEALER'?'医士':''}}
						{{ item.academicTitle=='RESIDENT_PHYSICIAN'?'住院医师':''}}
					</view>
					<view class="text">
						{{item.personIntroduce}}
					</view>
				</view>
				<view style="width: 46%;" v-if="HospitalPersonlist.length%2!=0">
				</view>
				<view style="width: 46%;" v-if="HospitalPersonlist.length%2!=0">
				</view>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		selectDepartmentNoPage,
		selectHospitalPerson
	} from '@/api/pagesB/medicine/index.js'
	import baseurl from '../../api/baseurl';
	export default {
		data() {
			return {
				baseurl: '',
				region: '',
				tabcurrent: 0,
				pageNum: 1,
				pageSize: 10,
				departmentId: null,
				HospitalPersonlist: null,
				HospitalPersontotal: 0,
				hospitalDepartmentList: null,
			};
		},
		onLoad() {
			this.baseurl = baseurl
			this.info()
			this.selectDepartmentinfo();
		},
		methods: {
			info() {
				this.region = uni.getStorageSync('region')
				if (this.region == 3) {
					this.$refs.uToast.show({
						title: '当前地区不支持，请重新选择区域',
						type: 'error',
						duration: '2000',
					})
				}
			},
			//人员
			selectHospitalPersonInfo() {
				var status = '1'
				selectHospitalPerson(this.pageNum, this.pageSize, this.departmentId, status).then(res => {
					this.HospitalPersonlist = res.rows
					this.HospitalPersontotal = res.total
				})
			},
			//齐鲁名医科室
			selectDepartmentinfo() {
				selectDepartmentNoPage().then(res => {
					if (res.data.length > 0) {
						res.data.forEach(e => {
							e.name = e.departmentName
						})
						this.hospitalDepartmentList = res.data
						this.departmentId = this.hospitalDepartmentList[0].departmentId
						this.selectHospitalPersonInfo();
					}
				})
			},
			tabchange(e) {
				this.tabcurrent = e
				this.departmentId = this.hospitalDepartmentList[e].departmentId
				this.selectHospitalPersonInfo();
			},
			//专家问诊
			gomedicine() {
				uni.navigateTo({
					url: '/pagesB/medicine/medicine'
				})
			},
			//图文问诊
			goimagetextConsultation() {
				uni.navigateTo({
					url: '/pagesB/imagetextConsultation/imagetextConsultation'
				})
			},
			//医生详情
			// godoctordetails() {
			// 	uni.navigateTo({
			// 		url: '/pagesB/doctordetails/doctordetails'
			// 	})
			// },
		},
		onReachBottom() { //下滑加载
			if (this.HospitalPersonlist.length >= this.HospitalPersontotal) {} else {
				this.pageNum++
				getHeathHousingList(this.pageNum, this.pageSize).then(res => {
					if (res.rows) {
						res.rows.forEach(e => {
							this.HospitalPersonlist.push(e)
						})
					}
				})
			}
		},
		onPullDownRefresh() { //下拉刷新
			this.pageNum = 1;
			this.selectHospitalPersonInfo();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
	}
</script>

<style lang="scss">
	.app {

		.card {
			background-color: #fff;
			width: 94%;
			margin: 0 auto;
			padding-top: 35rpx;
			padding-bottom: 200rpx;
			border-radius: 0 0 10rpx 10rpx;

			.list {
				margin-top: 20rpx;
				width: 100%;
				display: flex;
				justify-content: space-around;
				flex-wrap: wrap;

				.item {
					width: 46%;
					height: 382rpx;
					background: #FFFFFF;
					border: 1px solid #26A888;
					border-radius: 10rpx;
					position: relative;

					image {
						position: absolute;
						width: 120rpx;
						top: 20rpx;
						left: 20rpx;
						height: 120rpx;
					}

					.name {
						position: absolute;
						top: 40rpx;
						left: 160rpx;
						font-size: 28rpx;
						font-weight: 400;
						color: #000000;
					}

					.position {
						position: absolute;
						top: 84rpx;
						left: 160rpx;
						font-size: 24rpx;
						color: #666666;
					}

					.text {
						word-break: break-all;
						width: 90%;
						margin: 170rpx auto 0;
						font-size: 22rpx;
						color: #666666;
						line-height: 33rpx;
						text-overflow: -o-ellipsis-lastline;
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp: 5; //行数需设置
						line-clamp: 5;
						-webkit-box-orient: vertical;
						text-align: justify;
					}
				}
			}

			::v-deep .u-tabs {
				padding-top: 30rpx;
			}

			.title {
				width: 94%;
				margin: 0 auto;
				border-bottom: 2rpx solid #CDC9C9;
				font-size: 34rpx;
				font-weight: 500;
				color: #000000;
				margin-top: 40rpx;
				padding-bottom: 30rpx;
			}

			.topbar {
				width: 100%;
				display: flex;
				justify-content: space-around;
				color: #fff;

				.item {
					width: 46%;
					height: 180rpx;
					background: #26A888;
					border-radius: 5rpx;
					position: relative;

					.text {
						position: absolute;
						top: 50%;
						left: 40%;
						transform: translateY(-50%);
						display: inline-block;
						font-size: 34rpx;
						font-weight: 500;
					}

					image {
						position: absolute;
						top: 50%;
						left: 20%;
						transform: translateY(-50%);
						width: 48rpx;
						height: 41rpx;
					}
				}

				.item:nth-child(2) {
					background: #FFA115;
				}
			}
		}

		.banner {
			display: block;
			width: 94%;
			height: 350rpx;
			margin: 20rpx auto 0;
		}
	}
</style>