<template>
	<view class="pageBgImg">
		<topNavbar title="安全驾驶"></topNavbar>
		<view class="pad">
			<view class="searcBox">
				<searchRow placeholder="搜索视频名称" @searchFn="searchFn"/>
			</view>
			<view class="ul">
				<view class="li" v-for="(item,index) in listData" :key="index"  @click="$goPage('/pages/indexEntry/publicVideo/videoDetail/videoDetail?id='+ item.id)">
					<videoItem :item="item"></videoItem>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import videoItem from './comp/videoItem'
	import { publicVideoPage } from '@/config/api.js'
	export default {
		components: { videoItem },
		data() {
			return {
				params: {
					pageNo: 1,
					pageSize: 20,
					title: ''
				},
				listData: [],
				total: 20,
			}
		},
		onLoad() {
			this.publicVideoPageFn()
		},
		methods: {
			initList() {
				this.params.pageNo = 1
				this.listData = []
				this.publicVideoPageFn()
			},
			async publicVideoPageFn() {
				const {data: res} = await publicVideoPage(this.params)
				this.listData.push(...res.list)
				this.total = res.total
			},
			searchFn(val) {
				this.params.title = val
				this.initList()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.ul {
		width: 100%;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
	  .li {
		  width: 100%;
		  width: 48%;
		  height: 260rpx;
		  background: #FFFFFF;
		  box-shadow: 0px 8rpx 20rpx 0px rgba(0,0,0,0.04), 2rpx 2rpx 8rpx 0px rgba(0,0,0,0.06);
		  border-radius: 16rpx;
		  margin-bottom: 24rpx;
		  padding: 16rpx;
	    
	  }
	}
	.searcBox {
		padding: 0rpx 0 32rpx 0;
	}
</style>