feat:对接视频收藏功能

This commit is contained in:
zjc
2025-02-25 17:54:34 +08:00
parent b5c1b97818
commit ee2cc5b94a
2 changed files with 67 additions and 5 deletions

View File

@@ -44,3 +44,12 @@ export function postVideoControlApi(data) {
data data
}) })
} }
// 收藏视频
export function postVideoCollectApi(data) {
return request({
url: '/fjtcc-api/api/largeScreen/video/collect',
method: 'get',
params: data
})
}

View File

@@ -53,6 +53,18 @@
@click="handleItemVideo(item.hlsUrl, 100)" @click="handleItemVideo(item.hlsUrl, 100)"
> >
<div class="video-item__inner"> <div class="video-item__inner">
<div
v-if="item.isCollect == 1"
class="video-item__follow"
@click.stop="handleCollect(item.id, item.isCollect, index)"
>取消关注
</div>
<div
v-if="item.isCollect == 0"
class="video-item__unfollow"
@click.stop="handleCollect(item.id, item.isCollect, index)"
>关注
</div>
<video <video
class="video-item__video" class="video-item__video"
:id="'monitorVideo' + index" :id="'monitorVideo' + index"
@@ -133,7 +145,12 @@
<script setup> <script setup>
import { getVideoListApi, postRefreshApi, getPreviewUrlApi } from '@/api/home' import { getVideoListApi, postRefreshApi, getPreviewUrlApi } from '@/api/home'
import { getVideoTypeApi, getVideoRegionsApi, postVideoRemainApi } from '@/api/monitor' import {
getVideoTypeApi,
getVideoRegionsApi,
postVideoRemainApi,
postVideoCollectApi
} from '@/api/monitor'
import { debounce } from 'lodash' import { debounce } from 'lodash'
import PubSub from 'pubsub-js' import PubSub from 'pubsub-js'
@@ -185,11 +202,9 @@
}) })
}) })
} }
const onInput = debounce((e) => { const onInput = debounce((e) => {
getVideoRegions() getVideoRegions()
}, 500) }, 500)
const currentChange = (e) => { const currentChange = (e) => {
videoList.value = [] videoList.value = []
getVideoList() getVideoList()
@@ -234,6 +249,17 @@
}) })
videoSrc.value = res.data.url videoSrc.value = res.data.url
} }
const handleCollect = async (id, status, index) => {
let res = await postVideoCollectApi({
id,
isCollect: status == 0 ? 1 : 0
})
if (status == 0) {
videoList.value[index].isCollect = 1
} else {
videoList.value[index].isCollect = 0
}
}
const getVideoList = async () => { const getVideoList = async () => {
try { try {
if (loading.value) return if (loading.value) return
@@ -243,6 +269,7 @@
total.value = res.total total.value = res.total
if (res.data.length > 0) { if (res.data.length > 0) {
videoList.value = res.data videoList.value = res.data
console.log(videoList.value, 'videoList.value')
nextTick(() => { nextTick(() => {
videoList.value.forEach(async (x, index) => { videoList.value.forEach(async (x, index) => {
const video = document.getElementById(`monitorVideo${index}`) const video = document.getElementById(`monitorVideo${index}`)
@@ -533,6 +560,7 @@
align-content: flex-start; align-content: flex-start;
} }
&-item { &-item {
position: relative;
width: vw(686); width: vw(686);
height: vh(420); height: vh(420);
padding: vw(10); padding: vw(10);
@@ -541,7 +569,34 @@
&:nth-child(3n) { &:nth-child(3n) {
margin-right: 0; margin-right: 0;
} }
&:hover {
.video-item__follow {
display: block !important;
} }
}
}
&-item__follow {
cursor: pointer;
display: none;
position: absolute;
right: vw(8);
top: vw(8);
z-index: 9999;
padding: 0 vw(20);
height: vh(24);
text-align: center;
line-height: vh(24);
font-weight: 400;
font-size: vw(16);
color: #ffffff;
background-image: url('@/assets/images/unfollow.png');
background-size: 100% 100%;
}
&-item__unfollow {
@extend .video-item__follow;
background-image: url('@/assets/images/unfollow.png');
}
&-item__inner { &-item__inner {
position: relative; position: relative;
} }
@@ -778,5 +833,3 @@
} }
} }
</style> </style>
<style lang="scss" scoped></style>