161 lines
3.9 KiB
Vue
161 lines
3.9 KiB
Vue
<template>
|
|
<div class="core-video">
|
|
<div class="title">核心景区视频</div>
|
|
|
|
<ul class="list">
|
|
<li
|
|
class="item"
|
|
:style="{ backgroundImage: `url(${index == 0 ? primary : error})` }"
|
|
v-for="(item, index) in list"
|
|
:key="index"
|
|
@click.shop="handleItem(item)"
|
|
>
|
|
<div>
|
|
<p :class="[index % 2 === 0 ? 'item-title--primary' : 'item-title--error']">
|
|
{{ item.cameraName }}
|
|
</p>
|
|
<video
|
|
class="item-img"
|
|
:id="'video' + index"
|
|
muted
|
|
autoplay
|
|
:controls="false"
|
|
style="object-fit: cover"
|
|
>
|
|
<source src="" type="application/x-mpegURL" />
|
|
</video>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<VideoDialog v-model="videoShow" :src="src" />
|
|
</template>
|
|
|
|
<script setup>
|
|
import primary from '@/assets/images/item-primary.png'
|
|
import error from '@/assets/images/item-error.png'
|
|
import { getVideoListApi, postRefreshApi } from '@/api/home'
|
|
import Hls from 'hls.js'
|
|
|
|
let list = ref([])
|
|
let src = ref('')
|
|
let videoShow = ref(false)
|
|
|
|
const handleItem = (item) => {
|
|
src.value = item.hlsUrl
|
|
videoShow.value = true
|
|
}
|
|
|
|
const getVideoList = async () => {
|
|
let res = await getVideoListApi({
|
|
businessVideoDisplayPosition: ''
|
|
})
|
|
list.value = res.data
|
|
nextTick(() => {
|
|
list.value.forEach(async (item, index) => {
|
|
var video = document.getElementById(`video${index}`)
|
|
let res1 = await postRefreshApi({
|
|
type: 'hls',
|
|
businessVideoDisplayPosition: item.businessVideoDisplayPosition,
|
|
cameraIndexCode: item.cameraIndexCode
|
|
})
|
|
item.hlsUrl = res1.data.hlsUrl
|
|
const hls = new Hls()
|
|
hls.loadSource(res1.data.hlsUrl)
|
|
hls.attachMedia(video)
|
|
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
|
video.play()
|
|
})
|
|
})
|
|
})
|
|
}
|
|
onMounted(() => {
|
|
getVideoList()
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
:deep(.el-loading-mask) {
|
|
background-color: transparent !important;
|
|
}
|
|
.core-video {
|
|
margin: vw(8);
|
|
width: vw(300);
|
|
border-radius: vw(2);
|
|
background-image: url('@/assets/images/bg-1.png');
|
|
background-size: 100% 100%;
|
|
|
|
.title {
|
|
width: 100%;
|
|
height: vh(26);
|
|
text-align: center;
|
|
line-height: vh(26);
|
|
font-size: vw(16);
|
|
font-weight: 800;
|
|
color: #fff;
|
|
}
|
|
|
|
.list {
|
|
overflow-y: auto;
|
|
overflow-x: hidden;
|
|
height: vh(1026);
|
|
padding: vw(8);
|
|
/* 滚动条整体样式 */
|
|
&::-webkit-scrollbar {
|
|
width: vw(0); /* 滚动条的宽度 */
|
|
}
|
|
|
|
/* 滚动条轨道 */
|
|
&::-webkit-scrollbar-track {
|
|
background: #f1f1f1; /* 轨道的背景色 */
|
|
}
|
|
|
|
/* 滚动条滑块 */
|
|
&::-webkit-scrollbar-thumb {
|
|
background: #888; /* 滑块的背景色 */
|
|
border-radius: 5px; /* 滑块的圆角 */
|
|
}
|
|
|
|
/* 当鼠标悬停在滚动条上时滑块的样式 */
|
|
&::-webkit-scrollbar-thumb:hover {
|
|
background: #555; /* 滑块的背景色 */
|
|
}
|
|
}
|
|
|
|
.item {
|
|
margin-bottom: vh(10);
|
|
padding: vw(10);
|
|
background-size: 100% 100%;
|
|
& > div {
|
|
position: relative;
|
|
}
|
|
&-title {
|
|
position: absolute;
|
|
bottom: 0;
|
|
width: 100%;
|
|
padding: vw(10);
|
|
color: #fff;
|
|
font-size: vw(14);
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
z-index: 999;
|
|
}
|
|
&-title--error {
|
|
@extend .item-title;
|
|
background-color: rgba(226, 27, 27, 0.72);
|
|
}
|
|
&-title--primary {
|
|
@extend .item-title;
|
|
background-color: rgba(4, 30, 69, 0.72);
|
|
}
|
|
&-img {
|
|
width: 100%;
|
|
height: vh(164);
|
|
display: block;
|
|
object-fit: cover;
|
|
}
|
|
}
|
|
}
|
|
</style>
|