From b1c0e9fea7c074aa823e45fa2dc50455e8f8106c Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期四, 22 五月 2025 09:51:13 +0800
Subject: [PATCH] 1.送货单收货

---
 H5/Js/Config.js |  172 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 133 insertions(+), 39 deletions(-)

diff --git a/H5/Js/Config.js b/H5/Js/Config.js
index ca234a3..7be17a0 100644
--- a/H5/Js/Config.js
+++ b/H5/Js/Config.js
@@ -3,56 +3,47 @@
     data: function () {
         return {
             isLoading: false,
-            textInput:''
+            textInput: '',
+            scanWorkstation: '', // 鏂板锛氭壂鎻忓伐浣嶇粦瀹氬瓧娈�
+            html5QrCode: null    // 鏂板锛氭壂鐮佸櫒瀹炰緥
         }
     },
     mounted() {
         var that = this;
     },
     methods: {
-		sendMessage() {
-			var detail = ["绗竴缁勬寚浠�"+
-                "! 0 203 203 480 1\r\n" +
-                "PREFEED 0\n\r" +
-                "POSTFEED 0\n\r" +
-                "PAGE - WIDTH 640\r\n" +
-
-                // 鍙充笂瑙掓斁缃竴涓柟鍨嬩簩缁寸爜锛�80*80锛夛紝鎵弿鍚庣殑鍊间负鈥�123456鈥�
-                "BOX 560 10 640 90 2\r\n" + // 缁樺埗浜岀淮鐮佺殑鏂规
-                "TEXT 570 20 5 \"鏉$爜\"\r\n" + // 鍦ㄦ柟妗嗕腑涓婃柟鏄剧ず鈥滄潯鐮佲��
-                "QRCODE 570 40 M 4 U 0 \"123456\"\r\n" + // 鍒涘缓浜岀淮鐮�
-
-                // 鍙充笅瑙掓樉绀轰竴涓潯褰㈢爜锛屾渶宸﹀湪320浣嶇疆锛岄暱搴︿负100锛屽悓鏃惰繖涓潯褰㈢爜灏嗗叾鎵弿鐨勫�兼樉绀哄湪鏉″舰鐮佷笅渚э紝鏉″舰鐮佺殑鍊间负鈥�987654鈥�
-                "BARCODE 320 350 100 50 1 \"987654\"\r\n" + // 鏄剧ず鏉″舰鐮佺殑浣嶇疆鍜屽ぇ灏�
-                "TEXT 320 410 5 \"987654\"\r\n" + // 
-                "GAP-SENSE\r\n" +
+		sendMessage(obj) {
+            var detail = ["! 0 200 200 210 1\r\n" +
+                "PAGE - WIDTH 700 \r\n" +
+                "BOX 0 0 700 180 2 \r\n" +
+                "T 16 0 200 10  鏉$爜1" + "\r\n" + // 娣诲姞瀛椾綋鍚嶇О
+                "BARCODE 128 1 1 20 0 80 " + '123456' + "\r\n" +
+                "TEXT 7 0 50 80 SIMSUN.GB2312 " + '123456' + "\r\n" + // 娣诲姞瀛椾綋鍚嶇О
+                //"B QR 500 10 M 1 U 9 \r\n" +  
+                //"MA," + '001' + "\r\n" +
+                "B QR 580 15 M 2 U 4" + "\r\n" +
+                "MA,QR code ABC123" + "\r\n" +
                 "ENDQR\r\n" +
                 "FORM\r\n" +
                 "PRINT\r\n",
-				"绗簩缁勬寚浠�" + "! 0 400 400 480 1\r\n" +
-				"PREFEED 0\n\r" +
-				"POSTFEED 0\n\r" +
-				"PAGE - WIDTH 640\r\n" +
-				"GAP-SENSE\r\n" +
-				"BOX 5 10 620 450 2\r\n" +
-				"LINE 5 60 620 60 1\r\n" + // 妯嚎1  
-				"LINE 5 110 620 110 1\r\n" + // 妯嚎2  
-				"LINE 5 160 620 160 1\r\n" + // 妯嚎3  
-				"LINE 5 210 620 210 1\r\n" + // 妯嚎4  
-				"LINE 5 260 620 260 1\r\n" + // 妯嚎5  
-				"LINE 120 10 120 260 1\r\n" + // 瀛楁鍚嶇О鍙充晶绔栫嚎  
-				"LINE 240 260 240 450 1\r\n" + // 瑙勬牸鍨嬪彿宸︿晶绔栫嚎  
-				"LINE 285 210 285 450 1\r\n" + // 瑙勬牸鍨嬪彿鍙充晶绔栫嚎  
-				"LINE 410 210 410 260 1\r\n" + // 鍒拌揣鏃ユ湡鍙充晶绔栫嚎  
-				"ENDQR\r\n" +
-				"FORM\r\n" +
-				"PRINT\r\n" ];
+                "! 0 200 200 210 1\r\n" +
+                "PAGE - WIDTH 700 \r\n" +
+                "BOX 0 0 700 180 2 \r\n" +
+                "T 16 0 200 10 鏉$爜2" + "\r\n" + // 娣诲姞瀛椾綋鍚嶇О
+                "BARCODE 128 1 1 20 0 80 " + '123456' + "\r\n" +
+                "TEXT270 10 0 200 50 10#鏍煎紡澶у皬娴嬭瘯" + "\r\n" +
+                "TEXT 7 0 50 80 SIMSUN.GB2312 " + '123456' + "\r\n" + // 娣诲姞瀛椾綋鍚嶇О
+                "B QR 580 15 M 2 U 4" + "\r\n" +
+                "MA,QR code ABC123" + "\r\n" +
+                "ENDQR\r\n" +
+                "FORM\r\n" +
+                "PRINT\r\n" ];
 
             let sendData = {
                 Type: 'Bar',
                 Barcode: 'TM250304-000104-2',
 				Detail: detail,
-				Ip: '192.168.38.25',
+				Ip: '192.168.38.135',
 				Port: '9100',
             }
             console.log('sendMessage 寮�濮�1:')
@@ -61,9 +52,112 @@
                 data: JSON.stringify(sendData)
             })
         },
+        // 淇敼sendScan鏂规硶涓哄疄闄呮壂鐮佸姛鑳�
         sendScan() {
-            var that = this;
-            that.$toast.fail("鏆傛椂涓嶈兘浣跨敤锛�");
+            const that = this;
+            if (!this.html5QrCode) {
+                // 楦胯挋璁惧闇�瑕佷娇鐢ㄧ壒瀹氳澶嘔D
+                this.html5QrCode = new Html5Qrcode("qr-reader", {
+                    experimentalFeatures: {
+                        useBarCodeDetectorIfSupported: true
+                    },
+                    formatsToSupport: [ Html5QrcodeSupportedFormats.QR_CODE ]
+                });
+            }
+
+            const config = {
+                fps: 10,
+                qrbox: 250,
+                // 楦胯挋闇�瑕佹槑纭寚瀹氳棰戣緭鍏ヨ澶�
+                videoConstraints: {
+                    deviceId: 'default' // 浣跨敤榛樿鎽勫儚澶�
+                }
+            };
+
+            // 淇敼鎽勫儚澶磋皟鐢ㄦ柟寮�
+            this.html5QrCode.start(
+                config,
+                qrCodeMessage => {
+                    that.scanWorkstation = qrCodeMessage;
+                    that.stopScan();
+                    that.$toast.success("鎵爜鎴愬姛锛�");
+                },
+                errorMessage => {
+                    console.error("鎵爜澶辫触:", errorMessage);
+                    that.$toast.fail("鎵爜澶辫触");
+                }
+            ).catch(err => {
+                console.error("鎽勫儚澶撮敊璇�:", err);
+                // 澧炲姞楦胯挋璁惧閿欒澶勭悊
+                const errMsg = err.message || err.name || '鎽勫儚澶翠笉鍙敤';
+                that.$toast.fail("鏃犳硶鍚姩鎽勫儚澶�: " + errMsg);
+                
+                // 鍘熺敓鎵爜澶囩敤鏂规
+                if(window.plus && plus.barcode){
+                    plus.barcode.scan(
+                        'qr',
+                        (type, result) => {
+                            that.scanWorkstation = result;
+                            that.$toast.success("鎵爜鎴愬姛锛�");
+                        },
+                        (error) => {
+                            that.$toast.fail("鎵爜澶辫触: "+error.code);
+                        }
+                    );
+                }
+            });
+
+            // 鏄剧ず鎵爜妗嗭紙闇�鍦ˋSPX涓坊鍔�<div id="qr-reader"></div>锛�
+            document.getElementById('qr-reader').style.display = 'block';
+        },
+
+        // 鏂板锛氬仠姝㈡壂鐮佹柟娉�
+        stopScan() {
+            if (this.html5QrCode && this.html5QrCode.isScanning) {
+                this.html5QrCode.stop().then(() => {
+                    document.getElementById('qr-reader').style.display = 'none';
+                }).catch(err => {
+                    console.error("鍏抽棴鎽勫儚澶村け璐�:", err);
+                });
+            }
+        },
+
+        testSuccessSound() {
+            this.$playSound('success');
+        },
+        
+        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';
         }
     }
-})
\ No newline at end of file
+})

--
Gitblit v1.9.3