浏览代码

重构下一个播放

谢杰标 2 年之前
父节点
当前提交
b236d95435

+ 1 - 1
App.vue

@@ -19,7 +19,7 @@ export default {
   },
   onHide: function () {
     uni.$emit("playPause");
-  }
+  },
 };
 </script>
 

+ 6 - 6
components/course/answerBox.vue

@@ -76,17 +76,12 @@
 export default {
   name: "SaasMiniprogramAnswerBox",
   props: {
-    params: {
-      type: Object,
-      defaule: () => {
-        return {};
-      },
-    },
     userId: {
       type: Number,
       defaule: 0,
     },
   },
+  inject: ["paramsFn"],
   data() {
     return {
       answerList: [],
@@ -179,6 +174,11 @@ export default {
       this.placeholder = "@" + item.realname;
     },
   },
+  computed: {
+    params() {
+      return this.paramsFn(["orderGoodsId", "goodsId", "courseId", "gradeId"]);
+    },
+  },
 };
 </script>
 

+ 62 - 41
components/course/courseChapter.vue

@@ -8,8 +8,13 @@
       </view>
 
       <view class="fl">
-        <view class="title_status gre" v-if="menuItem.commonSign == 1">公共章</view>
-        <view class="title_status" :class="['grey', 'blue', 'gre'][learnStatus + 1]">
+        <view class="title_status gre" v-if="menuItem.commonSign == 1"
+          >公共章</view
+        >
+        <view
+          class="title_status"
+          :class="['grey', 'blue', 'gre'][learnStatus + 1]"
+        >
           {{ ["待学习", "学习中", "已学完"][learnStatus + 1] }}
         </view>
       </view>
@@ -17,39 +22,62 @@
     <view v-show="!down">
       <view v-for="(itemM, indexM) in list" :key="indexM">
         <view v-if="itemM.type != 2">
-          <courseSection ref="ChapterSection" :isLive="isLive" :orderGoodsId="orderGoodsId" :sectionMaxNum="sectionMaxNum"
-            :preItem="list[indexM - 1] || preItem" :learningOrder="learningOrder" :courseId="courseId"
-            @playEnd="refreshList($event)" :goodsId="goodsId" :isBuy="isBuy" :nextMenuItem="findNextSection(indexM)"
-            :isRebuild="isRebuild" :gradeId="gradeId" :menuItem="itemM" :levelId="levelId + '-' + itemM.sectionId"
-            :testType="2" :ChapterSectionExam="sectionExam" :menuAllList="menuAllList"></courseSection>
+          <courseSection
+            ref="ChapterSection"
+            :isLive="isLive"
+            :orderGoodsId="orderGoodsId"
+            :sectionMaxNum="sectionMaxNum"
+            :preItem="list[indexM - 1] || preItem"
+            :learningOrder="learningOrder"
+            :courseId="courseId"
+            @playEnd="refreshList($event)"
+            :goodsId="goodsId"
+            :sectionItem="sectionItem"
+            :isBuy="isBuy"
+            :nextMenuItem="findNextSection(indexM)"
+            :isRebuild="isRebuild"
+            :gradeId="gradeId"
+            :menuItem="itemM"
+            :levelId="levelId + '-' + itemM.sectionId"
+            :testType="2"
+            :ChapterSectionExam="sectionExam"
+            :menuAllList="menuAllList"
+          ></courseSection>
           <!-- @togoBack='togoBack()' -->
           <u-line v-if="indexM < list.length - 1"></u-line>
         </view>
         <!-- 章卷 -->
         <view v-if="itemM.type == 2">
           <u-line></u-line>
-          <view class="examBox" @click="
-            toDo(
-              itemM.typeId,
-              goodsId,
-              itemM.moduleId,
-              itemM.chapterId,
-              itemM,
-              indexM
-            )
-            ">
+          <view
+            class="examBox"
+            @click="
+              toDo(
+                itemM.typeId,
+                goodsId,
+                itemM.moduleId,
+                itemM.chapterId,
+                itemM,
+                indexM
+              )
+            "
+          >
             <view class="exam">
               <view class="eTag">
                 {{ itemM.doType == 1 ? "练习" : "考试" }}
               </view>
               <view style="margin-left: 15rpx; flex: 1">{{ itemM.name }}</view>
             </view>
-            <view v-if="isRebuild || itemM.rebuild > 0" class="tagRe">待重修</view>
+            <view v-if="isRebuild || itemM.rebuild > 0" class="tagRe"
+              >待重修</view
+            >
             <view v-else>
-              <view :class="{
-                tagGreen: itemM.learning == 1,
-                tagRe: itemM.learning == 0 || itemM.rebuild > 0,
-              }">
+              <view
+                :class="{
+                  tagGreen: itemM.learning == 1,
+                  tagRe: itemM.learning == 0 || itemM.rebuild > 0,
+                }"
+              >
                 <text v-if="itemM.rebuild > 0">待重测</text>
                 <text v-else-if="itemM.learning == 1">合格</text>
                 <text v-else-if="itemM.learning == 0">不及格(需重考)</text>
@@ -127,9 +155,8 @@ export default {
       default: () => [],
     },
     sectionItem: {
-      // 用户最后一次看的录播的信息
       type: Object,
-      default: () => { },
+      default: () => {},
     },
   },
   components: {
@@ -144,15 +171,9 @@ export default {
       sectionExam: [],
     };
   },
-  onLoad() { },
-  created() { },
-  mounted() {
-    // console.log('needOpen:', this.needOpen, this.chapterOpen);
-    // if (this.needOpen && this.chapterOpen) {
-    //   this.updateChapterOpen(false);
-    //   this.openChapter(this.menuItem);
-    // }
-  },
+  onLoad() {},
+  created() {},
+  mounted() {},
   onPageShow() {
     if (this.isBuy) {
       this.refreshList({ isRebuild: this.isRebuild });
@@ -170,7 +191,7 @@ export default {
           .goodsTodayStudySectionNum({
             goodsId: this.goodsId,
             gradeId: this.gradeId,
-            orderGoodsId: this.orderGoodsId
+            orderGoodsId: this.orderGoodsId,
           })
           .then((res) => {
             if (res.data.code == 200) {
@@ -216,7 +237,7 @@ export default {
             courseId: this.courseId,
             gradeId: this.gradeId,
             goodsId: this.goodsId,
-            orderGoodsId: this.orderGoodsId
+            orderGoodsId: this.orderGoodsId,
           })
           .then((res) => {
             if (res.data.code == 200) {
@@ -237,7 +258,7 @@ export default {
             moduleId: this.menuItem.moduleId || 0,
             chapterId: this.menuItem.chapterId || 0,
             examId: id,
-            orderGoodsId: this.orderGoodsId
+            orderGoodsId: this.orderGoodsId,
           })
           .then((res) => {
             resolve(res.data.data);
@@ -537,7 +558,7 @@ export default {
             courseId: this.courseId,
             moduleId: 0,
             examId: examId,
-            orderGoodsId: this.orderGoodsId
+            orderGoodsId: this.orderGoodsId,
           })
           .then((res) => {
             resolve(res.data.data);
@@ -561,7 +582,7 @@ export default {
               chapterId: item.chapterId || item.menuId,
               courseId: item.courseId,
               gradeId: item.gradeId,
-              orderGoodsId: this.orderGoodsId
+              orderGoodsId: this.orderGoodsId,
             })
             .then((res) => {
               if (res.data.code == 200) {
@@ -637,7 +658,7 @@ export default {
           courseId: courseId,
           rebuild: 1,
           moduleId: moduleId,
-          orderGoodsId: this.orderGoodsId
+          orderGoodsId: this.orderGoodsId,
         })
         .then((res) => {
           if (res.data.code == 200) {
@@ -675,7 +696,7 @@ export default {
           gradeId: this.gradeId,
           courseId: courseId,
           moduleId: moduleId,
-          orderGoodsId: this.orderGoodsId
+          orderGoodsId: this.orderGoodsId,
         })
         .then((res) => {
           if (res.data.code == 200) {
@@ -707,7 +728,7 @@ export default {
     },
   },
   computed: {
-    ...mapGetters(["goodsAuditionConfigIdList", "chapterOpen"]),
+    ...mapGetters(["goodsAuditionConfigIdList"]),
     learnStatus() {
       if (!this.isBuy) {
         return;

+ 2 - 15
components/course/courseModule.vue

@@ -20,7 +20,6 @@
     </view>
     <view v-show="!down">
       <view v-for="(itemM, indexM) in list" :key="indexM">
-        <!-- v-if='itemM.type != 2' -->
         <courseChapter
           v-if="itemM.type != 2"
           :orderGoodsId="orderGoodsId"
@@ -28,7 +27,6 @@
           :preItem="list[indexM - 1] || preItem"
           :sectionMaxNum="sectionMaxNum"
           :needOpen="itemM.needOpen"
-          @playEnd="playEnd($event)"
           @toDo="toDo($event)"
           :courseId="courseId"
           :learningOrder="learningOrder"
@@ -87,7 +85,6 @@
 </template>
 
 <script>
-import { mapGetters } from "vuex";
 import courseChapter from "@/components/course/courseChapter.vue";
 export default {
   name: "courseModule",
@@ -154,7 +151,6 @@ export default {
       default: () => [],
     },
     sectionItem: {
-      // 用户最后一次看的录播的信息
       type: Object,
       default: () => {},
     },
@@ -169,9 +165,6 @@ export default {
     };
   },
   methods: {
-    playEnd(isRebuild) {
-      this.$emit("playEnd", { isRebuild: isRebuild.isRebuild });
-    },
     toDo(item) {
       this.$emit("toDo", item);
     },
@@ -210,7 +203,7 @@ export default {
           gradeId: this.gradeId,
           courseId: courseId,
           rebuild: 1,
-          orderGoodsId: this.orderGoodsId
+          orderGoodsId: this.orderGoodsId,
         })
         .then((res) => {
           if (res.data.code == 200) {
@@ -230,7 +223,7 @@ export default {
           moduleId: moduleId,
           gradeId: this.gradeId,
           courseId: courseId,
-          orderGoodsId: this.orderGoodsId
+          orderGoodsId: this.orderGoodsId,
         })
         .then((res) => {
           if (res.data.code == 200) {
@@ -326,7 +319,6 @@ export default {
     },
   },
   computed: {
-    ...mapGetters(["chapterOpen"]),
     learnStatus() {
       let { id, courseId } = this.menuItem;
       if (
@@ -344,11 +336,6 @@ export default {
       return isAllLearn ? 1 : -1;
     },
   },
-  mounted() {
-    // if (this.needOpen && this.chapterOpen) {
-    //   this.openModule(this.menuItem);
-    // }
-  },
   watch: {
     courseId: {
       handler(val) {

+ 132 - 146
components/course/courseSection.vue

@@ -1,28 +1,46 @@
 <template>
-  <view style="display: flex; justify-content: space-between; align-items: center" @click="getVideo">
-    <view style="
+  <view
+    style="display: flex; justify-content: space-between; align-items: center"
+    @click="getVideo"
+  >
+    <view
+      style="
         display: flex;
         justify-content: space-between;
         align-items: center;
         margin: 20rpx 0;
         width: 100%;
-      ">
+      "
+    >
       <view style="display: flex; align-items: center; flex: 1">
         <view class="tag tagColor1" v-if="menuItem.sectionType == 1">视频</view>
         <view class="tag tagColor2" v-if="menuItem.sectionType == 2">直播</view>
         <view class="tag tagColor3" v-if="menuItem.sectionType == 3">回放</view>
         <view class="t_content">
-          <view v-if="menuItem.sectionType == 1" :class="playSectionId == newId && playNextId == playId ? 'color1' : ''
-            ">{{ menuItem.name || "" }}</view>
-          <view v-if="menuItem.sectionType == 2" :class="playSectionId == newId && playNextId == playId ? 'color2' : ''
-            ">{{ menuItem.name || "" }}</view>
-          <view v-if="menuItem.sectionType == 3" :class="playSectionId == newId && playNextId == playId ? 'color3' : ''
-            ">{{ menuItem.name || "" }}</view>
-          <view style="font-size: 20rpx; color: #ff3b30" v-if="menuItem.sectionType == 2 && menuItem.liveStartTime">
+          <view
+            v-if="menuItem.sectionType == 1"
+            :class="{ color1: isActive }"
+            >{{ menuItem.name || "" }}</view
+          >
+          <view
+            v-if="menuItem.sectionType == 2"
+            :class="{ color2: isActive }"
+            >{{ menuItem.name || "" }}</view
+          >
+          <view
+            v-if="menuItem.sectionType == 3"
+            :class="{ color3: isActive }"
+            >{{ menuItem.name || "" }}</view
+          >
+          <view
+            style="font-size: 20rpx; color: #ff3b30"
+            v-if="menuItem.sectionType == 2 && menuItem.liveStartTime"
+          >
             <view v-if="menuItem.liveStartTime > nowTime || !isBuy">
               <text>{{
                 $method.timestampToTime(menuItem.liveStartTime, (isDay = false))
-              }}</text>-
+              }}</text
+              >-
               <text>{{
                 $method.timestampToTime(menuItem.liveEndTime, (isDay = false))
               }}</text>
@@ -35,14 +53,11 @@
                 <text>当前直播回放视频请稍后再查看</text>
               </view>
             </template>
-            <!-- <view v-if="menuItem.liveStartTime<=nowTime&&menuItem.liveEndTime>nowTime">
-							<text>直播中</text>
-						</view>
-						<view v-if="menuItem.liveEndTime<nowTime">
-							<text>回放</text>
-						</view> -->
           </view>
-          <view style="font-size: 20rpx; color: #ff3b30" v-if="menuItem.sectionType == 3">
+          <view
+            style="font-size: 20rpx; color: #ff3b30"
+            v-if="menuItem.sectionType == 3"
+          >
             <view v-if="!menuItem.recordingUrl">
               <text>当前直播回放视频请稍后再查看</text>
             </view>
@@ -53,18 +68,28 @@
           menuItem.name || ""
         }}</view>
         <!-- 学习中 -->
-        <view v-if="playSectionId == newId && playNextId == playId" class="learnings">
-          <image src="/pages3/static/imgs/learning_icon.gif" class="learning_icon"></image>
+        <view v-if="isActive" class="learnings">
+          <image
+            src="/pages3/static/imgs/learning_icon.gif"
+            class="learning_icon"
+          ></image>
         </view>
       </view>
-      <view style="font-size: 20rpx; color: #ff3b30" v-if="menuItem.liveStartTime && menuItem.sectionType != 3 && isBuy">
+      <view
+        style="font-size: 20rpx; color: #ff3b30"
+        v-if="menuItem.liveStartTime && menuItem.sectionType != 3 && isBuy"
+      >
         <template v-if="!isLast() && !isLive">
           <view class="tagWillPlay" v-if="menuItem.liveStartTime > nowTime">
             <text>待开播</text>
           </view>
-          <view class="tagPlaying" v-if="menuItem.liveStartTime <= nowTime &&
-            menuItem.liveEndTime > nowTime
-            ">
+          <view
+            class="tagPlaying"
+            v-if="
+              menuItem.liveStartTime <= nowTime &&
+              menuItem.liveEndTime > nowTime
+            "
+          >
             <text>直播中</text>
           </view>
           <view class="tagPlayed" v-if="menuItem.liveEndTime < nowTime">
@@ -74,13 +99,19 @@
       </view>
       <!-- 直播课程没有学习状态 -->
       <template v-if="!isLive">
-        <view v-if="isRebuild || menuItem.rebuild > 0" class="tagRe">待重修</view>
+        <view v-if="isRebuild || menuItem.rebuild > 0" class="tagRe"
+          >待重修</view
+        >
         <view v-else>
           <view v-if="menuItem.learning == 1" class="tagGreen">已学完</view>
         </view>
       </template>
 
-      <view v-if="checkTest()" class="exercises" @click.stop="toDoSectionExam()">
+      <view
+        v-if="checkTest()"
+        class="exercises"
+        @click.stop="toDoSectionExam()"
+      >
         <text class="exe_w">习题</text>
         <u-icon name="arrow-right" color="#498AFE" size="28"></u-icon>
       </view>
@@ -158,6 +189,12 @@ export default {
       type: Array,
       default: () => [],
     },
+    sectionItem: {
+      type: Object,
+      default: () => {
+        return {};
+      },
+    },
   },
   watch: {
     menuItem(val) {
@@ -167,7 +204,6 @@ export default {
   data() {
     return {
       nowTime: 0,
-      newId: 0,
       playId: "",
       clickLock: false, //点击锁,防止连续点击多次
       moduleSectionExam: [], // 模块下的所有节试卷列表
@@ -176,7 +212,7 @@ export default {
       // newMenuAllList: [],
     };
   },
-  onLoad() { },
+  onLoad() {},
   created() {
     if (this.testType == 3) {
       // 模块下的所有节试卷列表
@@ -185,7 +221,7 @@ export default {
           chapterId: 0,
           courseId: this.courseId,
           gradeId: this.gradeId,
-          orderGoodsId: this.orderGoodsId
+          orderGoodsId: this.orderGoodsId,
         })
         .then((res) => {
           if (res.data.code == 200) {
@@ -195,63 +231,7 @@ export default {
     }
   },
   mounted() {
-    // console.log('节的播放---menuItem', this.menuItem, 'playSectionId:', this.playSectionId, 'isBuy:', this.isBuy)
     this.nowTime = Number(new Date().getTime() / 1000).toFixed(0);
-    this.newId =
-      this.menuItem.sectionId > 0
-        ? this.menuItem.sectionId
-        : this.menuItem.menuId;
-    let moduleId = this.menuItem.moduleId || 0;
-    let chapterId = this.menuItem.chapterId || 0;
-    let sectionId = this.menuItem.sectionId || this.menuItem.menuId;
-    let playNextId = `moduleId${moduleId}chapterId${chapterId}sectionId${sectionId}${this.isRebuild ? "isRebuild" : ""
-      }`;
-    this.playId = playNextId;
-    if (this.playSectionId == this.newId) {
-      this.$store.commit("updatePlayNextId", playNextId);
-    }
-    uni.$off("playNext" + playNextId); //绑定前先移除之前的事件
-    uni.$once("playNext" + playNextId, async (data) => {
-      //到时会触发每个节的监听事件,只允许当前节的接收
-      let self = this;
-      if (
-        this.nextMenuItem.recordingUrl &&
-        this.isRebuild &&
-        this.newId == this.playSectionId &&
-        data.fromRebuild
-      ) {
-        // fromRebuild 来自重修目录的点击才弹出播放下一节
-        //重修存在下一节
-        uni.showModal({
-          title: "提示",
-          content: "是否播放下一节",
-          success: function (res) {
-            if (res.confirm) {
-              let nextId =
-                self.nextMenuItem.sectionId > 0
-                  ? self.nextMenuItem.sectionId
-                  : self.nextMenuItem.menuId;
-              //设置播放的节ID
-              let ids = self.levelId.split("-");
-              ids[2] = nextId;
-              uni.$emit("levelId", ids.join("-"));
-              uni.$emit("getSection", self.nextMenuItem);
-              self.$emit("playEnd", { isRebuild: self.isRebuild });
-            } else {
-              let nextId =
-                self.nextMenuItem.sectionId > 0
-                  ? self.nextMenuItem.sectionId
-                  : self.nextMenuItem.menuId;
-              let ids = self.levelId.split("-");
-              ids[2] = nextId;
-              self.$emit("playEnd", { isRebuild: self.isRebuild });
-            }
-          },
-        });
-      } else {
-        this.$emit("playEnd", { isRebuild: this.isRebuild });
-      }
-    });
   },
   methods: {
     isLast() {
@@ -349,7 +329,7 @@ export default {
             courseId: this.courseId,
             gradeId: this.gradeId,
             goodsId: this.goodsId,
-            orderGoodsId: this.orderGoodsId
+            orderGoodsId: this.orderGoodsId,
           })
           .then((res) => {
             if (res.data.code == 200) {
@@ -367,7 +347,7 @@ export default {
             moduleId: this.menuItem.moduleId || 0,
             chapterId: this.menuItem.chapterId || 0,
             sectionId: this.menuItem.sectionId || this.menuItem.menuId,
-            orderGoodsId: this.orderGoodsId
+            orderGoodsId: this.orderGoodsId,
           })
           .then((res) => {
             resolve(res.data.data);
@@ -380,7 +360,7 @@ export default {
           .goodsTodayStudySectionNum({
             goodsId: this.goodsId,
             gradeId: this.gradeId,
-            orderGoodsId: this.orderGoodsId
+            orderGoodsId: this.orderGoodsId,
           })
           .then((res) => {
             if (res.data.code == 200) {
@@ -495,10 +475,6 @@ export default {
           this.clickLock = false;
           return;
         }
-        /* if(this.playSectionId==this.newId){
-          //切换为同一节
-          return
-        } */
         // 回放
         if (this.menuItem.sectionType == 3) {
           let moduleId = this.menuItem.moduleId || 0;
@@ -508,32 +484,32 @@ export default {
           // buyCourse 是否购买课程:1是 0否,type=vod是回放
           let encode = encodeURIComponent(
             this.config.hostLive +
-            "/pages/live/index?token=" +
-            uni.getStorageSync("token") +
-            "&userInfo=" +
-            JSON.stringify(this.userInfo) +
-            "&channelId=" +
-            this.menuItem.liveUrl +
-            "&gradeId=" +
-            this.gradeId +
-            "&courseId=" +
-            this.courseId +
-            "&goodsId=" +
-            this.goodsId +
-            "&orderGoodsId=" +
-            this.orderGoodsId +
-            "&sectionId=" +
-            sectionId +
-            "&chapterId=" +
-            chapterId +
-            "&moduleId=" +
-            moduleId +
-            "&buyCourse=1" +
-            "&ident=" +
-            uuid +
-            "&sectionType=3" +
-            "&vid=" +
-            this.menuItem.recordingUrl
+              "/pages/live/index?token=" +
+              uni.getStorageSync("token") +
+              "&userInfo=" +
+              JSON.stringify(this.userInfo) +
+              "&channelId=" +
+              this.menuItem.liveUrl +
+              "&gradeId=" +
+              this.gradeId +
+              "&courseId=" +
+              this.courseId +
+              "&goodsId=" +
+              this.goodsId +
+              "&orderGoodsId=" +
+              this.orderGoodsId +
+              "&sectionId=" +
+              sectionId +
+              "&chapterId=" +
+              chapterId +
+              "&moduleId=" +
+              moduleId +
+              "&buyCourse=1" +
+              "&ident=" +
+              uuid +
+              "&sectionType=3" +
+              "&vid=" +
+              this.menuItem.recordingUrl
           );
           uni.navigateTo({
             url: `../../pages/webview/index?url=` + encode,
@@ -631,30 +607,30 @@ export default {
         // buyCourse 是否购买课程:1是 0否
         let encode = encodeURIComponent(
           this.config.hostLive +
-          "/pages/live/index?token=" +
-          uni.getStorageSync("token") +
-          "&userInfo=" +
-          JSON.stringify(this.userInfo) +
-          "&channelId=" +
-          this.menuItem.liveUrl +
-          "&gradeId=" +
-          this.gradeId +
-          "&courseId=" +
-          this.courseId +
-          "&goodsId=" +
-          this.goodsId +
-          "&orderGoodsId=" +
-          this.orderGoodsId +
-          "&sectionId=" +
-          sectionId +
-          "&chapterId=" +
-          chapterId +
-          "&moduleId=" +
-          moduleId +
-          "&buyCourse=1" +
-          "&ident=" +
-          uuid +
-          "&sectionType=2"
+            "/pages/live/index?token=" +
+            uni.getStorageSync("token") +
+            "&userInfo=" +
+            JSON.stringify(this.userInfo) +
+            "&channelId=" +
+            this.menuItem.liveUrl +
+            "&gradeId=" +
+            this.gradeId +
+            "&courseId=" +
+            this.courseId +
+            "&goodsId=" +
+            this.goodsId +
+            "&orderGoodsId=" +
+            this.orderGoodsId +
+            "&sectionId=" +
+            sectionId +
+            "&chapterId=" +
+            chapterId +
+            "&moduleId=" +
+            moduleId +
+            "&buyCourse=1" +
+            "&ident=" +
+            uuid +
+            "&sectionType=2"
         );
         uni.navigateTo({
           url: `../../pages/webview/index?url=` + encode,
@@ -667,13 +643,23 @@ export default {
   computed: {
     ...mapGetters([
       "playSectionId",
-      "playChannelId",
-      "playVID",
-      "playNextId",
       "userInfo",
       "liveLast",
       "config",
     ]),
+    isActive() {
+      let moduleId = this.menuItem.moduleId || 0;
+      let chapterId = this.menuItem.chapterId || 0;
+      let sectionId = this.menuItem.sectionId || this.menuItem.menuId;
+      let moduleId1 = this.sectionItem.moduleId || 0;
+      let chapterId1 = this.sectionItem.chapterId || 0;
+      let sectionId1 = this.sectionItem.sectionId || this.sectionItem.menuId;
+      return (
+        moduleId == moduleId1 &&
+        chapterId == chapterId1 &&
+        sectionId == sectionId1
+      );
+    },
   },
 };
 </script>
@@ -803,7 +789,7 @@ export default {
   font-size: 26rpx;
   color: #498afe;
 
-  >text {
+  > text {
     margin-right: 6rpx;
   }
 }

+ 37 - 2
components/course/courseTree.vue

@@ -19,6 +19,7 @@
             :goodsType="1"
             :menuAllList="menuAllList"
             :sectionItem="sectionItem"
+            :isRebuild="isRebuild"
           ></courseModule
         ></view>
         <!--章 -->
@@ -31,7 +32,6 @@
             "
             :courseId="courseId"
             :preItem="menuList[index - 1]"
-            @playEnd="sectionPlayEnd($event, index)"
             :learningOrder="learningOrder"
             :goodsId="goodsId"
             :gradeId="gradeId"
@@ -41,6 +41,7 @@
             :goodsType="1"
             :menuAllList="menuAllList"
             :sectionItem="sectionItem"
+            :isRebuild="isRebuild"
           ></courseChapter
         ></view>
         <!--节 -->
@@ -49,7 +50,6 @@
             ref="MoudleSection"
             :orderGoodsId="orderGoodsId"
             :sectionMaxNum="sectionMaxNum"
-            @playEnd="sectionPlayEnd($event, index)"
             :courseId="courseId"
             :preItem="menuList[index - 1]"
             :learningOrder="learningOrder"
@@ -61,6 +61,8 @@
             :goodsType="1"
             :testType="3"
             :menuAllList="menuAllList"
+            :isRebuild="isRebuild"
+            :sectionItem="sectionItem"
           ></courseSection
         ></view>
       </view>
@@ -185,6 +187,39 @@ export default {
 </script>
 
 <style lang="scss" scoped>
+.top {
+  &__header {
+    position: relative;
+    width: 100%;
+    height: 150rpx;
+    padding: 24rpx 150rpx 24rpx 24rpx;
+
+    .img {
+      position: absolute;
+      left: 0;
+      top: 0;
+      width: 100%;
+    }
+
+    .note {
+      position: relative;
+      z-index: 10;
+      font-size: 24rpx;
+      font-family: PingFang SC;
+      font-weight: bold;
+      color: #efdbff;
+    }
+
+    .title {
+      position: relative;
+      z-index: 10;
+      font-size: 26rpx;
+      font-family: PingFang SC;
+      font-weight: bold;
+      color: #ffffff;
+    }
+  }
+}
 .menuBox {
   width: 100%;
   background: #ffffff;

+ 3 - 0
components/course/handoutsBox.vue

@@ -59,6 +59,9 @@ export default {
       this.courseHandouts();
     },
     courseHandouts() {
+      if (!this.handoutsId) {
+        return;
+      }
       this.$api
         .courseHandouts({
           handoutsId: this.handoutsId,

+ 4 - 6
components/course/noteBox.vue

@@ -80,12 +80,6 @@ import { mapGetters } from "vuex";
 export default {
   name: "SaasMiniprogramNoteBox",
   props: {
-    params: {
-      type: Object,
-      defaule: () => {
-        return {};
-      },
-    },
     refPlv: {
       type: Object,
       defaule: () => {
@@ -94,6 +88,7 @@ export default {
     },
     isPlayRebuild: {},
   },
+  inject: ["paramsFn"],
   data() {
     return {
       noteList: [],
@@ -167,6 +162,9 @@ export default {
   },
   computed: {
     ...mapGetters(["playSectionId"]),
+    params() {
+      return this.paramsFn(["orderGoodsId", "goodsId", "courseId"]);
+    },
   },
   watch: {
     playSectionId: {

+ 4 - 0
components/myPlayer/polyvPlayer.vue

@@ -83,6 +83,10 @@ export default {
       Elevideo: null,
     };
   },
+  created() {
+    polyvPlayerContext = null;
+  },
+
   mounted() {
     if (this.vid) {
       this.changeVid(this.vid);

+ 69 - 55
components/popup/camera.vue

@@ -15,7 +15,7 @@
             <view class="centersq">请正视手机屏幕</view>
           </view>
           <view class="photoCenter">
-            <view class="center_camera" v-if="photoPopup && isTaking">
+            <view class="center_camera" v-if="isTaking">
               <!-- #ifdef MP-WEIXIN -->
               <camera
                 device-position="front"
@@ -130,26 +130,26 @@
 </template>
 
 <script>
+import myCompressImage from "@/common/compressPhoto.js";
 import PopupPhoto from "./index.vue";
 export default {
   name: "SaasMiniprogramCamera",
-  props: {
-    goodsId: {
-      type: Number,
-      default: 0,
-    },
-  },
+  inject: ["paramsFn"],
   data() {
     return {
       isShow: false,
+      isTaking: true,
       avatarUrl: false,
       isCameraAuth: false,
       showSet: false,
       popupPhotoShow: false,
+      faceUrl: "",
     };
   },
 
-  mounted() {},
+  mounted() {
+    console.log(this.params, "params");
+  },
 
   methods: {
     async submit() {
@@ -158,43 +158,13 @@ export default {
       }
       this.uploadLock = true;
       let compareFaceData = await this.faceRecognition();
-      this.compareFaceData = compareFaceData;
       if (compareFaceData >= 80) {
-        await this.imageInfos();
-        this.postCoursePhotoRecord()
-          .then(async (res) => {
-            this.photoHistoryList.push(this.photoIndex);
-            // console.log('拍照确定提交', this.photoHistoryList);
-            this.postStudyRecord(); //提交记录
-            if (this.erJianErZao && this.isReach) {
-              console.log("1校验");
-              await this.postStudyRecord(1);
-              this.photoPopup = false;
-              this.uploadLock = false;
-              this.enableAutoRotation = true;
-              this.nextSection();
-              return;
-            }
-            //恢复播放
-            // #ifdef MP-WEIXIN
-            uni.setKeepScreenOn({
-              keepScreenOn: false,
-            });
-            // #endif
-            this.photoPopup = false;
-            this.uploadLock = false;
-            this.enableAutoRotation = true;
-            this.refPlv.resumeVideo();
-          })
-          .catch((err) => {
-            console.log("拍照记录接口的err", err);
-            uni.showToast({
-              title: "上传接口报错,请重新拍照上传" + err,
-              icon: "none",
-            });
-            this.uploadLock = false;
-            this.openPhoto();
-          });
+        this.$emit(
+          "submitPhoto",
+          await this.imageInfos(),
+          compareFaceData,
+          this.reTakeOrClose
+        );
       } else {
         uni.showToast({
           title: "人脸匹配不通过,请重新拍照上传",
@@ -203,21 +173,35 @@ export default {
         });
 
         setTimeout(() => {
-          this.uploadLock = false;
-          this.openPhoto();
+          if (!this.isTaking) {
+            this.reTake();
+          }
         }, 2000);
       }
     },
+    async imageInfos() {
+      let resPath = await myCompressImage(this.avatarUrl || this.faceUrl, 50);
+      const waitUpload = await this.$method.uploadFile(resPath, 0);
+      return waitUpload;
+    },
+    reTakeOrClose(type = 0) {
+      type ? this.reTake() : this.closeCamera();
+    },
+    closeCamera() {
+      this.isShow = false;
+      this.showSet = false;
+      this.popupPhotoShow = false;
+    },
     openCamera() {
+      this.uploadLock = false;
       // 同一个商品只谈一次提示
-      if (!uni.getStorageSync(`tabkePhotoShow${this.goodsId}`)) {
-        uni.setStorageSync(`tabkePhotoShow${this.goodsId}`, this.goodsId);
+      let popupList = uni.getStorageSync("popupList") || [];
+      if (!popupList.includes(this.goodsId)) {
+        popupList.push(this.goodsId);
+        uni.setStorageSync("popupList", popupList);
         this.popupPhotoShow = true;
         return;
       }
-      if (this.isCameraAuth) {
-        return this.showCamera();
-      }
       // #ifdef MP-WEIXIN
       // 屏幕亮度
       uni.setKeepScreenOn({
@@ -272,7 +256,8 @@ export default {
       // #endif
     },
     showCamera() {
-      this.show = true;
+      this.isTaking = true;
+      this.isShow = true;
     },
     //确认拍照
     takePhoto() {
@@ -300,6 +285,26 @@ export default {
       this.isTaking = false;
       // #endif
     },
+    reTake() {
+      console.log("🚀 ~ file: camera.vue:287 ~ reTake ~ reTake:", "reTake");
+      this.uploadLock = false;
+      this.isTaking = true;
+      // #ifdef H5
+      this.faceUrl = "";
+      this.getUserMedia(
+        {
+          video: {
+            width: 400,
+            height: 300,
+            facingMode: "user",
+          },
+        },
+        this.photographSuccess,
+        this.photographError
+      );
+      // #endif
+    },
+
     /**
      * 人脸匹配
      */
@@ -343,8 +348,8 @@ export default {
       this.$api
         .faceCertificationCompareFace({
           imageA: url,
-          orderGoodsId: this.orderGoodsId,
-          gradeId: this.gradeId,
+          orderGoodsId: this.params.orderGoodsId,
+          gradeId: this.params.gradeId,
         })
         .then((res) => {
           clearTimeout(timer);
@@ -372,6 +377,7 @@ export default {
       this.showCamera();
       this.$nextTick(() => {
         const box = document.querySelector(".photo_v");
+        console.log("🚀 ~ file: camera.vue:375 ~ this.$nextTick ~ box:", box);
         const video = box.querySelector("video");
         video.srcObject = stream;
         video.play();
@@ -394,7 +400,7 @@ export default {
       });
     },
     getUserMedia(constraints, success, error) {
-      console.log("getUserMedia===", constraints,);
+      console.log("getUserMedia===", constraints);
       if (window.navigator.mediaDevices.getUserMedia) {
         // 最新的标准API
         window.navigator.mediaDevices
@@ -413,6 +419,14 @@ export default {
       }
     },
   },
+  computed: {
+    params() {
+      return this.paramsFn();
+    },
+    goodsId() {
+      return this.params.goodsId;
+    },
+  },
   components: {
     PopupPhoto,
   },

+ 1 - 9
pages3/polyv/detail copy.vue

@@ -2332,8 +2332,6 @@ export default {
         this.needSeek = true; //需要跳转到播放记录
       }
       this.startStatus = true;
-      //获取节笔记
-      this.getNoteList();
     },
     //正常播放视频
     async playVideo(item) {
@@ -2357,8 +2355,6 @@ export default {
       // #ifdef H5
       await this.loadPlayerScript(this.loadPlayer);
       // #endif
-      //获取节笔记
-      this.getNoteList();
     },
     getRecordLast() {
       return new Promise((resolve) => {
@@ -3173,6 +3169,7 @@ export default {
         await this.imageInfos();
         this.postCoursePhotoRecord()
           .then(async (res) => {
+            console.log("🚀 ~ file: detail copy.vue:3176 ~ .then ~ res:", res)
             this.photoHistoryList.push(this.photoIndex);
             // console.log('拍照确定提交', this.photoHistoryList);
             this.postStudyRecord(); //提交记录
@@ -3324,10 +3321,6 @@ export default {
     getGoodsDetail() {
       let self = this;
       this.$api.goodsDetail(this.goodsId).then(async (res) => {
-        console.log(
-          "🚀 ~ file: detail.vue:3398 ~ this.$api.goodsDetail ~ res:",
-          res
-        );
         this.goodsData = res.data.data;
         this.option.periodWaitTime && (await this.checkFinishRequiredCourse());
         if (this.goodsData.buyNote) {
@@ -3344,7 +3337,6 @@ export default {
           }
         }, 500);
         //获取节笔记
-        this.getNoteList();
         if (self.goodsData.goodsPlayConfig) {
           self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
           if (self.goodsPlayConfig.autoPlay > 0) {

+ 118 - 301
pages3/polyv/detail.vue

@@ -17,6 +17,7 @@
       </view>
       <view v-else>
         <my-player
+          v-if="playVID"
           ref="player"
           :playVid="playVID"
           :autoplay="autoplay"
@@ -104,11 +105,8 @@
           ></course-tree>
         </view>
         <!--讲义 -->
-        <view v-show="current == 1">
-          <handouts-box
-            :handoutsId="goodsData.handoutsId"
-            v-if="goodsData.handoutsId"
-          ></handouts-box>
+        <view v-if="current == 1">
+          <handouts-box :handoutsId="goodsData.handoutsId"></handouts-box>
         </view>
         <!--笔记 -->
         <view v-if="current == 2">
@@ -120,76 +118,25 @@
           ></note-Box>
         </view>
         <!--答疑 -->
-        <view v-show="current == 3">
-          <answer-box
-            :userId="userInfo ? userInfo.userId : 0"
-            :params="params(['orderGoodsId', 'goodsId', 'courseId', 'gradeId'])"
-          ></answer-box>
+        <view v-if="current == 3">
+          <answer-box :userId="userInfo ? userInfo.userId : 0"></answer-box>
         </view>
         <!--目录 -->
-        <view v-show="current == 4">
-          <view
-            class="menuBox"
-            v-for="(item, index) in reMenuList"
-            :key="index"
-          >
-            <!--模块 -->
-            <view v-if="item.type == 1"
-              ><courseModule
-                :orderGoodsId="orderGoodsId"
-                :sectionMaxNum="goodsData.sectionMaxNum"
-                :courseId="courseId"
-                :learningOrder="orderNum"
-                :goodsId="goodsId"
-                :gradeId="gradeId"
-                :isRebuild="true"
-                :isBuy="true"
-                :menuItem="item"
-                :levelId="item.menuId"
-                :goodsType="1"
-                :menuAllList="menuAllList"
-                :sectionItem="sectionItem"
-              ></courseModule
-            ></view>
-            <!--章 -->
-            <view v-if="item.type == 2">
-              <courseChapter
-                :orderGoodsId="orderGoodsId"
-                :courseId="courseId"
-                :learningOrder="orderNum"
-                :sectionMaxNum="goodsData.sectionMaxNum"
-                @playEnd="sectionPlayEnd($event, index)"
-                :gradeId="gradeId"
-                :goodsId="goodsId"
-                :isRebuild="true"
-                :isBuy="true"
-                :menuItem="item"
-                :levelId="'0-' + item.menuId"
-                :goodsType="1"
-                :menuAllList="menuAllList"
-              ></courseChapter>
-            </view>
-            <!--节 -->
-            <view v-if="item.type == 3">
-              <courseSection
-                :orderGoodsId="orderGoodsId"
-                :courseId="courseId"
-                :learningOrder="orderNum"
-                :sectionMaxNum="goodsData.sectionMaxNum"
-                @playEnd="sectionPlayEnd($event, index)"
-                :gradeId="gradeId"
-                :goodsId="goodsId"
-                :isRebuild="true"
-                :isBuy="true"
-                :nextMenuItem="findMenuNextSection(index)"
-                :menuItem="item"
-                :levelId="'0-0-' + item.menuId"
-                :goodsType="1"
-                :testType="3"
-                :menuAllList="menuAllList"
-              ></courseSection>
-            </view>
-          </view>
+        <view v-if="current == 4">
+          <course-tree
+            v-if="sectionItem.id || sectionItem.sectionId"
+            :orderGoodsId="orderGoodsId"
+            :sectionMaxNum="goodsData.sectionMaxNum"
+            :courseId="courseId"
+            :learningOrder="orderNum"
+            :goodsId="goodsId"
+            :gradeId="gradeId"
+            :isRebuild="true"
+            :isBuy="true"
+            :goodsType="1"
+            :menuAllList="menuAllList"
+            :sectionItem="sectionItem"
+          ></course-tree>
         </view>
       </scroll-view>
     </view>
@@ -356,19 +303,14 @@
       </view>
     </u-popup>
     <!-- 摄像头 -->
-    <Popup-camera :goodsId="goodsId" ref="camera"></Popup-camera>
+    <Popup-camera @submitPhoto="submitPhoto" ref="camera" />
   </view>
 </template>
 
 <script>
-import plv from "../static/polyv-sdk/index";
-import courseModule from "@/components/course/courseModule.vue";
-import courseChapter from "@/components/course/courseChapter.vue";
-import courseSection from "@/components/course/courseSection.vue";
 import handoutsBox from "@/components/course/handoutsBox.vue";
 import courseTree from "@/components/course/courseTree.vue";
 import PopupCamera from "../../components/popup/camera.vue";
-import myCompressImage from "@/common/compressPhoto.js";
 import myPlayer from "@/components/myPlayer/polyvPlayer.vue";
 import noteBox from "@/components/course/noteBox.vue";
 import answerBox from "@/components/course/answerBox.vue";
@@ -376,9 +318,6 @@ import { mapGetters, mapMutations } from "vuex";
 import { lockAction } from "../../utils/lock";
 export default {
   components: {
-    courseModule,
-    courseChapter,
-    courseSection,
     handoutsBox,
     myPlayer,
     noteBox,
@@ -396,9 +335,6 @@ export default {
       orderGoodsId: 0,
       noticeShow: false,
       enableAutoRotation: true,
-      seekTime: "",
-      toastTimer: null,
-      videoToastShow: false,
       showSet: false,
       startStatus: false,
       courseId: 0,
@@ -414,9 +350,7 @@ export default {
       playbackRate: [1.0],
       timer: null,
       goodsPhotographConfig: null,
-      intervalTimeList: [], // 间隔拍照时长
-      intervalTimeIndex: 0, //当前处于哪个时间段拍照
-      playTime: 0, //页面播放时长,不含暂停
+      playTime: 0, // 播放时刻
       currentTime: 0,
       avatarUrl: "",
       ossAvatarUrl: "",
@@ -426,6 +360,7 @@ export default {
       moduleId: 0,
       reMenuList: [],
       recordObj: {},
+      photoIndex: 0,
       isTaking: true, //是否正在拍照
       needSeek: false, //第一次播放是否需要跳转
       photoNum: 0,
@@ -433,7 +368,6 @@ export default {
       photoConfig: false, //是否配置好拍照次数
       photoHistoryList: [], //已拍照历史的下标点
       sectionItem: {},
-      showNotes: true,
       uploadLock: false, //上传图片
       isPlayRebuild: false, //是否正在播放重修视频needOpen
       isRebuild: false, //视频是否从重修目录点击
@@ -465,6 +399,7 @@ export default {
       isReach: false,
       noticeShow1: false,
       refPlv: null,
+      isCache: true,
     };
   },
   computed: {
@@ -476,6 +411,7 @@ export default {
       "config",
     ]),
     playSecIsLearn() {
+      return false;
       return this.sectionItem.learning != 1;
     },
     orderNum() {
@@ -518,28 +454,6 @@ export default {
       return this.courseList.find((e) => e.courseId == this.courseId);
     },
   },
-  watch: {
-    showSet(n) {
-      if (n) {
-        if (polyvPlayerContext) {
-          // #ifdef MP-WEIXIN
-          polyvPlayerContext.pause();
-          // #endif
-          // #ifdef H5
-          polyvPlayerContext.j2s_pauseVideo(); // 暂停播放视频
-          // #endif
-        }
-      }
-    },
-    photoPopup(n) {
-      if (n) {
-        if (this.prendreAutoCarme) {
-          this.photoPopup = false;
-        }
-        this.showSet && (this.photoPopup = false);
-      }
-    },
-  },
   async onLoad(option) {
     if (option.isOther) {
       this.showMark = true;
@@ -547,39 +461,47 @@ export default {
     }
     this.option = option;
     let { skipPort, id, goodsId, orderGoodsId, gradeId, informId } = option;
+    this.orderGoodsId = Number(orderGoodsId) || "";
+    this.courseId = Number(id) || "";
+    this.goodsId = Number(goodsId);
+    this.gradeId = Number(gradeId);
+    this.isCache = false;
     if (skipPort) {
       await this.$method.skipLogin(skipPort);
     }
     if (this.$method.isGoLogin()) {
       return;
     }
-    this.orderGoodsId = Number(orderGoodsId) || "";
-    this.isCanLearn();
-    !this.userInfo && this.$api.refreshUserInfo();
-    this.courseId = Number(id) || "";
-    this.goodsId = Number(goodsId);
-    this.gradeId = Number(gradeId);
     // 公众号模板消息的数据埋点
     informId && this.clickOfficial(informId);
-    this.init();
-    this.courseCourseList();
+    await this.init();
   },
   async onShow() {
-    // this.closePhoto();
+    if (this.isCache) {
+      // #ifdef H5
+      location.reload();
+      // #endif
+      // #ifdef MP-WEIXIN
+      this.init();
+      // #endif
+    }
   },
   onUnload() {
     console.log("onUnloadonUnloadonUnloadonUnload");
     this.originUnload();
-    this.clears();
     clearInterval(this.lockTimer);
   },
   onHide() {
+    setTimeout(() => {
+      this.isCache = true;
+    }, 2000);
     this.originUnload();
   },
   mounted() {},
   methods: {
     ...mapMutations(["updateChapterOpen", "updateLiveLast"]),
-    init() {
+    async init() {
+      this.isCache = false;
       // #ifdef MP-WEIXIN
       this.isAllowSeek = "no";
       // #endif
@@ -589,6 +511,9 @@ export default {
       // 锁
       lockAction();
       this.lockTimer = setInterval(lockAction, 10000);
+      await this.isCanLearn();
+      !this.userInfo && this.$api.refreshUserInfo();
+      this.courseCourseList();
     },
     // 七大员是否能进入学习
     async qCheckIsCanLearn() {
@@ -640,9 +565,7 @@ export default {
         .courseCourseList({
           pageNum: 1,
           pageSize: 200,
-          goodsId: this.goodsId,
-          gradeId: this.gradeId,
-          orderGoodsId: this.orderGoodsId,
+          ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
         })
         .then((res) => {
           if (res.data.code == 200) {
@@ -898,7 +821,6 @@ export default {
       //移除所有的事件监听器
       uni.$off();
       this.clearTimer && clearTimeout(this.clearTimer);
-      this.toastTimer && clearTimeout(this.toastTimer);
 
       if (this.studyTimer) {
         clearInterval(this.studyTimer);
@@ -960,9 +882,7 @@ export default {
       if (item.rebuild === 0) {
         this.$navTo.togo("/pages2/learn/details", {
           id: item.courseId,
-          gradeId: item.gradeId,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
+          ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
         });
         return;
       }
@@ -1060,6 +980,7 @@ export default {
     async initPlayVideo(sectionItem) {
       this.moduleId = sectionItem.moduleId;
       this.chapterId = sectionItem.chapterId;
+      this.sectionItem = sectionItem
       if (sectionItem.sectionType == 1) {
         //录播
         this.playVideo(sectionItem);
@@ -1082,6 +1003,31 @@ export default {
         return;
       }
     },
+    async submitPhoto(url, compareFaceData, cb) {
+      this.ossAvatarUrl = url;
+      this.compareFaceData = compareFaceData;
+      this.postCoursePhotoRecord()
+        .then(async (res) => {
+          this.photoHistoryList[this.photoIndex] = true;
+          await this.postStudyRecord();
+          if (!this.erJianErZao && this.isReach) {
+            await this.postStudyRecord(1);
+            cb();
+            this.nextSection();
+            return;
+          }
+          cb();
+          this.refPlv.resumeVideo();
+          this.enableAutoRotation = true;
+        })
+        .catch((err) => {
+          uni.showToast({
+            title: "上传接口报错,请重新拍照上传" + err,
+            icon: "none",
+          });
+          cb(1);
+        });
+    },
     toQuestionBank(sectionItem) {
       uni.navigateTo({
         url:
@@ -1116,6 +1062,7 @@ export default {
           courseId: this.courseId,
         })
         .then((res) => {
+          console.log("🚀 ~ file: detail.vue:1071 ~ .then ~ res:", res)
           let { data } = res.data;
           if (!data.sectionId) {
             data = this.menuAllList[0];
@@ -1283,9 +1230,7 @@ export default {
       return this.$api
         .studMenuAllList({
           courseId: this.courseId,
-          gradeId: this.gradeId,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
+          ...this.params(["goodsId", "orderGoodsId", "gradeId"]),
         })
         .then((res) => {
           let nowTime = Number(new Date().getTime() / 1000).toFixed(0);
@@ -1397,22 +1342,16 @@ export default {
     },
     loadedmetadata(event) {
       this.refPlv = this.$refs.player;
-      this.$refs["camera"].openCamera();
+      // this.openCamera()
     },
     getPhotoLastRecord() {
-      // if (this.erJianErZao || !this.playSecIsLearn || this.photoNum <= 0) {
-      //   return;
-      // }
-      let self = this;
       let { chapterId, sectionId, moduleId } = this.sectionItem;
       let data = {
+        ...this.params(),
         sectionId: sectionId || 0,
-        goodsId: this.goodsId,
-        courseId: this.courseId,
         gradeId: this.gradeId,
         chapterId: chapterId || 0,
         moduleId: moduleId || 0,
-        orderGoodsId: this.orderGoodsId,
       };
       this.$api.getPhotoLastRecord(data).then((res) => {
         if (res.data.code == 200) {
@@ -1433,33 +1372,19 @@ export default {
       });
     },
     //postTime 只提交随机时间
-    postCoursePhotoRecord() {
+    postCoursePhotoRecord(postTime = false) {
       return new Promise((resolve, reject) => {
-        let currentTime = 0;
-        // var polyvPlayerContext = this.selectComponent("#playerVideo");
-        if (polyvPlayerContext) {
-          // #ifdef MP-WEIXIN
-          currentTime = polyvPlayerContext.getCurrentTime();
-          // #endif
-          // #ifdef H5
-          currentTime = polyvPlayerContext.j2s_getCurrentTime();
-          // #endif
-        }
         let data = {
+          ...this.params("orderGoodsId", "goodsId", "courseId", "gradeId"),
           photo: this.ossAvatarUrl,
           sectionId: this.playSectionId,
-          goodsId: this.goodsId,
-          courseId: this.courseId,
-          photoTime: parseInt(currentTime > 0 ? currentTime : 0),
-          gradeId: this.gradeId,
-          photoIndex: -2, //从0算起,-2只提交随机时间
+          photoTime: this.playTime || 0,
+          photoIndex: postTime ? -2 : this.photoIndex, //从0算起,-2只提交随机时间
           photoNum: this.photoNum,
           chapterId: this.chapterId,
           moduleId: this.moduleId,
-          timeInterval: this.photoList.join(","),
-          orderGoodsId: this.orderGoodsId,
+          timeInterval: postTime ? this.photoList.join(",") : "",
         };
-        // console.log("提交接口", data);
         this.$api
           .coursePhotoRecord(data)
           .then((res) => {
@@ -1492,7 +1417,7 @@ export default {
       if (this.photoConfig) {
         return;
       }
-      let totalVideoTime = this.refPlv.getDuration()
+      let totalVideoTime = this.refPlv.getDuration();
       this.photoConfig = true;
       if (this.erJianErZao) {
         this.photoList = this.randomConfig(totalVideoTime, duration);
@@ -1500,12 +1425,14 @@ export default {
       }
       //没有历史拍照间隔数据
       if (!this.photoList || this.photoList.length == 0) {
+        // 46 * 60
         this.photoList = this.commonConfig(
           totalVideoTime,
-          this.jjShiGongYuan ? 46 * 60 : undefined
+          this.jjShiGongYuan ? 10 : undefined
         );
-        this.postCoursePhotoRecord(); //提交随机拍照时间数组
+        this.postCoursePhotoRecord(true); //提交随机拍照时间数组
       }
+      console.log(this.photoList, "this.photoList");
     },
     // 二建随机拍摄时间
     randomConfig(totalVideoTime, duration) {
@@ -1590,7 +1517,6 @@ export default {
       this.recordObj = videoCurrentTime
         ? { videoCurrentTime }
         : await this.getRecordLast(item);
-      await this.getPhotoLastRecord();
       // 查找拍照历史
       if ((this.photoNum > 0 || this.jjShiGongYuan) && learning != 1) {
         await this.getPhotoLastRecord();
@@ -1613,15 +1539,12 @@ export default {
       let { chapterId, sectionId, courseId, moduleId } = sectionItem;
       return new Promise((resolve) => {
         let data = {
+          ...this.params(),
           gradeId:
             this.gradeId || this.gradeId == 0 ? Number(this.gradeId) : null,
-          goodsId:
-            this.goodsId || this.goodsId == 0 ? Number(this.goodsId) : null,
           sectionId: sectionId || 0,
-          courseId: courseId || courseId == 0 ? Number(courseId) : null,
           chapterId: chapterId || 0,
           moduleId: moduleId || 0,
-          orderGoodsId: this.orderGoodsId,
         };
         this.$api.recordLast(data).then((res) => {
           resolve(res.data.data);
@@ -1679,22 +1602,24 @@ export default {
       }
       let self = this;
       let data = {
+        ...this.params(
+          "orderGoodsId",
+          "goodsId",
+          "courseId",
+          "erJianErZao",
+          "gradeId"
+        ),
         fromPlat: 1, //来源平台 1小程序 2网站
         photo: self.ossAvatarUrl,
         sectionId: sectionId || 0,
-        goodsId: parseInt(self.goodsId),
-        courseId: parseInt(self.courseId),
-        orderGoodsId: this.orderGoodsId,
         studyDuration: parseInt(
           PlayDuration > 0 ? PlayDuration : self.studyDuration
         ),
-        gradeId: parseInt(self.gradeId),
         chapterId: this.chapterId || 0,
         moduleId: this.moduleId || 0,
         videoCurrentTime: parseInt(
           currentTime > 0 ? currentTime : self.studyDuration
         ),
-        erJianErZao: this.erJianErZao,
       };
       if (this.ossAvatarUrl) {
         data.similarity = this.compareFaceData; // 相似度
@@ -1751,12 +1676,12 @@ export default {
                 title: res.data.msg,
                 duration: 2000,
               });
-              if (this.erJianErZao && code == 559) {
+              if (!this.erJianErZao && code == 559) {
                 this.isReach = true;
-                this.openPhoto();
+                this.$refs["camera"].reTake();
               }
               if (code == 559 || code == 588) {
-                reject("中断执行");
+                reject(res.data.msg);
               }
             }
             resolve();
@@ -1766,149 +1691,38 @@ export default {
           });
       });
     },
-    uploadFile(options, int) {
-      var self = this;
-      return new Promise((resolve, reject) => {
-        var data = {
-          imageStatus: int,
-          gradeId: this.gradeId,
-          orderGoodsId: this.orderGoodsId,
-        };
-        self.$api.aliyunpolicy(data).then((res) => {
-          if (res.data.code != 200) {
-            self.$method.showToast("签名错误" + JSON.stringify(res.data));
-            return;
-          }
-          var ossToken = res.data.data.resultContent;
-          if (ossToken.host == null || ossToken.host == undefined) {
-            self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
-            return;
-          }
-          let filePath = "";
-          // #ifdef H5
-          var localData = options; //dataUrl为base64位
-          let base = atob(localData.substring(localData.indexOf(",") + 1)); // base是将base64编码解码,去掉data:image/png;base64部分
-          let length = base.length;
-          let url = new Uint8Array(length);
-          while (length--) {
-            url[length] = base.charCodeAt(length);
-          }
-          filePath = new File([url], "a.jpg", {
-            type: "image/jpg",
-          });
-          uni.uploadFile({
-            url: ossToken.host,
-            name: "file",
-            file: filePath,
-            fileType: "image",
-            header: {
-              AuthorizationToken: "WX " + uni.getStorageSync("token"),
-            },
-            formData: {
-              key: ossToken.dir,
-              OSSAccessKeyId: ossToken.accessid,
-              policy: ossToken.policy,
-              Signature: ossToken.signature,
-              callback: ossToken.callback,
-              success_action_status: 200,
-            },
-            success: (result) => {
-              this.$u.toast("上传成功");
-              self.ossAvatarUrl = ossToken.dir;
-              resolve(ossToken.dir);
-            },
-            fail: (error) => {
-              uni.showToast({
-                title: "上传接口报错,请重新拍照上传" + error,
-                icon: "none",
-              });
-              this.openPhoto();
-              return;
-            },
-          });
-          // #endif
-
-          // #ifdef MP-WEIXIN
-          uni.uploadFile({
-            url: ossToken.host,
-            name: "file",
-            filePath: options,
-            fileType: "image",
-            header: {
-              AuthorizationToken: "WX " + uni.getStorageSync("token"),
-            },
-            formData: {
-              key: ossToken.dir,
-              OSSAccessKeyId: ossToken.accessid,
-              policy: ossToken.policy,
-              Signature: ossToken.signature,
-              callback: ossToken.callback,
-              success_action_status: 200,
-            },
-            success: (result) => {
-              // if (result.statusCode === 200) {
-              this.$u.toast("上传成功");
-              self.ossAvatarUrl = ossToken.dir;
-              resolve(ossToken.dir);
-            },
-            fail: (error) => {
-              uni.showToast({
-                title: "上传接口报错,请重新拍照上传" + error,
-                icon: "none",
-              });
-              this.openPhoto();
-              return;
-            },
-          });
-          // #endif
-        });
-      });
-    },
-    imageInfos() {
-      var self = this;
-      return new Promise(async (resolve, reject) => {
-        let resPath = await myCompressImage(this.avatarUrl || this.faceUrl, 50);
-        const waitUpload = await self.uploadFile(resPath, 0);
-        resolve(waitUpload);
-      });
-    },
     timeEvent(time) {
       this.clearPauseTimer();
       if (this.playSecIsLearn && (this.erJianErZao || this.photoNum > 0)) {
         this.configPhoto(time);
         this.isReach = false;
-        const index = this.photoList.findIndex(
-          (e) => e.photoTime < time && e.photoTime > time - 8
-        );
+        const index = this.photoList.findIndex((e) => e < time && e > time - 8);
+        console.log(index, time, this.photoHistoryList, 789);
         if (index != -1 && !this.photoHistoryList[index]) {
+          this.photoIndex = index;
           // 拍照
           this.openCamera();
         }
       }
     },
-    closeToast() {
-      clearTimeout(this.toastTimer);
-      this.videoToastShow = false;
-    },
     // 新增用户视频学习日志
     studyLog() {
       this.$http({
         url: "/user/study/log",
         method: "post",
         data: {
-          goodsId: this.goodsId,
-          courseId: this.courseId,
+          ...this.params(),
           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) => {});
     },
     timeupdate(time) {
       // console.log("播放中", time);
+      this.playTime = time;
       this.clearPauseTimer();
       this.timeEvent(time);
     },
@@ -1918,7 +1732,6 @@ export default {
         this.refPlv.playPause();
         return;
       }
-      // this.$refs["camera"].openCamera();
       this.studyLog();
       if (!this.recordObj.videoCurrentTime) {
         this.postStudyRecord(0);
@@ -1930,6 +1743,8 @@ export default {
     },
     openCamera() {
       this.$refs["camera"].openCamera();
+      this.refPlv.playPause();
+      this.refPlv.exitFullScreen();
     },
     pause() {
       this.erJianErZaoPauseTip();
@@ -2099,6 +1914,7 @@ export default {
       let { data } = await this.$api.goodsDetail(this.goodsId);
       this.goodsData = data.data;
       this.erJianErZao = this.goodsData.erJianErZao;
+      this.jjShiGongYuan = this.goodsData.jjShiGongYuan;
       this.erJianErZao && (await this.userConfirmInfoDetail());
       this.option.periodWaitTime && (await this.checkFinishRequiredCourse());
       this.goodsData.buyNote && this.baseHandoutTipList();
@@ -2149,7 +1965,6 @@ export default {
             self.reMenuList = res.data.rows;
             this.current = 0;
             if (self.reMenuList.length > 0) {
-              this.showNotes = false;
               if (Object.keys(this.sectionItem).length) {
                 let playNextIdisRebuild = `moduleId${this.sectionItem.moduleId}chapterId${this.sectionItem.chapterId}sectionId${this.sectionItem.sectionId}isRebuild`;
                 this.$store.commit("updatePlayNextId", playNextIdisRebuild);
@@ -2176,14 +1991,6 @@ export default {
     change(index) {
       this.current = index;
     },
-    clears() {
-      return new Promise((resolve, reject) => {
-        this.vid = "";
-        polyvPlayerContext && polyvPlayerContext.destroy();
-        polyvPlayerContext = null;
-        resolve();
-      });
-    },
     /**
      * 退出全屏
      */
@@ -2209,6 +2016,16 @@ export default {
         null
       );
     },
+    paramsFn(
+      keys = ["orderGoodsId", "goodsId", "courseId", "gradeId", "sectionItem"]
+    ) {
+      return this.params(keys);
+    },
+  },
+  provide() {
+    return {
+      paramsFn: this.paramsFn,
+    };
   },
 };
 </script>