<template>
	<view class="content">
		<view class="bg">
			<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/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://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/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">
					<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/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://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/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">
					<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_arrow_r.png"></image>
				</view>
			</view>
		</view>
	</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,
			}
		},
		onLoad(options) {
			if(!this.$isEmpty(options.isShare)){
				this.isShare=options.isShare
			}
			else{
				uni.hideShareMenu()
			}
			this.inquiryType=options.inquiryType;
			if(this.inquiryType==3){
				uni.setNavigationBarTitle({
					title:"药师咨询"
				})
				this.typeText="药师"
			}
			this.companyId=options.companyId;
			this.companyUserId=options.companyUserId;
		},
		onShow() {
			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_order/inquirySelect?inquiryType=3&companyId="+this.companyId+"&companyUserId="+this.companyUserId
			}
			
			
		},
		methods: {
			getConfigByKey(){
				let data = {key:"his.inquiryConfig",appId:wx.getAccountInfoSync().miniProgram.appId,};
				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){
				this.$isLogin().then(
					res => {
						console.log(res)
						if(res){
							if(this.inquiryType==1){
								uni.navigateTo({
								 	url: "/pages_order/inquiryForm1?inquiryType="+this.inquiryType+"&orderType="+price.type
								})
							}
							else if(this.inquiryType==3){
								uni.navigateTo({
								 	url: "/pages_order/inquiryForm3?inquiryType="+this.inquiryType+"&orderType="+price.type+"&companyId="+this.companyId+'&companyUserId='+this.companyUserId
								})
							}
						}
						else{
							uni.navigateTo({
								url:'/pages/auth/login'
							})
						}
					}
				);
				
				
			}
		}
	}
</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;
					}
					
				}
			}
		}
	}
</style>
