Sfoglia il codice sorgente

fix: 拍照人脸识别接口超时

xuqiaoying 2 anni fa
parent
commit
80678201c0
3 ha cambiato i file con 77 aggiunte e 7 eliminazioni
  1. 33 1
      pages2/class/questionBank.vue
  2. 22 0
      pages3/live/detail.vue
  3. 22 6
      pages3/polyv/detail.vue

+ 33 - 1
pages2/class/questionBank.vue

@@ -1177,6 +1177,24 @@ export default {
           success: (res) => {
             let base64 = "data:image/jpg;base64," + res.data;
 
+            console.log('试卷-base64Data人脸识别参数:', {
+              imageA: base64,
+              orderGoodsId: this.orderGoodsId,
+              gradeId: this.gradeId,
+            })
+            
+            let timer = setTimeout(() => {
+              uni.showToast({
+                icon: "none",
+                title: '拍照超时,请重新拍照',
+                success: () => {
+                  setTimeout(() => {
+                    uni.navigateBack()
+                  }, 1000)
+                }
+              })
+            }, 10 * 1000)
+
             this.$api
               .faceCertificationCompareFace({
                 imageA: base64,
@@ -1184,8 +1202,22 @@ export default {
                 gradeId: this.gradeId,
               })
               .then((res) => {
+                clearTimeout(timer)
                 resolve(res.data.data);
-              });
+              }).catch((err) => {
+                clearTimeout(timer)
+                // 当前网络延迟,
+                console.log('人脸识别错误:', err)
+                uni.showModal({
+                  content: "当前网络延迟",
+                  showCancel: false,
+                  success: (resultst) => {
+                    if (resultst.confirm) {
+                      uni.navigateBack()
+                    }
+                  },
+                })
+              })
           },
           fail(err) {
             console.error(err, "err");

+ 22 - 0
pages3/live/detail.vue

@@ -2039,6 +2039,26 @@ export default {
           position: 0,
           success: (res) => {
             let base64 = "data:image/jpg;base64," + res.data;
+
+            console.log('直播课-base64Data人脸识别参数:', {
+              imageA: base64,
+              orderGoodsId: this.orderGoodsId,
+              gradeId: this.gradeId,
+            })
+
+            let timer = setTimeout(() => {
+              uni.showToast({
+                icon: "none",
+                title: '拍照超时,请重新拍照',
+                duration: 2000,
+                success: () => {
+                  setTimeout(() => {
+                    uni.navigateBack()
+                  }, 1000)
+                }
+              })
+            }, 10 * 1000)
+
             this.$api
               .faceCertificationCompareFace({
                 imageA: base64,
@@ -2046,8 +2066,10 @@ export default {
                 gradeId: this.gradeId,
               })
               .then((res) => {
+                clearTimeout(timer)
                 resolve(res.data.data);
               }).catch((err) => {
+                clearTimeout(timer)
                 // 当前网络延迟,
                 console.log('人脸识别错误:', err)
                 uni.showModal({

+ 22 - 6
pages3/polyv/detail.vue

@@ -2684,11 +2684,25 @@ export default {
           position: 0,
           success: (res) => {
             let base64 = "data:image/jpg;base64," + res.data;
-						// console.log({
-            //     imageA: base64,
-            //     orderGoodsId: this.orderGoodsId,
-            //     gradeId: this.gradeId,
-            //   },'base64Data')
+						console.log('base64Data人脸识别参数:', {
+              imageA: base64,
+              orderGoodsId: this.orderGoodsId,
+              gradeId: this.gradeId,
+            })
+            
+            let timer = setTimeout(() => {
+              uni.showToast({
+                icon: "none",
+                title: '拍照超时,请重新拍照',
+                duration: 2000,
+                success: () => {
+                  setTimeout(() => {
+                    uni.navigateBack()
+                  }, 1000)
+                }
+              })
+            }, 10 * 1000)
+
             this.$api
               .faceCertificationCompareFace({
                 imageA: base64,
@@ -2696,9 +2710,11 @@ export default {
                 gradeId: this.gradeId,
               })
               .then((res) => {
-                console.log(res, "res");
+                clearTimeout(timer)
+                console.log(res, "人脸识别成功res");
                 resolve(res.data.data);
               }).catch((err) => {
+                clearTimeout(timer)
                 // 当前网络延迟,
                 console.log('人脸识别错误:', err)
                 uni.showModal({