fix:培训视频播放时长接口调用异常导致重复添加同一组数据bug

This commit is contained in:
xuchao
2025-12-10 18:45:43 +08:00
parent f5bd523985
commit 844ff8c582

View File

@@ -10,7 +10,7 @@
<!-- 视频播放组件 -->
<view class="video-wrapper">
<video v-if="videoInfo && videoInfo.cover" id="myVideo" :src="videoInfo.currentUrl" :poster="trainVideoImgUrl+ videoInfo.cover" @seeked="onSeeked"
:initial-time="initialTime"
preload="metadata"
enable-danmu controls style="width: 100%;" @pause="onPause" @timeupdate="onTimeupdate" @ended="onEnded"></video>
</view>
@@ -148,6 +148,7 @@ const trainVideoImgUrl=config.trainVideoImgUrl
const categories=ref([])
const levalLabels=ref([])
const latestTime = ref(0)
const initialTime = ref(0)
const totalTime=ref(0)
const baseUrl = config.imgBaseUrl
const pageEnterTime = ref(0)
@@ -174,12 +175,12 @@ onLoad((options) => {
videoId.value=options.id
getDictionary()
});
onHide(() => {
updateVideoInfo() // 用缓存值,不要调 getCurrentTime
reportPageDuration()
})
// onHide(() => {
// updateVideoInfo() // 用缓存值,不要调 getCurrentTime
// reportPageDuration()
// })
onUnload(() => {
updateVideoInfo()
// updateVideoInfo()
reportPageDuration()
})
function getData() {
@@ -197,6 +198,11 @@ function getData() {
videoInfo.value.currentUrl=trainVideoImgUrl+videoInfo.value.trainClassList[0].url
videoInfo.value.percentage=((videoInfo.value.process/(videoInfo.value.hour*60))*100).toFixed(2)
videoInfo.value.uploadTime=videoInfo.value.uploadTime.split(' ')[0]
if(videoInfo.value.process !=null){
latestTime.value=videoInfo.value.process
initialTime.value=videoInfo.value.process
}
updateVideoInfo()
});
}
function getHeart() {
@@ -216,7 +222,6 @@ function getUserInfo(){
$api.myRequest('/system/user/login/user/info', {},'get',10100,header).then((resData) => {
userId.value=resData.info.userId
getData()
updateVideoInfo()
});
}
function getDictionary(){
@@ -279,7 +284,7 @@ function updateVideoInfo(){
$api.myRequest("/dashboard/auth/heart", {}, "POST", 10100, header).then((resData) => {
if (resData.code == 200) {
if(videoInfo.value.isCollect===null && videoInfo.value.process ===null){
if(videoInfo.value.isCollect===null && videoInfo.value.process ===null && paramsData.process ==0 ){
$api.myRequest('/train/public/videoUser/add', paramsData,'post',9100,header).then((resData) => {
console.log("视频播放时长更新成功")
});