<template>
	<view>
		<view :key="index">
			<u-swiper :list="detailList.images" indicatorMode="line " width="750rpx" height="530rpx" radius="0"
				circular>
			</u-swiper>
			<view class="collect">
				<view class="star">
					<u-image v-if="showStar==false" src="/static/detail/xp_icon_wstar.png" width="28rpx" height="28rpx"
						@click="starTap">
					</u-image>
					<u-image v-if="showStar==true" src="/static/detail/xp_icon_star.png" width="28rpx" height="28rpx"
						@click="starTap">
					</u-image>
				</view>

				<u-image src="/static/detail/xiangqing_icon_shoucang.png" width="119rpx" height="48rpx">
				</u-image>
			</view>

			<view class="content">
				<view class="title_box">
					<text class="title">{{detailList.name}}</text>
					<view class="title_tag">{{detailList.cate_bname}}</view>
				</view>
				<view class="desc">
					{{detailList.title}}
				</view>
				<view class="classify">
					{{detailList.cate_name}}
				</view>
				<view class="tag_view">
					<view>
						<text class="tagOne">{{detailList.tags}}</text>
						<!-- <text class="tagTwo">{{item.tagTwo}}</text>  v-for="item in detailList.tags" :key="item.id" -->
					</view>
					<view v-if="isThumb==false" class="heart">
						<u-image v-if="showHeart==false" src="/static/detail/xp_icon_heart.png" width="34rpx"
							height="32rpx" @click="heartTap">
						</u-image>
						<u-image v-if="showHeart==true" src="/static/detail/xp_icon_ysc.png" width="34rpx"
							height="32rpx" @click="heartTap">
						</u-image>
						<text class="thumb">点赞</text>
					</view>
					<view v-if="isThumb==true" class="heart">
						<u-image src="/static/detail/xp_icon_ysc.png" width="34rpx" height="32rpx" @click="heartTap">
						</u-image>
						<text class="thumb">{{detailList.thumb}}赞</text>
					</view>
				</view>
			</view>

			<view class="releaseDate">
				<u-image src="/static/products/xp_icon_sjf.png" width="24rpx" height="24rpx">
				</u-image>
				<text class="release">发布日期：</text>
				<text>{{detailList.pub_time}}</text>
			</view>
			<u-parse :content="detailList.desc" @preview="preview" @navigate="navigate"></u-parse>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				showStar: false,
				showHeart: false,
				isThumb: false,
				detailList: [
					// 	{
					// 	title: '锅巴',
					// 	tag: '零食铺子',
					// 	desc: '糯米蟹黄锅巴散装，非油炸绿色健康食品',
					// 	classify: '薯片膨化',
					// 	tagOne: '无添加剂1',
					// 	tagTwo: '无添加剂',
					// 	time: '2022年12月04日',
					// 	content: '<h1>一级标题</h1><br/><h2>二级标题</h2>'
					// },
				],
				swiperList: [
					'/static/detail/zhanwei_xppx.png',
					'/static/detail/zhanwei_xppx.png'
				]
			}
		},
		onLoad(option) {
			console.log('产品id', option.id);
			this.id = option.id
			this.getProductDetail()
		},
		methods: {
			//获取详情信息
			getProductDetail() {
				this.$apiServe.getProductDetail(this.id).then(res => {
					// console.log('详情页', res.data.data.thumb)
					if (res.data.data.thumb) {
						this.isThumb = true
					}
					this.detailList = res.data.data
				}).finally(_ => {})
			},
			//收藏按钮
			starTap() {
				this.showStar = !this.showStar
			},
			//点赞按钮
			heartTap() {
				this.showHeart = !this.showHeart
			}
		}
	}
</script>

<style lang="scss">
	.collect {
		display: flex;
		position: absolute;
		top: 16rpx;
		right: 0;
		color: #fff;
		border-radius: 54rpx 0px 0px 54rpx;
		padding: 2px 2px 2px 3px;

		.star {
			position: absolute !important;
			top: 6px !important;
			right: 77rpx;
			z-index: 99;
		}

	}


	.content {
		padding: 20rpx;
		background-color: #fff;

		.title_box {
			position: relative;
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.title {
				font-size: 36rpx;
				font-weight: 400;
				color: #0EBB5B;
				line-height: 50rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

			.title_tag {
				height: 30rpx;
				background: #0EBB5B;
				border-radius: 7rpx;
				font-size: 20rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
				line-height: 28rpx;
				padding: 1rpx 15rpx;
			}
		}

		.desc {
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #3E3E3E;
			line-height: 34rpx;
			padding: 15rpx 0;
		}

		.classify {
			width: 80rpx;
			height: 30rpx;
			border-radius: 6rpx;
			border: 1rpx solid #EEEEEE;
			font-size: 20rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #666666;
			line-height: 28rpx;
			padding: 1rpx 15rpx;
		}

		.tag_view {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding-top: 14rpx;
			font-size: 20rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #CCCCCC;
			line-height: 28rpx;

			.tagOne {
				padding-right: 20rpx;
			}

			.heart {
				display: flex;

				.thumb {
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
					line-height: 33rpx;
					margin-left: 14rpx;
				}
			}
		}

	}

	.releaseDate {
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
		line-height: 33rpx;
		display: flex;
		align-items: center;
		padding: 24rpx 20rpx;
		margin-top: 20rpx;
		background-color: #fff;


		.release {
			padding: 0 10rpx 0 6rpx;
		}
	}
</style>
