谢杰标 2 tahun lalu
induk
melakukan
9fab3cd30b
2 mengubah file dengan 90 tambahan dan 115 penghapusan
  1. 1 0
      components/myPlayer/polyvPlayer.vue
  2. 89 115
      pages3/polyv/detail.vue

+ 1 - 0
components/myPlayer/polyvPlayer.vue

@@ -182,6 +182,7 @@ export default {
         s2j_onPlayOver: "ended", // 当前视频播放完毕时触发
         s2j_onVideoSeek: "onVideoSeek", // 视频拖拽进度时触发
         s2j_onPlayerError: "playerError", // 播放出现错误时触发
+        serverError: "playerError", // 逻辑错误
       };
       let that = this;
       for (const key in states) {

+ 89 - 115
pages3/polyv/detail.vue

@@ -28,6 +28,7 @@
           @ended="ended"
           @loadedmetadata="loadedmetadata"
           @timeupdate="timeupdate"
+          @playerError="playerError"
         ></my-player>
       </view>
       <view class="course_name">
@@ -607,7 +608,6 @@ export default {
       videoToastShow: false,
       showSet: false,
       startStatus: false,
-      detail: {},
       courseId: 0,
       menuList: [],
       current: 0,
@@ -720,6 +720,12 @@ export default {
         return params;
       };
     },
+    detail() {
+      if (!this.courseId) {
+        return {};
+      }
+      return this.courseList.find((e) => e.courseId == this.courseId);
+    },
   },
   watch: {
     showSet(n) {
@@ -744,7 +750,7 @@ export default {
     },
   },
   async onLoad(option) {
-    console.log("🚀 ~ file: detail.vue:747 ~ onLoad ~ option:", option)
+    console.log("🚀 ~ file: detail.vue:747 ~ onLoad ~ option:", option,this.$refs.player);
     if (option.isOther) {
       this.showMark = true;
       return;
@@ -823,7 +829,7 @@ export default {
         .then((res) => {
           if (res.data.code == 200) {
             this.courseList = res.data.rows;
-            console.log(this.courseList,789)
+            console.log(this.courseList, "课程列表");
             // 科目
             let allItem = [{ subjectId: 0, subjectName: "所有" }];
             let ids = [];
@@ -835,20 +841,16 @@ export default {
               }
             });
             this.subList = [...allItem, ...newArr];
-            if(!this.courseId){
-               this.courseId = this.courseList[0].courseId
-            }
             if (res.data.total > 1) {
               this.getUserWatchLast();
-            } else{
+            } else {
               this.originOnShow();
               this.originMounted();
             }
-            
           }
         });
     },
-        // 查询用户最后一次看的录播的信息
+    // 查询用户最后一次看的录播的信息
     getUserWatchLast() {
       this.$http({
         url: "/study/record/getUserWatchLast",
@@ -857,18 +859,12 @@ export default {
           orderGoodsId: this.orderGoodsId,
         },
       }).then((res) => {
-        if (res.data.code == 200) {
-          this.sectionItem = res.data.data || {};
-          if (res.data.data && Object.keys(res.data.data).length) {
-            //有最后一次看的录播的信息
-            this.courseId = res.data.data.courseId;
-            // console.log('查询用户最后一次看的录播的信息', res.data, this.courseId)
-          } else {
-            this.courseId = this.courseList[0].courseId; // 没有观看记录默认一个课程
-            // this.toggleCourseShow = true
-          }
-        } else {
-          this.courseId = this.courseList[0].courseId; // 没有观看记录默认一个课程
+        console.log("🚀 ~ file: detail.vue:859 ~ getUserWatchLast ~ res:", res);
+        if (res.data.code == 200 && res.data.data) {
+          this.courseId = res.data.data.courseId;
+        }
+        if (!this.courseId) {
+          this.courseId = this.courseList[0].courseId;
         }
         this.originOnShow();
         this.originMounted();
@@ -884,7 +880,6 @@ export default {
           goodsId: this.goodsId,
         })
         .then((res1) => {
-          console.log("🚀 ~ file: detail.vue:878 ~ .then ~ res1:", res1)
           if (res1.data.data && res1.data.data.length > 0) {
             //课程老师模板
             let teacherTel = res1.data.data;
@@ -945,7 +940,6 @@ export default {
               this.goodsTeacher.push(data);
             });
           }
-          // console.log(this.goodsTeacher,'this.goodsTeacher', this.courseId);
           this.goodsTeacher.forEach((item) => {
             if (item.courseList.some((x) => x.courseId == this.courseId)) {
               this.teacherList = item.teaList;
@@ -990,8 +984,8 @@ export default {
     },
     // 原来onshow里面的内容
     async originOnShow() {
-      this.courseDetail();
-      this.getGoodsDetail();
+      this.getMenuList();
+      this.getReMenuList(); 
       await this.studyRecordMenuAllList();
       // 消息过来 定位某个节
       if (this.option.noteSecond) {
@@ -1018,6 +1012,9 @@ export default {
         this.photoIndex = 0;
         //清除直播
         this.$store.commit("setPlayChannelId", { playChannelId: 0 });
+        if(!this.refPlv){
+          this.refPlv = this.$refs.player;
+        }
         this.postStudyRecord(0, oldSectionId);
       });
       uni.$on("getSection", (item) => {
@@ -1131,8 +1128,10 @@ export default {
     },
     // 进入学习
     async jump(item, index, type) {
-      // console.log('item------>', index,item,this.goodsTeacher)
-
+      console.log("🚀 ~ file: detail.vue:1127 ~ jump ~ item:", item)
+      if(this.courseId===item.courseId){
+        return
+      }
       if (index == 0) {
         await this.nextCourses(item, type);
 
@@ -1146,17 +1145,9 @@ export default {
           });
           return;
         }
-
-        this.$api.courseDetail(item.courseId).then((res) => {
-          if (res.data.code == 200) {
-            // if (res.data.data.educationName == "继续教育") {
-            this.$method.checkLock().then((res) => {
-              this.courseId = item.courseId;
-              this.originOnShow();
-              this.originMounted();
-            });
-          }
-        });
+        this.courseId = item.courseId;
+        this.originOnShow();
+        this.originMounted();
       } else {
         if (this.orderNum == 2) {
           //学习顺序是从头到尾学习,没学完上一课不能学习下一课
@@ -1174,17 +1165,9 @@ export default {
               });
               return;
             }
-
-            this.$api.courseDetail(item.courseId).then((res) => {
-              if (res.data.code == 200) {
-                // if (res.data.data.educationName == "继续教育") {
-                this.$method.checkLock().then((res) => {
-                  this.courseId = item.courseId;
-                  this.originOnShow();
-                  this.originMounted();
-                });
-              }
-            });
+            this.courseId = item.courseId;
+            this.originOnShow();
+            this.originMounted();
           } else {
             uni.showToast({
               icon: "none",
@@ -1203,17 +1186,9 @@ export default {
             });
             return;
           }
-
-          this.$api.courseDetail(item.courseId).then((res) => {
-            if (res.data.code == 200) {
-              // if (res.data.data.educationName == "继续教育") {
-              this.$method.checkLock().then((res) => {
-                this.courseId = item.courseId;
-                this.originOnShow();
-                this.originMounted();
-              });
-            }
-          });
+          this.courseId = item.courseId;
+          this.originOnShow();
+          this.originMounted();
         }
       }
     },
@@ -1365,7 +1340,6 @@ export default {
           courseId: this.courseId,
         })
         .then((res) => {
-          console.log("🚀 ~ file: detail.vue:1575 ~ .then ~ res:", res);
           let { data } = res.data;
           if (!data.sectionId) {
             data = this.menuAllList[0];
@@ -1622,28 +1596,12 @@ export default {
           }
         }
       }
-      let detail = await this.$api.goodsDetail(this.goodsId);
-      if (detail.data.data.erJianErZao) {
-        let info = await this.$api.userConfirmInfoDetail({
-          orderGoodsId: this.orderGoodsId,
-        });
-        if (!info.data.data || info.data.data.pushInfo !== 1) {
-          uni.showModal({
-            showCancel: false,
-            title: "提示",
-            content: "开通信息推送不成功,无法进入学习!",
-            success: (resultst) => {
-              uni.navigateBack();
-            },
-          });
-          return Promise.reject();
-        }
-      }
       return Promise.resolve();
     },
     async isCanLearn() {
       await this.getbaseprofiletplists();
       await this.getGradeInfo();
+      await this.getGoodsDetail();
     },
     /**
      * 计算tabs宽度
@@ -1968,7 +1926,9 @@ export default {
       });
     },
     postStudyRecord(status = 0, sectionId = this.playSectionId) {
-      console.log(this.refPlv, "this.refPlv");
+      if(!this.refPlv){
+        return
+      }
       let currentTime = this.refPlv.playCurrentTime();
       let PlayDuration = this.refPlv.playVideoTime();
       if (currentTime < 10 && !this.ossAvatarUrl) {
@@ -2174,7 +2134,6 @@ export default {
     },
     timeEvent(playTime) {
       this.configPhoto();
-      console.info(this.photoList, "photoList");
       let photoTime = 0; //获取拍照秒数
       for (let i = 0; i < this.photoList.length; i++) {
         photoTime = Number(this.photoList[i]); //获取拍照秒数
@@ -2264,7 +2223,9 @@ export default {
       await this.postStudyRecord(1);
       this.nextSection();
     },
-    playerError() {},
+    playerError() {
+      console.log(46546)
+    },
     //播放下一节
     nextSection() {
       console.log("播放下一节");
@@ -2611,6 +2572,22 @@ export default {
       this.photoPopup = false;
       this.enableAutoRotation = true;
     },
+    async userConfirmInfoDetail() {
+      let info = await this.$api.userConfirmInfoDetail({
+        orderGoodsId: this.orderGoodsId,
+      });
+      if (!info.data.data || info.data.data.pushInfo !== 1) {
+        uni.showModal({
+          showCancel: false,
+          title: "提示",
+          content: "开通信息推送不成功,无法进入学习!",
+          success: (resultst) => {
+            uni.navigateBack();
+          },
+        });
+        return Promise.reject();
+      }
+    },
     checkFinishRequiredCourse() {
       return this.$api
         .checkFinishRequiredCourse({
@@ -2632,42 +2609,39 @@ export default {
           return Promise.resolve();
         });
     },
-    getGoodsDetail() {
-      let self = this;
-      this.$api.goodsDetail(this.goodsId).then(async (res) => {
-        this.goodsData = res.data.data;
-        this.option.periodWaitTime && (await this.checkFinishRequiredCourse());
-        this.goodsData.buyNote && this.baseHandoutTipList();
-        this.gradeId = this.goodsData.gradeId;
-        this.erJianErZao = this.goodsData.erJianErZao;
-        this.getMenuList();
-        this.getReMenuList(); //获取重修目录
-        if (self.goodsData.goodsPlayConfig) {
-          self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
-          if (self.goodsPlayConfig.autoPlay > 0) {
-            self.autoplay = true;
-          }
-          if (self.goodsPlayConfig.drag > 0 && !self.erJianErZao) {
-            // #ifdef MP-WEIXIN
-            self.isAllowSeek = "yes";
-            // #endif
-            // #ifdef H5
-            self.isAllowSeek = "off";
-            // #endif
-          }
-          if (self.goodsPlayConfig.speed > 0) {
-            self.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
-          }
+    async getGoodsDetail() {
+      let { data } = await this.$api.goodsDetail(this.goodsId);
+      this.goodsData = data.data;
+      this.erJianErZao = this.goodsData.erJianErZao;
+      this.erJianErZao && (await this.userConfirmInfoDetail());
+      this.option.periodWaitTime && (await this.checkFinishRequiredCourse());
+      this.goodsData.buyNote && this.baseHandoutTipList();
+      this.gradeId = this.goodsData.gradeId;
+      if (this.goodsData.goodsPlayConfig) {
+        this.goodsPlayConfig = JSON.parse(this.goodsData.goodsPlayConfig);
+        if (this.goodsPlayConfig.autoPlay > 0) {
+          this.autoplay = true;
         }
-        if (self.goodsData.goodsPhotographConfig) {
-          self.goodsPhotographConfig = JSON.parse(
-            self.goodsData.goodsPhotographConfig
-          );
-          if (self.goodsPhotographConfig.photoNum > 0) {
-            self.photoNum = self.goodsPhotographConfig.photoNum;
-          }
+        if (this.goodsPlayConfig.drag > 0 && !this.erJianErZao) {
+          // #ifdef MP-WEIXIN
+          this.isAllowSeek = "yes";
+          // #endif
+          // #ifdef H5
+          this.isAllowSeek = "off";
+          // #endif
         }
-      });
+        if (this.goodsPlayConfig.speed > 0) {
+          this.playbackRate = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
+        }
+      }
+      if (this.goodsData.goodsPhotographConfig) {
+        this.goodsPhotographConfig = JSON.parse(
+          this.goodsData.goodsPhotographConfig
+        );
+        if (this.goodsPhotographConfig.photoNum > 0) {
+          this.photoNum = this.goodsPhotographConfig.photoNum;
+        }
+      }
     },
     getReMenuList() {
       let self = this;