From 1e5646aadae902d9f9043cc0d79395bf6b06a38c Mon Sep 17 00:00:00 2001
From: 曹睿 <360930172@qq.com>
Date: 星期一, 21 四月 2025 14:46:59 +0800
Subject: [PATCH] feat: 完成框架

---
 src/pages/production/twist/receive/monofil.vue |   56 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index 80d234f..884b6f6 100644
--- a/src/pages/production/twist/receive/monofil.vue
+++ b/src/pages/production/twist/receive/monofil.vue
@@ -2,48 +2,64 @@
   <view class="page">
     <CardTitle title="鍗曚笣棰嗙敤" :hideAction="false">
       <template #action>
-        <wd-button type="icon" icon="scan" color="#0D867F" @click="scanCode"></wd-button>
+        <wd-button type="icon" icon="scan" color="#0D867F" @click="openScan"></wd-button>
       </template>
     </CardTitle>
     <view class="list_box">
-      <MonofilCard v-for="(item, index) in 4" :key="index" />
+      <MonofilCard v-for="(item, index) in cardList" :key="index" />
     </view>
-    <scan />
+    <Scan ref="scanRef" />
   </view>
 </template>
 
 <script setup lang="ts">
 import CardTitle from "@/components/card-title/index.vue";
 import MonofilCard from "../components/MonofilCard.vue";
-import scan from "@/components/scan/index.vue";
-import { onLoad, onUnload } from "@dcloudio/uni-app";
+import { onLoad, onUnload, onShow, onHide } from "@dcloudio/uni-app";
+import Scan from "@/components/scan/index.vue";
+// import { useZebraScan } from "@/hooks/useZebraScan";
 
+// const { init, start, stop, triggerScan } = useZebraScan();
+
+const scanRef = ref();
 const cardList = ref<any[]>([]);
 
-const BroadcastScanningToObtainData = (res: any) => {
-  console.log("鑾峰彇娆℃暟", res.code);
-  let barcode = res.code;
-  console.log("鎵撳嵃鏁版嵁", barcode);
+const getScanCode = (code: any) => {
+  // let parseData = code.trim();
+  console.log("鑷畾涔夋壂鎻忕殑缁撴灉鍥炶皟鍑芥暟:", code);
+  cardList.value.push({});
 };
 
-const scanCode = () => {
-  uni.scanCode({
-    onlyFromCamera: true,
-    success: (res) => {
-      console.log("鏉$爜绫诲瀷锛�" + res.scanType);
-      console.log("鏉$爜鍐呭锛�" + res.result);
-      cardList.value.push(res.result);
-    },
-  });
+const openScan = () => {
+  // uni.scanCode({
+  //   onlyFromCamera: true,
+  //   success: (res) => {
+  //     console.log("鏉$爜绫诲瀷锛�" + res.scanType);
+  //     console.log("鏉$爜鍐呭锛�" + res.result);
+  //     cardList.value.push(res.result);
+  //   },
+  // });
+  // triggerScan();
+  scanRef.value.triggerScan();
 };
 
 onLoad(() => {
   // 寮�鍚箍鎾洃鍚簨浠�
-  uni.$on("scan", BroadcastScanningToObtainData);
+  uni.$on("scan", getScanCode);
+  // init(getScanCode);
 });
 onUnload(() => {
   // 寮�鍚箍鎾洃鍚簨浠�
-  uni.$off("scan", BroadcastScanningToObtainData);
+  uni.$off("scan", getScanCode);
+  // stop();
+});
+
+onShow(() => {
+  // start();
+});
+
+onHide(() => {
+  // stop();
 });
 </script>
 

--
Gitblit v1.9.3