From 455a1e7d429da9ffdaf3763e3450624223c71fc5 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期三, 14 五月 2025 15:59:33 +0800
Subject: [PATCH] 1.摄像头可调用demo,但需https

---
 H5/Js/Config.js |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/H5/Js/Config.js b/H5/Js/Config.js
index 008839d..7be17a0 100644
--- a/H5/Js/Config.js
+++ b/H5/Js/Config.js
@@ -128,6 +128,36 @@
         
         testErrorSound() {
             this.$playSound('error');
+        },
+
+
+
+        startScan() {
+            const qrScanner = new Html5Qrcode("qr-reader");
+            const config = { 
+                fps: 10,
+                qrbox: 250
+            };
+    
+            qrScanner.start(
+                { facingMode: "environment" },
+                config,
+                (decodedText) => {
+                    // 鎵爜鎴愬姛澶勭悊
+                    this.scanWorkstation = decodedText;
+                    qrScanner.stop();
+                    document.getElementById('qr-reader').style.display = 'none';
+                },
+                (errorMessage) => {
+                    // 閿欒澶勭悊
+                    console.error(errorMessage);
+                }
+            ).catch(err => {
+                alert('鏃犳硶鍚姩鎽勫儚澶�: ' + err);
+            });
+            
+            // 鏄剧ず鎵爜瀹瑰櫒
+            document.getElementById('qr-reader').style.display = 'block';
         }
     }
 })

--
Gitblit v1.9.3