<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 list" :key="index"  @click="$goPage('/pages/indexEntry/publicVideo/videoDetail/videoDetail?id='+ item.id)">
					<videoItem :item="item"></videoItem>
				</view>
			</view>
			<view style="padding-bottom: 20rpx;" v-if="list.length">
				<u-loadmore :status="status" />
			</view>
			<nodata v-if="!list.length"></nodata>
		</view>
	</view>
</template>

<script>
	import videoItem from './videoItem.vue'
	import { getcollectVideo } from '@/config/api.js'
	export default {
		components: { videoItem },
		data() {
			return {
				list: [],
				params: {
					phone: '',
					title: '',
					pageNo: 1,
					pageSize: 20
				},
				total: 20,
				status: 'loading'
			}
		},
		onLoad() {
			this.params.phone = this.vuex_userInfo.phone
			this.getcollectVideoFn()
		},
		onPullDownRefresh() {
			this.params.pageNo = 1
			this.list = []
			this.getcollectVideoFn().then(()=>{
				uni.stopPullDownRefresh()
			})
		},
		onReachBottom() {
			if(this.total>this.list.length) {
				this.getcollectVideoFn()
			}				
		},
		methods: {
			searchFn(val) {
				this.params.title = val
				this.list = []
				this.params.pageNo = 1
				this.getcollectVideoFn()
			},
			async getcollectVideoFn() {
				const {data: res} = await getcollectVideo(this.params)
				this.params.pageNo ++
				this.list.push(...res.list)
				this.total = res.total
				if(this.list.length>=this.total) this.status = 'nomore'
			}
		}
	}
</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>