<template>
	<view class="content">
		<view class="bg">
			<image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/f06ec63771984f3b9f9aa65eb0c17eeb.png"></image>
		</view>
		<view class="title">20秒快速匹配{{inquiryType==1?"专家医生":"执业药师"}}</view>
		<view class="cont"  >
			 
			<view class="inquiry-item"   v-if="price1!=null" @click="doInquiryForm(price1)">
				<view class="left" >
					<image  src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/939cf3ad7d1a4186a7195e84a1db84bf.png"></image>
					<view class="inquiry-cont" v-if="inquiryType==1">
						<view class="name">图文问诊 {{price1.price}}/次</view>
						<view class="desc">和医生1对1在线图文问诊</view>
					</view>
					<view class="inquiry-cont" v-if="inquiryType==3">
						<view class="name">图文咨询 {{price1.price}}/次</view>
						<view class="desc">和药师1对1在线图文咨询</view>
					</view>
				</view>
				<view class="right x-ac">
				    <view v-if="isShare" class="btn share" @click.stop="doShare(item,price1)">分享</view>
					<image src="/static/images/icon_arrow_r.png"></image>
				</view>
			</view>
			<view class="inquiry-item"   v-if="price2!=null&&inquiryType==1" @click="doInquiryForm(price2)">
				<view class="left" >
					<image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/cf80011807af45c9af1bea6c4cf4bb3a.png"></image>
			 
					<view class="inquiry-cont" v-if="inquiryType==1">
						<view class="name">视频问诊 {{price2.price}}/次</view>
						<view class="desc">和医生1对1在线视频问诊</view>
					</view>
					<view class="inquiry-cont" v-if="inquiryType==3">
						<view class="name">图文咨询 {{price2.price}}/次</view>
						<view class="desc">和药师1对1在线视频咨询</view>
					</view>
				</view>
				<view class="right x-ac">
				    <view v-if="isShare" class="btn share" @click.stop="doShare(item,price2)">分享</view>
					<image src="/static/images/icon_arrow_r.png"></image>
				</view>
			</view>
		</view>
		
		<u-popup :show="showShare" @close="showShare = false" >
			<share-box :shareItem="shareItem"  @closeShare='showShare = false' ></share-box>
		</u-popup>
		
	</view>
</template>

<script>
	import {getConfigByKey} from '@/api/common.js'
	export default {
		data() {
			return {
				isShare:null,
				companyId:null,
				companyUserId:null,
				inquiryType:null,
				price1:null,
				price2:null,
				isH5:false,
				showShare:false,
				shareItem:{ imageUrl:"",title:"",path:"",isMini:true },
			}
		},
		onLoad(options) {
			if(!this.$isEmpty(options.isShare)){
				this.isShare=options.isShare
			}
			this.inquiryType=options.inquiryType;
			if(!this.$isEmpty(options.companyId)){
				this.companyId=options.companyId == 'undefined' || options.companyId == 'null' ? null: options.companyId
			}
			if(!this.$isEmpty(options.companyUserId)){
				this.companyUserId=options.companyUserId == 'undefined' || options.companyUserId == 'null'? null: options.companyUserId
			}
			//#ifdef H5
			this.isH5=true;
			//#endif
			this.inquiryType=options.inquiryType;
			if(this.inquiryType==3){
				uni.setNavigationBarTitle({
					title:"药师咨询"
				})
				this.typeText="药师"
			}
		},
		onShow() {
			if(!this.$isLogin()) {
				uni.navigateTo({
					url: '/pages/auth/loginIndex'
				})
				return
			}
			this.getConfigByKey();
		},
		onShareAppMessage(res) {
			//禁止二次转发--
			uni.showShareMenu({
				withShareTicket: true
			});
			wx.updateShareMenu({
				isPrivateMessage: true,
				withShareTicket: false,
				success(res) {
					console.log('updateShareMenu: ', res);
				},
				fail() {}
			}); //禁止二次转发--end
			return {
				title: "御君方互联网医院--健康会诊",
				path: "/pages/store/inquirySelect?inquiryType=3&companyId="+this.companyId+"&companyUserId="+this.companyUserId
			}
			
			
		},
		methods: {
			getConfigByKey(){
				let data = {key:"his.inquiryConfig"};
				getConfigByKey(data).then(
					res => {
						if(res.code==200){
							var data=JSON.parse(res.data);
							this.price1 = data.prices.find((item,index)=>item.type=== 1)
							this.price2 = data.prices.find((item,index)=>item.type=== 2)
						}else{
							uni.showToast({
								icon:'none',
								title: "请求失败",
							});
						}
					},
					rej => {}
				);
			},
			doInquiryForm(price){
				if(this.$isLogin()){
					if(this.inquiryType==1){
						uni.navigateTo({
						 	url: "/pages/store/inquiryForm1?inquiryType="+this.inquiryType+"&orderType="+price.type
						})
					}
					else if(this.inquiryType==3){
						uni.navigateTo({
						 	url: "/pages/store/inquiryForm3?inquiryType="+this.inquiryType+"&orderType="+price.type+"&companyId="+this.companyId+'&companyUserId='+this.companyUserId
						})
					}
				}
			},
			doShare(item,price){
				if(this.isH5){
				   return;
				}
				this.shareItem.imageUrl="../../static/image/course/zyzd.png";
				this.shareItem.isMini=true;
				let url = ''
				if(this.inquiryType==1){
					this.shareItem.path="/pages_order/inquiryForm1?inquiryType="+this.inquiryType+"&orderType="+price.type;
					url = "/pages/store/inquiryForm1?inquiryType="+this.inquiryType+"&orderType="+price.type;
					this.shareItem.title="图文问诊 "+price.price+"/次";
				}
				else{
					this.shareItem.path="/pages_order/inquiryForm3?inquiryType="+this.inquiryType+"&orderType="+price.type+"&companyId="+this.companyId+'&companyUserId='+this.companyUserId;
				    url = "/pages/store/inquiryForm3?inquiryType="+this.inquiryType+"&orderType="+price.type+"&companyId="+this.companyId+'&companyUserId='+this.companyUserId;
					this.shareItem.title="视频问诊 "+price.price+"/次";
				}
				console.log("qxj share path:"+this.shareItem.path);
				let cdn=uni.getStorageSync('h5Path');
				this.shareItem.url=cdn+url;
				this.showShare=true;
			}
		}
	}
</script>
<style lang="scss">
	page{
		background: #f1f6fc;
	}
</style>
<style scoped lang="scss">
	.content{
		position: relative;
		.bg{
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
		}
		.title{
			margin: 30rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 32upx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #111111;
		}
		.cont{
			
			margin: 30rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			.inquiry-item{
				margin: 15rpx 0rpx;
				padding: 50rpx 30rpx;
				box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
				background-color: #fff;
				border-radius: 15rpx;
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.left{
					display: flex;
					align-items: center;
					justify-content: flex-start;
					image{
						width: 100rpx;
						height:100rpx;
					}
					.inquiry-cont{
						margin-left: 20rpx;
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						justify-content: flex-start;
						.name{
							font-size: 32upx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #111111;
						}
						.desc{
							margin-top: 15rpx;
							font-size: 28upx;
							font-family: PingFang SC;
							color: #9a9a9c;
						}
					}
				}
				.right{
					image{
						width: 30rpx;
						height:30rpx;
					}
					
				}
			}
		
		    .btn{
		    	width: 100upx;
		    	height: 64upx;
		    	line-height: 64upx;
		    	font-size: 26upx;
		    	font-family: PingFang SC;
		    	font-weight: 500;
		    	text-align: center;
		    	border-radius: 30upx;
		    	margin-right: 20rpx;
		    }
		    .share{
		    	border:2rpx solid #FF5C03;
		    	color: #FF5C03;
		    	margin-top: 10rpx;
		    }
		}
	}
</style>
