增加公共状态管理

This commit is contained in:
2025-01-13 18:18:45 +08:00
parent f410719b46
commit 3919dc507c
6 changed files with 100 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
<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>
@@ -20,7 +21,7 @@
} from 'lodash'
const sysInfo = uni.getSystemInfoSync()
let isFirstLoad=true
let isFirstLoad = true
let options = {}
const state = reactive({
collect: 0,
@@ -33,7 +34,7 @@
async function init() {
try {
const res = await Api.getVideoDetail(options)
isFirstLoad=false
isFirstLoad = false
Object.assign(state, res)
state.list = res.list
} catch (error) {
@@ -69,17 +70,18 @@
}) {}
onShow(async () => {
if(!isFirstLoad){
if (!isFirstLoad) {
await init()
refVideoList.value.videoListUpdata()
const drawRes=await Api.getDrawCount()
const drawRes = await Api.getDrawCount()
console.log(drawRes);
const nobuyCourseId=uni.getStorageSync('nobuyCourseId')
const item=state.list.find(v=>v.courseId==nobuyCourseId)
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){
if (drawRes.count * 1 > 0 && nobuyCourseId !== null && nobuyCourseId !== undefined && item
.videoUrl) {
uni.navigateTo({
url:'/pages/me/prizeDraw'
url: '/pages/me/prizeDraw'
})
}
}