完善直播页面

This commit is contained in:
zyronon 2024-04-03 01:41:54 +08:00
parent 8c2bb79da2
commit 52a1260c98
5 changed files with 48 additions and 32 deletions

View File

@ -299,33 +299,34 @@ export default {
}, },
click({ uniqueId, index, type }) { click({ uniqueId, index, type }) {
if (this.position.uniqueId === uniqueId && this.position.index === index) { if (this.position.uniqueId === uniqueId && this.position.index === index) {
if (this.isLive) { if (type === EVENT_KEY.ITEM_TOGGLE) {
if (type === EVENT_KEY.ITEM_TOGGLE) { if (this.isLive) {
bus.emit(EVENT_KEY.NAV, { if (type === EVENT_KEY.ITEM_TOGGLE) {
path: '/home/live', this.pause()
query: { id: this.item.id } bus.emit(EVENT_KEY.NAV, {
}) path: '/home/live',
} query: { id: this.item.id }
} else { })
if (type === EVENT_KEY.ITEM_TOGGLE) { }
}else {
if (this.status === SlideItemPlayStatus.Play) { if (this.status === SlideItemPlayStatus.Play) {
this.pause() this.pause()
} else { } else {
this.play() this.play()
} }
} }
if (type === EVENT_KEY.ITEM_STOP) { }
this.$refs.video.currentTime = 0 if (type === EVENT_KEY.ITEM_STOP) {
this.ignoreWaiting = true this.$refs.video.currentTime = 0
this.pause() this.ignoreWaiting = true
setTimeout(() => (this.ignoreWaiting = false), 300) this.pause()
} setTimeout(() => (this.ignoreWaiting = false), 300)
if (type === EVENT_KEY.ITEM_PLAY) { }
this.$refs.video.currentTime = 0 if (type === EVENT_KEY.ITEM_PLAY) {
this.ignoreWaiting = true this.$refs.video.currentTime = 0
this.play() this.ignoreWaiting = true
setTimeout(() => (this.ignoreWaiting = false), 300) this.play()
} setTimeout(() => (this.ignoreWaiting = false), 300)
} }
} }
}, },

View File

@ -2,6 +2,7 @@
<div class="LivePage" ref="page"> <div class="LivePage" ref="page">
<div class="live-wrapper"> <div class="live-wrapper">
<video <video
ref="videoEl"
src="https://www.douyin.com/aweme/v1/play/?video_id=v0d00fg10000cj1lq4jc77u0ng6s1gt0&amp;line=0&amp;file_id=bed51c00899b458cbc5d8280147c22a1&amp;sign=7749aec7bd62a3760065f60e40fc1867&amp;is_play_url=1&amp;source=PackSourceEnum_PUBLISH" src="https://www.douyin.com/aweme/v1/play/?video_id=v0d00fg10000cj1lq4jc77u0ng6s1gt0&amp;line=0&amp;file_id=bed51c00899b458cbc5d8280147c22a1&amp;sign=7749aec7bd62a3760065f60e40fc1867&amp;is_play_url=1&amp;source=PackSourceEnum_PUBLISH"
poster="/images/jwWCPZVTIA4IKM-8WipLF.png" poster="/images/jwWCPZVTIA4IKM-8WipLF.png"
preload="" preload=""
@ -200,8 +201,7 @@ export default {
computed: { computed: {
...mapState(useBaseStore, ['friends', 'userinfo']) ...mapState(useBaseStore, ['friends', 'userinfo'])
}, },
created() {}, activated() {
mounted() {
this.page = this.$refs.page this.page = this.$refs.page
this.timer1 = setInterval(async () => { this.timer1 = setInterval(async () => {
this.sendGift() this.sendGift()
@ -215,8 +215,9 @@ export default {
this.timer3 = setInterval(async () => { this.timer3 = setInterval(async () => {
this.sendComment() this.sendComment()
}, 700) }, 700)
this.$refs.videoEl.play()
}, },
unmounted() { deactivated() {
clearInterval(this.timer1) clearInterval(this.timer1)
clearInterval(this.timer2) clearInterval(this.timer2)
clearInterval(this.timer3) clearInterval(this.timer3)

View File

@ -47,6 +47,7 @@
</div> </div>
<SlideList <SlideList
:active="props.active" :active="props.active"
uniqueId="uniqueId3"
:style="{ :style="{
background: 'black', background: 'black',
marginTop: state.subTypeVisible ? state.subTypeHeight : 0 marginTop: state.subTypeVisible ? state.subTypeHeight : 0

View File

@ -2,7 +2,7 @@
<SlideItem class="slide-item-class"> <SlideItem class="slide-item-class">
<div class="sub-type" :class="state.subTypeIsTop ? 'top' : ''" ref="subTypeRef"> <div class="sub-type" :class="state.subTypeIsTop ? 'top' : ''" ref="subTypeRef">
<div class="card" @touchmove.capture="stop"> <div class="card" @touchmove.capture="stop">
<div class="nav-item" :key="j" v-for="(i, j) in store.users"> <div class="nav-item" @click="goLive(i)" :key="j" v-for="(i, j) in store.users">
<img :src="_checkImgUrl(i.avatar_168x168.url_list[0])" alt="" /> <img :src="_checkImgUrl(i.avatar_168x168.url_list[0])" alt="" />
<span>{{ i.nickname }}</span> <span>{{ i.nickname }}</span>
</div> </div>
@ -18,6 +18,7 @@
<SlideList <SlideList
:cbs="{ isLive: true }" :cbs="{ isLive: true }"
:active="props.active" :active="props.active"
uniqueId="uniqueId2"
:style="{ :style="{
background: 'black', background: 'black',
marginTop: state.subTypeVisible ? state.subTypeHeight : 0 marginTop: state.subTypeVisible ? state.subTypeHeight : 0
@ -77,6 +78,13 @@ function pageClick(e) {
} }
} }
function goLive(item) {
bus.emit(EVENT_KEY.NAV, {
path: '/home/live',
query: { id: item.id }
})
}
onMounted(() => { onMounted(() => {
// getData() // getData()
}) })

View File

@ -1,9 +1,9 @@
<template> <template>
<SlideVerticalInfinite <SlideVerticalInfinite
ref="listRef" ref="listRef"
v-love="state.uniqueId" v-love="props.uniqueId"
:id="state.uniqueId" :id="props.uniqueId"
:uniqueId="state.uniqueId" :uniqueId="props.uniqueId"
name="main" name="main"
:active="props.active" :active="props.active"
:loading="baseStore.loading" :loading="baseStore.loading"
@ -46,6 +46,12 @@ const props = defineProps({
default() { default() {
return [] return []
} }
},
uniqueId: {
type: String,
default() {
return 'uniqueId1'
}
} }
}) })
@ -62,7 +68,6 @@ const listRef = ref(null)
const state = reactive({ const state = reactive({
index: props.index, index: props.index,
list: props.list, list: props.list,
uniqueId: 'uniqueId1',
totalSize: 0, totalSize: 0,
pageSize: 10, pageSize: 10,
pageNo: 0 pageNo: 0
@ -106,7 +111,7 @@ async function getData(refresh = false) {
// } // }
function click(uniqueId) { function click(uniqueId) {
if (uniqueId !== state.uniqueId) return if (uniqueId !== props.uniqueId) return
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, {
uniqueId, uniqueId,
index: state.index, index: state.index,
@ -115,7 +120,7 @@ function click(uniqueId) {
} }
function updateItem({ position, item }) { function updateItem({ position, item }) {
if (position.uniqueId === state.uniqueId) { if (position.uniqueId === props.uniqueId) {
state.list[position.index] = item state.list[position.index] = item
} }
} }
@ -128,4 +133,4 @@ onUnmounted(() => {
bus.off(EVENT_KEY.SINGLE_CLICK, click) bus.off(EVENT_KEY.SINGLE_CLICK, click)
bus.on(EVENT_KEY.UPDATE_ITEM, updateItem) bus.on(EVENT_KEY.UPDATE_ITEM, updateItem)
}) })
</script> </script>