<template>
	<view class="list-box">
		<van-cell @click='clickCell' :title="carVideoList.chapterName" />
		<view class="tabs-box">
			<view class="video-item" @click="gotoPaly(currentItem.list[0])">
				<view class="image-box">
					<view class="img-box">
						<image  class="image" :src="currentItem.list[0].cover" mode="aspectFill"></image>
					</view>
					<image v-if="currentItem.list[0].permission==1" class="img-tip" :src="shikan"></image>
					<image v-if="currentItem.list[0].permission==2" class="img-tip" :src="vip"></image>
					<text>{{currentItem.list[0].duration}}</text>
					<m-icon class="icon" type="bofangshipin"></m-icon>
				</view>
			</view>
			<view class="tabs-bfc">
				<view class="tabs">
					<view class="tab" :class="{'tab-active':active===index}" @click="active=index" v-for="(item,index) in carVideoList.children"
					 :key='index'>
						{{item.chapterName}}
					</view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
import shikan from "@/assets/img/shikan.png";
import vip from "@/assets/img/vip.png";
	export default {
		name: "video-listBox",
		props: {
			carVideoList: {
				type: Object,
				default: ()=>{
					return {}
				}
			},
		},
		data() {
			return {
				active: 0,
				shikan,
				vip
			};
		},
		computed: {
			currentItem() {
				console.log(this.carVideoList,'this.carVideoList')
				return this.carVideoList.children[this.active]
			}
		},
		methods: {
			gotoPaly(item) {
				this.$utils.route.goPage('/pages/carVideo/play', null, {
					carVideoItem: item
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.list-box {
		margin-bottom: 10px;
		background-color: #FFFFFF;

		.tabs-box {
			margin: 5px 15px;
			border-radius: 10px;
			overflow: hidden;
		}
		
		.tabs-bfc{
			overflow: auto;
		}
		
		.tabs {
			background-color: #0A1A33;
			overflow: auto;
			white-space: nowrap;

			.tab {
				display: inline-flex;
				justify-content: center;
				align-items: center;
				text-align: center;
				width: 75px;
				height: 37px;
				background: #5C6066;
				border-radius: 3px;
				margin: 3px;
				font-size: 11px;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				letter-spacing: 0.2800000011920929px;
			}

			.tab-active {
				background-color: #498EF5;
				position: relative;
				&::after{
					content: '';
					width: 5px;
					height: 5px;
					position: absolute;
					top: 0;
					left: 50%;
					transform: translate(-50%,-50%) rotate(45deg);
					background-color: #498EF5;
					z-index: 1;
				}
			}
		}

		.video-item {
			position: relative;
			background-color: #ffffff;
			display: flex;
			flex-direction: column;
			justify-content: center;
			text-align: center;

			.image-box {
				position: relative;
				.img-tip{
					position: absolute;
					right: 10rpx;
					top: 10rpx;
					width: 50rpx;
					height: 28rpx;
				}

				.img-box {
					width: 100%;
					padding-bottom: 64%;
					position: relative;

					.image {
						position: absolute;
						left: 0;
						top: 0;
						width: 100%;
						height: 100%;
					}
				}

				text {
					position: absolute;
					color: red;
					right: 8rpx;
					bottom: 8rpx;
					color: #8A9099;
				}

				.icon {
					width: 44rpx;
					position: absolute;
					left: 50%;
					top: 50%;
					transform: translate(-50%, -50%);
				}
			}

			text {
				font-size: 30rpx;
				font-weight: 400;
				line-height: 39rpx;
				color: #0F0404;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
		}
	}
</style>
