<template>
	<scroll-view 
	scroll-y="true" 
	:style="{height: height}"
	@scrolltolower="loadMoreData">
		<view class="videoList">
			<view class="video-item" v-for="(item, index) in list" :key="index"
			@click="showVideo(item)">
				<view class="image">
					<image :src="item.videoImage" mode="aspectFill">
					</image>
					<view class="icon">
						<uv-icon size="35rpx" name="play-right-fill">
						</uv-icon>
					</view>
				</view>
				<view class="bottom">
					<view class="headImage">
						<!-- <image src="https://img-s-msn-com.akamaized.net/tenant/amp/entityid/BB1msKSi.img" mode="aspectFill">
						</image> -->
						{{ item.videoTitle }}
					</view>
					<view class="like">
						<uv-icon size="45rpx" v-if="false" name="heart"></uv-icon>
						<uv-icon size="45rpx" color="#FF4340" v-else name="heart-fill"></uv-icon>
						{{ item.videoThumpup }}
					</view>
				</view>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	export default {
		props : {
			height : {
				default : 'auto'
			},
			roleId : {
			}
		},
		data() {
			return {
				queryParams: {
					pageNo: 1,
					pageSize: 10,
				},
				total : 0,
				list : [],
			}
		},
		methods: {
			showVideo(item){
				this.$utils.hanldePreview
			},
			queryVideoList(){
				
				if(this.roleId){
					this.queryParams.roleInfoId = this.roleId
				}
				
				this.$api('queryVedioById', this.queryParams, res => {
					if(res.code == 200){
						this.list = res.result.records
						this.total = res.result.total
					}
				})
			},
			loadMoreData(){
				if(this.queryParams.pageSize < this.total){
					this.queryParams.pageSize += 10
					this.queryVideoList()
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.videoList {
		display: flex;
		flex-wrap: wrap;

		.video-item {
			margin: 20rpx;
			width: 335rpx;

			.image {
				position: relative;
				width: 100%;
				height: 420rpx;
				border-radius: 30rpx;
				overflow: hidden;

				image {
					width: 100%;
					height: 100%;
				}

				.icon {
					position: absolute;
					right: 30rpx;
					top: 30rpx;
					width: 60rpx;
					height: 60rpx;
					background-color: #ffffffaa;
					border-radius: 50%;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}

			.bottom {
				padding: 10rpx 0;
				font-size: 22rpx;
				display: flex;
				justify-content: space-between;

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

					image {
						width: 50rpx;
						height: 50rpx;
						border-radius: 50%;
						margin-right: 6rpx;
					}
				}

				.like {
					display: flex;
					align-items: center;
				}
			}
		}
		.showVideo{
			display: flex;
			justify-content: center;
			align-items: center;
			height: 100%;
			width: 1000%;
			video{
				// width: 100%;
				// height: 100%;
			}
		}
	}
</style>