谢杰标 2 年之前
父節點
當前提交
08543e1776
共有 2 個文件被更改,包括 235 次插入88 次删除
  1. 35 12
      components/myPlayer/polyvPlayer.vue
  2. 200 76
      pages3/polyv/detail.vue

+ 35 - 12
components/myPlayer/polyvPlayer.vue

@@ -90,6 +90,7 @@ export default {
       config: null,
       Elevideo: null,
       isInitSeek: false,
+      needSeek: false,
       playTime: 0,
     };
   },
@@ -148,7 +149,6 @@ export default {
       });
     },
     wxStatechange(newstate) {
-      console.log("🚀 ~ file: polyvPlayer.vue:151 ~ wxStatechange ~ newstate:", newstate)
       polyvPlayerContext = this.selectComponent("#playerVideo");
       // ["playing", "pause", "ended","error"]
       let state = newstate.detail.newstate;
@@ -159,9 +159,19 @@ export default {
       this.$emit(state);
     },
     playing() {
-      // #ifdef MP-WEIXIN
-      this.seekVideo(this.videoCurrentTime);
-      // #endif
+      // 设置播放时间会重复触发
+      if (this.needSeek) {
+        this.videoToastShow = true;
+        setTimeout(() => {
+          this.closeToast();
+        }, 3000);
+        // #ifdef MP-WEIXIN
+        this.seekVideo(this.videoCurrentTime);
+        // #endif
+        this.$emit("studyLog");
+        this.needSeek = false;
+      }
+
       // #ifdef H5
       if (!this.Elevideo) {
         this.Elevideo = document.querySelector("video.plv-player-video");
@@ -226,11 +236,29 @@ export default {
       //   this.seekVideo(start);
       // }
     },
+    // 新增用户视频学习日志
+    studyLog() {
+      this.$http({
+        url: "/user/study/log",
+        method: "post",
+        data: {
+          goodsId: this.goodsId,
+          courseId: this.courseId,
+          moduleId: this.moduleId || 0,
+          chapterId: this.chapterId || 0,
+          sectionId: this.playSectionId || 0,
+          fromPlat: 1, //来源平台 1小程序 2PC网站
+          goodsType: 1, // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
+          orderGoodsId: this.orderGoodsId,
+        },
+      }).then((res) => {});
+    },
     onVideoSeek1(time) {
       if (this.allowSeek == "off") {
         return;
       }
       if (Math.abs(time - this.playTime) > 5) {
+        console.log("进度条回拉", this.playTime, this.vct);
         this.seekVideo(this.playTime);
       } else {
         this.playTime = time;
@@ -387,14 +415,9 @@ export default {
   watch: {
     vct: {
       handler(time) {
-        this.playTime = time;
-        if (time > 0 && !this.videoToastShow) {
-          setTimeout(() => {
-            this.videoToastShow = true;
-            setTimeout(() => {
-              this.closeToast();
-            }, 3000);
-          }, 8000);
+        if (time > 0) {
+          this.needSeek = true;
+          this.playTime = time;
         }
       },
       immediate: true,

+ 200 - 76
pages3/polyv/detail.vue

@@ -1,16 +1,37 @@
 <template>
   <view class="polyv_detail">
-    <uni-nav-bar left-icon="back" :statusBar="true" fixed="true" :title="detail.courseName || '课程详情'"
-      @clickLeft="clickLeft"></uni-nav-bar>
+    <uni-nav-bar
+      left-icon="back"
+      :statusBar="true"
+      fixed="true"
+      :title="detail.courseName || '课程详情'"
+      @clickLeft="clickLeft"
+    ></uni-nav-bar>
     <view id="top">
       <view class="video_box" v-if="!playVid">
-        <image :src="$method.splitImgHost(goodsData.coverUrl)" mode="widthFix" style="width: 100%; height: 421rpx">
+        <image
+          :src="$method.splitImgHost(goodsData.coverUrl)"
+          mode="widthFix"
+          style="width: 100%; height: 421rpx"
+        >
         </image>
       </view>
       <view v-else>
-        <my-player ref="player" :playVid="playVid" :autoplay="autoplay" :allowSeek="isAllowSeek"
-          :playbackRate="playbackRate" :videoCurrentTime="videoCurrentTime || 0" @playing="playing" @pause="pause"
-          @ended="ended" @loadedmetadata="loadedmetadata" @timeupdate="timeupdate" @playerError="playerError"></my-player>
+        <my-player
+          ref="player"
+          :playVid="playVid"
+          :autoplay="autoplay"
+          :allowSeek="isAllowSeek"
+          :playbackRate="playbackRate"
+          :videoCurrentTime="videoCurrentTime || 0"
+          @playing="playing"
+          @pause="pause"
+          @ended="ended"
+          @loadedmetadata="loadedmetadata"
+          @timeupdate="timeupdate"
+          @playerError="playerError"
+          @studyLog="studyLog"
+        ></my-player>
       </view>
       <view class="course_name">
         <view class="course_titles">
@@ -20,8 +41,16 @@
           <view class="notice_wrap" v-if="goodsData.buyNote">
             <view class="video_t1_t" @click="studyNotice"> 学员须知 </view>
           </view>
-          <view class="toggle_course" v-if="goodsTeacher.length > 1" @click="changeCourses()">
-            <image class="img" src="/pages3/static/imgs/toggle.png" mode="widthFix"></image>
+          <view
+            class="toggle_course"
+            v-if="goodsTeacher.length > 1"
+            @click="changeCourses()"
+          >
+            <image
+              class="img"
+              src="/pages3/static/imgs/toggle.png"
+              mode="widthFix"
+            ></image>
             <view class="toggle_name">切换课程</view>
             <view class="numbers">共{{ goodsTeacher.length }}门</view>
           </view>
@@ -30,8 +59,15 @@
       <u-line color="#D6D6DB" />
       <view>
         <view>
-          <u-tabs :item-width="itemWidth()" :list="list" font-size="32" bar-width="24" :current="current" @change="change"
-            active-color="#007AFF"></u-tabs>
+          <u-tabs
+            :item-width="itemWidth()"
+            :list="list"
+            font-size="32"
+            bar-width="24"
+            :current="current"
+            @change="change"
+            active-color="#007AFF"
+          ></u-tabs>
         </view>
       </view>
       <u-line color="#D6D6DB" />
@@ -40,13 +76,26 @@
       <scroll-view class="box_in" scroll-y="true">
         <!--目录 -->
         <view v-show="current == 0">
-          <view class="top__header" v-if="livingItem" @click="goLive(livingItem)">
-            <image class="img" src="/pages3/static/imgs/live.png" mode="widthFix"></image>
+          <view
+            class="top__header"
+            v-if="livingItem"
+            @click="goLive(livingItem)"
+          >
+            <image
+              class="img"
+              src="/pages3/static/imgs/live.png"
+              mode="widthFix"
+            ></image>
             <view class="note">正在直播中</view>
             <view class="title">{{ livingItem.sectionName }}</view>
           </view>
-          <course-tree v-if="sectionItem.id || sectionItem.sectionId" :sectionMaxNum="goodsData.sectionMaxNum"
-            :isRebuild="false" :isBuy="true" @isHaverebuild="isHaverebuild = true"></course-tree>
+          <course-tree
+            v-if="sectionItem.id || sectionItem.sectionId"
+            :sectionMaxNum="goodsData.sectionMaxNum"
+            :isRebuild="false"
+            :isBuy="true"
+            @isHaverebuild="isHaverebuild = true"
+          ></course-tree>
         </view>
         <!--讲义 -->
         <view v-if="current == 1">
@@ -62,29 +111,57 @@
         </view>
         <!--重修目录 -->
         <view v-if="current == 4">
-          <course-tree v-if="sectionItem.id || sectionItem.sectionId" :sectionMaxNum="goodsData.sectionMaxNum"
-            :isRebuild="true" :isBuy="true"></course-tree>
+          <course-tree
+            v-if="sectionItem.id || sectionItem.sectionId"
+            :sectionMaxNum="goodsData.sectionMaxNum"
+            :isRebuild="true"
+            :isBuy="true"
+          ></course-tree>
         </view>
       </scroll-view>
     </view>
-    <u-popup v-model="noticeShow" class="notice_modal" mode="center" border-radius="28" width="650rpx" height="622rpx"
-      :mask-close-able="false">
+    <u-popup
+      v-model="noticeShow"
+      class="notice_modal"
+      mode="center"
+      border-radius="28"
+      width="650rpx"
+      height="622rpx"
+      :mask-close-able="false"
+    >
       <view class="content">
         <view class="title">学员须知</view>
         <scroll-view scroll-y="true">
-          <view class="text" v-html="goodsData.buyNote && goodsData.buyNote.replace(/\n|\r\n/g, '<br>')
-            ">
+          <view
+            class="text"
+            v-html="
+              goodsData.buyNote && goodsData.buyNote.replace(/\n|\r\n/g, '<br>')
+            "
+          >
           </view>
         </scroll-view>
-        <view class="had_read" :class="{ gray: CountTo > 0 }" @click="noticeConfirm()">
-          <text v-if="CountTo > 0">请阅读学员须知,{{ " " + CountTo + "s" }}后可关闭</text>
+        <view
+          class="had_read"
+          :class="{ gray: CountTo > 0 }"
+          @click="noticeConfirm()"
+        >
+          <text v-if="CountTo > 0"
+            >请阅读学员须知,{{ " " + CountTo + "s" }}后可关闭</text
+          >
           <text v-else>我已阅读学员须知</text>
         </view>
       </view>
     </u-popup>
     <!-- 倒计时提交 -->
-    <u-popup v-model="noticeShow1" class="notice_modal" mode="center" border-radius="28" width="650rpx" height="262rpx"
-      :mask-close-able="false">
+    <u-popup
+      v-model="noticeShow1"
+      class="notice_modal"
+      mode="center"
+      border-radius="28"
+      width="650rpx"
+      height="262rpx"
+      :mask-close-able="false"
+    >
       <view class="content">
         <view class="title">提示</view>
         <view class="had_read">
@@ -93,8 +170,15 @@
         </view>
       </view>
     </u-popup>
-    <u-modal v-model="showMark" title="提示" @confirm="markConfirm" @cancel="toBack" confirm-text="复制学习网址"
-      :show-cancel-button="true" cancel-text="关闭">
+    <u-modal
+      v-model="showMark"
+      title="提示"
+      @confirm="markConfirm"
+      @cancel="toBack"
+      confirm-text="复制学习网址"
+      :show-cancel-button="true"
+      cancel-text="关闭"
+    >
       <view class="slot-content">
         <view>您的学习账号已经开通,请按照步骤操作,进行学习。</view>
         <view>1.复制学习地址:{{ markContent }}</view>
@@ -106,18 +190,36 @@
     </u-modal>
 
     <!-- 切换课程弹窗 -->
-    <u-popup v-model="toggleCourseShow" mode="bottom" border-radius="40" :mask-close-able="false">
+    <u-popup
+      v-model="toggleCourseShow"
+      mode="bottom"
+      border-radius="40"
+      :mask-close-able="false"
+    >
       <view class="popup_box">
         <view class="check_head">
           <view class="headers">
             <view class="grade">切换课程</view>
-            <u-icon name="close" color="#9C9C9C" size="40" @click="closePop()"></u-icon>
+            <u-icon
+              name="close"
+              color="#9C9C9C"
+              size="40"
+              @click="closePop()"
+            ></u-icon>
           </view>
           <view class="coruse_num">共{{ goodsTeacher.length }}门</view>
           <view class="menuSel">
             <scroll-view class="sub_sliper" scroll-x="true">
-              <view v-for="(item, index) in subList" :key="index" style="margin-right: 50rpx; display: inline-block">
-                <view class="r_t1" :class="{ nactive: subIndex == index }" @click="cMenu(item, index)">
+              <view
+                v-for="(item, index) in subList"
+                :key="index"
+                style="margin-right: 50rpx; display: inline-block"
+              >
+                <view
+                  class="r_t1"
+                  :class="{ nactive: subIndex == index }"
+                  @click="cMenu(item, index)"
+                >
                   {{ item.subjectName }}
                 </view>
               </view>
@@ -128,15 +230,27 @@
         <view class="check_con">
           <scroll-view scroll-y="true" style="height: 700rpx">
             <view v-for="(courseItem, gTindex) in goodsTeacher" :key="gTindex">
-              <view v-for="(item, index) in courseItem.courseList" :key="index" v-show="item.subjectId === newActiveSubjectId || !newActiveSubjectId
-                ">
+              <view
+                v-for="(item, index) in courseItem.courseList"
+                :key="index"
+                v-show="
+                  item.subjectId === newActiveSubjectId || !newActiveSubjectId
+                "
+              >
                 <view class="course_items" v-if="item.show && item.show == 1">
                   <view class="course_lefts">
                     <view class="course_title">
                       {{ item.courseName }}
                     </view>
-                    <view v-if="courseItem.teaList && courseItem.teaList.length > 0" class="teacher_names">
-                      <view v-for="(tea, tindex) in courseItem.teaList" :key="tindex" class="names">{{ tea.aliasName }}
+                    <view
+                      v-if="courseItem.teaList && courseItem.teaList.length > 0"
+                      class="teacher_names"
+                    >
+                      <view
+                        v-for="(tea, tindex) in courseItem.teaList"
+                        :key="tindex"
+                        class="names"
+                        >{{ tea.aliasName }}
                       </view>
                     </view>
                     <view class="course_pros">
@@ -144,12 +258,20 @@
                       <text>
                         {{ item.stuAllNum + item.recordNum }}/{{
                           item.secAllNum + item.examNum
-                        }}</text>
+                        }}</text
+                      >
                     </view>
                   </view>
-                  <view class="course_rights" @click="jump(item, gTindex, 'jump')">
+                  <view
+                    class="course_rights"
+                    @click="jump(item, gTindex, 'jump')"
+                  >
                     <view class="cicles">
-                      <u-icon name="arrow-right" color="#498AFE" size="20"></u-icon>
+                      <u-icon
+                        name="arrow-right"
+                        color="#498AFE"
+                        size="20"
+                      ></u-icon>
                     </view>
                     <view class="intoStudy">进入学习</view>
                   </view>
@@ -327,22 +449,32 @@ export default {
     if (this.$method.isGoLogin()) {
       return;
     }
+    lockAction();
+    this.lockTimer = setInterval(lockAction, 10000);
     // 公众号模板消息的数据埋点
     informId && this.clickOfficial(informId);
+    uni.addInterceptor("navigateTo", {
+      success: () => {
+        this.isCache = true;
+      },
+    });
     this.init();
   },
   async onShow() {
-    console.log("🚀 ~ file: detail.vue:455 ~ onShow ~ onShow:", this.isCache);
     if (this.isCache) {
+      console.log("返回刷新数据");
       this.isCache = false;
       // #ifdef H5
       location.reload();
       // #endif
       // #ifdef MP-WEIXIN
+      this.sectionItem = {};
       this.init();
       // #endif
+      return;
     }
     if (this.beforeHideIsPlaying) {
+      console.log("显示重新播放");
       // 二建二造提示弹出来
       if (this.playSecIsLearn && this.erJianErZao && this.pauseTimer == null) {
         return;
@@ -362,7 +494,7 @@ export default {
     }
     this.originUnload();
   },
-  mounted() { },
+  mounted() {},
   methods: {
     ...mapMutations(["updateChapterOpen", "updateLiveLast"]),
     async init() {
@@ -372,15 +504,7 @@ export default {
       // #ifdef H5
       this.isAllowSeek = "on";
       // #endif
-      // 锁
-      lockAction();
-      uni.addInterceptor("navigateTo", {
-        success() {
-          this.isCache = true;
-        },
-      });
-      this.lockTimer = setInterval(lockAction, 10000);
-      await this.isCanLearn()
+      await this.isCanLearn();
       this.courseCourseList();
     },
     // 七大员是否能进入学习
@@ -426,8 +550,8 @@ export default {
       this.newActiveSubjectId = item.subjectId;
     },
     courseCourseList() {
-      this.courseList = [];
       this.photoConfig = false;
+      this.courseList = [];
       this.$api
         .courseCourseList({
           pageNum: 1,
@@ -558,7 +682,7 @@ export default {
         console.log("开启定时器");
         this.pauseTimer = setInterval(() => {
           console.log("暂停时间", Date.now() - this.pauseTime, this.pauseTime);
-          if (Date.now() - this.pauseTime > 20 * 1000) {
+          if (Date.now() - this.pauseTime > 1 * 60 * 1000) {
             // 5 * 60 * 1000
             let text = "暂停";
             if (this.showCamera) {
@@ -828,6 +952,7 @@ export default {
         });
     },
     toQuestionBank(sectionItem) {
+      // type 1模块 2章 3节 4章卷 5模块卷
       uni.navigateTo({
         url:
           "/pages2/class/questionBank?courseId=" +
@@ -879,29 +1004,29 @@ export default {
       // buyCourse 是否购买课程:1是 0否
       let encode = encodeURIComponent(
         this.config.hostLive +
-        "/pages/live/index?token=" +
-        uni.getStorageSync("token") +
-        "&userInfo=" +
-        JSON.stringify(this.userInfo) +
-        "&channelId=" +
-        item.liveUrl +
-        "&gradeId=" +
-        this.gradeId +
-        "&courseId=" +
-        this.courseId +
-        "&goodsId=" +
-        this.goodsId +
-        "&orderGoodsId=" +
-        this.orderGoodsId +
-        "&sectionId=" +
-        sectionId +
-        "&chapterId=" +
-        chapterId +
-        "&moduleId=" +
-        moduleId +
-        "&buyCourse=1" +
-        "&ident=" +
-        uuid
+          "/pages/live/index?token=" +
+          uni.getStorageSync("token") +
+          "&userInfo=" +
+          JSON.stringify(this.userInfo) +
+          "&channelId=" +
+          item.liveUrl +
+          "&gradeId=" +
+          this.gradeId +
+          "&courseId=" +
+          this.courseId +
+          "&goodsId=" +
+          this.goodsId +
+          "&orderGoodsId=" +
+          this.orderGoodsId +
+          "&sectionId=" +
+          sectionId +
+          "&chapterId=" +
+          chapterId +
+          "&moduleId=" +
+          moduleId +
+          "&buyCourse=1" +
+          "&ident=" +
+          uuid
       );
       uni.navigateTo({
         url: `../../pages/webview/index?url=` + encode,
@@ -1002,7 +1127,6 @@ export default {
       return Promise.resolve();
     },
     async isCanLearn() {
-      return Promise.resolve();
       this.option.isQ !== "" && (await this.qCheckIsCanLearn());
       await this.getbaseprofiletplists();
       await this.getGradeInfo();
@@ -1094,6 +1218,7 @@ export default {
       this.photoConfig = true;
       if (this.erJianErZao) {
         this.photoList = this.randomConfig(totalVideoTime, duration);
+        console.log(this.photoList, "this.photoList");
         return;
       }
       //没有历史拍照间隔数据
@@ -1362,7 +1487,7 @@ export default {
           fromPlat: 1, //来源平台 1小程序 2PC网站
           goodsType: 1, // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
         },
-      }).then((res) => { });
+      }).then((res) => {});
     },
     timeupdate(time) {
       if (this.noticeShow) {
@@ -1376,7 +1501,6 @@ export default {
     playing() {
       console.log("palying");
       this.isPlaying = true;
-      this.studyLog();
       if (!this.videoCurrentTime) {
         this.postStudyRecord(0);
       }