From 46450acdd9971825bd4665a8363b0257162a56f1 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Tue, 23 Jun 2026 17:11:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:OCR=E8=AF=86=E5=88=AB=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=9A=E7=A7=8DISBN/=E4=B9=A6=E5=8F=B7=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=90=8D(ISBN/isbn/isbn13/=E6=9D=A1=E7=A0=81/=E4=B9=A6?= =?UTF-8?q?=E5=8F=B7/=E7=BB=9F=E4=B8=80=E4=B9=A6=E5=8F=B7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 36948cd..92e0391 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -3126,6 +3126,7 @@ export default { uni.hideLoading() try { const ocrData = JSON.parse(res.data) + console.log('【OCR】原始返回:', JSON.stringify(ocrData)) if (ocrData && ocrData.texts) { const texts = ocrData.texts // 自动填充表单 @@ -3140,12 +3141,16 @@ export default { const fmt = String(texts.开本).replace('开', '').trim() this.noIsbnFormat = this.noIsbnFormatOptions.includes(fmt) ? fmt : fmt + '开' } - if (texts.ISBN && /^\d/.test(texts.ISBN)) { - this.noIsbnIsbn = texts.ISBN + // 尝试多种字段名获取 ISBN(OCR 可能返回不同字段名) + var isbnText = texts.ISBN || texts.isbn || texts.isbn13 || texts.barcode || texts.条码 || '' + if (isbnText && /^\d/.test(isbnText)) { + this.noIsbnIsbn = isbnText this.noIsbnUnifyIsbn = '' } - if (texts.书号) { - const bookCode = texts.书号.replace(/\D/g, '') + // 书号(OCR 可能返回 书号 或 统一书号) + var bookCodeText = texts.书号 || texts.统一书号 || texts.bookcode || texts.unified_code || '' + if (bookCodeText) { + const bookCode = bookCodeText.replace(/\D/g, '') if (bookCode.length === 13) { this.noIsbnIsbn = bookCode } else if (bookCode.length === 10 && /^\d{9}[\dXx]$/i.test(bookCode)) { @@ -3153,7 +3158,7 @@ export default { } else { this.noIsbnIsbn = '678' + String(Date.now()).slice(-10) } - this.noIsbnUnifyIsbn = texts.书号 + this.noIsbnUnifyIsbn = bookCodeText } if (texts.字数) this.noIsbnWordCount = this.processNoIsbnWordage(texts.字数)