diff --git a/src/components/slide/BVideo.vue b/src/components/slide/BVideo.vue index 6b3d1ad..474622e 100644 --- a/src/components/slide/BVideo.vue +++ b/src/components/slide/BVideo.vue @@ -94,12 +94,6 @@ export default { return {} } }, - index: { - type: Number, - default: () => { - return -1 - } - }, position: { type: Object, default: () => { @@ -169,6 +163,7 @@ export default { } }, mounted() { + console.log('video', this.localItem.id) // console.log(this.commentVisible) this.height = document.body.clientHeight this.width = document.body.clientWidth @@ -282,12 +277,11 @@ export default { this.commentVisible = false } }, - click({baseIndex, navIndex, itemIndex, type}) { - // console.log(baseIndex, navIndex, itemIndex, this.position) + click({uniqueId, index, type}) { + // console.log(this.position) if ( - this.position.baseIndex === baseIndex && - this.position.navIndex === navIndex && - this.position.itemIndex === itemIndex + this.position.uniqueId === uniqueId && + this.position.index === index ) { if (type === EVENT_KEY.ITEM_TOGGLE) { if (this.status === SlideItemPlayStatus.Play) { diff --git a/src/components/slide/SlideVerticalInfinite.vue b/src/components/slide/SlideVerticalInfinite.vue index e8cb5ff..b4696c2 100644 --- a/src/components/slide/SlideVerticalInfinite.vue +++ b/src/components/slide/SlideVerticalInfinite.vue @@ -6,6 +6,7 @@ import {SlideType} from "@/utils/const_var"; import SlideItem from '@/components/slide/SlideItem.vue' import bus, {EVENT_KEY} from "../../utils/bus"; import {useStore} from 'vuex' +import Loading from "@/components/Loading.vue"; const props = defineProps({ index: { @@ -14,12 +15,6 @@ const props = defineProps({ return 0 } }, - position: { - type: Object, - default: () => { - return {} - } - }, render: { type: Function, default: () => { @@ -40,6 +35,18 @@ const props = defineProps({ type: String, default: () => '' }, + uniqueId: { + type: String, + default: () => '' + }, + loading: { + type: Boolean, + default: () => false + }, + active: { + type: Boolean, + default: () => false + }, }) const emit = defineEmits(['update:index', 'loadMore']) @@ -86,26 +93,36 @@ watch( }) } } - } -) + }) + watch( () => props.index, (newVal, oldVal) => { // console.log('watch-index', newVal, oldVal,props.list, props.list[newVal].id) bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { - ...props.position, - itemIndex: newVal, + uniqueId: props.uniqueId, + index: newVal, type: EVENT_KEY.ITEM_PLAY }) setTimeout(() => { bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { - ...props.position, - itemIndex: oldVal, + uniqueId: props.uniqueId, + index: oldVal, type: EVENT_KEY.ITEM_STOP }) }, 200) - } -) + }) + +watch( + () => props.active, + (newVal, oldVal) => { + console.log('newVal', newVal, 'oldVal', oldVal) + bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { + uniqueId: props.uniqueId, + index: state.localIndex, + type: newVal === false ? EVENT_KEY.ITEM_STOP : EVENT_KEY.ITEM_PLAY + }) + }) onMounted(() => { slideInit(wrapperEl.value, state, SlideType.VERTICAL) @@ -157,7 +174,7 @@ defineExpose({dislike}) function getInsEl(item, index, play = false) { // console.log('index', index, play) - let slideVNode = props.render(item, index, play, props.position) + let slideVNode = props.render(item, index, play, props.uniqueId) const app = createApp({ render() { return {slideVNode} @@ -252,6 +269,7 @@ function canNext(isNext) {