Просмотр исходного кода

h5拍照和节卷不需要拍照

xuqiaoying 2 лет назад
Родитель
Сommit
ffb4c14eac
1 измененных файлов с 18 добавлено и 20 удалено
  1. 18 20
      pages2/class/questionBank.vue

+ 18 - 20
pages2/class/questionBank.vue

@@ -948,7 +948,6 @@ export default {
     this.gradeId = option.gradeId || "";
     this.orderGoodsId = Number(option.orderGoodsId);
     this.learning = option.learning
-    console.log('learning:', this.learning)
     let isBack = option.isback;
 
     let showDialog = uni.getStorageSync("showDialog");
@@ -974,11 +973,16 @@ export default {
 
       //需要拍没拍过直接弹出摄像头
       if (this.needPhoto && !this.isTakePhoto) {
-        if (this.learning != 1) {
+        if (this.learning != 1 && this.examType != 2) {
           if (uni.getStorageSync('tabkePhotoShow')) {
+            // #ifdef MP-WEIXIN
             this.photoPopup = true;
             this.isTaking = true;
+            // #endif
             this.avatarUrl = "";
+            // #ifdef H5
+            this.isHadCamera()
+            // #endif
           } else {
             this.popupPhotoShow = true
             uni.setStorageSync('tabkePhotoShow', 1) // 本地缓存用来判断是否已经弹出过弹窗
@@ -1012,9 +1016,7 @@ export default {
       this.bankExam();
     }
   },
-  onShow() {
-    // this.photoPopup = true;
-    // this.isTaking = true;
+  mounted() {
   },
   onUnload() {
     if (this.isSubmit) {
@@ -1367,19 +1369,6 @@ export default {
 
       let compareFaceData = await this.faceRecognition();
       this.compareFaceData = compareFaceData
-      // 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(); //提交记录
@@ -1399,6 +1388,7 @@ export default {
     },
     //拍照
     openPhoto() {
+      console.log('开始拍照');
       // this.enableAutoRotation = false;
       // #ifdef MP-WEIXIN
       this.photoPopup = true;
@@ -1412,6 +1402,10 @@ export default {
       });
       // #endif
       // #ifdef H5
+      this.isHadCamera()
+      // #endif
+    },
+    isHadCamera() {
       if (
         (window.navigator.mediaDevices &&
           window.navigator.mediaDevices.getUserMedia) ||
@@ -1435,7 +1429,6 @@ export default {
         console.log("1111没有摄像");
         this.photographError();
       }
-      // #endif
     },
     //确认拍照
     takePhoto() {
@@ -2098,10 +2091,15 @@ export default {
             this.recordId = res.data.data;
 
             if (this.needPhoto) {
-              if (this.learning != 1) {
+              if (this.learning != 1 && this.examType != 2) {
                 if (uni.getStorageSync('tabkePhotoShow')) {
+                // #ifdef MP-WEIXIN
                 this.photoPopup = true; //拍照
                 this.isTaking = true;
+                // #endif
+                // #ifdef H5
+                this.isHadCamera()
+                // #endif
                 } else {
                   this.popupPhotoShow = true
                   uni.setStorageSync('tabkePhotoShow', 1) // 本地缓存用来判断是否已经弹出过弹窗