<template>
	<view class="min-page">
		<my-video-list ref="refVideoList" v-if="state.list.length" @swiperChange="swiperChange" :list="state.list" @update="update"
			:info="state"></my-video-list>
	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app'
	import * as Api from '@/api/video/index.js'
	import {
		reactive, ref
	} from 'vue'
	import {
		slice
	} from 'lodash'
	const boxStyle = {
		height: '835px'
	}
	let options = {}
	const state = reactive({
		collect: 0,
		current: {},
		list: [],
		price: 0,
		title: ''
	})
	const refVideoList=ref(null)
	async function init() {
		try {
			const res = await Api.getVideoDetail(options)
			Object.assign(state, res)
			state.list = res.list
		} catch (error) {
			// if(getCurrentPages().length>=2){
			// 	uni.navigateBack()
			// }else{
			// 	uni.switchTab({
			// 		url:'/pages/index/index'
			// 	})
			// }
		}
	}

	async function update({
		index,
		item
	}) {
		if(item){
			state.list[index] = item
		}else{
			await init()
			refVideoList.value.videoListUpdata()
		}
	}
	onLoad((opt) => {
		Object.assign(options, opt)
		init()
	})

	function swiperChange({
		current,
		direction,
		data
	}) {}

	onShow(() => {
		init()
	})
</script>

<style lang="scss" scoped>
	.min-page {
		height: 100vh;
		flex: 1;
		background-color: #000;
		overflow: hidden;
	}

	.u-popup {
		position: fixed;
	}
</style>