增加推荐页面

This commit is contained in:
2025-01-09 17:28:30 +08:00
parent 8572bebabb
commit f6d386e793
5 changed files with 348 additions and 102 deletions

View File

@@ -1,16 +1,17 @@
<template>
<view class="item" @appear="appear" @disappear="disappear">
<view class="item" @appear="appear" @disappear="disappear" @click.stop>
<video class="u-flex-1 video" :show-fullscreen-btn="false" @controlstoggle="controlstoggles"
v-if="showVideo" @waiting="waiting()" object-fit="cover"
<video class="u-flex-1 video" :show-fullscreen-btn="false" @controlstoggle="controlstoggles" v-if="showVideo"
@waiting="waiting()" object-fit="cover"
@play="videoPlay('myVideo'+item.courseDetailsId,item.courseDetailsId)" :play-strategy="2"
:show-loading="true" codec="software" :muted="false" :show-center-play-btn="true" :loop="false"
:enable-progress-gesture="false" :poster="item.titleImg" :ref="'myVideo'+item.courseDetailsId"
:autoplay="autoplay" @ended="ended" :id="'myVideo'+item.courseDetailsId" :src="item.videoUrl"></video>
<image class="poster" v-else @click="popupShow('pay')" :src="item.titleImg" mode="aspectFill"></image>
<image class="poster" v-else @click="!item.videoUrl?popupShow('pay'):''" :src="item.titleImg" mode="aspectFill">
</image>
<view class="info">
<view class="info" v-if="!isCommand">
<text class="color-fff" v-if="item.courseDetailsName">{{item.courseDetailsName}}</text>
<view v-if="item.content" v-html="item.content"></view>
<view class="u-m-t-20 color-fff" @click="popupShow('show')">
@@ -19,21 +20,31 @@
</text>
</view>
</view>
<view class="info" v-if="isCommand">
<text class="color-fff" v-if="item.courseDetailsName">{{item.courseDetailsName}}</text>
<view v-if="item.content" v-html="item.content"></view>
<view class="u-m-t-20 color-fff" @click="toDetail">
<text class="color-fff">
查看更多续集 >
</text>
</view>
</view>
<view class="right">
<view class="love u-flex u-flex-xy-center u-flex-col u-m-b-40 u-text-center" @click="dianzanClick">
<up-icon name="heart-fill" v-if="item.isGood==1" color="red" size="30"></up-icon>
<up-icon name="heart-fill" v-else color="#ffffff" size="30"></up-icon>
<text class="text color-fff">{{item.goodNum}}</text>
<text class="text color-fff u-font-24">{{item.goodNum}}</text>
</view>
<view class="share u-m-b-40 u-flex u-flex-xy-center u-flex-col u-text-center" @click="share">
<image class="icon" src="@/static/images/share.png" mode=""></image>
<text class="text color-fff">分享</text>
<text class="text color-fff u-font-24">分享</text>
</view>
<view class="zhuiju u-m-b-40 u-flex u-flex-xy-center u-flex-col u-text-center" @click="zhuijuClick">
<image class="icon" v-if="isCollect" src="@/static/images/shuqian.png" mode=""></image>
<image class="icon" v-else src="@/static/images/shuqian_s.png" mode=""></image>
<text class="text color-fff">{{isCollect?'已追':'追剧'}}</text>
<text class="text color-fff u-font-24">{{isCollect?'已追':'追剧'}}</text>
</view>
</view>
@@ -43,17 +54,25 @@
<script setup>
import {
computed,
nextTick,
onMounted,
ref
ref,
watch
} from 'vue'
const props = defineProps({
item: {
type: Object,
defaulr: () => {
return {videoUrl:''}
return {
videoUrl: ''
}
}
},
isCommand: {
type: Boolean,
default: false
},
instance: {
type: Object,
defaulr: () => {
@@ -71,7 +90,7 @@
type: Number,
default: 0
},
nowIndex:{
nowIndex: {
//app判断是否是当前项目
type: Number,
default: 0
@@ -83,16 +102,27 @@
isCollect: {
type: [Number, Boolean],
default: 0
},
playSpeeds: {
type: Number,
default: 1
}
})
let autoplay = ref(props.item.videoUrl?true:false)
let autoplay = ref(props.item.videoUrl ? true : false)
const emits = defineEmits(['controlstoggles', 'disappear', 'appear', 'waiting', 'videoPlay', 'ended', 'dianzanClick',
'share', 'zhuijuClick', 'popupShow'
'share', 'zhuijuClick', 'popupShow', 'itemMounted', 'toDetail'
])
function controlstoggles() {
function controlstoggles(e) {
emits('controlstoggles', e)
}
function toDetail() {
if (video) {
video.pause()
}
emits('toDetail')
}
function waiting() {
@@ -123,18 +153,28 @@
emits('popupShow', key)
}
let first = true
function appear() {
video && video.play()
emits('appear')
if (video) {
video.playbackRate(props.playSpeeds)
video.play()
}
emits('appear', first)
if (first) {
first = false
}
}
let video = null
function disappear() {
video && video.pause()
if (video) {
video.pause()
}
emits('disappear')
}
const showVideo=computed(()=>{
const showVideo = computed(() => {
// #ifdef H5
return props.current === props.index && props.item.videoUrl
// #endif
@@ -143,15 +183,33 @@
// #endif
})
onMounted(() => {
console.log('onMounted');
init()
emits('itemMounted', props.index)
})
function init() {
try {
if(props.item.videoUrl){
if (props.item.videoUrl && showVideo.value) {
video = uni.createVideoContext('myVideo' + props.item.courseDetailsId)
video.playbackRate(props.playSpeeds)
}
} catch (error) {
console.error('------')
//TODO handle the exception
}
}
watch(() => props.playSpeeds, (newval) => {
console.log('speed' + newval);
if (video) {
video.playbackRate(newval)
}
})
watch(() => showVideo.value, (newval) => {
if (newval) {
init()
} else {
video = null
}
})
</script>