谢杰标 2 年 前
コミット
4c5617d4bd
2 ファイル変更27 行追加50 行削除
  1. 17 14
      components/popup/camera.vue
  2. 10 36
      pages3/polyv/detail.vue

+ 17 - 14
components/popup/camera.vue

@@ -135,6 +135,12 @@ import PopupPhoto from "./index.vue";
 export default {
   name: "SaasMiniprogramCamera",
   inject: ["paramsFn"],
+  props: {
+    visible: {
+      type: Boolean,
+      default: false,
+    },
+  },
   data() {
     return {
       isShow: false,
@@ -146,11 +152,6 @@ export default {
       faceUrl: "",
     };
   },
-
-  mounted() {
-    console.log(this.params, "params");
-  },
-
   methods: {
     async submit() {
       if (this.uploadLock) {
@@ -159,12 +160,7 @@ export default {
       this.uploadLock = true;
       let compareFaceData = await this.faceRecognition();
       if (compareFaceData >= 80) {
-        this.$emit(
-          "submitPhoto",
-          await this.imageInfos(),
-          compareFaceData,
-          this.reTakeOrClose
-        );
+        this.$emit("submitPhoto", await this.imageInfos(), compareFaceData);
       } else {
         uni.showToast({
           title: "人脸匹配不通过,请重新拍照上传",
@@ -184,9 +180,6 @@ export default {
       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;
@@ -433,6 +426,16 @@ export default {
   components: {
     PopupPhoto,
   },
+  watch: {
+    visible(val) {
+      console.log("🚀 ~ file: camera.vue:439 ~ visible ~ val:", val);
+      if (val) {
+        this.openCamera();
+      } else {
+        this.closeCamera();
+      }
+    },
+  },
 };
 </script>
 

+ 10 - 36
pages3/polyv/detail.vue

@@ -283,7 +283,11 @@
       </view>
     </u-popup>
     <!-- 摄像头 -->
-    <Popup-camera @submitPhoto="submitPhoto" ref="camera" />
+    <Popup-camera
+      @submitPhoto="submitPhoto"
+      :visible.sync="showCamera"
+      ref="camera"
+    />
   </view>
 </template>
 
@@ -353,7 +357,6 @@ export default {
       newActiveSubjectId: "", //当前选中ID
       compareFaceData: 0, // 拍照匹配相似度
       prendreAutoCarme: false, // 是否发起授权相机
-      studyTimer: null, // 学习记录定时器
       CountTo: 0, // 倒计时
       CountTo1: 0,
       menuAllList: [],
@@ -739,8 +742,6 @@ export default {
             this.refPlv.playPause();
           }
           this.postStudyRecord(0);
-          //清除直播
-          this.studyTimer && clearInterval(this.studyTimer);
           this.photoConfig = false;
           this.photoList = [];
           this.moduleId = item.moduleId || null;
@@ -767,16 +768,8 @@ export default {
         this.postStudyRecord();
       }
       this.refPlv = null;
-      //清除正在播放的节ID
-      // this.$store.commit('setPlayObj',null)
-      this.$store.commit("setPlaySectionId", { playSectionId: 0 });
-
       //移除所有的事件监听器
       uni.$off();
-
-      if (this.studyTimer) {
-        clearInterval(this.studyTimer);
-      }
       this.clearPauseTimer();
       if (this.lockTimer) {
         clearInterval(this.lockTimer);
@@ -936,7 +929,7 @@ export default {
         return;
       }
     },
-    async submitPhoto(url, compareFaceData, cb) {
+    async submitPhoto(url, compareFaceData) {
       this.ossAvatarUrl = url;
       this.compareFaceData = compareFaceData;
       this.postCoursePhotoRecord()
@@ -945,11 +938,11 @@ export default {
           await this.postStudyRecord();
           if (this.erJianErZao && this.isReach) {
             await this.postStudyRecord(1);
-            cb();
+            this.closeCamera();
             this.nextSection();
             return;
           }
-          cb();
+          this.closeCamera();
           this.refPlv.resumeVideo();
         })
         .catch((err) => {
@@ -957,7 +950,7 @@ export default {
             title: "上传接口报错,请重新拍照上传" + err,
             icon: "none",
           });
-          cb(1);
+          this.$refs["camera"].reTake();
         });
     },
     toQuestionBank(sectionItem) {
@@ -1314,9 +1307,6 @@ export default {
       if ((this.photoNum > 0 || this.jjShiGongYuan) && learning != 1) {
         await this.getPhotoLastRecord();
       }
-      this.$store.commit("setPlaySectionId", {
-        playSectionId: sectionId,
-      });
       if (this.refPlv) {
         this.refPlv.changeVid({
           vid: recordingUrl,
@@ -1498,6 +1488,7 @@ export default {
       }).then((res) => {});
     },
     timeupdate(time) {
+      console.log("🚀 ~ file: detail.vue:1498 ~ timeupdate ~ time:");
       if (this.noticeShow) {
         this.refPlv.playPause();
         return;
@@ -1509,31 +1500,21 @@ export default {
     playing() {
       console.log("palying");
       this.isPlaying = true;
-      if (!this.videoCurrentTime) {
-        this.postStudyRecord(0);
-      }
       this.clearPauseTimer();
-      // this.studyTimer && clearInterval(this.studyTimer);
-      // this.studyTimer = setInterval(() => {
-      //   this.postStudyRecord(0);
-      // }, 15000);
     },
     openCamera() {
       console.log("拍照");
       this.showCamera = true;
-      this.$refs["camera"].openCamera();
       this.refPlv.playPause();
       this.refPlv.exitFullScreen();
     },
     closeCamera() {
       this.showCamera = false;
-      this.$refs["camera"].closeCamera();
     },
     pause() {
       console.log("暂停");
       this.isPlaying = false;
       this.erJianErZaoPauseTip();
-      clearInterval(this.studyTimer);
     },
     async ended() {
       console.log("结束");
@@ -1543,7 +1524,6 @@ export default {
         title: "播放完毕",
       });
       this.clearPauseTimer();
-      clearInterval(this.studyTimer);
       await this.postStudyRecord(1);
       this.nextSection();
     },
@@ -1613,9 +1593,6 @@ export default {
               this.sectionId = data.sectionId;
               if (data.sectionType == 1) {
                 //录播
-                this.$store.commit("setPlaySectionId", {
-                  playSectionId: data.sectionId,
-                });
                 this.photoConfig = false;
                 this.sectionItem = data;
                 this.playVideo(data);
@@ -1624,9 +1601,6 @@ export default {
                 this.studyRecordGetLastLive();
               } else if (data.sectionType == 3) {
                 //回放
-                this.$store.commit("setPlaySectionId", {
-                  playSectionId: data.sectionId,
-                });
                 this.sectionItem = data;
                 this.playVideo(data);
               }