From 1d23463d34a423a459cd5d74676bc3fae8f62207 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Thu, 4 Jun 2026 15:56:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80camera=E6=89=AB=E7=A0=81:?= =?UTF-8?q?=E5=AE=89=E5=8D=93=E5=8C=85=E4=B8=8D=E6=94=AF=E6=8C=81,?= =?UTF-8?q?=E6=94=B9=E7=94=A8uni.scanCode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 80 ++++++----------------------------------- 1 file changed, 10 insertions(+), 70 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 35bad12..597f922 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -676,13 +676,6 @@ - - - - - 对准条码自动识别 - - @@ -826,7 +819,6 @@ export default { historyList: [], isSubmitting: false, isLoading: false, - showScanCamera: false, // 无ISBN表单 noIsbnPrintTime: '', @@ -1155,23 +1147,16 @@ export default { uni.showToast({ title: '请先登录孔网账号', icon: 'none' }) return } - // 打开全屏摄像头实时扫码(无取景框) - this.showScanCamera = true - }, - - // 摄像头实时扫码回调 - handleScancode(e) { - const code = (e.detail && e.detail.result) || '' - if (code && code.length === 13) { - this.showScanCamera = false - this.isbn = code.trim() - this.searchISBN() - } - }, - - // 关闭扫码摄像头 - closeScanCamera() { - this.showScanCamera = false + // 打开安卓原生扫码界面(无自定义取景框,对准即识别) + uni.scanCode({ + onlyFromCamera: true, + scanType: ['barcode'], + success: (res) => { + this.isbn = (res.result || '').trim() + this.searchISBN() + }, + fail: () => {} + }) }, // ISBN搜索 - 查询图书中心 + 孔网市场 @@ -2870,51 +2855,6 @@ picker { height: 40rpx; } -/* ========== 全屏扫码摄像头 ========== */ -.scan-camera-overlay { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 9999; - background-color: #000; -} - -.scan-camera { - width: 100%; - height: 100%; -} - -.scan-camera-close { - position: fixed; - top: 60rpx; - left: 30rpx; - width: 60rpx; - height: 60rpx; - border-radius: 50%; - background-color: rgba(0,0,0,0.4); - color: #fff; - font-size: 36rpx; - display: flex; - align-items: center; - justify-content: center; - z-index: 10000; -} - -.scan-camera-tip { - position: fixed; - bottom: 120rpx; - left: 50%; - transform: translateX(-50%); - color: #fff; - font-size: 28rpx; - background-color: rgba(0,0,0,0.5); - padding: 12rpx 30rpx; - border-radius: 40rpx; - z-index: 10000; -} - /* ========== 底部提交栏 ========== */ .bottom-bar { background-color: #ffffff;