فهرست منبع

fix: 视频loadedmetadata事件触发俩次 和 题库拍照

xuqiaoying 3 سال پیش
والد
کامیت
107018d241
2فایلهای تغییر یافته به همراه51 افزوده شده و 18 حذف شده
  1. 44 13
      pages2/class/questionBank.vue
  2. 7 5
      pages3/polyv/detail.vue

+ 44 - 13
pages2/class/questionBank.vue

@@ -885,6 +885,7 @@ export default {
       compareFaceData: 0, // 拍照匹配相似度
       learning: -1, // 1合格,0不合格
       originShowDialog: false,
+      uploadLock: false, //上传图片
     };
   },
   watch: {
@@ -899,7 +900,6 @@ export default {
   },
   async onLoad(option) {
     this.examType = option.type
-    console.log('examType:', this.examType)
     this.id = option.id;
     this.goodsId = option.goodsid;
     this.chapterId = option.chapterId;
@@ -1113,6 +1113,8 @@ export default {
                 title: "上传接口报错" + error,
                 icon: "none",
               });
+              this.uploadLock = false
+              this.openPhoto()
               return;
             },
           });
@@ -1226,28 +1228,57 @@ export default {
       });
     },
     async submitPhoto() {
+      if (this.uploadLock) {
+        return
+      }
+      this.uploadLock = true
+
       let compareFaceData = await this.faceRecognition();
       this.compareFaceData = compareFaceData
-      if (compareFaceData == 0) {
+      // if (compareFaceData == 0) {
+      //   uni.showToast({
+      //     title: "人脸匹配不通过,请重新拍照上传",
+      //     icon: "none",
+      //     duration: 2000,
+      //   });
+
+      //   // setTimeout(() => {
+      //   //   this.uploadLock = false;
+      //   //   this.openPhoto();
+      //   // }, 2000);
+      //   return;
+      // }
+
+      if (compareFaceData >= 80) {
+        const waitYS = await this.imageInfos();
+        this.postStudyRecord(); //提交记录
+        this.photoPopup = false;
+      } else {
         uni.showToast({
           title: "人脸匹配不通过,请重新拍照上传",
           icon: "none",
           duration: 2000,
         });
 
-        // setTimeout(() => {
-        //   this.uploadLock = false;
-        //   this.openPhoto();
-        // }, 2000);
-        return;
-      }
-
-      if (compareFaceData >= 80) {
-        const waitYS = await this.imageInfos();
-        this.postStudyRecord(); //提交记录
-        this.photoPopup = false;
+        setTimeout(() => {
+          this.uploadLock = false
+          this.openPhoto()
+        }, 2000);
       }
     },
+    //拍照
+    openPhoto() {
+      // this.enableAutoRotation = false;
+      this.photoPopup = true;
+      this.isTaking = true;
+      uni.setKeepScreenOn({
+        keepScreenOn: true,
+      });
+      uni.authorize({
+        scope: "scope.camera",
+        success() {},
+      });
+    },
     //确认拍照
     takePhoto() {
       var self = this;

+ 7 - 5
pages3/polyv/detail.vue

@@ -1788,8 +1788,11 @@ export default {
       }
       return {};
     },
-		loadedmetadata(e) {
-      console.log('------: loadedmetadata', 'this.recordObj:', this.recordObj);
+		loadedmetadata(event) {
+      if (this.hasStart) { // 防止loadedmetadata事件第二次触发
+        return
+      }
+      console.log('------: loadedmetadata');
 			var polyvPlayerContext = this.selectComponent("#playerVideo");
 			this.hasStart = true;
 			uni.$off('playPause')
@@ -1802,7 +1805,6 @@ export default {
       this.studyTimer = setInterval(() => {
         this.postStudyRecord(0)
       }, 15 * 1000)
-      console.log('studyTimer:', this.studyTimer);
 		},
     getPhotoLastRecord() {
       let self = this;
@@ -2823,7 +2825,7 @@ export default {
 						this.baseHandoutTipList()
 				}
         self.gradeId = self.goodsData.gradeId;
-        console.log(self.gradeId, "班级ID");
+        // console.log(self.gradeId, "班级ID");
         this.courseBusiness(this.goodsData.businessId);
         this.courseHandouts();
         self.getMenuList();
@@ -2943,7 +2945,7 @@ export default {
               item.menuType = item.type;
             }
             self.menuList = res.data.rows;
-            console.log('======menuList', this.menuList)
+            // console.log('======menuList', this.menuList)
             this.reStart = true
             for (let i = 0; i < res.data.rows.length; i++) {
               if (res.data.rows[i].type == 1) {