<template>
	<view class="fullHeight">
		<scroll-view scroll-y="true" class="pageContent">
			<headers style="position: fixed; top: 0; left: 0; width: 100%; z-index: 10;" :showBack="true">
				<view class="headerName">
					视频播放列表
				</view>
			</headers>
			<view class="videoBox" :style="{ 'padding-top': (statusBarHeight + 50 ) * 2+ 'rpx' }" v-if="videoList.length>0">
				<view class="videoItem" v-for="(item,index) in videoList" :key="index" @click="playVideoFn(item)">
					<image v-if="item.coverUrl" class="videoPoster" :src="item.coverUrl" mode="aspectFill"></image>
					<view v-else class="videoPoster">
						<image src="/static/no_poster.png" class="no_poster"></image>
					</view>
					<view class="videoName">
						{{item.videoName}}
					</view>
				</view>
			</view>
			<!-- <view class="placeholderBox" v-else>
				<image src="/static/noData.png" class="noDataImg"></image>
				<view class="text">
					暂无数据
				</view>
			</view> -->
			<view class="no_data1" v-else>
				<image src="/static/bthgIcon/noData1.png"></image>
			</view>
		</scroll-view>
		<!-- <footers v-if="pageType=='company'" :activeTab="'videoManage'"></footers> -->
	</view>
</template>

<script>
	import footers from "../../components/footers/footers.vue"
	import headers from "../../components/headers/headers.vue"
	export default {
		components: {
			footers
		},
		data() {
			return {
				videoList: [],
				pageType: 'company',
				groupInfo: {},
				projectSn: "",
				videoConfig:{},
				statusBarHeight: 0,
			};
		},
		onLoad(options) {
			this.statusBarHeight = uni.getStorageSync('systemInfo').statusBarHeight;
			if (options.pageType) {
				this.pageType = options.pageType
			}
			if (options.obj) {
				this.groupInfo = JSON.parse(options.obj)
			}
			this.projectSn = JSON.parse(uni.getStorageSync('projectDetail')).projectSn;
			this.getUseProjectVideoConfig();
		},
		methods: {
			getUseProjectVideoConfig() {
				var that = this
				let requestData = {
					projectSn: this.projectSn
				}
				this.sendRequest({
					url: "xmgl/projectVideoConfig/getUseProjectVideoConfig",
					data: requestData,
					method: "POST",
					success(res) {
						console.log('找封面', res)
						that.videoConfig = res.result;
						that.loadData()
					}
				})
			},
			playVideoFn(item) {
				// console.log(item)
				uni.setStorageSync('videoInfo', {...item,videoType: this.videoConfig.videoType,})
				// if(item.liveRadioUrl){
				uni.navigateTo({
					// url:'./playVideo?url='+item.liveRadioUrl,
					url: 'playVideo'
				})
				// }

			},
			//获取项目分组视频
			loadData(sn) {
				var that = this
				let requestData = {
					groupId: this.groupInfo.id,
					projectSn: this.projectSn,
					videoType: this.videoConfig.videoType,
				}
				this.sendRequest({
					url: "xmgl/videoItem/selectVideoItemListByType",
					data: requestData,
					method: "POST",
					success(res) {
						console.log('找封面', res)
						that.videoList = res.result
					}
				})
			},
			// //获取项目视频
			// loadData(sn) {
			// 	var that = this
			// 	this.sendRequest({
			// 		url: "xmgl/company/getComapnyStatisticsList",
			// 		data: {sn: sn,videoType:1},
			// 		method: "POST",
			// 		success(res){
			// 			console.log('找封面',res)
			// 			that.videoList = res.result.videoList
			// 		}
			// 	})
			// },
		}
	}
</script>

<style lang="scss" scoped>
	.videoBox {
		padding: 40rpx 20rpx 20rpx;
		overflow: hidden;
	}

	.videoItem {
		float: left;
		background-color: white;
		width: calc(50% - 20rpx);
		margin-bottom: 20rpx;

		&:nth-child(2n-1) {
			margin-right: 20rpx;
		}

		.videoPoster {
			height: 180rpx;
			width: 100%;
			background-color: #282828;
			text-align: center;

			.no_poster {
				width: 110rpx;
				height: 100rpx;
				margin-top: 40rpx;
			}
		}

		.videoName {
			font-size: 28rpx;
			color: $uni-text-color;
			padding: 3px 0 16rpx;
			width: 100%;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
			text-align: center;
		}
	}
</style>