<template>
	<view class="video_wrapper">
		<view class="content">

			<view class="title">{{videoData.title}}</view>
			<view class="timeBox">
				<view class="time">
					上传时间：{{ $util.timeStampTurnTime(videoData.create_time) }}
				</view>
				<view class="view_num">
					<u-icon name="play-right" size="28rpx" color="#999"></u-icon>
					<view class="num">
						{{videoData.view_num}}
					</view>
				</view>
			</view>
			<view class="tagsBox">
				<view class="tags" v-for="(item,index) in videoData.tags" :key="index">
					<u-tag :text="item" type="success"></u-tag>
				</view>
			</view>
			<view class="desc">{{videoData.remark}}</view>
			<view class="video">
				<ls-dom-video :ref="'DomVideo'+videoId" v-if="videoId" :src="videoData.video" :autoplay="false"
					:controls="true"></ls-dom-video>
			</view>
		</view>
		<view class="title_box">
			<view class="title_icon">

			</view>
			<view class="title">
				相关商品
			</view>
		</view>
		<horizontalGoodsItem :item="goodsInfo" @click="toDetail" coverName="sku_image">
		</horizontalGoodsItem>
	</view>


</template>

<script>
	import horizontalGoodsItem from '@/components/horizontalGoodsItem.vue';
	export default {
		components: {
			horizontalGoodsItem
		},
		data() {
			return {
				videoId: undefined,
				videoData: {},
				goodsInfo: {},
			}

		},
		onLoad(e) {
			this.videoId = e.id
		},
		onShow() {
			this.getVideoDetails()
		},
		methods: {
			getVideoDetails() {
				// 根据videoId获取视频详情
				this.$api.sendRequest({
					url: '/api/video/getDetail',
					data: {
						id: this.videoId,
					},
					success: res => {
						this.videoData = res.data
						this.getGoodsItem(res.data)
					}
				})
			},
			getGoodsItem(item) {
				this.$api.sendRequest({
					url: '/api/goodssku/detail',
					data: {
						goods_id: item.goods_id
					},
					success: res => {
						this.goodsInfo = res.data.goods_sku_detail
					}
				});
			},
			toDetail() {
				this.$util.redirectTo('/page_goods/detail/detail', {
					goods_id: this.goodsInfo.goods_id
				});
			}
		},
	}
</script>

<style lang="scss" scoped>
	.video_wrapper {
		padding: 20rpx;


		.content {
			padding: 20rpx;
			background-color: #fff;
			border-radius: 10rpx;
			box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
			margin-bottom: 30rpx;

			.title {
				font-size: 28rpx;
				font-weight: bold;
				margin-bottom: 10rpx;

			}

			.timeBox {
				display: flex;
				justify-content: space-between;

				.time,
				.view_num {
					font-size: 24rpx;
					color: #999;
					margin-bottom: 10rpx;

				}

				.view_num {
					display: flex;
					align-items: center;

					.num {
						padding-left: 10rpx;
						font-size: 24rpx;
						color: #999;
					}
				}
			}


			.tagsBox {
				display: flex;
				flex-wrap: wrap;
				margin-bottom: 10rpx;

				.tags {
					margin-right: 20px;
				}
			}

			.desc {
				font-size: 24rpx;
				color: #666;
				margin-bottom: 20rpx;

			}

			.video {
				width: 100%;
				height: 400rpx;

				video {
					width: 100%;
					height: 100%;

				}

			}
		}

		.title_box {
			display: flex;
			height: 40rpx;
			margin: 20rpx;
			margin-left: 0;

			.title_icon {
				width: 4rpx;
				height: 30rpx;
				background: #89D961;
				line-height: 40rpx;
				margin: 5rpx 10rpx;
			}

			.title {
				font-size: 28rpx;
				font-weight: bold;
				height: 40rpx;
				line-height: 40rpx;
			}
		}
	}
</style>