<template>
	<view class="content">
		<view class="cont-bg">
			<image  src="../../static/images/inquiry_bg.png"></image>
		</view>
		  <u-navbar
		  :bgColor="bgColor"
		  leftIconColor="#FFFFFF"
		            title="会诊通道"
		            :autoBack="true"
		        > </u-navbar>
		<!-- <view class="bg">
			<view></view>
			<image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/65d12607ca874b0d8536c7201a0dfa97.png"></image>
		</view> -->
		<view class="cont" >
			<view class="inquiry-item" v-for="(item) in inquirySubTypes"  @click="doInquiryForm(item)" >
				<view class="emptyBox"></view>
				<view class="left"  >
					<image  mode="aspectFit" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/33a4d6077e394d37a920c45ca10f8c4d.png"></image>
					<view class="rightContent">
						<view class="inquiry-cont">
							<view class="name ellipsis">{{item.lable}}</view>
							<view class="desc">医疗专家团队会诊咨询</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>
			</view>
		</view>
		<u-modal @cancel="showTips = false" @confirm="showTips = false" :show="showTips" title="温馨提示" content='按配置上限无法下单的时候，用户点击通道提示【当日预约已满】'></u-modal>
		<u-popup :show="showShare" @close="showShare = false" >
			<share-box :shareItem="shareItem"  @closeShare='showShare = false' ></share-box>
		</u-popup>
	</view>
</template>

<script>
	import {getInquiryConfig} 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,
				bgColor:'transparent',
				showTips: false
			}
		},
		onPageScroll(e) {
			if(e.scrollTop > 30){
				this.bgColor = '#FF5701'
			}else{
				this.bgColor = 'transparent'
			}
		},
		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(){
				getInquiryConfig().then(
					res => {
						if(res.code==200){
							this.inquirySubTypes=JSON.parse(res.data).inquirySubType;
						}
					},
					rej => {}
				);
			},
			doInquiryForm(item){
				let type = item.value
				if(item.isCanBuy!=1) {
					this.showTips = true
					return
				}
				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="https://cos.his.cdwjyyh.com/fs/20250730/186f5f22c89f46d29882227f199ab673.png"; // logo;
				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{
		background: #FFF3F1;
		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: 560rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			margin: 0 32rpx;
			.inquiry-item{
				background:  #FFFFFF;
				border-radius: 16rpx;
				margin-top: 34rpx;
				padding: 32rpx;
				width: 100%;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: space-between;
				position: relative;
				.emptyBox{
					width: 160rpx;
					height: 60rpx;
					background: #FF5030;
					border-radius: 12rpx;
					position: absolute;
					top: -12rpx;
					left: 0;
					z-index: -1;
				}
				.left{
					display: flex;
					align-items: center;
					justify-content: flex-start;
					width: 100%;
					box-sizing: border-box;
					height: 216rpx;
					image{
						background-color: #fff;
						width: 216rpx;
						height: 216rpx;
						margin-right: 30rpx;
						border-radius: 12rpx
					}
					.inquiry-cont{
						margin-left: 20rpx;
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						justify-content: flex-start;
						flex: 1;
						.name{
							width: 100%;
							font-family: PingFang SC;
							font-weight: bold;
							font-size: 34rpx;
							color: #222222;
						}
						.desc{
							margin-top: 10rpx;
							font-family: PingFang SC;
							font-size: 24rpx;
							color: #FF5030;
						}
					}
				}
				.rightContent{
					    width: calc(100% - 246rpx);
					    display: flex;
					    flex-direction: column;
					    justify-content: space-between;
					    height: 100%;
				}
				.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;
					font-size: 28rpx;
					color: #FFFFFF;
					width: 200rpx;
					height: 72rpx;
					background: linear-gradient( 90deg, #FF5701 0%, #FFB501 100%);
					box-shadow: 0rpx 8rpx 8rpx 0rpx rgba(238,124,80,0.2);
					border-radius: 36rpx;
				}
			}
		}
	}
	::v-deep .u-navbar__content__title{
		color: #FFFFFF !important;
	}
</style>
