Files
new_app/pages/video/detail.nvue

100 lines
1.8 KiB
Plaintext

<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 sysInfo = uni.getSystemInfoSync()
let isFirstLoad=true
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)
isFirstLoad=false
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()
}
}
onLoad((opt) => {
Object.assign(options, opt)
init()
})
function swiperChange({
current,
direction,
data
}) {}
onShow(async () => {
if(!isFirstLoad){
await init()
refVideoList.value.videoListUpdata()
const drawRes=await Api.getDrawCount()
console.log(drawRes);
const nobuyCourseId=uni.getStorageSync('nobuyCourseId')
const item=state.list.find(v=>v.courseId==nobuyCourseId)
uni.clearStorageSync('nobuyCourseId')
if(drawRes.count*1>0&&nobuyCourseId!==null&&nobuyCourseId!==undefined&&item.videoUrl){
uni.navigateTo({
url:'/pages/me/prizeDraw'
})
}
}
})
</script>
<style lang="scss" scoped>
.min-page {
height: 100vh;
flex: 1;
background-color: #000;
overflow: hidden;
}
.u-popup {
position: fixed;
}
</style>