<template>
	<view class="">
		<u-navbar :border-bottom="false" back-icon-size="35" :title="type_name" title-size="32" :background="background"
			:back-text-style="hhyanm" title-color="#FFFFFF" back-icon-color="#FFFFFF"></u-navbar>

		<view class="zykkddr">
			<view class="zykkddra">
				<image src="/static/zy/zya1.png"
					style="width: 750rpx;height: 410rpx;margin-top: -102rpx;margin-left: 132rpx;" mode=""></image>
			</view>
			<view class="zykkddrb">
				<view style="margin: 0 24rpx;">
					<u-swiper :list="imglist" interval="58000" height="364" border-radius="16"></u-swiper>
				</view>
			</view>
		</view>
		<view class="zynnuy">
			<view class="zyhttry">
				<view class="zyjjdew"></view>
				<text>更多视频</text>
			</view> 
			<view class="">
				<!-- <block v-for="(item,index) in list" :key="index">
					
				</block> -->
				<view class="zytlidde" @click="toDetail(item)">
					<image class="zytyyrimg" :src="item.cover" mode=""></image>
					<view class="zytyyopf">
						<view class="zytyotxta"><text>{{item.title}}</text></view>
						<view class="flztoa zytyotxtb">
							<text>{{item.desc}}</text>
							<image src="/static/zy/zyb3.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
						</view>
						<!-- <view class="flztoa">
							<view class="fzctob zytyotxtc">
								<text>{{item.sales}}人观看</text>
								<image :src="item.is_collect == 1?'/static/zy/zyb1.png':'/static/zy/zyb2.png'" style="width: 40rpx;height: 40rpx;margin-left: 20rpx;" @click="shocuang(item.id)"></image>
							</view>
							<text class="zytyotxtd">{{item.time}}分钟</text>
						</view> -->
					</view>
				</view>
				<view class="zyhxyyer"></view>
				
			</view>
		</view>
	</view>
</template>
<style>
	page {
		background: #FAFAFA;
	}
</style>
<script>
	export default {
		data() {
			return {
				item:null,
				background: {
					backgroundColor: '#486A92',
				},
				hhyanm: {
					color: '#FFFFFF',
				},
				timestamp: 86400,
				type_id: '',
				user_id: '',
				page: 1,
				num: 20,
				list: [],
				imglist:[],
				total: 0,
				type_name: '视频'
			}
		},
		onLoad(e) {
			this.item = JSON.parse(e.item);
			let imgs = [];
			imgs.push(this.item.cover);
			this.imglist = imgs;
			// this.user_id = uni.getStorageSync('id');
			// this.getlist();
			// this.getimg();
		},
		onReachBottom() {
			if (this.list.length < this.total) {
				this.page = this.page + 1
				this.getlist();
			} else {
				uni.showToast({
					title: '没有更多数据了',
					icon: 'none'
				})
			}
		},
		methods: {
			getlist() {
				let that = this;
				let data = {
					page: that.page,
					num: that.num,
					type_id: that.type_id,
					user_id: that.user_id,
					title: ''
				}
				console.log(data)
				this.$post({
					data: {
						do: 'CourseList',
						data: {
							page: that.page,
							num: that.num,
							type_id: that.type_id,
							user_id: that.user_id,
							title: ''
						}
					}
				}).then(res => {
					that.list = [...that.list, ...res.data.data]
					that.total = Number(res.data.total)
					that.type_name = res.data.type_name
				})
			},
			shocuang(id){
				let that = this;
				this.$post({
					data: {
						do: 'CourseAttribute',
						data: {
							id: id,
							user_id: that.user_id,
							pw:'375'
						}
					}
				}).then(res => {
					that.page = 1;
					that.list = [];
					that.getlist();
				})
			},
			// 获取分类列表
			getimg() {
				let user_id = uni.getStorageSync('id');
				this.$post({
					data: {
						do: 'CourseType',
						data: {
							user_id: user_id,
							type_id: this.type_id,
							pw: '375'
						}
					}
				}).then(res => {
					this.imglist = res.data[0].img
			
				})
			},
			// 去详情
			toDetail(i){
				uni.navigateTo({
					url:'/pages/index/kcxq-x?item='+ JSON.stringify(this.item)
				})
			}
			
			
		}
	}
</script>

<style lang="scss" scoped>

</style>
