From 878304b2c9ecbb74e029d70999a711789a07c747 Mon Sep 17 00:00:00 2001 From: hwj Date: Wed, 25 Mar 2026 18:19:10 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E8=AE=BE=E5=A4=87=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E4=BB=B6=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages_function/pages/equipment/detail.vue | 10 +- src/pages_function/pages/keypart/detail.vue | 224 ++++-------------- src/pages_function/pages/keypart/index.vue | 82 +++---- src/pages_function/pages/mold/detail.vue | 12 +- src/pages_function/pages/mold/index.vue | 14 +- 5 files changed, 106 insertions(+), 236 deletions(-) diff --git a/src/pages_function/pages/equipment/detail.vue b/src/pages_function/pages/equipment/detail.vue index 2f51bdc..14cc1da 100644 --- a/src/pages_function/pages/equipment/detail.vue +++ b/src/pages_function/pages/equipment/detail.vue @@ -209,7 +209,8 @@ diff --git a/src/pages_function/pages/keypart/index.vue b/src/pages_function/pages/keypart/index.vue index 09ea870..f5bd3bb 100644 --- a/src/pages_function/pages/keypart/index.vue +++ b/src/pages_function/pages/keypart/index.vue @@ -31,10 +31,7 @@ - 正在扫描中... - - - + 正在打开扫码... @@ -45,13 +42,13 @@ - 手动输入关键件编码 + 手动输入关键件ID @@ -68,7 +65,6 @@ import { ref } from 'vue'; const keypartCode = ref(''); const isScanning = ref(false); -const scanProgress = ref(0); function goBack() { uni.navigateBack(); @@ -76,33 +72,44 @@ function goBack() { function startScan() { if (isScanning.value) return; - + isScanning.value = true; - scanProgress.value = 0; - - const duration = 2000; - const interval = 50; - const steps = duration / interval; - let currentStep = 0; - - const timer = setInterval(() => { - currentStep++; - scanProgress.value = Math.min((currentStep / steps) * 100, 100); - - if (currentStep >= steps) { - clearInterval(timer); - setTimeout(() => { - isScanning.value = false; - navigateToDetail('KP-SCAN-001'); - }, 200); - } - }, interval); + + const finish = () => { + isScanning.value = false; + } + + uni.scanCode({ + onlyFromCamera: true, + scanType: ['qrCode', 'barCode'], + success: (res) => { + const id = String(res?.result || res?.code || res?.qrCode || res?.barCode || '').trim() + if (!id) { + uni.showToast({ title: '未获取到扫码结果', icon: 'none' }) + return + } + navigateToDetail(id) + }, + fail: (err) => { + const msg = String(err?.errMsg || '') + if (msg.includes('cancel')) { + uni.showToast({ title: '已取消扫码', icon: 'none' }) + return + } + if (msg.toLowerCase().includes('not support') || msg.toLowerCase().includes('not supported')) { + uni.showToast({ title: '当前平台不支持扫码', icon: 'none' }) + return + } + uni.showToast({ title: '扫码失败', icon: 'none' }) + }, + complete: finish + }) } function confirmInput() { if (keypartCode.value.trim().length === 0) { uni.showToast({ - title: '请输入关键件编码', + title: '请输入关键件ID', icon: 'none' }); return; @@ -111,9 +118,9 @@ function confirmInput() { navigateToDetail(keypartCode.value.trim()); } -function navigateToDetail(code) { +function navigateToDetail(id) { uni.navigateTo({ - url: `/pages_function/pages/keypart/detail?code=${encodeURIComponent(code)}` + url: `/pages_function/pages/keypart/detail?id=${encodeURIComponent(id)}` }); } @@ -316,21 +323,6 @@ function navigateToDetail(code) { margin-bottom: 30rpx; } -.progress-bar { - width: 400rpx; - height: 8rpx; - background: rgba(255, 255, 255, 0.2); - border-radius: 4rpx; - overflow: hidden; -} - -.progress-fill { - height: 100%; - background: #ff8c00; - border-radius: 4rpx; - transition: width 0.05s linear; -} - .divider { display: flex; align-items: center; diff --git a/src/pages_function/pages/mold/detail.vue b/src/pages_function/pages/mold/detail.vue index f12fb87..a2bc2a2 100644 --- a/src/pages_function/pages/mold/detail.vue +++ b/src/pages_function/pages/mold/detail.vue @@ -202,7 +202,8 @@