<template>
	<view class="patientInfo-wrap">
		<uni-list>
			<uni-list-item title="姓名" :rightText="info.name"></uni-list-item>
			<uni-list-item title="手机号" :rightText="info.phone"></uni-list-item>
			<uni-list-item title="检测时间" :rightText="info.createTime"></uni-list-item>
			<uni-list-item title="heartTime" :rightText="info.heartTime|formateRightText"></uni-list-item>
			<uni-list-item title="hzTime" :rightText="info.hzTime|formateRightText"></uni-list-item>
			<uni-list-item title="medicalHistory" :rightText="info.medicalHistory"></uni-list-item>
			<uni-list-item title="xtTime" :rightText="info.xtTime|formateRightText"></uni-list-item>
			<uni-list-item title="xyTime" :rightText="info.xyTime|formateRightText"></uni-list-item>
			<uni-list-item title="ypTime" :rightText="info.ypTime|formateRightText"></uni-list-item>			
			<uni-list-item title="其他信息" :rightText="info.otherInfo"></uni-list-item>
		</uni-list>
		<button class="chat-bt" @click="showDrawer" type="primary" size="mini">聊天</button>
		<uni-drawer ref="showRight" mode="right" :mask-click="true">
			<view class="user-wrap">
				<uni-list>
					<uni-list-item 
					 v-for="(item,index) in doctorList"
					 :key="index" @click="linkUser(item)"
					 :title="item.doctorTitle" 
					:rightText="item.name" clickable>
					</uni-list-item>
				</uni-list>
			</view>
		</uni-drawer>		
	</view>
</template>

<script>
	import {parseTime} from'@/libs';
	import {getDetailByIdApi} from '@/api/patient';
	import {getListAll} from '@/api/doctor.js';
	export default {
		filters:{
			formateRightText(value){
				if(value){
					if(typeof(value)==="number"){
						value=value.toString();
					}
				}else{value="未填写"}
				return value;
			}
		},
		data() {
			return {
				info:{},
				doctorList:[]
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init(){
				let patientInfo=uni.getStorageSync('patientInfo');
				let id=patientInfo.id;
				getDetailByIdApi(id).then((res)=>{
					this.info=res.data;
				})
				getListAll().then((res)=>{
					this.doctorList=res.data;
				})
			},
			linkUser(item){
				uni.setStorageSync('chat-info',item);
				uni.navigateTo({
					url:'/pages/chatconnect/chatconnect?id='+item.userId
				})
			},
			showDrawer() {
				this.$refs.showRight.open();
			},
			closeDrawer() {
				this.$refs.showRight.close();
			}			
		}
	}
</script>

<style>
.chat-bt{
	position: fixed;
	top: 200px;
	right: 10px;
	z-index: 9;
}
.user-wrap{
	height: 100%;
	overflow-y: auto;
}
</style>
