谢杰标 2 жил өмнө
parent
commit
8c6eb62643

+ 5 - 1
components/course/courseSection.vue

@@ -640,7 +640,11 @@ export default {
       let { listenConfigList } = this.params;
       return (
         listenConfigList &&
-        listenConfigList.find((e) => e.sectionId == this.menuItem.sectionId)
+        listenConfigList.find(
+          (e) =>
+            e.sectionId == this.menuItem.sectionId ||
+            e.sectionId == this.menuItem.menuId
+        )
       );
     },
   },

+ 21 - 2
components/course/courseTree.vue

@@ -75,6 +75,13 @@ export default {
       type: [Number, String],
       default: 1,
     },
+    // 兼容props传参
+    propParam: {
+      type: Object,
+      default: () => {
+        return {};
+      },
+    },
   },
   data() {
     return {
@@ -112,14 +119,26 @@ export default {
       });
     },
   },
+  provide() {
+    return { paramsFn: this.propParamFn };
+  },
   computed: {
+    isProps() {
+      return !this.$method.isEmptyObject(this.propParam);
+    },
+    propParamFn() {
+      return (key) => {
+        return { ...this.paramsFn(key), ...this.propParam };
+      };
+    },
     params() {
-      return this.paramsFn(["orderGoodsId", "gradeId", "courseId"]);
+      return this.propParamFn(["orderGoodsId", "gradeId", "courseId"]);
     },
     sectionItem() {
-      return this.paramsFn(["sectionItem"]);
+      return this.propParamFn(["sectionItem"]);
     },
     courseId() {
+      console.log(this.params, "params");
       return this.params.courseId;
     },
   },

+ 15 - 84
pages3/course/detail.vue

@@ -140,7 +140,12 @@
                   </view>
                 </view>
                 <view v-show="!item.down">
-                  <course-tree :isBuy="false"></course-tree>
+                  <course-tree
+                    :propParam="{
+                      courseId: item.courseId,
+                    }"
+                    :isBuy="false"
+                  ></course-tree>
                   <u-line></u-line>
                 </view>
               </view>
@@ -167,10 +172,8 @@
                 </view>
               </view>
               <view v-show="!item.down">
-                <view v-for="(itemM, indexM) in item.menuList" :key="indexM">
-                  <course-tree :isBuy="false"></course-tree>
-                  <u-line></u-line>
-                </view>
+                <course-tree :isBuy="false"></course-tree>
+                <u-line></u-line>
               </view>
             </view>
           </view>
@@ -361,9 +364,7 @@ export default {
       courseList: [],
       menuList: [],
       freeMenuList: [],
-      startStatus: false,
       playbackRate: [1.0],
-      isAllowSeek: "no",
       vid: "",
       autoplay: true,
       listenConfigList: [],
@@ -506,6 +507,9 @@ export default {
       this.listenSecond = listen.auditionMinute;
       if (this.listenSecond > 0) {
         if (item.recordingUrl) {
+          if (this.vid && !this.refPlv) {
+            this.refPlv = this.$refs.player;
+          }
           this.vid = item.recordingUrl;
           if (this.refPlv) {
             this.refPlv.changeVid({
@@ -609,54 +613,19 @@ export default {
     },
     timeupdate(time) {
       if (time >= this.listenSecond) {
-        this.refPlv && (this.refPlv = this.$refs.player);
-        this.refPlv.playPause();
-        this.refPlv.exitFullScreen();
+        let refPlv = this.$refs.player;
+        refPlv.playPause();
+        refPlv.exitFullScreen();
         uni.showModal({
           title: "提示",
           content: "试听结束,购买课程可学习全部",
           showCancel: false,
           success: (resst) => {
             this.vid = "";
+            this.refPlv = "";
           },
         });
       }
-      console.log("🚀 ~ file: detail.vue:615 ~ timeupdate ~ time:", time);
-    },
-    onStateChange(newstate, oldstate) {
-      if (newstate.detail.newstate == "playing") {
-        //开始播放
-        if (this.timer) {
-          clearInterval(this.timer);
-        }
-        this.timer = setInterval(this.timeEvent, 1500); //定时器
-      }
-    },
-    closePlay() {
-      this.$store.commit("setPlaySectionId", { playSectionId: 0 });
-      this.vid = "";
-      this.startStatus = false;
-    },
-    timeEvent() {
-      let self = this;
-      var polyvPlayerContext = this.selectComponent("#playerVideo");
-      if (polyvPlayerContext != null) {
-        let PlayCurrentTime = polyvPlayerContext.getCurrentTime();
-        if (PlayCurrentTime >= this.listenSecond) {
-          polyvPlayerContext.stop();
-          polyvPlayerContext.exitFullScreen();
-          clearInterval(this.timer);
-          this.timer = null;
-          uni.showModal({
-            title: "提示",
-            content: "试听结束,购买课程可学习全部",
-            showCancel: false,
-            success: function (resst) {
-              self.closePlay();
-            },
-          });
-        }
-      }
     },
     openCourse(item) {
       this.courseId = item.courseId;
@@ -850,7 +819,6 @@ export default {
     },
     paramsFn() {
       return {
-        courseId: this.courseId,
         listenConfigList: this.listenConfigList,
       };
     },
@@ -1233,43 +1201,6 @@ export default {
         this.closePop();
       });
     },
-    loadPlayerScript(callback) {
-      if (!window.polyvPlayer) {
-        const myScript = document.createElement("script");
-        myScript.setAttribute(
-          "src",
-          "https://player.polyv.net/script/player.js"
-        );
-        myScript.onload = callback;
-        document.body.appendChild(myScript);
-      } else {
-        callback();
-      }
-    },
-    // 播放视频
-    loadPlayer() {
-      const polyvPlayer = window.polyvPlayer;
-      this.$api.polyvVideoSign(this.vid).then(async (res) => {
-        console.log("播放凭证res", res);
-        this.player = await polyvPlayer({
-          wrap: "#player",
-          width: "100%",
-          showLine: "off",
-          height: 218,
-          ban_history_time: "on",
-          vid: this.vid,
-          forceH5: true,
-          autoplay: this.autoplay,
-          speed: this.playbackRate,
-          teaser_show: 1,
-          tail_show: 1,
-          hideSwitchPlayer: true,
-          ts: res.data.data.ts,
-          sign: res.data.data.sign,
-        });
-        this.polyvPlayerContext = this.player;
-      });
-    },
   },
   provide() {
     return {