<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>
				<view style="color:gray;text-align: center;margin-top:20upx;">{{loadingText}}</view>
		</uni-list>
		<!-- <view v-for="item in dataList" style="display: flex   ; padding: 24rpx 30rpx;font-size: 28rpx;color: #3b4144;border-bottom: 1px solid #dcdcdc;">
			<view class="leftAction" style="flex: 3;">
				<view>{{item.video_.name}}</view>
				<view style="margin-top: 6rpx;  color: #999; font-size: 24rpx;">上次观看进度:</view>
				<view style="margin-top: 6rpx;  color: #999; font-size: 24rpx;">上次观看时间:{{item.update_time}}</view>
			</view>
			<view class="rightAction" style="flex: 1;    display: flex; flex-direction: column;justify-content: space-around;">
				<a class="mui-navigate-right" style=" color: #999; font-size: 24rpx;">继续观看</a><image src="../../static/common/right_err.png"></image>
			</view>
		</view> -->
	</scroll-view>	
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				dataList: [],
				refreStatus: false,
			}
		},
		onShow(){
            this.page = 1;
			this.getLists();
			//this.$u.api.getMyVideoRecord({}).then(res => {
			//	this.dataList = res.data.results;
			//	console.log(res.data.results)
			//})
		},
		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(){
				var params = {
					page: this.page
				}
				this.$u.api.getMyVideoRecord(params).then(res => {
					this.refreStatus = false
					let results = res.data.results
					
					if (this.page == 1) {
						if (results == 0) {
							this.loadingText = '暂无观看记录'
						} else {
							this.loadingText = ''
							this.dataList = results
						}
					} else {
						this.loadingText = ''
						this.dataList.concat(results)
					}
				
				}).catch(res => {
					this.refreStatus = false
					if (res.code == 404) {
						this.loadingText = '到底了'
					}
				})
			},
		},
	
		
	}
</script>

<style>
</style>
