<template>
	<view class="box">
		<!-- 视频 -->
		<view class="video-box" v-if="tabType == 3 && videoList.length != 0">
			<view class="video-single w-50"  v-for="item in videoList" :key="item.videold">
				<video class="w-100" src="" :poster="item.recFirstFrameUrl" object-fit="fill"></video>
				<view class="video-name">
					{{item.name}}
				</view>
			</view>
		</view>
		<!-- 内容为空时 -->
		<u-empty v-else mode="data" :text="text" class="empty">
		</u-empty>
	</view>
</template>

<script>
	export default {
		name: "courseware",
		props: ["tabType"],
		mounted() {
			this.tabsif(this.tabType)
		},
		watch: {
			tabType: function(newValue, oldValue) {
				this.tabsif(newValue)
			}
		},
		data() {
			return {
				videoList: [],
				text:""
			};
		},
		methods: {
			// 列表判断
			tabsif(value) {
				switch (value) {
					case 2:
						this.text = "课件内容为空"
						break;
					case 3:
						this.$api.getroombindvideos().then(res => {
							if (res.data.code == 200) {
								this.videoList = res.data.data
								console.log(res.data.data)
							}
						})
						break;
					case 4:
						this.text = "问答内容为空"
						break;
					case 5:
						this.text = "讲师评价为空"
						break;
					case 7:
						this.text = "外部链接为空"
						break;
					case 9:
						this.text = "图文编辑为空"
						break;
					default:
						this.text = "自定义页面为空"
						break;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 公用区
	.box {
		height: calc(100vh - 500rpx);
		.empty{
			height: 100%;
		}
	}
	.w-50 {
		width: 50%;
	}
	.w-100{
		width: 100%;
	}
	// 视频区
	.video-box{
		overflow-y: auto;
		height: 100%;
		box-sizing: border-box;
		padding: 40rpx;
		.video-single{
			display: inline-block;
			box-sizing: border-box;
			padding: 10rpx;
			video{
				height: 200rpx;
				border-radius: 20rpx;
			}
			.video-name{
				text-align: center;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				padding-bottom: 20rpx;
			}
		}
	}
	
</style>