绿满眶商城微信小程序-uniapp
xiangpei
6 天以前 315e138130844326f2aa64d6a6a8043282efffe9
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() {