<template>
	<view class="ai-container">
		<view class="ai-content">
			<view class="top-box">
				<view class="back-box x-f">
					<image src="/static/image/device/back_icon32.png"></image>
					<view @click="back()">返回</view>
				</view>
				<view class="title">
					舌诊体质辨识报告
				</view>
				<view></view>
			</view>
		<!-- <cover-view class="uni-nav-barbox" :style="{height:height+'px',backgroundColor:headerBG,backgroundImage: baseUrl+'/images/ai_top_bg.png'}">
			<cover-view class="uni-nav" :style="{height:height+'px',paddingTop: statusBarHeight+ 'px'}">
				<cover-view class="uni-nav-back" @click="back()">返回</cover-view>
				<cover-view class="uni-nav-title">舌诊体质辨识报告</cover-view>
				<cover-view style="min-width: 104rpx;"></cover-view>
			</cover-view>
		</cover-view> -->
		<image class="jkda_top_bg" :src="baseUrl+'/images/ai_top_bg.png'" mode="widthFix"></image>
		<image class="ai_bottom_bg" :src="baseUrl+'/images/ai_bottom_bg.png'" mode="widthFix"></image>
		<view class="ai-container-body" v-if="item!=null">
			<view class="report-avatar">
				<image :src="item.avatar" mode="aspectFill" style="width: 100%;height: 100%;"></image>
			</view>
			<view class="report-user">
				<text>{{item.name}}</text>
				<text style="padding: 0 18rpx 0 10rpx;">{{item.sex==1?"男":"女"}}</text>
				<text>{{item.age}}岁</text>
			</view>
			<view class="report-infobox">
				<image class="ai_sz_img" :src="baseUrl+'/images/ai_sz_img.png'" mode="widthFix"></image>
				<view class="report-info-border">
					<view class="report-info">
						<view class="report-time">检测时间 {{item.createTime}}</view>
						<view class="report-info-restit">您属于{{item.typeName}}</view>
						<view class="report-info-res">{{item.typeName}}</view>
						<!-- 视频 -->
						<view class="videobox" v-if="videoUrl">
							<video class="myVideo" :src="videoUrl" :poster="imageUrl" :autoplay='true'></video>
						</view>
						<!-- 舌苔特征 -->
						<view class="report-title bold">舌苔特征</view>
						<view class="report-info-item">
							<view class="item-round"></view>
							<view>
								<text class="item-title">{{item.taiseName}}：</text>
								<text>{{item.taiseDesc}}</text>
							</view>
						</view>
						<view class="report-info-item">
							<view class="item-round"></view>
							<view>
								<text class="item-title">{{item.shemianName}}：</text>
								<text>{{item.shemianDesc}}</text>
							</view>
						</view>
						<view class="report-info-item">
							<view class="item-round"></view>
							<view>
								<text class="item-title">{{item.botai==1?"有剥苔":"未见剥苔"}}：</text>
								<text>{{item.botaiDesc}}</text>
							</view>
						</view>
						<view class="report-info-item">
							<view class="item-round"></view>
							<view>
								<text class="item-title">{{item.liewen==1?"有裂纹":"未见裂纹"}}：</text>
								<text>{{item.liewenDesc}}</text>
							</view>
						</view>
						<view class="report-info-item">
							<view class="item-round"></view>
							<view>
								<text class="item-title">{{item.chihen==1?"有齿痕":"未见齿痕"}}：</text>
								<text>{{item.chihenDesc}}</text>
							</view>
						</view>
						<!-- 体质解析 -->
						<view class="report-title bold" >体质解析</view>
						<view class="report-info-item" v-for="(item) in typeList">
							<view class="item-round"></view>
							<view>
								<text class="item-title">{{item.name}}：</text>
								<text>{{item.value}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 解锁 -->
			<view class="lockbox">
				<image class="mask x-c" src="/static/images/other/bg_bar.png"></image>
				<view class="lockbox-con y-f">
					<view class="lockbox-con-tip">联系伴学助手，查看全部内容</view>
					<!-- <image src="@/static/bxzs.jpg" mode="widthFix"></image> -->
					<view>注：报告内容参考王琦教授《九种体质使用手册》</view>
				</view>
			</view>
			<!-- 分享弹窗 -->
			<u-popup :show="showShare" @close="showShare = false" >
				<share-box :shareItem="shareItem" :showCopy="false" @closeShare='showShare = false' ></share-box>
			</u-popup>
			<view class="footer-btnbox">
				<!-- <view class="border-btn">
					<button class="footer-btn footer-btn-left">保存本图</button>
				</view> -->
				<view class="border-btn">
					<!-- #ifdef APP-PLUS -->
					<view class="footer-btn" v-if="isShare==null" @click="doShare()">分享好友</view>
					<!-- #endif -->
					<!-- #ifndef APP-PLUS -->
					<view class="footer-btn" v-if="isShare==null">
						分享好友
						<button class="contact-btn"   data-name="shareBtn" open-type="share">分享</button>
					</view>
					<!-- #endif -->
					<!-- #ifdef H5 -->
					<view class="footer-btn" v-if="isShare!=null&&isShare==1" @click="doTongue()">
						开始检测
					</view>
					<!-- #endif -->
				</view>
			</view>
			<!-- <view class="banner-box">
				<image src="@/static/images/banner.png" mode="widthFix"></image>
			</view> -->
		</view>
		</view>
	</view>
</template>

<script>
	import {getHealthTongueById} from '@/api/healthTongue.js'
	
	export default {
		data() {
			return {
				type:null,
				id:null,
				isShare:null,
				avatar:null,
				item:null,
				typeList:[],
				baseUrl:uni.getStorageSync('requestPath'),
				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
				defaultHeadimg: "/static/images/my_heads_icon.png",
				showShare:false,
				shareItem:{ imageUrl:"",title:"",path:"",isMini:true },
				isLock: true,
				videoUrl: '',
				imageUrl: '',
				headerBG:"transparent",
				height: 44
			}
		},
		onLoad(options) {
			this.type=options.type;
			this.isShare=options.isShare;
			this.id=options.id;
			this.height = this.statusBarHeight + 44
			// var json=uni.getStorageSync("tongueResult")
			// this.item=JSON.parse(json);
			// this.typeList=JSON.parse(this.item.typeJson)
			this.getHealthTongueById()
		},
		onShow() {
			if(!this.$isLogin()) {
				this.$showLoginPage()
			}
		},
		//发送给朋友
		onShareAppMessage(res) {
			return {
				title: "舌苔检测报告",
				path:"/pages_user/tongue/report?isShare=1&id="+this.id
			}
			
		},
		//分享到朋友圈
		onShareTimeline(res) {
			return {
				title: "舌苔检测报告",
				path:"/pages_user/tongue/report?isShare=1&id="+this.id
			}
			
		},
		onPageScroll(e) {
			if(e.scrollTop > 44) {
				this.headerBG = '#FF8A00'
			} else {
				this.headerBG = "transparent"
			}
		},
		methods: {
			doTongue(){
				uni.redirectTo({
					url:"/pages/user/tongue/index"
				})
			},
			getHealthTongueById(){
				getHealthTongueById(this.id).then(
					res => {
						if(res.code==200){
							this.isLock = res.isAddQw == 1 ? true : false
							this.videoUrl = res.url || ''
							this.imageUrl = res.imageUrl || ''
							this.item=res.data;
							const jsoninfo = JSON.parse(this.item.typeJson)
							let index = jsoninfo.findIndex(item => item.name === '用药调治');
							if(index > -1) {
								this.typeList=jsoninfo.splice(0,index)
							} else {
								this.typeList=jsoninfo
							}
						}else{
							 
						}
					},
					rej => {}
				);
			},
			back() {
				if(this.type!=null&&this.type=="back"){
					uni.navigateBack()
				}
				else{
					uni.redirectTo({
						url:"/pages/index/index"
					})
				}
				
			},
			doShare(){
				//#ifdef APP-PLUS
				this.shareItem.title= "舌苔检测报告";
				this.shareItem.imageUrl="https://cos.his.cdwjyyh.com/fs/20250730/186f5f22c89f46d29882227f199ab673.png"; // logo
				this.shareItem.isMini=true;
				this.shareItem.path="/pages_user/tongue/report?isShare=1&id="+this.id
				let cdn=uni.getStorageSync('h5Path');
				this.shareItem.url=cdn+"/pages/user/tongue/report?isShare=1&id="+this.id
				this.showShare=true;
				//#endif 
			}
		}
	}
</script>

<style scoped lang="scss">
	@mixin u-flex($flexD, $alignI, $justifyC) {
		display: flex;
		flex-direction: $flexD;
		align-items: $alignI;
		justify-content: $justifyC;
	}
	.pb50 {
		padding-bottom: calc(var(--window-bottom) + 50rpx);
	}
	.lockbox {
		margin-top: -200rpx;
		position: relative;
		z-index: 9;
		.mask{
			width: 100%;
			height:160rpx;
			margin-bottom: -2px;
		}
		&-con-tip {
			padding: 16rpx 24rpx 30rpx 24rpx;
			box-sizing: border-box;
			color: #8F6726;
			font-size: 32rpx;
			font-weight: bold;
		}
		&-con {
			padding: 0 24rpx 40rpx 24rpx;
			box-sizing: border-box;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 24rpx;
			color: #999999;
			background-color: #fff;
			image {
				width: 702rpx;
				height: auto;
				border-radius: 16rpx;
				overflow: hidden;
				margin-bottom: 40rpx;
			}
		}
	}
	.footer-btnbox {
		width: 100%;
		padding-bottom: 44rpx;
		@include u-flex(row, center, center);
		background-color: #fff;
		.border-btn {
			width: 400rpx;
			height: 78rpx;
			padding: 4rpx;
			box-sizing: border-box;
			background: linear-gradient(0deg, #8F6726, #FBF4EE);
			box-shadow: 0rpx 9rpx 17rpx 0rpx #FBF4EE;
			border-radius: 78rpx;
			
			
		}
		.footer-btn {
			width: 100%;
			height: 100%;
			background: #8F6726;
			border-radius: 78rpx;
			font-family: SourceHanSansCN-Bold;
			font-weight: bold;
			font-size: 40rpx;
			color: #FFFFFF;
			line-height: 69rpx;
			border-radius: 33rpx;
			border: 3rpx solid #FBF4EE;
			text-align: center;
			&::after {
				border: none;
			}
			position: relative;
			.contact-btn{
				display: inline-block;
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
				opacity: 0;
				z-index: 9999;
			}
			
		}
	}
	.uni-nav-bar_bg {
		width: 100%;
		height: 782rpx;
	}
	.uni-nav-barbox {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		z-index: 998;
		overflow: hidden;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		font-size: 32rpx;
		background-repeat: no-repeat;
		background-size: 100% auto;
		.uni-nav {
			width: 100%;
			padding-left: 20rpx;
			box-sizing: border-box;
			@include u-flex(row, center, space-between);
		}
		.uni-nav-back {
			width: 110rpx;
			box-sizing: border-box;
			@include u-flex(row, center, center);
			text-align: center;
		}
	}
	.videobox {
		width: 568rpx;
		height: 320rpx;
		margin-top: 40rpx;
		position: relative;
		.myVideo {
			width: 568rpx;
			height: 320rpx;
		}
	}
	.ai-container {
		width: 100vw;
		min-height: 100vh;
		background-image: url(/static/image/device/ipad_yjf_boder.png);
		background-repeat: no-repeat;
		position: relative;
		background-size: 100% 100%;
		box-sizing: border-box;
		padding: 20rpx;
		.ai-content {
			// height: 100%;
			width: 100%;
			height: 100%;
			background-image: url(/static/image/device/inner_page_bg.png);
			background-repeat: no-repeat;
			background-size: 100% 100%;
			position: relative;
			padding: 30rpx;
			.top-box {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 60rpx;
			
				.title {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 40rpx;
					color: #8F6726;
					text-align: center;
				}
			
				.back-box {
					width: 138rpx;
					height: 64rpx;
					background: #FFFFFF;
					border-radius: 8rpx;
					border: 2rpx solid #8F6726;
					padding: 24rpx 16rpx;
					justify-content: center;
			
					view {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #8F6726;
						text-align: center;
						margin-left: 10rpx;
					}
			
					// position: absolute;
					// left: 30rpx;
					image {
						width: 32rpx;
						height: 32rpx;
					}
				}
			}
			}
		// background: #FF8A00;
		.jkda_top_bg {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: auto;		
		}
		.ai_bottom_bg {
			position: absolute;
			bottom: 0;
			left: 0;
			width: 100%;
			height: auto;		
		}
		&-body {
			position: relative;
			// padding-top: calc(var(--status-bar-height) + 132rpx);
		}
	}

	.bold {
		height: 42rpx;
		font-size: 44rpx !important;
		color: #8F6726 !important;
		border-left: 10rpx solid #8F6726;
		line-height: 42rpx;
		margin: 54rpx 0 40rpx 0;
	}

	.ai_sz_img {
		width: 100%;
		height: auto;
		position: absolute;
		top: 0;
		left: 16rpx;
		z-index: 1;
	}

	.item-round {
		flex-shrink: 0;
		width: 23rpx;
		height: 23rpx;
		margin-right: 12rpx;
		background: #8F6726;
		border-radius: 50%;
	}

	.report {
		&-avatar {
			width: 171rpx;
			height: 171rpx;
			padding: 3rpx;
			margin: 0 auto;
			border-radius: 50%;
			overflow: hidden;
			box-sizing: border-box;
			background: linear-gradient(0deg, #8F6726, #FBF4EE);
		}

		&-user {
			font-family: SourceHanSansCN;
			font-weight: bold;
			font-size: 40rpx;
			color: #FFFFFF;
			line-height: 91rpx;
			text-shadow: 2rpx 2rpx 3rpx #8F6726;
			text-align: center;
		}

		&-infobox {
			padding: 36rpx 47rpx 0 47rpx;
			// padding-top: 184rpx;
			position: relative;
		}

		&-info-border {
			padding: 4rpx;
			border-radius: 45rpx;
			box-sizing: border-box;
			background: linear-gradient(0deg, #8F6726, #FBF4EE);
			box-shadow: 8rpx 11rpx 14rpx 0rpx #8F6726;
			position: relative;
			z-index: 2;
		}

		&-info {
			padding: 34rpx 40rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			border-radius: 45rpx;
			font-family: SourceHanSansCN-Regular;
			font-weight: 400;
			color: #4D4D4D;
			

			&-restit {
				margin: 27rpx 0 33rpx 0;
				font-family: SourceHanSansCN-Bold;
				font-weight: bold;
				font-size: 33rpx;
				color: #4D4D4D;
				text-align: center;
			}

			&-res {
				font-weight: 800;
				font-size: 54rpx;
				color: #8F6726;
				text-align: center;
			}

			&-item {
				margin-bottom: 30rpx;
				display: flex;
				align-items: baseline;
				font-family: SourceHanSansCN-Regular;
				font-size: 27rpx;
				color: #414141;
				line-height: 36rpx;
				word-break: break-all;

				.item-title {
					font-family: SourceHanSansCN-Bold;
					font-weight: bold;
					font-size: 27rpx;
					color: #414141;
				}
			}
		}

		&-time {
			font-size: 24rpx;
			text-align: center;
		}

		&-title {
			padding-left: 10rpx;
			font-family: SourceHanSansCN-Bold;
			font-weight: bold;
			color: #414141;
		}
	}
	.banner-box {
		padding: 48rpx 34rpx 0 34rpx;
		image {
			width: 100%;
			height: auto;
		}
	}
</style>