<template>
	<view class="content" v-if="item!=null">
		<view class="image">
			<image mode="aspectFill" :src="item.imgUrl"></image>
		</view>
		<view class="detail-cont">
			<view class="title-box">
				<view class="line"></view>
				<view class="title">{{item.foodName}}</view>
				<view class="title-py">{{item.pinyin}}</view>
			</view>
			<view class="desc">
				{{item.actionTitle}}
			</view>
			<view class="line-h"></view>
			<view class="content"   v-html="item.descs">
			</view>
		</view>
	</view> 
</template>

<script>
	import {getMedicatedFoodById} from '@/api/index'
	export default {
		data() {
			return {
				item:{},
			};
		},
		onLoad(option) {
			this.id=option.id;
			 
		},
		onShow() {
			this.getMedicatedFoodById();
		},
		onShareAppMessage(res) {
			if(this.utils.isLogin()){
				return {
					title: this.item.foodName,
					path: '/pages_index/medicatedFoodDetails?id='+this.id,
					imageUrl: 'https://user.test.ylrztop.com/images/logo.png' //分享图标，路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
				}
			}
			
		},
		//分享到朋友圈
		onShareTimeline(res) {
			if(this.utils.isLogin()){
				return {
					title: this.item.title,
					imageUrl: 'https://user.test.ylrztop.com/images/logo.png' //分享图标，路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
				}
			}
			
		},
		methods:{
			getMedicatedFoodById(){
				let data = {id:this.id};
				getMedicatedFoodById(data).then(
					res => {
						if(res.code==200){
							this.item=res.data;
						}else{
							uni.showToast({
								icon:'none',
								title: "请求失败",
							});
						}
					},
					rej => {}
				);
			},
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
	.content{
		height: 100%;
		image{
			height:450rpx;
			width:100%;
		}
		.detail-cont{
			flex: 1;
			padding: 20upx;
			overflow-y: auto;
			.title-box{
				width: 100%;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				.line{
					border-radius: 5rpx;
					width: 8rpx;
					height:30rpx;
					background-color: #0bb3f2;
				}
				.title{
					margin-left: 15rpx;
					font-size: 40upx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333;
				}
				.title-py{
					margin-left: 15rpx;
					font-size: 32upx;
					font-family: PingFang SC;
					color: #333;
				}
			}
			.desc{
				margin-top: 20rpx;
				font-size: 32upx;
				font-family: PingFang SC;
				color: #333;
			}
			.line-h{
				margin: 15rpx 0rpx;
				border-bottom: 1rpx dashed #d4d4d4;
			}
			.tabs{
				width: 100%;
				margin: 20rpx 0rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				// border: 1rpx solid #0bb3f2;
				border-radius: 30rpx;
				line-height: 60rpx;
				.tab1{
					border-radius: 30rpx 0rpx 0rpx 30rpx;
					width: 25%;
					display: flex;
					justify-content: center;
					align-items: center;
					background-color: #fff;
					color: #4F575A;
					font-size: 28upx;
					font-weight: bold;
					font-family: PingFang SC;
				}
				.tab2{
					
					width: 25%;
					display: flex;
					justify-content: center;
					align-items: center;
					background-color: #fff;
					color: #4F575A;
					font-size: 28upx;
					font-weight: bold;
					
					font-family: PingFang SC;
				}
				.tab3{
					width: 25%;
					display: flex;
					justify-content: center;
					align-items: center;
					background-color: #fff;
					color: #4F575A;
					font-size: 28upx;
					font-weight: bold;
					font-family: PingFang SC;
				}
				.tab4{
					border-radius: 0rpx 30rpx 30rpx 0rpx;
					width: 25%;
					display: flex;
					justify-content: center;
					align-items: center;
					background-color: #fff;
					color: #4F575A;
					font-size: 28upx;
					font-weight: bold;
					font-family: PingFang SC;
				}
				.active{
					background-color: #0bb3f2;
					color: #fff;
				}
				 
			}
			 
		}
	}
	
	 
</style>
