<template>
	<view class="content">
		<view class="cont-bg">
			<image  src="../../static/images/inquiry_bg.jpg"></image>
		</view>
		<view class="bg">
			<view></view>
			<image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/65d12607ca874b0d8536c7201a0dfa97.png"></image>
		</view>
		<view class="cont" >
			<view class="inquiry-item" v-for="(item) in inquirySubTypes"  @click="doInquiryForm(item.value)" >
				<view class="left"  >
					<image  mode="aspectFit" src="/static/logo.png"></image>
					<view class="inquiry-cont">
						<view class="name">{{item.lable}}</view>
						<view class="desc">医疗专家团队远程咨询</view>
					</view>
				</view>
				<view v-if="isShare" class="btn share" @click.stop="doShare(item)">分享</view>
				<view v-else class="btn share" @click.stop="sendIM(item)">发送</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 {
				inquirySubTypes:[],
				companyId:null,
				companyUserId:null,
				isShare:null,
				isH5:false,
				showShare:false,
				shareItem:{ imageUrl:"",title:"",path:"",isMini:true },
				isIM:false,
			}
		},
		onLoad(options) {
			this.isShare=options.isShare;
			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
			}
			if(!!options.isIM){
				this.isIM=options.isIM;
			}
			
		
			this.getConfig();
			//#ifdef H5
			this.isH5=true;
			//#endif
		},
		onShow() {
			if(!this.$isLogin()) {
				uni.navigateTo({
					url: '/pages/auth/loginIndex'
				})
				return
			}
		},
		methods: {
			getConfig(){
				var data={key:"his.inquiryConfig"}
				getConfigByKey(data).then(
					res => {
						if(res.code==200){
							this.inquirySubTypes=JSON.parse(res.data).inquirySubType;
						}
					},
					rej => {}
				);
			},
			doInquiryForm(type){
				if(this.$isLogin()){
					if(type==3){
						uni.navigateTo({
						 	url: "/pages/store/inquiryForm2_2?inquiryType=2&orderType=2&inquirySubType="+type+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&isShare="+this.isShare,
						})
					} else if(type==4){
						
					}  else {
						uni.navigateTo({
						 	url: "/pages/store/inquiryForm2_1?inquiryType=2&orderType=2&inquirySubType="+type+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&isShare="+this.isShare,
						})
					}
					
				}
			},
			doShare(item){
				if(this.isH5){
				   return;
				}
				this.shareItem.title=item.lable;
				this.shareItem.imageUrl="../../static/logo.png";
				this.shareItem.isMini=true;
				let type=item.value;
				let url = ''
				if(type==3){
					this.shareItem.path="/pages_order/inquiryForm2_2?inquiryType=2&orderType=2&inquirySubType="+type+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&isShare="+this.isShare;
					url = "/pages/store/inquiryForm2_2?inquiryType=2&orderType=2&inquirySubType="+type+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&isShare="+this.isShare;
				} else if(type==4){
					
				}else {
					this.shareItem.path="/pages_order/inquiryForm2_1?inquiryType=2&orderType=2&inquirySubType="+type+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&isShare="+this.isShare;
					url = "/pages/store/inquiryForm2_1?inquiryType=2&orderType=2&inquirySubType="+type+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&isShare="+this.isShare;
				}
				let cdn=uni.getStorageSync('h5Path');
				this.shareItem.url=cdn+url;
				this.showShare=true;
			},
			sendIM(item){
				item.companyId=uni.getStorageSync('companyId');
				item.companyUserId=uni.getStorageSync('companyUserId');		
				item.type="inquirySelect";
				uni.$emit("sendIMCts",item);
				uni.navigateBack({
					delta: 1
				});
			},
		}
	}
</script>
<style lang="scss">
	page{
		background: #f1f6fc;
	}
</style>
<style scoped lang="scss">
	.content{
		position: relative;
		.cont-bg{
			z-index: 0;
			position: fixed;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			height:100%;
			image{
				width: 100%;
				height:100%
			}
		}
		.bg{
			position: relative;
			z-index: 999;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			image{
				width:350rpx;
				height:350rpx;
			}
		}
		 
		.cont{
			position: relative;
			z-index: 1;
			padding: 10rpx;
			padding-top: 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			.inquiry-item{
				background: linear-gradient(0deg, #ffffff, #FFFBF5);
				border: 5rpx solid rgba(247,201,162,0.25);
				box-shadow: 0px 5rpx 20rpx 3rpx rgba(0,0,0,0.61);
				border-radius: 120rpx;
				margin-bottom: 28rpx;
				padding: 10rpx;
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.left{
					display: flex;
					align-items: center;
					justify-content: flex-start;
					image{
						border: 10rpx solid #fff;
						border-radius: 50%;
						background-color: #fff;
						width: 150rpx;
						height:150rpx;
					}
					.inquiry-cont{
						margin-left: 20rpx;
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						justify-content: flex-start;
						.name{
							font-size: 30upx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #76491C;
						}
						.desc{
							margin-top: 15rpx;
							font-size: 28upx;
							font-family: PingFang SC;
							color: #6F471E;
						}
					}
				}
				.right{
					
				}
				.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 #FF233C;
					color: #FF233C;
					margin-top: 10rpx;
				}
			}
		}
	}
</style>
