<template>
	<!-- 首页 -->
	<view style="height: 0; width: 0; overflow: hidden;">
	<nav-bar id="navBar" ref="navBar" :navbar-data="navbarData" @handleReRender="onInit" @checkForNewMessage="checkForNewMessage" @handleChangeHosp="handleChangeHosp" />
	</view>
	<scroll-view class="new-home" scroll-y="true" :style="{ height: '100vh' }" @scroll="scrollPage">
		<!-- 顶部的背景，页面滚动时才显示背景色 -->
		<view class="header-bg" v-if="showScrollBg" :style="{ height: height + 'px', background: (showScrollBg ? '#308BDA' : 'transparent') }"></view>

		<!-- 背景图-->
		<view class="bg" :style="{top: -height +'px'}">
			<image class="img" :src="imgHost + '/images/icon/head-bg@2x.png'"></image>
		</view>

		<!--整个页面加背景图  :style="{ paddingTop: height + 'px' }"-->
		<view class="page-bg">
			<!-- 页头 -->
			<view class="head-content">
				<view class="head-search">
					<view class="head-search-input" @tap="handleGoFindDoctor">
						<view class="head-search-icon" :style="{ backgroundImage: 'url(' + imgHost + '/images/icon/search.png)' }"></view>
						<text class="head-search-text">搜索医生/科室</text>
					</view>
				</view>
			</view>

			<!-- 轮播图 -->
			<!-- <custom-swiper :imgUrls="carouselImgUrls" :autoplay="false" /> -->

			<!-- 医院详情 -->
			<view class="hospital-content" :class="{ 'small': !userData.hospID }">
				<button v-if="!userData.hospID" class="btn-select-hosp" @tap="notHospitalChooseHospital" data-type="noHospital" :data-page="{ 'routePath': '../../index/pages/switchHospital/switchHospital' }">请选择医院</button>
				<view v-else class="hospital-info">
					<view class="info-head">
						<text class="hosp-name">{{ userData && userData.hospDesc ? userData.hospDesc : '' }}</text>
						<!-- <view class="switch-hosp" @tap="trunByNavList" :data-page="{'routePath':'../../index/pages/switchHospital/switchHospital'}">
							<text>切换医院</text>
							<van-icon name="arrow" size="24rpx" color="#cccccc" />
						</view> -->
					</view>
					<view class="info-btm">
						<view class="logo-box">
							<view class="logo" :style="'background-image: url(' + (userData.logoUrl ? userData.logoUrl : imgHost +'/images/logo/logo1.png') +')'"></view>
							<!-- <view class="logo" :style="{'background-image': 'url('+ imgHost +'/images/icon/logo1.png);'}"></view> -->
						</view>
						<view class="info-btm-r">
							<view class="info-btm-rt">
								<view class="date">
									{{ userData.businessHoursInfo.indexOf("诊") > -1 ? '':'接诊时间：' }}{{ userData && userData.businessHoursInfo ? userData.businessHoursInfo : '' }}
								</view>
								<view class="date" v-if="userData && userData.emergBusTimeInfo">
									{{ userData && userData.emergBusTimeInfo ? userData.emergBusTimeInfo : '' }}
								</view>
								<view class="date" v-if="userData && userData.nightBusTimeInfo">
									{{ userData && userData.nightBusTimeInfo ? userData.nightBusTimeInfo : '' }}
								</view>
								<view class="addr">
									医院地址：{{ userData && userData.hospAddress ? userData.hospAddress : '' }}
								</view>
							</view>
							<view class="btn-box">
								<!-- <view class="btn btn-dh" @tap="onNavigationPhone" data-type="navigation">
									<image :src="imgHost + '/images/icon/icon-car.png'" mode="scaleToFill" />
									<text>导航</text>
								</view> -->
								<view class="btn btn-phone" @tap="onNavigationPhone" data-type="phone" :data-phone="userData && userData.telephone">
									<image :src="imgHost + '/images/icon/icon-phone.png'" mode="scaleToFill" />
									<text>电话</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>

			<view class="message" v-if="newMsgData && newMsgData[0] && newMsgData[0].isNewMsg !== 'N' ? true : false">
				<view class="message-icon"></view>
				<view class="message-text">消息提示：</view>
				<view class="message-text1">{{ newMsgData[0].text }}</view>
			</view>

			<!-- 看诊挂号 btn_registration.png btn_pay.png btn_consultation-->
			<view class="reg-content">
				<view @tap="turnGraphic" class="reg-content-img">
					<image :src="imgHost + '/images/icon/graphicIcon-background@2x.png?v=20260703'"></image>
					<view style="font-weight:600;font-size:30rpx;margin-left:20rpx">图文咨询预约</view>
				</view>
				<view @tap="turnVideo" class="reg-content-img">
					<image :src="imgHost + '/images/icon/videoIcon-background@2x.png?v=20260703'"></image>
					<view style="font-weight:600;font-size:30rpx;margin-left:20rpx">视频问诊预约</view>
				</view>
			</view>

			<!-- 导航 -->
			<view class="nav-show" v-if="navList && navList.length > 0">
				<view v-for="(item, index) in navList" :key="index" class="nav-show-content" @tap="trunByNavList"
					:data-page="item">
					<view class="nav-show-img">
						<image style="width:90rpx; height:90rpx" :src="item.icon" />
					</view>
					<view class="nav-show-text">
						<text style="font-weight:400">{{ item.name }}</text>
					</view>
				</view>
			</view>

			<!-- 挂号就诊卡 -->
			<view class="patcard">
				<view class="patcard-l">
					<!-- <view class="patcard-show" @tap="turnOutline">
						<view class="patcard-show-bg">
							<image :src="imgHost + '/images/icon/I want to register@2x.png'"></image>
						</view>
						<view class="patcard-show-font">
							<view class="patcard-show-text"><text>我要挂号</text></view>
							<view class="patcard-show-text1"><text>提前挂号不排队</text></view>
						</view>
					</view> -->
					<view class="patcard-show" @tap="turnOrder">
						<view class="patcard-show-bg">
							<image :src="imgHost + '/images/icon/img_v3_hlwjf.png'"></image>
						</view>
						<!-- <view class="patcard-show-font">
							<view class="patcard-show-text"><text>我要缴费</text></view>
							<view class="patcard-show-text1"><text>移动支付更省时</text></view>
						</view> -->
					</view>
				</view>

				<view class="patcard-r">
					<view class="pat-bg">
						<view class="pat-per">
							<view class="pat-bg-photo" :style="{ background: 'url(' + (userData && userData.patSexDesc === '男' ? genderMale : userData.patSexDesc === '女' ? genderFemale : unknownGender) + ') no-repeat', backgroundSize: '100% auto' }"></view>
							<view style="margin-left: 20rpx;">
								<view class="pat-bg-intr">
									<view class="font-text1" v-if="userData && userData.patDesc" style="font-size:32rpx">
										<text>{{ userData.patDesc || "" }}</text>
										<text style="margin-left:30rpx">{{ userData.patSexDesc || "" }}</text>
									</view>
								</view>
								<view class="font-text1" v-if="userData && userData.patDesc" style="font-size:26rpx">
									<text>{{ userData.hisPatNo || "" }}</text>
								</view>
							</view>
						</view>
						<view class="pat-btn">
							<view class="pat-bg-intr-switch" @tap="handleChangePat" :style="{ backgroundImage: 'url(' + imgHost + '/images/icon/switch-l@2x.png)' }">
								<text class="font-text2">{{ userData && userData.hisPatID ? "切换就诊人" : (patDataLen > 0 ? "选择就诊人" : " 添加就诊人") }}</text>
							</view>
							<!-- <view class="pat-bg-intr-switch" @tap="showImgPopup" v-if="userData && userData.hisPatID" :style="{ backgroundImage: 'url(' + imgHost + '/images/icon/switch-r@2x.png)' }">
								<text class="font-text2">出示就诊卡</text>
							</view> -->
						</view>
					</view>
				</view>
			</view>

			<!-- 健康讲堂  -->
			<view class="tell-content" v-if="false">
				<view class="tell-content-title">
					<view class="tell-content-title-left">
						<view class="tell-content-title-tip"></view>
						<text class="tell-content-title-text1">健康讲堂</text>
					</view>
					<view class="tell-content-title-right">
						<text class="tell-content-title-text2">更多</text>
						<van-icon name="arrow" size="30rpx" color="##333333" />
					</view>
				</view>
				<view class="tell-content-show" v-for="(item, index) in healthList" :key="index">
					<view class="tell-content-show-detail">
						<view class="tell-content-show-text1">{{ item.title }}</view>
						<view class="tell-content-show-per">
							<image style="width:36rpx;height:36rpx;border-radius: 18rpx;" :src="item.docImg"></image>
							<view class="tell-content-show-text2" style="margin-left:10rpx">{{ item.docName }}</view>
							<view class="tell-content-show-text2" style="margin-left:20rpx">{{ item.hosp }}</view>
						</view>
					</view>
					<view :style="{ background: 'url(' + item.showImg + ') no-repeat', width: 182 + 'rpx', height: 134 + 'rpx', backgroundSize: 'auto 100%' }">
					</view>
				</view>
			</view>

			<!-- 推荐医生 -->
			<view class="tell-content">
				<view class="tell-content-title">
					<view class="tell-content-title-left">
						<view class="tell-content-title-tip"></view>
						<text class="tell-content-title-text1">推荐医生</text>
					</view>
					<view class="tell-content-title-right" @tap="turnMoreDoctor">
						<text class="tell-content-title-text2">更多</text>
						<van-icon name="arrow" size="24rpx" color="#7f7f7f" />
					</view>
				</view>
				<view class="doc-content-list">
					<view v-for="(item, index) in recommendedDoctor" :key="index" class="doc-show-content"
						@tap="doctorDetail" :data-page="item">
						<view class="doc-info-box" :style="{ backgroundImage: 'url(' + item.image + ')' }">
							<view class="img-desc">
								<view class="doc-info">
									<text class="name">{{ item.doctorName }}</text>
									<text class="department">{{ item.locDesc }}</text>
								</view>
								<view class="num">接诊{{ item.totalNum }}次</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</scroll-view>
	
	<!-- 医院就诊人选择组件-->
	<hosp-pat-select ref="hosp_pat_select" @handleReRender="onInit" @upDateAdmData="upDateAdmData" @chooseHospital="chooseHospital" @isToAddCard="isToAddCard" />
	
	<!-- 就诊须知 -->
	<registration-notice id="registrationNotice" ref="registrationNotice" @topage="jumpTo($event, { tagId: 'registrationNotice' })" closeButtonText="我要挂号" />
	
	<!-- 就诊码 -->
	<adm-ewm id="admEwm" ref="admEwm"></adm-ewm>
	
	<!--出示就诊卡弹窗-->
	<!-- <van-popup :show="upImgShow" @close="onClose">
		<view class="qrcode-box">
			<view class="img-text" style="display:flex;align-items: center;justify-content: center;">
				<text>姓名：{{ userData.patDesc }}</text><text
					style="margin-left:40rpx">人员标识：{{ userData.hisPatNo }}</text>
			</view>
			<view style="display:flex;align-items: center;justify-content: center;">
				<canvas canvas-id="barcode" id="barcode" style="width:300px;height:70px;"></canvas>
			</view>
			<view style="padding:30rpx;display:flex;align-items: center;justify-content: center;margin-top:30rpx">
				<canvas canvas-id='canvas' id="canvas" style="width:200px;height:200px"></canvas>
			</view>
			<view class="img-text2">扫一扫上面的二维码图案，快速就诊</view>
		</view>
	</van-popup> -->
</template>

<script>
	import UQRCode from 'uqrcodejs';
	import drawBarcode from '@/utils/barcode.js';
	import GenerateTestUserSig from '@/debug/GenerateTestUserSig';
	import httpConfig from '@/utils/httpConfig';
	import Utils from '@/utils/utils';
	import $http from '@/utils/https';
	import {
		getHospList,
		checkChooseHosp,
		addOrSwitchPatient,
		dealHospData
	} from "@/utils/common";
	import hospPatSelect from '@/components/hospPatSelect/index.vue';
	import NavBar from '@/components/navBar/index.vue';
	import empty from '@/components/empty/index.vue';
	import customSwiper from '@/components/customSwiper/index.vue';
	import VanIcon from '@/components/icon/index.vue';
	import VanLoading from '@/components/loading/index.vue';
	import VanOverlay from '@/components/overlay/index.vue';
	import VanCellGroup from '@/components/cell-group/index.vue';
	import VanCell from '@/components/cell/index.vue';
	import VanPopup from '@/components/popup/index.vue';
	import RegistrationNotice from '@/components/registrationNotice/registrationNotice';
	import AdmEwm from '@/components/admEwm/admEwm';
	import { mapGetters } from 'vuex';
	// #ifdef MP-ALIPAY
	import monitor from '@/utils/alipayLogger.js';
	// #endif
	// #ifdef MP-WEIXIN
	import TIM from 'tim-wx-sdk';
	// import COS from "cos-wx-sdk-v5";
	// #endif
	// #ifdef H5
	import TIM from 'tim-js-sdk';
	// import COS from "cos-js-sdk-v5";
	// #endif
	import TIMUploadPlugin from "tim-upload-plugin";
	const app = getApp()
	const imgHost = httpConfig.imgHost
	const ipDeault = httpConfig.ipDeault
	let timer = null;
	let count = 30;
	export default {
		components: {
			'hosp-pat-select': hospPatSelect,
			'nav-bar': NavBar,
			'empty': empty,
			'custom-swiper': customSwiper,
			'van-icon': VanIcon,
			'van-loading': VanLoading,
			'van-overlay': VanOverlay,
			"van-cell-group": VanCellGroup,
			"van-cell": VanCell,
			"van-popup": VanPopup,
			"registration-notice": RegistrationNotice,
			"adm-ewm": AdmEwm
		},
		data() {
			return {
				pageLoading: true, // 页面加载loading
				showScrollBg: false, // 滚动时头部背景是否显示
				height: 0,
				imgHost: imgHost,
				windowHost: ipDeault,
				navbarData: {
					isIndex: true,
					isMonitorNewMessage: 'homeNoModalMsg',
					announcementData: [], // 公告数据
					background: 'transparent'
				},
				curImg: imgHost + "/images/icon/banner@2x.png",
				imageArr: [{
					key: 0,
					url: imgHost + "/images/icon/banner@2x.png"
				}, {
					key: 1,
					url: imgHost + "/images/icon/banner2@2x.png"
				}, {
					key: 2,
					url: imgHost + "/images/icon/banner3@2x.png"
				}],
				navList: [],
				outList: [],
				inList: [],
				imgsrc: '', //二维码图片
				upImgShow: false, //展开二维码
				menuData: [],
				genderMale: imgHost + "/images/icon/gender-male.png", // 男
				genderFemale: imgHost + "/images/icon/gender-female.png", // 女
				unknownGender: imgHost + "/images/icon/unknown-gender.png", // 未知性别
				recommendedDoctor: [], //推荐医生列表
				userData: {},
				newMsgData: [], //未读消息
				hospDataLen: 0,
				patDataLen: 0,
				carouselImgUrls: [
					imgHost + "/images/icon/banner@2x.png",
					imgHost + "/images/icon/banner2@2x.png",
					imgHost + "/images/icon/banner3@2x.png"
				],
				show: false,
				isAutoSwichHospital: false, // 是否切换医院
				hospVal: null, // 医院Code
				wechatVisible: false,
				videoAuths: [false, false],
				// 调用次数
				checkHospitalCount: 10,
				navList: '',
				isNewMsg: '',
				text: '',
				healthList: [],
				openCloseRegistrationNotice: false,
			}
		},
		onLoad: function(options) {
			console.log('onLoad')
			const _this = this
			const userData = this.$cache.get('userData')
			_this.setData({
				userData,
				height: app.globalData.height
			}, () => {
				console.log('onLoad userData ==== ', this.userData)
			})
			try {
				console.log("首页触发了onLoad");
				// #ifdef MP-ALIPAY
				!options && (options = {})
				options['q'] = app.globalData.alipayQuery
				// #endif
				_this.scanningCode(options)
			} catch (error) {
				uni.showToast({
					title: error.errMsg,
					icon: 'none',
				})
			}

			//支付宝差异处理
			//#ifdef MP-ALIPAY
			my.setNavigationBar({
				frontColor: "#ffffff",
				backgroundColor: '#000000',
				success(res) {
					console.log('setNavigationBar success', res)
				},
				fail(err) {
					console.log('setNavigationBar fail ', err)
				}
			})
			//#endif
		},
		onReady() {
			const self = this
			this.announcementList(); //公告数据
			this.zpSelectComponent('#hosp_pat_select')._init(); // 获取医院列表
			this.updateNavbarData();
			
			// 如果是第一次进入，且只有一家医院，获取医院后会自动切换到这家医院，但是页面没有刷新,这个时候需要强制属性一次
			// timer = setInterval(() => {
			// 	const refresh = this.$cache.get('refresh')
			// 	console.log(count, refresh)
			// 	if(count < 0) {
			// 		count = 30
			// 		clearInterval(timer)
			// 		return
			// 	} else {
			// 		if(refresh == 1) {
			// 			// self.onShowPub()
			// 			self.$forceUpdate()
			// 			self.$cache.remove('refresh')
			// 			clearInterval(timer)
			// 			return
			// 		}
			// 		count--
			// 	}
			// }, 1000)
			/* 正式发布时注释start */
			// this.$cache.set('userData',{"ipAddress":"125.71.65.150","hospID":"21","openID":"o8tnW5NzZByxweSecr3KW9chsZuc","pubAccCode":"PRYKZHYY","session_key":"CofMaEuFXTL4bwPCyXBYXQ==","hospDesc":"昆明普瑞眼科医院","hisHospID":"H05","hospAddress":"云南省昆明市五华区龙泉路29号","telephone":"0871-63111756","menuMode":"01","serviceCall":"0871-63111756","serviceCallTips":"服务电话：0871-63111756","insuType":"Y","bizType":"04107","cityCode":"530100","channel":"AAFOoYYlnvpKHDSM6yz_2ufX","orgChnlCrtfCodg":"BqK1kMStlhVDgN2uHf4EsLK/F2LjZPYJ81nK2eYQqxs1EmrYdMvYteJm/+diMwYR","orgCodg":"H53010200715","orgAppId":"1H1INA1L30OG3F60C80A0000DEE43558","sourceapp":"wx46ebcca90d33ba63-1","insuTestFlag":"Y","idCardNo":"500225198710113839","imUserID":"patient67051","patDesc":"陈建华","patID":"616","hisPatNo":"0000066959","hisPatID":"67051","mobile":"18964879268","patValue":"","patSexDesc":"男","medCardID":""})
			/* 正式发布时注释end */
		},
		onShow: function() {
			const self = this
			console.log('onShow')
			const refresh = this.$cache.get('refresh')
			if (app.globalData.isUpdatePatList) { // 更新就诊人列表
				this.zpSelectComponent('#hosp_pat_select').getAdmSelectData(); //子组件的方法->获取就诊人下拉数据
			}
			// 如果storage发生了变化则更新
			let userData = this.userData;
			let newData = this.$cache.get('userData');
			if (newData && newData.mobile) {
				newData.mobile = (newData.mobile && newData.mobile.length === 11) ? Utils.phoneAddGap(Utils.removeSpacesFromString(newData.mobile)) : (userData && userData.mobile ? userData.mobile : "");
			}
			app.globalData.reservationEntrance = "";
			if (userData && newData && userData.imUserID && newData.imUserID && (userData.imUserID !== newData.imUserID) || refresh == 1) {
				console.log('刷新页面数据 ====')
				app.globalData.isLtogOut = false;
				this.onShowPub()
				this.zpSelectComponent('#hosp_pat_select') && this.zpSelectComponent('#hosp_pat_select').getAdmSelectData() // 获取就诊人下拉数据
				this.$cache.remove('refresh')
			} else if (newData && newData.imUserID) {
				this.setData({
					userData: newData
				}, () => {
					this.checkForNewMessage() // 查询病人是否有新消息
					// 关联公众号
					// this.handleAssociatedOfficialAccount();
				})
			}  else {
				// 关联公众号
				// this.handleAssociatedOfficialAccount();
			}
		},
		onHide() {
		    this.zpSelectComponent('#registrationNotice').reset() // 弹出就诊须知
		},
		watch: {
		},
		methods: {
			onShowPub() {
			    app.globalData.isLtogOut = false;
			    let obj = {
			      detail: {
			        type: "selectAdm"
			      }
			    }
			    this.initPage(obj); // 刷新页面数据
			},
			
			// 初始化页面数据
			initPage(options) {
				return new Promise((resolve, reject) => {
					// #ifdef MP
					let { navbarData, userData, hospDataLen, patDataLen } =  this.data
					//#endif;
					// #ifdef H5
					let { navbarData, userData, hospDataLen, patDataLen } =  this
					//#endif;
					let newUserData = this.$cache.get('userData');
					const newApp = getApp();
					const type = (options.detail && options.detail.type) || ''
					if (newUserData && newUserData.mobile) {
					  newUserData.mobile = (newUserData.mobile && newUserData.mobile.length === 11) ? Utils.phoneAddGap(Utils.removeSpacesFromString(newUserData.mobile)) : (userData && (userData.mobile || ""));
					}
					navbarData.patName = newUserData.patDesc;
					hospDataLen = options && options.detail && (options.detail.hospDataLen || options.detail.hospDataLen === 0) ? options.detail.hospDataLen : hospDataLen;
					patDataLen = options && options.detail && (options.detail.patDataLen || options.detail.patDataLen === 0) ? options.detail.patDataLen : patDataLen;
					this.setData({
					  userData: newUserData,
					  navbarData,
					  newMsgData: [],
					  hospDataLen,
					  patDataLen
					}, () => {
						//#ifdef MP-WEIXIN
						// 有默认就诊人时，通知绑定 + openID，调用03
						if (newUserData && newUserData.patID) addOrSwitchPatient(this, newUserData.patID)
						//#endif
					  
						if(newUserData.hospID) {
							this.zpSelectComponent("#navBar").upDateUserData(); // 更新userData    重新刷新医院描述
							this.getMenuDate(); // 获取菜单数据
							this.getRecommendedDoctor(); // 获取医生数据
							this.checkForNewMessage(); // 查询病人是否有新消息
						}
						
						// 如果是切换了医院或者就诊人需跟新相应组件数据
						if (type && (type === 'selectAdm' || type === 'selectHosp')) {
							this.updateNavbarData().then(res => {
								resolve()
							})
						}
			
						// 咨询信息
						console.log('咨询信息1 == ', newUserData, newUserData.imUserID, newApp.globalData)
						if (newUserData && newUserData.imUserID) {
							console.log('咨询信息2 == ', newApp.globalData.initTim, newApp.globalData.tim, newApp.globalData.SDKAPPID)
							if (!newApp.globalData.initTim && newApp.globalData.SDKAPPID) { // 判断是否已经初始化
								this.initRoom(newUserData.imUserID);
								return;
							}
							console.log('咨询信息3 == ', options, options.type)
							if (options && options.type) {
								if (type === 'selectAdm' && newApp.globalData.SDKAPPID) {
									this.drawImage();
									console.log("app.globalData.isLogOut1", newApp.globalData.isLogOut)
									if (!newApp.globalData.isLogOut) { // 判断是否以及退出，已经退出则不需要退出再登录，而是直接登录
										this.login(newUserData.imUserID)
									} else {
										this.signOut('signOut', newUserData.imUserID)
									}
								} else {
									console.log("app.globalData.isLogOut2", newApp.globalData.isLogOut)
									if (!newApp.globalData.isLogOut) { // 判断是否以及退出，已经退出则不需要退出
										return;
									}
									this.signOut()
								}
							}
						} else {
							if (!app.globalData.initTim && newApp.globalData.SDKAPPID) { // 判断是否已经初始化
								this.initRoom();
							}
						}
				
						// 关联公众号
						// this.handleAssociatedOfficialAccount();
					})
				})
			},
			
			onPrivacyAgree(e, _dataset) {
			    /* ---处理dataset begin--- */
			    this.handleDataset(e, _dataset);
			    /* ---处理dataset end--- */
			    // 用户点击同意按钮后
			    this.resolvePrivacyAuthorization(e.detail);
			},
			
			showPopup() {
				this.setData({
					show: true
				})
			},
			closePopup() {
				this.setData({
					show: false
				})
			},
			
			// 扫二维码进入参数处理
			scanningCode(options) {
				console.log(options)
				let qrCodeUrl = options.q
				console.log('qrCodeUrl', qrCodeUrl)
				if (qrCodeUrl) {
					let parString = decodeURIComponent(qrCodeUrl) + "";
					let hospID = parString.split("^")[1];
					// options['type'] = 'selectHosp'
					let userData = this.$cache.get('userData');
					this.$cache.set('userData', {
						...userData,
						hospID: hospID,
					})
					this.setData({
						isAutoSwichHospital: true,
						hospVal: hospID
					})
				}
				this.onInit(options).then(res => {
					if (qrCodeUrl) {
						options.q = ''
						//#ifdef MP-ALIPAY
						// 支付宝处理 重置globalData参数alipayQuery的数据
						Utils.resetGlobalDataParams(app, ['alipayQuery'])
						//#endif
					}
				})
			},

			onInit(options) {
				console.log('重新初始化参数', options)
				return new Promise((resolve, reject) => {
					// #ifdef MP
					let { navbarData, userData, hospDataLen, patDataLen } =  this.data
					//#endif;
					// #ifdef H5
					let { navbarData, userData, hospDataLen, patDataLen } =  this
					//#endif;
					const newApp = getApp();
					const allHospitalData = this.$cache.get('allHospitalData');
					let newUserData = this.$cache.get('userData');
					const type = (options && options.detail && options.detail.type) || '';
					if (newUserData && newUserData.mobile) {
						newUserData.mobile = (newUserData.mobile && newUserData.mobile.length === 11) ? Utils.phoneAddGap(Utils.removeSpacesFromString(newUserData.mobile)) : (userData && (userData.mobile || ""));
					}
					navbarData.patName = newUserData.patDesc;
					// navbarData.title = newUserData && newUserData.hospDesc ? newUserData.hospDesc : "首页";
					hospDataLen = allHospitalData ? allHospitalData.length : hospDataLen;
					this.setData({
						userData: newUserData,
						navbarData,
						newMsgData: [],
						hospDataLen: allHospitalData
					}, () => {
						console.log('onload compelete')
						//#ifdef MP-WEIXIN
						// 有默认就诊人时，通知绑定 + openID，调用03
						if (newUserData && newUserData.patID) addOrSwitchPatient(this, newUserData.patID)
						//#endif
						
						newUserData.hospID && this.getRecommendedDoctor(); // 获取医生数据
						newUserData.hospID && this.getMenuDate();
						newUserData.hospID && this.zpSelectComponent('#hosp_pat_select').getAdmSelectData() // 获取就诊人下拉数据;
						this.checkForNewMessage(); // 查询病人是否有新消息

						// 如果是切换了医院或者就诊人需跟新相应组件数据
						if (type && (type === 'selectAdm' || type === 'selectHosp')) {
							this.updateNavbarData().then(res => {
								resolve()
							})
						}
						
						// 咨询信息
						console.log('咨询信息1 == ', newUserData, newUserData.imUserID, newApp.globalData)
						if (newUserData && newUserData.imUserID) {
							console.log('咨询信息2 == ', newApp.globalData.initTim, newApp.globalData.tim, newApp.globalData.SDKAPPID)
							if (!newApp.globalData.initTim && newApp.globalData.SDKAPPID) { // 判断是否已经初始化
								this.initRoom(newUserData.imUserID);
								return;
							}
							console.log('咨询信息3 == ', type)
							if (type) {
								if (type === 'selectAdm' && newApp.globalData.SDKAPPID) {
									this.drawImage();
									console.log("app.globalData.isLogOut1", newApp.globalData.isLogOut)
									if (!newApp.globalData.isLogOut) { // 判断是否以及退出，已经退出则不需要退出再登录，而是直接登录
										this.login(newUserData.imUserID)
									} else {
										this.signOut('signOut', newUserData.imUserID)
									}
								} else {
									console.log("app.globalData.isLogOut2", newApp.globalData.isLogOut)
									if (!newApp.globalData.isLogOut) { // 判断是否以及退出，已经退出则不需要退出
										return;
									}
									this.signOut()
								}
							}
						} else {
							if (!app.globalData.initTim && newApp.globalData.SDKAPPID) { // 判断是否已经初始化
								this.initRoom();
							}
						}
					})
				})
			},
			
			// 更新就诊人数据
			upDateAdmData(options) {
				console.log('==更新就诊人数据===', options)
				// #ifdef MP
				let { patDataLen } =  this.data
				//#endif;
				// #ifdef H5
				let { patDataLen } =  this
				//#endif;
				this.setData({
					patDataLen : options?.patDataLen || patDataLen
				})
			},
			
			scrollPage(e) {
				if (e.detail.scrollTop > 10) {
					this.setData({
						showScrollBg: true
					})
				} else {
					this.setData({
						showScrollBg: false
					})
				}
			},

			// 更新标题组件中的数据
			updateNavbarData() {
				return new Promise((resolve, reject) => {
					this.$refs.navBar.upDateUserData() // Vue更新userData    重新刷新医院描述
					resolve()
				})
			},

			// 如果是扫描进入，需做处理
			isToAddCard(e) {
				const _this = this
				if (app.globalData.activityObj && [1011, 1012, 1013].indexOf(app.globalData.scene) > -1) {
					const patCount = e.detail && e.detail.admSelectData.length
					// console.log('首页 判断是否有就诊人', patCount)
					if (!patCount) {
						_this.toAddCard()
					}
				}
			},

			// 扫描自动切换医院
			chooseHospital() {
				console.log('chooseHospital')
				const {
					isAutoSwichHospital,
					hospVal
				} = this
				if (isAutoSwichHospital) {
					const hosp_pat_select = this.zpSelectComponent('#hosp_pat_select')
					hosp_pat_select.hospVanCellOnClick({
						currentTarget: {
							dataset: {
								name: hospVal
							}
						}
					}).then(() => {
						hosp_pat_select.handleConfirm()
					})
				}
			},

			// 获取推荐医生数据
			getRecommendedDoctor() {
				// #ifdef MP
				let { userData, windowHost } = this.data;
				// #endif
				// #ifdef H5
				let { userData, windowHost } = this;
				// #endif
				let data = {
					params: [{
						patID: userData.hisPatID || "",
						patNo: userData.hisPatNo || "",
						hospCode: userData.hisHospID || "",
						openID: userData.openID || ""
					}],
					pagination: [{
						pageSize: 4,
						currentPage: 1
					}]
				}
				$http.post("urlS", this, {
					code: "03100042",
					data: data,
					namespace: "Y",
					success: function(res) {
						if (+res.errorCode === 0) {
							let recommendedDoctor = res.result && res.result.data ? res.result.data.slice(0, 4) : [];
							for (var i = 0; i < recommendedDoctor.length; i++) {
								let url = recommendedDoctor[i] && recommendedDoctor[i].image ? recommendedDoctor[i].image : "";
								recommendedDoctor[i].image = url.indexOf("http") !== -1 ? url : windowHost + url;
							}
							this.setData({
								recommendedDoctor
							})
						} else {
							this.setData({
								recommendedDoctor: []
							})
						}
					}
				});
			},

			// 获取菜单数据
			getMenuDate() {
				const _this = this
				let userData = this.$cache.get('userData');
				if (_this.count > 10) {
					return;
				}
				if (!(userData && userData.openID)) { // 保证获取菜单数据时openID不能为空
					setTimeout(() => {
						_this.count++;
						_this.getMenuDate();
					}, 300);
					return;
				}
				let data = {
					params: []
				}
				$http.post("urlS", _this, {
					code: "01030009",
					data: data,
					success: function(res) {
						if (+res.errorCode === 0) {
							let menuData = res && res.rows && res.rows.length > 0 ? res.rows : [];
							let navList = []; // 基本
							let outList = []; // 门诊
							let inList = []; // 住院
							for (var i = 0; i < menuData.length; i++) {
								if (menuData[i].code === "0006") {
									navList = menuData[i].childMenu;
								}
								if (menuData[i].code === "0007") {
									outList = menuData[i].childMenu;
								}
								if (menuData[i].code === "0008") {
									inList = menuData[i].childMenu;
								}
							}
							console.log(navList)
							_this.setData({
								navList,
								outList,
								inList
							});
						}
					}
				});
			},

			// 查询病人是否有新消息
			checkForNewMessage(option) {
				let homeMsgData = this.$cache.get('homeMsgData') || [];
				if (option && option.detail) {
					let newMsgData = {
						...option.detail,
						datetamp: Date.parse(new Date()) / 1000
					};
					// let obj = {
					//   M: newMsgData.userName + '：' + (newMsgData.text ? newMsgData.text : (newMsgData.image ? '图片' : '')),
					//   B: '医生已停诊。',
					//   D: '您有一条待支付订单，请尽快支付。',
					//   F: '您有一个待评价的订单，点我去评价哦。',
					// }
					// newMsgData.newMsg = newMsgData && newMsgData.type ? obj[newMsgData.type] : '' ;
					homeMsgData.contact(newMsgData);
					this.setData({
						newMsgData: homeMsgData
					}, () => {
						this.$cache.set('homeMsgData', homeMsgData);
					});
					return;
				}
				const userData = this.$cache.get('userData')
				// 新消息
				if (!(userData && userData.hisPatID)) return;
				let data = {
					params: [{
						patID: userData.hisPatID || ""
					}]
				}
				$http.post("urlS", this, {
					code: "02090013",
					data: data,
					namespace: "Y",
					success: function(res) {
						if (+res.errorCode === 0) {
							if (res.result && res.result.unreadNmber > 0) {
								uni.setTabBarBadge({
									index: 2,
									text: res.result.unreadNmber > 99 ? '···' : (res.result.unreadNmber + '')
								})
							} else {
								uni.removeTabBarBadge({
									index: 2
								})
							}
							let unreadPay = res.result && res.result.unreadPay && res.result.unreadPay instanceof Array ? res.result.unreadPay : [];
							if (unreadPay && unreadPay.length > 0) {
								unreadPay.forEach(function(item, index) {
									let oneMsg = {
										...item,
										newMsg: "您有一条待支付订单，请尽快支付。",
										type: 'D',
										datetamp: Date.parse(new Date()) / 1000
									}
									homeMsgData.concat(oneMsg)
								})
								this.$cache.set('homeMsgData', homeMsgData);
							}
							this.setData({
								newMsgData: homeMsgData
							});
						} else {
							this.setData({
								newMsgData: homeMsgData
							})
						}
					}
				});
			},

			nextImage: function(e) {
				var _this = this;
				var count = 1
				var i = setInterval(function() {
					// #ifdef MP
					var img = _this.data.imageArr[count].url
					// #endif
					// #ifdef H5
					var img = _this.imageArr[count].url
					// #endif
					_this.setData({
						curImg: img
					}, () => {
						count = count + 1
						if (count >= 3) {
							count = 0
						}
					})
				}, 4000)
			},

			// 跳转到找医生界面
			handleGoFindDoctor: Utils.debounce(function() {
				uni.navigateTo({
					url: "../../index/pages/searchDoctorLoc/searchDoctorLoc"
				})
			}),

			//跳转图文资咨询
			turnGraphic: Utils.debounce(function() {
				app.globalData.reservationEntrance = "2"
				uni.navigateTo({
					url: "../../index/pages/graphicConsultation/graphicConsultation"
				})
			}),

			//跳转视频问诊
			turnVideo: Utils.debounce(function() {
				app.globalData.reservationEntrance = "3"
				uni.navigateTo({
					url: "../../index/pages/videoConsultation/videoConsultation"
				})
			}),

			//跳订单
			turnOrder: Utils.debounce(function() {
				uni.switchTab({
					url: '../order/order',
				})
			}),

			//跳转线下门诊
			turnOutline: Utils.debounce(function() {
				checkChooseHosp().then(() => {
					app.globalData.reservationEntrance = "4"
					this.zpSelectComponent('#registrationNotice').openShow() // 弹出就诊须知
				})
			}),
			
			jumpTo(e, _dataset) {
			    /* ---处理dataset begin--- */
			    this.handleDataset(e, _dataset);
			    /* ---处理dataset end--- */
			    const { option } = e.detail;
			    console.log(e.detail.option);
			    if (option === 'loc') {
			        uni.navigateTo({
			            url: '../../index/pages/videoConsultation/videoConsultation'
			        });
			    } else if (option === 'doctor') {
			        uni.navigateTo({
			            url: '../../index/pages/consultationChooseDoctorList/consultationChooseDoctorList'
			        });
			    }
			},
			
			//获取二维码
			drawImage: function() {
				let _this = this;
				const userData = _this.$cache.get('userData');
				let url = `${userData.hisPatNo}`
				var qr = new UQRCode();
				qr.data = url; // 设置二维码内容
				qr.size = 200; // 设置二维码大小，必须与canvas设置的宽高一致
				qr.make(); // 调用制作二维码方法
				// 获取canvas上下文
				var canvasContext = uni.createCanvasContext('canvas', _this); // 如果是组件，this必须传入
				qr.canvasContext = canvasContext; // 设置uQRCode实例的canvas上下文
				qr.drawCanvas(); // 调用绘制方法将二维码图案绘制到canvas上

				setTimeout(() => {
					uni.canvasToTempFilePath({
						x: 0,
						y: 0,
						canvasId: 'canvas',
						success: function(res) {
							_this.setData({
								imgsrc: res.tempFilePath,
							})
						},
						fail: function(res) {}
					})
				}, 300);
				_this.drawImage2()
			},
			//获取条形码
			drawImage2: function() {
				const { barcodeData } = this
				const userData = this.$cache.get('userData');
				const url = `${userData.hisPatNo}`
				drawBarcode.code128(uni.createCanvasContext('barcode'), url, 300, 70);
			},

			//打开二维码
			showImgPopup() {
				this.zpSelectComponent('#admEwm').openImgEwm();
			},

			//关闭二维码
			onClose() {
				this.setData({
					upImgShow: false
				});
			},

			//初始化TIM
			initRoom(userID) {
				console.log('初始化TIM')
				try {
					const newApp = getApp();
					let options = {
						SDKAppID: newApp.globalData.SDKAPPID // 普瑞
					};
					// 创建 SDK 实例，TIM.create() 方法对于同一个 SDKAppID 只会返回同一份实例
					newApp.globalData.tim = TIM.create(options); // SDK 实例通常用 tim 表示

					// 设置 SDK 日志输出级别，详细分级请参见 setLogLevel 接口的说明
					newApp.globalData.tim.setLogLevel(0); // 普通级别，日志量较多，接入时建议使用
					// tim.setLogLevel(1); // release 级别，SDK 输出关键信息，生产环境时建议使用

					// 注册 COS SDK 插件
					newApp.globalData.tim.registerPlugin({
						// // #ifdef MP
						// 'cos-wx-sdk': COS,
						// // #endif
						// // #ifdef H5
						// 'cos-js-sdk': COS,
						// // #endif
						'tim-upload-plugin': TIMUploadPlugin
					});
					newApp.globalData.initTim = true; // 初始化完成标识
					if (userID) {
						this.login(userID)
					}
				} catch(err) {
					console.log('初始化失败', err)
				}
			},

			// 登录TIM
			login: Utils.debounce(function(userID) {
				const _this = this
				const newApp = getApp();
				console.log('TIM login:',_this)
				let userData = GenerateTestUserSig.genTestUserSig(userID || '');
				let promise = newApp.globalData.tim.login({
					userID: userID || '',
					userSig: userData && userData.userSig ? userData.userSig : ""
				});
				promise.then((imResponse) => {
					console.log("tim登录成功：", imResponse.data);
					newApp.globalData.isLogOut = true;
					setTimeout(() => {
						_this.zpSelectComponent("#navBar").monitorMessageChanges()
					}, 300)
					if (imResponse.data.repeatLogin === true) {
						// 标识帐号已登录，本次登录操作为重复登录。v2.5.1 起支持
						console.log(imResponse.data.errorInfo);
					}
				}).catch((imError) => {
					console.log('tim登录失败', userID, imError); // 登录失败的相关信息
					_this.signOut('signOut', userID);
				});
			}),

			// 退出RTIM
			signOut: function(type, userID) {
				try {
					let promise = app.globalData.tim.logout();
					promise.then((imResponse) => {
						app.globalData.isLogOut = false;
						console.log("退出登录成功：", imResponse)
						if (type === "signOut") {
							this.login(userID);
						}
					}).catch(function(imError) {
						console.log('退出失败');
					});
				} catch (err) {
					console.log("退出失败")
				}
			},

			//图片加载出错，替换为默认图片
			imageError(e) {
				let {
					imgHost,
					recommendedDoctor
				} = this.data;
				var index = e.target.dataset.index;
				recommendedDoctor[index].image = imgHost + "/images/icon/avatar_doctor_act.png";
				this.setData({
					recommendedDoctor
				});
			},

			//跳转更多推荐医生
			turnMoreDoctor: Utils.debounce(function(event) {
				uni.navigateTo({
					url: "../../index/pages/moreDoctor/moreDoctor"
				})
			}),

			// 跳转到医生主页
			doctorDetail: Utils.debounce(function(e) {
				var docObj = e.currentTarget.dataset.page;
				app.globalData.docObj = docObj;
				app.globalData.locObj.locID = docObj.locID;
				app.globalData.schDate = docObj.date;
				uni.navigateTo({
					url: '../../index/pages/doctorInfo/doctorInfo',
					// success: (result) => {
					//   result.eventChannel.emit('docObj', { docObj: docObj, locID: locID })
					// },
				})
			}),

			// 切换医院
			handleChangeHosp: function() {
				console.log('点击了切换医院')
				const hosp_pat_select = this.zpSelectComponent("#hosp_pat_select");
				console.log(hosp_pat_select)
				hosp_pat_select.showHospVisible(); //子组件的方法
			},

			// 更换就诊人
			handleChangePat() {
				let {
					patDataLen,
					userData
				} = this;
				if (patDataLen > 0 || userData && userData.hisPatID) {
					const hosp_pat_select = this.zpSelectComponent("#hosp_pat_select");
					hosp_pat_select.handleShowPatModal(); //子组件的方法
				} else {
					this.toAddCard() // 跳转建卡页
				}
			},

			// 跳转建卡页
			toAddCard() {
				uni.navigateTo({
					url: '/pages/mine/addCard/visitorEntry/visitorEntry',
					success: (res) => {
						res.eventChannel.emit('back', {
							url: 'home'
						})
					}
				})
			},

			//公告数据
			announcementList: function() {
				let userData = this.$cache.get('userData');
				if (!(userData && userData.hisPatID)) return;
				let data = {
					params: [{
						hospCode: userData.hisHospID || "",
						openID: userData.openID || ""
					}]
				}
				$http.post("urlS", this, {
					code: "03100136",
					data: data,
					namespace: "Y",
					success: function(res) {
						if (+res.errorCode === 0 && res.result.rows.length > 0) {
							this.setData({
								navbarData: {
									...this.navbarData,
									announcementData: res.result.rows
								}
							}, () => {
								// console.log(this.navbarData)
							})
						} else {

							this.setData({
								navbarData: {
									...this.navbarData,
									announcementData: []
								}
							})
						}
					}
				});
			},

			// 跳转到我的问诊 // 根据消息类型跳转到相关界面
			goMyConsultation: Utils.debounce(function(event) {
				let timetamp = event.currentTarget.dataset.timetamp;
				let { newMsgData } = this;
				if (newMsgData && newMsgData.type === 'D') {
					uni.navigateTo({
						url: '/pages/order/pages/orderType/orderType?admID=' + newMsgData.admID + '&source=home&timetamp=' + timetamp
					})
				} else if (newMsgData.type === 'F') {
					uni.navigateTo({
						url: "/pages/mine/evaluate/evaluate?admID=" + newMsgData.admID + "&doctorname=" + newMsgData.userName + "&doctorID=" + newMsgData.userID + '&id=' + (newMsgData.msgID || '') + '&timetamp=' + timetamp
					})
				} else if (newMsgData.type === 'M' || newMsgData.type === 'H') { // 区分图文咨询与视频问诊跳转到相对应的界面
					uni.navigateTo({
						url: '/pages/message/pages/im/room/room?admID=' + newMsgData.admID +
							"&userID=patient" + newMsgData.patID + "&toUser=user" + newMsgData.userID +
							"&toUserName=" + newMsgData.userName + "&patName=" + newMsgData.patName +
							'&timetamp=' + timetamp
					})
				} else {
					uni.navigateTo({
						url: '../../mine/myConsultation/myConsultation',
					})
				}
			}),

			// 跳转
			trunByNavList: Utils.debounce(function(event) {
				let itemData = event.currentTarget.dataset.page;
				if (!(itemData && itemData.routePath)) {
					uni.showToast({
						title: '功能开发中...',
						icon: "none"
					})
					return;
				}
				if (itemData.routePath.indexOf("tabBar") !== -1) {
					uni.switchTab({
						url: itemData.routePath,
					})
				} else {
					if (itemData.routePath.indexOf("nucleicAcidTest") !== -1) {
						//调接口
						this.getNucleicAcidTest(itemData.routePath);
					} else {
						// #ifdef MP-ALIPAY
						// 服务办结埋点
						if (itemData.name == "报告查询") {
							monitor.api({
								api: "报告查询",
								success: true,
								c1: "taSR_YL",
								time: Math.floor(Math.random() * 100 + 50)
							})
						}
						// #endif
						uni.navigateTo({
							url: itemData.routePath
						})
					}
				}
			}),

			checkSelectedHosp() {
				checkChooseHosp();
			},

			// 没有医院选择医院
			notHospitalChooseHospital(e) {
				const self = this;
				console.log('notHospitalChooseHospital', e)
				let {
					type,
					page: {
						routePath
					}
				} = e.currentTarget.dataset;
				// console.log(type, routePath)
				// #ifdef H5 
				uni.navigateTo({
					url: routePath
				});
				// #endif
				// #ifdef MP
				uni.getSetting({
					success: async (res) => {
						if (!res.authSetting || (res.authSetting && !res.authSetting.hasOwnProperty('scope.userLocation'))) {
							self.zpSelectComponent('#hosp_pat_select')
								.getLocation()
								.then(() => {})
								.catch(() => {
									uni.navigateTo({
										url: routePath
									});
								});
						} else {
							const currentLocationData = this.$cache.get('currentLocationData');
							if (!currentLocationData) {
								await Utils.getPositionLocation().then((obj) => {});
							}
							let allHospitalData = this.$cache.get('allHospitalData');
							if (!allHospitalData) {
								// 获取医院列表数据
								getHospList(app).then((res) => {
									const currentLocationData = this.$cache.get('currentLocationData');
									const {
										currentLatlng,
										province
									} = currentLocationData.currentLocation;
									if (res.errorCode == 0) {
										dealHospData(res.result, currentLatlng, province);
									}
								});
							} else if (allHospitalData && allHospitalData.length > 0 && !allHospitalData[0].hasOwnProperty('distance')) {
								const currentLocationData = this.$cache.get('currentLocationData');
								const {
									currentLatlng,
									province
								} = currentLocationData.currentLocation;
								dealHospData(allHospitalData, currentLatlng, province);
							}
							uni.navigateTo({
								url: routePath
							});
						}
					}
				});
				//#endif
			},

			//获取核算检测信息
			getNucleicAcidTest: function(path) {
				let userData = this.$cache.get('userData');
				let data = {
					params: [{
						patNo: userData.hisPatNo || ""
						//patNo:"0000036123"
					}]
				}
				$http.post("urlS", this, {
					code: "03110003",
					data: data,
					namespace: "Y",
					success: function(res) {
						if (+res.errorCode === 0) {
							console.log("res.result.url123", res.result.url)
							let url = res.result.url
							let obj = res.result
							uni.navigateTo({
								url: path,
								success: (res) => {
									res.eventChannel.emit('page', {
										page: url,
										obj: obj
									})
								},
							})
						} else {
							uni.showToast({
								title: res.errorMessage,
								icon: "none"
							})
						}
					}
				});
			},

			// 医院信息中的导航
			onNavigationPhone: Utils.debounce(function(event) {
				const userData = this.$cache.get('userData');
				let type = event.currentTarget.dataset.type;
				switch (type) {
					case 'navigation':
						uni.openLocation({
							latitude: parseFloat(userData.latitude),
							// 纬度，浮点数，范围为-90~90，负数表示南纬
							longitude: parseFloat(userData.longitude),
							// 经度，浮点数，范围为-180~180，负数表示西经
							name: userData.hospDesc,
							// 位置名称
							address: userData.hospAddress,
							// 地址的详细说明
							scale: 18,
							// 缩放级别，5-18，默认是18
							success(res) {
								// 打开位置成功后的回调
								console.log('打开位置成功', res);
							},
							fail(err) {
								// 打开位置失败后的回调
								console.error('打开位置失败', err);
							}
						});
						// wx.navigateTo({
						//   url: '/pages/singleFun/pages/mapNavigation/mapNavigation?latitude='+ lat +'&longitude='+ lng +'&addr='+ addr,
						// })
						// qqmapsdk.openNavi({
						//   latitude: event.currentTarget.dataset.lat,
						//   longitude: event.currentTarget.dataset.lng,
						//   success: function(res) {
						//       console.log(res);
						//   },
						//   fail: function(error) {
						//       console.error(error);
						//   }
						// })
						break;
					case 'phone':
						uni.makePhoneCall({
							phoneNumber: event.currentTarget.dataset.phone
						});
						break;
				}
			})
		}
	}
</script>

<style>
	.wrapper {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.block {
		width: 120px;
		height: 120px;
		background-color: #fff;
	}

	.header-bg {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 88rpx;
		z-index: 9999998;
		background-color: #3c79ed;
	}

	.page-bg {
		padding-bottom: 40rpx;
	}

	.new-home {
		overflow-y: auto;
		position: relative;
		z-index: 1;
		box-sizing: border-box;
		background-color: #e9ecff;
		background-size: 100%;
		background-repeat: no-repeat;
	}

	.new-home .bg {
		position: absolute;
		left: 0;
		z-index: 0;
		width: 100%;
	}

	.new-home .bg .img {
		width: 100%;
		height: 520rpx;
	}

	.head-content {
		position: relative;
		z-index: 1;
		padding: 28rpx 30rpx 36rpx;
	}

	.head-search {
		width: 100%;
		height: 70rpx;
		box-sizing: border-box;
	}

	.head-search-text {
		font-size: 26rpx;
		color: #999;
		margin-left: 16rpx;
	}

	.head-search-icon {
		background-repeat: no-repeat;
		width: 36rpx;
		height: 33rpx;
		background-size: 100% auto;
		margin-left: 24rpx;
	}

	.head-search-input {
		width: 100%;
		height: 100%;
		background: #e8e8e8;
		color: #ffffff;
		border-radius: 44rpx;
		display: flex;
		align-items: center;
	}


	/* 医院详情板块start */
	.hospital-content {
		box-sizing: border-box;
		z-index: 100;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 710rpx;
		min-height: 280rpx;
		margin: 0 20rpx 20rpx 20rpx;
		padding: 20rpx;
		background-color: #fff;
		border-radius: 10rpx;
	}

	.small {
		height: 180rpx;
	}

	.btn-select-hosp {
		width: 500rpx;
		height: 100rpx;
		line-height: 100rpx;
		color: #fff;
		background: linear-gradient(0deg, #007fcc, #58b1ea);
		border-radius: 20rpx;
	}

	.hospital-info {
		display: flex;
		flex-direction: column;
		width: 100%;
		height: 100%;
	}

	.info-head {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 40rpx;
		margin-bottom: 26rpx;
	}

	.hosp-name {
		font-weight: bold;
		font-size: 34rpx;
		color: #333333;
		line-height: 32rpx;
	}

	.switch-hosp {
		display: flex;
		align-items: center;
	}

	.switch-hosp text {
		font-weight: 400;
		font-size: 24rpx;
		color: #ccc;
		line-height: 32rpx;
	}

	.info-btm {
		display: flex;
		justify-content: space-between;
		width: 100%;
	}

	.info-btm .logo-box {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 170rpx;
		height: 170rpx;
		background: #ffffff;
		border-radius: 10rpx;
	}

	.info-btm .logo-box .logo {
		width: 90%;
		height: 90%;
		background-size: 100%;
		background-repeat: no-repeat;
	}

	.info-btm .info-btm-r {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		flex: 1;
		margin-left: 20rpx;
		width: 454rpx;
	}

	.info-btm .info-btm-r .addr,
	.info-btm .info-btm-r .date {
		font-weight: 400;
		font-size: 22rpx;
		color: #333333;
		line-height: 34rpx;
	}

	.info-btm .info-btm-r .btn-box {
		display: flex;
		margin-top: 10rpx;
	}

	.info-btm .info-btm-r .btn-box .btn {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 180rpx;
		height: 64rpx;
		border-radius: 35rpx;
		color: #fff;
	}

	.info-btm .info-btm-r .btn-box .btn image {
		width: 28rpx;
		height: 24rpx;
		margin-right: 14rpx;
	}

	.info-btm .info-btm-r .btn-box .btn-dh {
		background: #2a82e4;
		margin-right: 56rpx;
	}

	.info-btm .info-btm-r .btn-box .btn-phone {
		background: #00baad;
	}

	/* 医院详情板块end */

	.inform-back {
		width: 100%;
		height: 80rpx;
		background: #FFFFFF;
		padding: 0 32rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
	}

	.inform-back-left {
		display: flex;
		align-items: center;
	}

	.inform-back-image {
		width: 172rpx;
		height: 30rpx;
		background: url("/images/icon/hospital_bulletin.png") no-repeat;
		background-size: 100% auto;
	}

	.inform-dividing-line {
		background: #E5E5E5;
		width: 1px;
		margin: 0 30rpx;
		height: 30rpx;
	}

	.inform-back-text {
		font-size: 28rpx;
		color: #333;
		line-height: 40rpx;
		margin-left: 8rpx;
	}

	.pat-bg {
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 385rpx;
		background-color: #ffffff;
		margin-left: 10rpx;
		height: 100%;
		border-radius: 12rpx;
		padding: 0 20rpx;
	}

	.pat-per {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.pat-bg-photo {
		box-sizing: border-box;
		width: 120rpx;
		height: 120rpx;
		border: 1px solid #5b9fff;
		border-radius: 50%;
	}

	.font-text1 {
		margin-top: 6rpx;
		font-size: 28rpx;
		color: #7f7f7f;
	}

	.font-text2 {
		font-size: 24rpx;
		color: #FFFDFB;
		line-height: 32rpx;
		margin-left: 8rpx;
	}

	.pat-bg-intr .font-text1 {
		color: #333;
	}

	.pat-bg-intr-base {
		margin: 0 0 6rpx 10rpx;
	}

	.pat-bg-intr-switch {
		box-sizing: border-box;
		/* background: -webkit-linear-gradient(top, #58b1ea, #007cff); */
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 10rpx 14rpx;
		width: 180rpx;
		height: 44rpx;
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}

	.pat-bg-intr-switch:last-child {
		margin-left: 18rpx;
	}

	.pat-bg-but {
		width: 164rpx;
		height: 64rpx;
		background: #FFFFFF;
		border-radius: 35rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		color: #007fcc;
	}

	.mes-tip {
		height: 128rpx;
		background: #FFFFFF;
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.mes-tip-up {
		display: flex;
		align-items: center;
		margin-left: 38rpx;
		width: 610rpx;
	}

	.mes-tip-up-spot {
		width: 14rpx;
		height: 14rpx;
		background: #FF7E3B;
		border-radius: 50%;
	}

	.mes-tip-text1 {
		font-size: 30rpx;
		font-weight: 600;
		color: #333333;
		line-height: 42rpx;
		margin-left: 20rpx;
	}

	.mes-tip-text2 {
		font-size: 24rpx;
		color: #999999;
		line-height: 32rpx;
	}

	.mes-tip-up-show {
		display: flex;
		width: 600rpx;
		justify-content: space-between;
		align-items: center;
	}

	.es-tip-text3 {
		font-size: 24rpx;
		color: #999999;
		line-height: 48rpx;
	}

	.nav-show {
		display: flex;
		padding: 24rpx 12rpx 0 12rpx;
		flex-wrap: wrap;
		box-sizing: border-box;
		margin: 0 20rpx 10rpx 20rpx;

	}

	.nav-show-content {
		width: 25%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin-bottom: 24rpx;
	}

	.nav-show-img {
		align-items: center;
		display: flex;
		justify-content: center;
	}

	.nav-show-text {
		align-items: center;
		display: flex;
		justify-content: center;
		font-size: 28rpx;
		color: #333333;
		line-height: 40rpx;
		white-space: nowrap;
		margin-top: 18rpx;
	}

	.margin-top-24 {
		margin-top: 24rpx;
	}

	.margin-bottom-30 {
		margin-bottom: 30rpx;
	}

	.reg-content {
		margin: 10rpx 20rpx 10rpx 20rpx;
		display: flex;
		justify-content: space-between;
	}

	.reg-content-img {
		overflow: hidden;
		position: relative;
		width: 340rpx;
		height: 148rpx;
		border-radius: 10rpx !important;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #ffffff !important;
	}

	.reg-content-img:last-child {
		margin-left: 18rpx;
	}

	.reg-content-img image {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
	}

	.in-content {
		width: 100%;
		background: #FFFFFF;
		margin-bottom: 20rpx;
	}

	.in-content-title {
		width: 100%;
		padding: 30rpx 0 42rpx 30rpx;
		box-sizing: border-box;
	}

	.in-content-title view {
		position: relative;
		height: 48rpx;
		width: 138rpx;
		font-size: 34rpx;
		font-weight: 600;
		color: #333333;
	}

	.in-content-title view text {
		position: absolute;
		top: 0;
		left: 0;
		display: inline-block;
		width: 100%;
		z-index: 5;
	}

	.in-content-title view::before {
		content: " ";
		width: 100%;
		height: 24rpx;
		position: absolute;
		bottom: 0;
		left: 0;
		border-radius: 12rpx;
		background: #D2E8FF;
	}

	.in-content-list {
		display: flex;
		flex-wrap: wrap;
		box-sizing: border-box;
	}

	.tell-content {
		background: #FFFFFF;
		padding: 24rpx 10rpx 5rpx 10rpx;
		box-sizing: border-box;
		margin: 0 20rpx;
		border-radius: 6rpx;
	}

	.tell-content-title {
		/* margin-bottom: 15rpx; */
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.tell-content-title-tip {
		width: 4rpx;
		height: 32rpx;
		background: #67a4fd;
		border-radius: 4rpx;
		margin-left: 8rpx;
	}

	.tell-content-title-text1 {
		font-size: 34rpx;
		font-weight: 400;
		color: #333333;
		line-height: 48rpx;
		margin-left: 12rpx;
	}

	.tell-content-title-left {
		display: flex;
		align-items: center;
	}

	.tell-content-title-right {
		display: flex;
		align-items: center;
	}

	.tell-content-title-text2 {
		margin-right: 4rpx;
		font-size: 24rpx;
		color: #7f7f7f;
		line-height: 34rpx;
	}

	.tell-content-show {
		padding: 25rpx 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.tell-content-show-detail {
		width: 456rpx;
	}

	.tell-content-show-per {
		display: flex;
		align-items: center;
	}

	.tell-content-show-text1 {
		font-size: 30rpx;
		font-weight: 900;
		color: #333333;
		margin-bottom: 20rpx;
	}

	.tell-content-show-text2 {
		font-size: 24rpx;
		color: #999999;
		line-height: 32rpx;
	}

	.doc-content-list {
		display: flex;
		flex-wrap: wrap;
		box-sizing: border-box;
		padding-bottom: 32rpx;
	}

	.doc-show-content {
		width: 50%;
		margin-top: 28rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.doc-info-box {
		position: relative;
		width: 324rpx;
		height: 390rpx;
		background-size: 100% auto;
		background-repeat: no-repeat;
	}

	.doc-show-text1 {
		align-items: center;
		display: flex;
		white-space: nowrap;
		font-size: 28rpx;
		color: #333333;
		line-height: 40rpx;
		margin-top: 8rpx;
	}

	.doc-show-text2 {
		align-items: center;
		display: flex;
		font-size: 24rpx;
		color: #333333;
		line-height: 34rpx;
		margin: 8rpx 0;
	}

	.doc-show-text3 {
		align-items: center;
		display: flex;
		white-space: nowrap;
		font-size: 24rpx;
		color: #007fcc;
		line-height: 34rpx;
	}

	.doc-show-text4 {
		align-items: center;
		display: flex;
		white-space: nowrap;
		font-size: 20rpx;
		color: #333333;
		line-height: 34rpx;
	}

	.qrcode-box {
		width: 700rpx;
		margin: 50rpx 0;
		background-color: #fff;
	}

	.img-text {
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
		line-height: 42rpx;
		padding: 30rpx;
	}

	.tell-content-show-img {
		width: 36rpx;
		height: 36rpx;
		border-radius: 18rpx;
		background-size: 100% auto;
	}

	.img-text2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #666666;
		line-height: 30rpx;
		text-align: center;
		padding-bottom: 30rpx;
	}

	.message {
		display: flex;
		align-items: center;
		justify-content: left;
		padding: 20rpx;
		background-color: #ffffff;
	}

	.message-icon {
		background: url("images/icon/SMS@2x.png") no-repeat;
		width: 30rpx;
		height: 30rpx;
		background-size: 100% auto;
	}

	.message-text {
		margin-left: 20rpx;
		color: #007fcc;
	}

	.message-text1 {
		color: #FFA500;
	}

	.patcard {
		position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 10rpx 20rpx 20rpx 20rpx;
	}

	.patcard-l,
	.patcard-r {
		height: 290rpx;
	}

	.patcard-show {
		overflow: hidden;
		position: relative;
		width: 316rpx;
		/* height: 140rpx; */
		height: 100%;
		display: flex;
		justify-content: center;
		background-color: #ffffff;
		margin-bottom: 10rpx;
		padding: 0;
		border-radius: 12rpx;
	}

	.patcard-show-font {
		box-sizing: border-box;
		position: relative;
		z-index: 2;
		width: 100%;
		height: 100%;
		padding: 20rpx 20rpx 20rpx 34rpx;
		color: #ff7e0a;
	}

	.patcard-show-text {
		font-size: 28rpx;
		line-height: 30rpx;
		display: flex;
		align-items: center;
		justify-content: left;
		letter-spacing: 10rpx;
		margin-bottom: 5rpx;
		font-weight: 500;
	}

	.patcard-show-text>text {
		width: 100%;
	}

	.patcard-show-text1 {
		font-size: 20rpx;
		display: flex;
		align-items: center;
		justify-content: left;
		color: #7f7f7f;
	}

	.patcard-show-text1>text {
		width: 100%;
	}

	.patcard-show-bg {
		position: absolute;
		z-index: 1;
		width: 100%;
		height: 100%;
		left: 0;
		top: 0;
	}

	.patcard-show-bg image {
		width: 100%;
		height: 100%;
	}

	.patcard-show:last-child {
		margin-bottom: 0;
	}

	.patcard-show:last-child .patcard-show-font {
		color: #5b9fff;
	}

	.pat-btn {
		display: flex;
		align-items: center;
		justify-content: left;
		margin-top: 10rpx;
	}

	.img-desc {
		position: absolute;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: rgba(59, 53, 53, 0.6);
		width: 94%;
		padding: 10rpx;
		white-space: nowrap;
		color: #fff;
	}

	.img-desc .doc-info {
		display: flex;
		flex-direction: column;
	}

	.img-desc .doc-info .name {
		font-size: 24rpx;
		line-height: 24rpx;
	}

	.img-desc .doc-info .department {
		display: block;
		font-size: 20rpx;
		line-height: 1.2;
		width: 140rpx;
		margin-top: 6rpx;
	}

	.img-desc .num {
		font-size: 18rpx;
		line-height: 20rpx;
		color: #fff100;
	}

	.nextimg {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 660rpx;
		height: 300rpx;
		padding: 0 45rpx;
	}
</style>