From 46cc7a29dc1f9b3dffee5cdcb9b7f9dfdac3b16d Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期五, 05 九月 2025 20:44:14 +0800
Subject: [PATCH] Merge branch 'Dev' of http://101.37.171.70:10101/r/~jhz/STUWMS into Dev

---
 components/BarCodePopup/BarCodePopup.vue |   78 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/components/BarCodePopup/BarCodePopup.vue b/components/BarCodePopup/BarCodePopup.vue
new file mode 100644
index 0000000..5fbe6bb
--- /dev/null
+++ b/components/BarCodePopup/BarCodePopup.vue
@@ -0,0 +1,78 @@
+<template>
+    <view>
+        <uni-popup ref="BarCodePopup" type="center" @change="onPupupStateChangeHandler">
+            <view class="content">
+                <view class="title">
+                    {{ title }}
+                </view>
+                <view class="img">
+                    <canvas id="barcodeCanvas" canvas-id="barcodeCanvas" style="width: 200px;height: 200px;"></canvas>
+                </view>
+            </view>
+        </uni-popup>
+    </view>
+</template>
+
+<script>
+    import UQRCode from 'uqrcodejs'
+    export default {
+        name: "BarCodePopup",
+        data() {
+            return {
+                imgSrc: '',
+                title: '',
+            };
+        },
+        methods: {
+            open() {
+                this.$refs.BarCodePopup.open()
+            },
+            async onPupupStateChangeHandler(e) {
+                if (e.show === true) {
+                    // this.getBillList()
+                    await this.$nextTick()
+                    await this.initCanvas()
+                } else {
+                    // 娓呯悊璧勬簮
+                    this.title = ''
+                }
+            },
+            async initCanvas() {
+                // 瑙﹀彂鍒濆鍖朿anvas浜嬩欢
+                let title = this.title
+                return new Promise((resolve, reject) => {
+                    let qr = new UQRCode();
+                    // 璁剧疆浜岀淮鐮佸唴瀹�
+                    qr.data = title;
+                    let canvasContext = uni.createCanvasContext('barcodeCanvas', this); // 濡傛灉鏄粍浠讹紝this蹇呴』浼犲叆
+                    // 璁剧疆浜岀淮鐮佸ぇ灏忥紝蹇呴』涓巆anvas璁剧疆鐨勫楂樹竴鑷�
+                    qr.size = 200;
+                    // 璋冪敤鍒朵綔浜岀淮鐮佹柟娉�
+                    qr.make();
+                    // 璁剧疆uQRCode瀹炰緥鐨刢anvas涓婁笅鏂�
+                    qr.canvasContext = canvasContext;
+                    // 璋冪敤缁樺埗鏂规硶灏嗕簩缁寸爜鍥炬缁樺埗鍒癱anvas涓�
+                    qr.drawCanvas();
+                    this.$forceUpdate()
+                    resolve()
+                })
+            },
+            async setCodeInfo(title) {
+                this.title = title
+            }
+        }
+    }
+</script>
+
+<style lang="scss">
+    .content {
+        box-sizing: border-box;
+        padding: 20rpx;
+        background-color: #fff;
+        // height: 400rpx;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        flex-direction: column;
+    }
+</style>
\ No newline at end of file

--
Gitblit v1.9.1