From 6bd7d902f5fecddc8bfa0a7f8e55829b5b228dea Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Thu, 4 Jun 2026 10:38:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0ISBN:=E4=B9=A6=E5=8F=B7=E9=9D=9E978?= =?UTF-8?q?=E4=B8=80=E5=BE=8B678ISBN/=E5=94=AE=E4=BB=B7=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=A1=AB=E5=85=A5/=E7=89=88=E6=9D=83=E9=A1=B5=E6=AF=94?= =?UTF-8?q?=E4=BB=B7/=E5=8D=95=E6=8F=90=E4=BA=A4=E6=8C=89=E9=92=AE/?= =?UTF-8?q?=E5=8F=8Ctab=E7=A1=AE=E8=AE=A4=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 255 ++++++++++++++++++++-------------------- utils/kongfz.js | 8 +- 2 files changed, 137 insertions(+), 126 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 298f735..e28f179 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -286,9 +286,6 @@ - - 系统建议售价 ¥{{ calculatedNoIsbnPrice }}(点击填入) - @@ -421,8 +418,13 @@ - - 在售商品 + + + 在售商品 + + + 版权页比价 + @@ -463,13 +465,6 @@ - - - - 确认上传 - - - @@ -862,7 +857,6 @@ export default { noIsbnProductList: [], noIsbnHistoryList: [], noIsbnLoading: false, - noIsbnSubmitting: false, noIsbnDetailExpanded: false, // 筛选 @@ -1631,42 +1625,54 @@ export default { return } - // ISBN与售价不能为空 - if (!this.isbn) { - uni.showToast({ title: 'ISBN不能为空', icon: 'none' }) - return - } - if (!this.price) { - uni.showToast({ title: '售价不能为空', icon: 'none' }) - return - } - - // 确认弹窗 const warehouseName = warehouseData.warehouseName || warehouseData.name || '' const locCode = warehouseData.locationCode || warehouseData.code || '' const locationText = warehouseName + (locCode ? ' - ' + locCode : '') - const isbn = this.isbn || '-' - const bookName = this.bookName || '-' - const price = this.price || '-' - const stock = this.stock ?? '-' - const author = this.author || '-' - const publisher = this.publisher || '-' - const fixPrice = this.fixPrice || '-' - const printTime = this.printTime || '-' - const photoCount = this.photoList.length - const contentLines = [ - '📦 货区:' + locationText, - '📖 ISBN:' + isbn, - '📕 书名:' + bookName, - '💰 价格:' + price, - '📊 库存:' + stock, - '✍️ 作者:' + author, - '🏢 出版社:' + publisher, - '🏷️ 定价:' + fixPrice, - '📅 印刷时间:' + printTime, - '📷 图片:' + photoCount + '张' - ] + let contentLines + if (this.currentTab === 'isbn') { + if (!this.isbn) { + uni.showToast({ title: 'ISBN不能为空', icon: 'none' }) + return + } + if (!this.price) { + uni.showToast({ title: '售价不能为空', icon: 'none' }) + return + } + contentLines = [ + '📦 货区:' + locationText, + '📖 ISBN:' + (this.isbn || '-'), + '📕 书名:' + (this.bookName || '-'), + '💰 价格:' + (this.price || '-'), + '📊 库存:' + (this.stock ?? '-'), + '✍️ 作者:' + (this.author || '-'), + '🏢 出版社:' + (this.publisher || '-'), + '🏷️ 定价:' + (this.fixPrice || '-'), + '📅 印刷时间:' + (this.printTime || '-'), + '📷 图片:' + this.photoList.length + '张' + ] + } else { + if (!this.noIsbnPrice) { + uni.showToast({ title: '售价不能为空', icon: 'none' }) + return + } + if (!this.noIsbnBookName) { + uni.showToast({ title: '书名不能为空', icon: 'none' }) + return + } + contentLines = [ + '📦 货区:' + locationText, + '📕 书名:' + (this.noIsbnBookName || '-'), + '✍️ 作者:' + (this.noIsbnAuthor || '-'), + '🏢 出版社:' + (this.noIsbnPublisher || '-'), + '🏷️ 定价:' + (this.noIsbnOriginalPrice || '-'), + '📖 ISBN:' + (this.noIsbnIsbn || this.noIsbnUnifyIsbn || '-'), + '📅 印刷时间:' + (this.noIsbnPrintTime || '-'), + '💰 价格:' + (this.noIsbnPrice || '-'), + '📊 库存:' + (this.noIsbnStock ?? '-'), + '📷 图片:' + this.noIsbnPhotoList.length + '张' + ] + } uni.showModal({ title: '确认上传', @@ -1755,6 +1761,12 @@ export default { // 填充下拉选项 this.noIsbnAuthorOptions = Array.from(authorSet).filter(Boolean).slice(0, 10) this.noIsbnPublisherOptions = Array.from(publisherSet).filter(Boolean).slice(0, 10) + // 自动计算并填入售价 + this.$nextTick(() => { + if (this.calculatedNoIsbnPrice > 0) { + this.noIsbnPrice = String(this.calculatedNoIsbnPrice) + } + }) }).catch(err => { console.error('无ISBN搜索失败:', err) this.noIsbnLoading = false @@ -1762,57 +1774,70 @@ export default { }) }, - // 无ISBN - 确认上传 - submitNoIsbnUpload() { - if (this.noIsbnSubmitting) return - - const warehouseData = this.currentTab === 'no-isbn' ? this.noIsbnWarehouseData : null - if (!warehouseData) { - uni.showToast({ title: '请选择货区', icon: 'none' }) - return - } - if (!this.noIsbnPrice) { - uni.showToast({ title: '售价不能为空', icon: 'none' }) + // 无ISBN - 版权页比价(带作者+出版社精确搜索) + searchNoIsbnCopyright() { + if (!this.isLoggedIn) { + uni.showToast({ title: '请先登录孔网账号', icon: 'none' }) return } if (!this.noIsbnBookName) { - uni.showToast({ title: '书名不能为空', icon: 'none' }) + uni.showToast({ title: '请输入书名', icon: 'none' }) return } - - const warehouseName = warehouseData.warehouseName || warehouseData.name || '' - const locCode = warehouseData.locationCode || warehouseData.code || '' - const locationText = warehouseName + (locCode ? ' - ' + locCode : '') - - const contentLines = [ - '📦 货区:' + locationText, - '📕 书名:' + (this.noIsbnBookName || '-'), - '✍️ 作者:' + (this.noIsbnAuthor || '-'), - '🏢 出版社:' + (this.noIsbnPublisher || '-'), - '🏷️ 定价:' + (this.noIsbnOriginalPrice || '-'), - '📖 ISBN:' + (this.noIsbnIsbn || this.noIsbnUnifyIsbn || '-'), - '📅 印刷时间:' + (this.noIsbnPrintTime || '-'), - '💰 价格:' + (this.noIsbnPrice || '-'), - '📊 库存:' + (this.noIsbnStock ?? '-'), - '📷 图片:' + this.noIsbnPhotoList.length + '张' - ] - - uni.showModal({ - title: '确认上传', - content: contentLines.join('\n'), - confirmText: '确认上传', - cancelText: '取消', - success: (res) => { - if (res.confirm) { - this.noIsbnSubmitting = true - uni.showLoading({ title: '上传中...' }) - setTimeout(() => { - uni.hideLoading() - this.noIsbnSubmitting = false - uni.showToast({ title: '上传成功', icon: 'success' }) - }, 1500) - } + this.noIsbnLoading = true + this.noIsbnProductList = [] + const phpsessid = this.kongfzToken || uni.getStorageSync('kongfz_phpsessid') || '' + const keyword = this.noIsbnBookName + searchProducts(keyword, { + phpsessid, + sortType: '7', + quality: this.noIsbnConditionValue, + publisher: this.noIsbnPublisher, + author: this.noIsbnAuthor + }).then((productsData) => { + this.noIsbnLoading = false + if (productsData && productsData.total > 0) { + const list = (productsData.list || []).slice(0, 12) + this.noIsbnProductList = list.map(item => { + const cleanPrice = parseFloat((item.priceText || '0').replace(/[^\d.]/g, '')) + let shippingFee = 0 + if (item.postage) { + if (typeof item.postage === 'number' || typeof item.postage === 'string') { + shippingFee = parseFloat(item.postage) || 0 + } else if (item.postage.shippingList && item.postage.shippingList.length > 0) { + shippingFee = parseFloat(item.postage.shippingList[0].shippingFee || 0) + } else if (item.postage.shippingFee) { + shippingFee = parseFloat(item.postage.shippingFee || 0) + } + } + if (shippingFee === 0 && item.shippingFee) { + shippingFee = parseFloat(item.shippingFee) || 0 + } + const totalPrice = Number((cleanPrice + shippingFee).toFixed(2)) + return { + image: item.imgBigUrl || '', + totalPrice: totalPrice, + bookPrice: cleanPrice, + shippingFee: shippingFee, + condition: item.qualityText || '', + shopName: item.shopName || '', + bookName: item.title || '', + author: item.author || '', + pubDate: item.pubDateText || '', + bookId: item.id || '' + } + }) + // 自动计算并填入售价 + this.$nextTick(() => { + if (this.calculatedNoIsbnPrice > 0) { + this.noIsbnPrice = String(this.calculatedNoIsbnPrice) + } + }) } + }).catch(err => { + console.error('版权比价失败:', err) + this.noIsbnLoading = false + uni.showToast({ title: '比价失败', icon: 'none' }) }) }, @@ -1883,23 +1908,17 @@ export default { this.noIsbnFormat = this.noIsbnFormatOptions.includes(fmt) ? fmt : fmt + '开' } if (texts.ISBN && /^\d/.test(texts.ISBN)) { - // ISBN有值则直接填入 this.noIsbnIsbn = texts.ISBN this.noIsbnUnifyIsbn = '' } if (texts.书号) { const bookCode = texts.书号.replace(/\D/g, '') if (bookCode.length === 13 && bookCode.startsWith('978')) { - // 978开头的13位数字 → 填入ISBN this.noIsbnIsbn = bookCode this.noIsbnUnifyIsbn = '' - } else if (bookCode.length === 13) { - // 非978的13位数字 → 填入书号,ISBN随机生成678开头 - this.noIsbnUnifyIsbn = bookCode - this.noIsbnIsbn = '678' + String(Date.now()).slice(-10) } else { - // 其他情况 → 直接填入书号 this.noIsbnUnifyIsbn = texts.书号 + this.noIsbnIsbn = '678' + String(Date.now()).slice(-10) } } if (texts.字数) this.noIsbnWordCount = this.processNoIsbnWordage(texts.字数) @@ -2329,23 +2348,20 @@ export default { background: transparent; } -/* ========== 价格建议提示 ========== */ -.price-suggest-hint { - margin-top: 10rpx; - padding: 12rpx 16rpx; - background-color: #f0f9eb; - border-radius: 8rpx; - border: 2rpx solid #e1f3d8; +/* ========== 版权页比价按钮 ========== */ +.copyright-btn { + padding: 8rpx 16rpx; + background-color: #409eff; + border-radius: 6rpx; + display: flex; + align-items: center; + justify-content: center; } -.price-suggest-hint .hint-text { - font-size: 26rpx; - color: #67c23a; -} - -.price-suggest-hint .hint-value { - font-weight: bold; - font-size: 28rpx; +.copyright-btn-text { + font-size: 24rpx; + color: #ffffff; + font-weight: 500; } /* ========== 扫描/搜索按钮 ========== */ @@ -2768,15 +2784,6 @@ export default { justify-content: center; } -.submit-area { - margin-top: 30rpx; - padding: 0 20rpx; -} - -.submit-btn.disabled { - opacity: 0.6; -} - /* ========== 折叠详情 ========== */ .detail-section-header { display: flex; @@ -2858,10 +2865,8 @@ export default { font-weight: 600; } -.submit-btn-text { - color: #ffffff; - font-size: 32rpx; - font-weight: 600; +.submit-btn.disabled { + opacity: 0.6; } /* ========== 筛选弹窗 ========== */ diff --git a/utils/kongfz.js b/utils/kongfz.js index 4d75f2b..679879d 100644 --- a/utils/kongfz.js +++ b/utils/kongfz.js @@ -190,7 +190,7 @@ export function fetchItems(token, params = {}, onProgress) { * list中每项: {id, title, author, press, priceText, imgBigUrl, shopName, qualityText, pubDateText, postage} */ export function searchProducts(keyword, options = {}) { - const { phpsessid = '', page = 1, sortType = '', quality = '' } = options + const { phpsessid = '', page = 1, sortType = '', quality = '', publisher = '', author = '' } = options return new Promise((resolve, reject) => { const reqData = { dataType: 0, @@ -208,6 +208,12 @@ export function searchProducts(keyword, options = {}) { reqData.quaSelect = '2' actionPaths.push('quality') } + if (publisher) { + reqData.press = publisher + } + if (author) { + reqData.author = author + } if (actionPaths.length > 0) { reqData.actionPath = actionPaths.join(',') }