new_app/pages/video/detail.nvue

143 lines
2.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="min-page">
<my-video-list ref="refVideoList" v-if="state.list.length" @swiperChange="swiperChange" :list="state.list"
:options="options" @update="update" :info="state"></my-video-list>
</view>
</template>
<script setup>
import {
onLoad,
onHide,
onShow
} from '@dcloudio/uni-app'
import {
login
} from '@/api/login/login.js';
import * as Api from '@/api/video/index.js'
import {
useCommonStore
} from '@/store/common.js';
const $common = useCommonStore();
import {
reactive,
ref
} from 'vue'
import {
slice
} from 'lodash'
const sysInfo = uni.getSystemInfoSync()
let isFirstLoad = true
let options = {
courseDetailsId: ''
}
const state = reactive({
collect: 0,
current: {},
list: [],
price: 0,
title: ''
})
const refVideoList = ref(null)
async function init() {
/**
* 如果是安卓則不做操作如果是ios判斷是否審核不審核不套裝
*/
// 是否审核,是否ios
if ($common.isIosExamine) {
const res = await Api.getVideoDetail(options)
isFirstLoad = false
Object.assign(state, res)
state.list = res.list
} else {
// ios是否登錄
console.log(uni.getStorageSync('tokenTwo'),'提送hi')
if (uni.getStorageSync('tokenTwo')) {
const res = await Api.getVideoDetail({...options,token:uni.getStorageSync('tokenTwo')})
isFirstLoad = false
Object.assign(state, res)
state.list = res.list
} else {
let res = await login({
password: '123456',
phone: '18681817128'
})
uni.setStorageSync('tokenTwo', res.token)
init()
}
}
// 是否审核,是否ios 保存本地
// 18681817128 123456 测试环境和正式环境都是这个账号 等会给添加上会员就可以了
// return res.token
try {
} 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.removeStorageSync('nobuyCourseId')
if (item) {
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>