| | |
| | | <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"; |
| | |
| | | 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(); |
| | |
| | | if (this.videoContexts[this.currentIndex]) { |
| | | this.videoContexts[this.currentIndex].play(); |
| | | } |
| | | // 设置当前播放视频的总时长 |
| | | this.duration = this.videoList[this.currentIndex].videoDuration; |
| | | this.formartDuration = this.sliderFormatTime(this.duration); |
| | | }, |
| | | |
| | | // 收藏/取消收藏 |
| | |
| | | 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 |
| | |
| | | const duration = Date.now() - this.startPauseTime |
| | | this.totalPauseTime += duration |
| | | } |
| | | |
| | | }, |
| | | |
| | | // 视频暂停事件 |
| | |
| | | }, |
| | | // 获取视频总时长 |
| | | 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() { |