修复h5默认值错误问题

This commit is contained in:
2025-01-17 18:19:29 +08:00
parent 35909ae42c
commit 9651c9cb6f
2 changed files with 47 additions and 71 deletions

View File

@@ -7,6 +7,7 @@
:show-play-btn="false"
:controls="true"
@click.stop="videoClick()"
@loadedmetadata="loadedmetadata"
@timeupdate="timeupdate" @waiting="waiting()" object-fit="cover" @pause="onpause"
@play="videoPlay('myVideo'+item.courseDetailsId,item.courseDetailsId)" :play-strategy="2"
:show-loading="true" codec="software" :muted="false" :loop="loop"
@@ -17,7 +18,7 @@
mode="aspectFill">
</image>
<view class="play-icon" v-if="showVideo&&!isPlying" @click.stop="videoClick()" :style="playStyle">
<view class="play-icon" v-if="videoIsLoadedmetadata&&showVideo&&!isPlying" @click.stop="videoClick()" :style="playStyle">
<image class="icon" src="@/static/images/play.png" mode=""></image>
</view>
@@ -181,6 +182,11 @@
function waiting() {
}
let videoIsLoadedmetadata=ref(false)
function loadedmetadata(){
videoIsLoadedmetadata.value=true
}
let isPlying = ref(false)
@@ -211,9 +217,7 @@
function timeupdate(e) {
//隐藏loding
// #ifdef H5
uni.hideLoading()
// #endif
if (isPlayFinish) {
return
}
@@ -308,7 +312,9 @@
}
const showVideo = computed(() => {
if(props.isAndriod){
return props.nowIndex === props.index && props.item.videoUrl ?true :false
console.log('props.nowIndex === props.index ');
console.log(props.nowIndex,props.index );
return (props.nowIndex === props.index && props.item.videoUrl) ?true :false
}else{
return props.current === props.index && props.item.videoUrl
}

View File

@@ -1,37 +1,36 @@
<template>
<view v-if="isH5||isIos" class=" w-full box" style="width: 100vw;">
<swiper @longpress="popupShow('speed')" :style="{height:wHeight+'px'}" v-if="videoList.length"
@change="swiperChange" :current="current" :circular="true" vertical class="u-flex-1"
@transition="transition" :indicator-dots="false" :autoplay="false" :interval="0" :duration="200">
<swiper-item v-for="(item,index) in videoList" :key="index">
<list-item-vue :total="list.length" :item="item" :isCommand="isCommand" :height="wHeight"
:isAndriod="isAndriod"
:isTabbar="isTabbar" @playStatusChange="playStatusChange" :showControls="control.showControls"
:current="current" :isCollect="isCollect" @toDetail="toDetail(item,index)"
@controlstoggles="controlstoggles" :playSpeeds="playSpeeds" :index="index" :nowIndex="nowIndex"
@dianzanClick="dianzanClick(item,index)" @share="share(item)" @zhuijuClick="zhuijuClick(item)"
@popupShow="popupShow($event,item,index)"></list-item-vue>
</swiper-item>
</swiper>
</view>
<list v-if="showAndriod" :bounce="false" :loadmoreoffset="wHeight*3" :show-scrollbar="false" ref="listBox" :pagingEnabled="true"
@loadmore="loadmore" :scrollable="true">
<list v-if="showAndriod" :bounce="false" :loadmoreoffset="wHeight*3" :show-scrollbar="false" ref="listBox"
:pagingEnabled="true" @loadmore="loadmore" :scrollable="true">
<cell v-for="(item,index) in list" :key="item.courseDetailsId" :ref="setRefList(index)">
<view class="swipers-items" :style="boxStyle" @longpress="popupShow('speed')">
<list-item-vue :total="list.length" :item="item" :current="current" :isCollect="isCollect"
:isAndriod="isAndriod"
:isTabbar="isTabbar" @playStatusChange="playStatusChange" :height="wHeight" :isCommand="isCommand"
:showControls="control.showControls" @toDetail="toDetail(item,index)" @itemMounted="itemMounted"
@controlstoggles="controlstoggles" :index="index" :instance="instance" :nowIndex="nowIndex"
@appear="appear($event,item,index)" :playSpeeds="playSpeeds"
:isAndriod="isAndriod" :isTabbar="isTabbar" @playStatusChange="playStatusChange" :height="wHeight"
:isCommand="isCommand" :showControls="control.showControls" @toDetail="toDetail(item,index)"
@itemMounted="itemMounted" @controlstoggles="controlstoggles" :index="index" :instance="instance"
:nowIndex="nowIndex" @appear="appear($event,item,index)" :playSpeeds="playSpeeds"
@disappear="disappear($event, item,index)" @dianzanClick="dianzanClick(item,index)"
@share="share(item)" @zhuijuClick="zhuijuClick(item)"
@popupShow="popupShow($event,item,index)"></list-item-vue>
</view>
</cell>
</list>
<view v-if="isH5||isIos" class=" w-full box" style="width: 100vw;">
<swiper @longpress="popupShow('speed')" :style="{height:wHeight+'px'}" v-if="videoList.length"
@change="swiperChange" :current="current" :circular="true" vertical class="u-flex-1"
@transition="transition" :indicator-dots="false" :autoplay="false" :interval="0" :duration="200">
<swiper-item v-for="(item,index) in videoList" :key="index">
<list-item-vue :total="list.length" :item="item" :isCommand="isCommand" :height="wHeight"
:isAndriod="isAndriod" :isTabbar="isTabbar" @playStatusChange="playStatusChange"
:showControls="control.showControls" :current="current" :isCollect="isCollect"
@toDetail="toDetail(item,index)" @controlstoggles="controlstoggles" :playSpeeds="playSpeeds"
:index="index" :nowIndex="nowIndex" @dianzanClick="dianzanClick(item,index)" @share="share(item)"
@zhuijuClick="zhuijuClick(item)" @popupShow="popupShow($event,item,index)"></list-item-vue>
</swiper-item>
</swiper>
</view>
<!-- 返回按钮 -->
<view class="back-icon" v-if="!isTabbar&&control.showBack">
@@ -262,17 +261,15 @@
getCurrentInstance,
onUnmounted
} from 'vue';
let isH5=true
let isH5 = false
// #ifdef H5
isH5=false
isH5 = true
// #endif
const sysinfo=uni.getSystemInfoSync()
const isIos=sysinfo.platform=='ios'?true:false
const isAndriod=sysinfo.platform=='android'?true:false
const showAndriod=!isH5&&isAndriod
const sysinfo = uni.getSystemInfoSync()
const isIos = sysinfo.platform == 'ios' ? true : false
const isAndriod = sysinfo.platform == 'android' ? true : false
const showAndriod = !isH5 && isAndriod ? true : false
let initing = true
const refPoster = ref(null)
@@ -413,7 +410,7 @@
console.log(e);
}
async function xuanjiInit() {
const height = 44
const marginBottom = 10
const oneItemHeight = height + marginBottom
@@ -465,25 +462,6 @@
$mountedComponents[index] = true
}
console.log('appear:' + index);
// if($common.isIos&&!initing){
// console.log('appear:'+index);
// nowIndex.value = index
// const item = props.list[nowIndex.value]
// if (!item.videoUrl) {
// popupShow('pay', item, nowIndex.value)
// }
// cacheIndex = null
// return
// }
if($common.isIos){
nowIndex.value = index
const item = props.list[nowIndex.value]
if (!item.videoUrl) {
popupShow('pay', item, nowIndex.value)
}
cacheIndex = null
return
}
if (!initing) {
cacheIndex = index
}
@@ -491,14 +469,6 @@
}
function disappear(e, item, index) {
if ($common.isIos) {
if(e.direction=='up'){
cacheIndex=nowIndex.value-1<0?0:nowIndex.value-1
}else{
cacheIndex=(nowIndex.value+1>(props.list.length-1)) ? props.list.length-1:nowIndex.value+1
}
return
}
if (index == nowIndex.value && cacheIndex !== null && !initing) {
console.log('disappear' + index);
console.log('disappear nowIndex' + nowIndex.value);
@@ -606,9 +576,9 @@
videoList.value[newCurrent] = item;
current.value = newCurrent;
popupClose('show')
// #ifdef APP
goListPosition(index)
// #endif
if (showAndriod) {
goListPosition(index)
}
}
let refList = ref([])
@@ -726,12 +696,12 @@
let item = props.list.find(v => props.options.courseDetailsId == v.courseDetailsId)
item = item ? item : props.info.current;
if (JSON.stringify(item) !== '{}') {
if(showAndriod){
if (showAndriod) {
nextTick(() => {
const index = props.list.findIndex(v => v.courseDetailsId == item.courseDetailsId)
goListPosition(index)
})
}else{
} else {
setVideoList(item)
}
}
@@ -916,7 +886,7 @@
})
watch(() => props.list.length, (newval) => {
console.log('props.list.length change' + newval);
if(!showAndriod){
if (!showAndriod) {
init()
}
})