From 6f6f7e03ca4fd4aa9995ef6ce304945ce7a1d338 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Thu, 4 Jun 2026 15:47:10 +0800 Subject: [PATCH] =?UTF-8?q?ISBN=E6=89=AB=E7=A0=81:=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=89=AB=E6=8F=8F(=E5=AF=B9=E5=87=86?= =?UTF-8?q?=E5=8D=B3=E8=AF=86,=E6=97=A0=E9=9C=80=E6=8B=8D=E7=85=A7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 440a846..8f06f5d 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -1147,37 +1147,13 @@ export default { uni.showToast({ title: '请先登录孔网账号', icon: 'none' }) return } - // 打开普通拍照摄像头(不带扫码框),拍照后OCR识别ISBN - uni.chooseImage({ - sourceType: ['camera'], - count: 1, + // 打开摄像头实时识别条形码,对准即识别,无需拍照 + uni.scanCode({ + onlyFromCamera: true, + scanType: ['barcode'], success: (res) => { - uni.showLoading({ title: '识别中...' }) - const filePath = res.tempFilePaths[0] - uni.uploadFile({ - url: 'https://book.xcx.ocr.buzhiyushu.cn/ocr', - filePath: filePath, - name: 'file', - success: (ocrRes) => { - uni.hideLoading() - try { - const ocrData = JSON.parse(ocrRes.data) - if (ocrData && ocrData.texts && ocrData.texts.ISBN) { - this.isbn = ocrData.texts.ISBN.replace(/\D/g, '') - this.searchISBN() - } else { - uni.showToast({ title: '未识别到ISBN,请重试或手动输入', icon: 'none' }) - } - } catch (e) { - console.error('OCR解析失败:', e) - uni.showToast({ title: '识别失败', icon: 'none' }) - } - }, - fail: () => { - uni.hideLoading() - uni.showToast({ title: '识别失败', icon: 'none' }) - } - }) + this.isbn = (res.result || '').trim() + this.searchISBN() }, fail: () => {} })