From 88af8584837a9d9c099246e3123b931274a85d41 Mon Sep 17 00:00:00 2001 From: ShenQiLun <97694732@qq.com> Date: Wed, 1 Jul 2026 15:08:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=80=89=E6=8B=A9=E4=BD=9C=E8=80=85/?= =?UTF-8?q?=E5=87=BA=E7=89=88=E7=A4=BE/=E5=88=86=E7=B1=BB=E6=97=B6?= =?UTF-8?q?=E8=81=94=E5=8A=A8=E5=88=B7=E6=96=B0=E5=B9=B6=E9=87=8D=E6=90=9C?= =?UTF-8?q?=E5=9C=A8=E5=94=AE=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 40 ++++++++++++++++++++++++++++++++++++++-- utils/kongfz.js | 16 +++++++++++----- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 04600c4..731525e 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -969,6 +969,7 @@ export default { noIsbnCategoryLoading: false, noIsbnSelectedCategoryValue: '', _noIsbnCategoryTimer: null, + _reSearchTimer: null, // 无ISBN - 市场竞争/在售 noIsbnProductList: [], @@ -1960,6 +1961,16 @@ export default { this.noIsbnCategoryIndex = index var item = this.noIsbnCategoryList[index] this.noIsbnSelectedCategoryValue = item ? item.value : '' + // 选择分类后:重新搜索在售商品 + this.debouncedReSearch() + }, + + // 防抖重新搜索在售商品(300ms) + debouncedReSearch() { + if (this._reSearchTimer) clearTimeout(this._reSearchTimer) + this._reSearchTimer = setTimeout(() => { + this.searchNoIsbnKongfz() + }, 300) }, // 印刷时间 - 列变化 @@ -3181,7 +3192,10 @@ export default { this.noIsbnLoading = true this.noIsbnProductList = [] const keyword = this.noIsbnBookName - this.kongfzSearchWithRetry(keyword, { sortType: '7', quality: this.noIsbnConditionValue }).then(function(result) { + var searchOpts = { sortType: '7', quality: this.noIsbnConditionValue } + if (this.noIsbnAuthor) searchOpts.author = this.noIsbnAuthor + if (this.noIsbnPublisher) searchOpts.publisher = this.noIsbnPublisher + this.kongfzSearchWithRetry(keyword, searchOpts).then(function(result) { var productsData = result[0] var onSaleFacet = result[1] var soldFacet = result[2] @@ -3449,14 +3463,36 @@ export default { // 无ISBN - 选择作者 selectNoIsbnAuthor(item) { - this.noIsbnAuthor = item + this.noIsbnAuthor = typeof item === 'string' ? item : (item.showName || '') this.noIsbnAuthorDropdownVisible = false + // 选择作者后:重新获取出版社(带作者过滤)+ 重新搜索在售商品 + this.fetchNoIsbnPressesByAuthor(this.noIsbnAuthor) + this.debouncedReSearch() + }, + + // 选择作者后重新获取出版社(按作者过滤) + async fetchNoIsbnPressesByAuthor(author) { + var bookName = (this.noIsbnBookName || '').trim() + if (!bookName || !author) return + try { + var pressList = await searchPresses(bookName, { + phpsessid: this.kongfzToken || '', + author: author + }) + if (pressList.length > 0) { + this.noIsbnPublisherOptions = pressList.slice(0, 20) + } + } catch (e) { + console.error('按作者获取出版社失败:', e) + } }, // 无ISBN - 选择出版社 selectNoIsbnPublisher(item) { this.noIsbnPublisher = typeof item === 'string' ? item : (item.showName || '') this.noIsbnPublisherDropdownVisible = false + // 选择出版社后:重新搜索在售商品 + this.debouncedReSearch() }, // 无ISBN - 选择开本 diff --git a/utils/kongfz.js b/utils/kongfz.js index 6198ead..420afc0 100644 --- a/utils/kongfz.js +++ b/utils/kongfz.js @@ -310,13 +310,13 @@ export function searchCategories(keyword, options = {}) { } /** - * 获取孔网出版社列表(根据书名) + * 获取孔网出版社列表(根据书名,可选按作者过滤) * @param {string} keyword 书名 - * @param {object} options { phpsessid, userArea } + * @param {object} options { phpsessid, userArea, author } * @returns {Promise>} 出版社列表 */ export function searchPresses(keyword, options = {}) { - const { phpsessid = '', userArea = '1006000000' } = options + const { phpsessid = '', userArea = '1006000000', author = '' } = options return new Promise((resolve) => { if (!keyword || !keyword.trim()) { resolve([]) @@ -337,8 +337,14 @@ export function searchPresses(keyword, options = {}) { tplParams: '{}', sortType: 0, abGroup: 'B', - filterType: 'press', - notSelectSearchMode: 'true' + filterType: 'press' + } + if (author) { + reqData.author = author + reqData.actionPath = 'author' + reqData.notSelectSearchMode = 'false' + } else { + reqData.notSelectSearchMode = 'true' } uni.request({ url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/more/press/facet',