<template>
	<scroll-view :lower-threshold="80" :refresher-triggered="refreStatus"
		@refresherrefresh="handleRefre" :refresher-enabled="true" class="swiper-scroll" scroll-y="true"
		@scrolltolower="swiperScrollLower" >
		<uni-list>
			<uni-list-item :title="item.video_.name" :note="'上次观看时间:'+item.update_time"  thumb-size="lg"
				rightText="继续观看" v-for="item in dataList" :key="item.id" @click="plauVideo(item)" link></uni-list-item>
				
		</uni-list>
		<view style="color:gray;text-align: center;margin-top:20upx;">{{loadingText}}</view>
	</scroll-view>	
	
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				page_size:20,
				dataList: [],
				loadingText:'',
				refreStatus: false,
			}
		},
		onShow(){

            this.page = 1;
			this.getLists();
		},
		methods: {
			plauVideo(item){
				uni.navigateTo({
					url: '/pages/vod/watchPage?id='+item.video_.id+'&current='+item.current
				});
			},
			// 下拉事件
			handleRefre() {
				this.refreStatus = true;
				this.page = 1
				this.getLists()
			},
			swiperScrollLower() {
				this.page = this.page + 1;
				this.getLists()
			},
			getLists(){
				// debugger;
				console.log(this.page)
				var params = {
					page: this.page,
					page_size:this.page_size
				}
				this.$u.api.getMyVideoRecord(params).then(res => {
					this.refreStatus = false
					let results = res.data.results;
					// debugger;
					if (this.page == 1) {
						if (results == 0) {
							this.loadingText = '暂无观看记录'
						} else {
							this.loadingText = ''
							this.dataList = results
						}
					} else {
						// debugger;
						this.loadingText = ''
						let a = this.dataList.concat(results);
						console.log(a)
						this.dataList=a;
					}
				
				}).catch(res => {
					this.refreStatus = false
					if (res.code == 404) {
						this.loadingText = '到底了'
					}
				})
			},
		},
	
		
	}
</script>

<style>
	
	.swiper-scroll {
		height: calc(100vh - 40upx);
	}
</style>
