From 315e138130844326f2aa64d6a6a8043282efffe9 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期二, 17 六月 2025 10:48:58 +0800 Subject: [PATCH] 视频分享点击记录、视频进度条长度使用后端返的视频长度 --- pages/tabbar/index/home.vue | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pages/tabbar/index/home.vue b/pages/tabbar/index/home.vue index d0904d5..df33ed7 100644 --- a/pages/tabbar/index/home.vue +++ b/pages/tabbar/index/home.vue @@ -232,7 +232,7 @@ <script> import { getRecommendVideos, savePlayRecord, subscribe, getVideoComments, addVideoComment, thubmsUpComment, cancelThubmsUpComment } from "@/api/video.js"; import { changeCollect } from "@/api/collect.js"; -import { saveShare } from "@/api/share.js"; +import { saveShare, saveShareClickRecord } from "@/api/share.js"; import { silentLogin } from "@/api/connect.js"; import { getUserInfo } from "@/api/members"; import storage from "@/utils/storage.js"; @@ -328,11 +328,16 @@ onHide() { this.startHidenTime = Date.now() }, - onLoad() { + onLoad(option) { const token = storage.getAccessToken(); if (! token) { this.wxSilentLogin(() => { this.loadVideos(); + // 鍒ゆ柇鏄笉鏄偣鍑诲垎浜摼鎺ヨ繘鏉ョ殑 + if (option.userId && option.videoId) { + // 淇濆瓨鍒嗕韩鐐瑰嚮璁板綍 + saveShareClickRecord({refId: option.videoId, shareUserId: option.userId}) + } }) } else { this.loadVideos(); @@ -712,6 +717,9 @@ if (this.videoContexts[this.currentIndex]) { this.videoContexts[this.currentIndex].play(); } + // 璁剧疆褰撳墠鎾斁瑙嗛鐨勬�绘椂闀� + this.duration = this.videoList[this.currentIndex].videoDuration; + this.formartDuration = this.sliderFormatTime(this.duration); }, // 鏀惰棌/鍙栨秷鏀惰棌 @@ -752,6 +760,11 @@ console.log(id, index, "瑙﹀彂鎾斁"); if(index === this.currentIndex) { this.currentVideoIsPlaying = true; + if(! this.duration) { + // 璁剧疆褰撳墠鎾斁瑙嗛鐨勬�绘椂闀� + this.duration = this.videoList[this.currentIndex].videoDuration; + this.formartDuration = this.sliderFormatTime(this.duration); + } } else { this.currentVideoIsPlaying = false; return @@ -765,6 +778,7 @@ const duration = Date.now() - this.startPauseTime this.totalPauseTime += duration } + }, // 瑙嗛鏆傚仠浜嬩欢 @@ -841,9 +855,9 @@ }, // 鑾峰彇瑙嗛鎬绘椂闀� onLoadedMetadata(e) { - this.duration = e.detail.duration; - this.formartDuration = this.sliderFormatTime(this.duration); - console.log("瑙嗛鎬绘椂闀�", this.duration); + // this.duration = e.detail.duration; + // this.formartDuration = this.sliderFormatTime(this.duration); + // console.log("瑙嗛鎬绘椂闀�", this.duration); }, // 淇濆瓨鎾斁璁板綍 async savePlayRecord() { -- Gitblit v1.8.0