From 78d1aaca90fae0681c17b692dda9ce63118b6ec2 Mon Sep 17 00:00:00 2001 From: ShenQiLun <97694732@qq.com> Date: Wed, 1 Jul 2026 16:07:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=80=89=E6=8B=A9=E5=87=BA=E7=89=88?= =?UTF-8?q?=E7=A4=BE=E6=97=B6=E6=8C=89=E5=87=BA=E7=89=88=E7=A4=BE=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E6=9B=B4=E6=96=B0=E4=BD=9C=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 27 +++++++++++++++++++---- utils/kongfz.js | 49 +++++++++++++++++++++++------------------ 2 files changed, 51 insertions(+), 25 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index c0589c5..5e34081 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -1904,16 +1904,17 @@ export default { try { // 并行获取分类、出版社、作者 var pressOpts = { phpsessid: this.kongfzToken || '' } + var authorOpts = { phpsessid: this.kongfzToken || '' } // 如果当前已填了作者,查询出版社时带上作者过滤 if (this.noIsbnAuthor) pressOpts.author = this.noIsbnAuthor + // 如果当前已填了出版社,查询作者时带上市出版社过滤 + if (this.noIsbnPublisher) authorOpts.publisher = this.noIsbnPublisher var results = await Promise.all([ searchCategories(bookName, { phpsessid: this.kongfzToken || '' }), searchPresses(bookName, pressOpts), - searchAuthors(bookName, { - phpsessid: this.kongfzToken || '' - }) + searchAuthors(bookName, authorOpts) ]) var catList = results[0] var pressList = results[1] @@ -3499,10 +3500,28 @@ export default { selectNoIsbnPublisher(item) { this.noIsbnPublisher = typeof item === 'string' ? item : (item.showName || '') this.noIsbnPublisherDropdownVisible = false - // 选择出版社后:重新搜索在售商品 + // 选择出版社后:重新获取作者(按出版社过滤)+ 重新搜索在售商品 + this.fetchNoIsbnAuthorsByPublisher(this.noIsbnPublisher) this.debouncedReSearch() }, + // 选择出版社后重新获取作者(按出版社过滤) + async fetchNoIsbnAuthorsByPublisher(publisher) { + var bookName = (this.noIsbnBookName || '').trim() + if (!bookName || !publisher) return + try { + var authorList = await searchAuthors(bookName, { + phpsessid: this.kongfzToken || '', + publisher: publisher + }) + if (authorList.length > 0) { + this.noIsbnAuthorOptions = authorList.map(function(item) { return item.showName }).slice(0, 20) + } + } catch (e) { + console.error('按出版社获取作者失败:', e) + } + }, + // 无ISBN - 选择开本 selectNoIsbnFormat(item) { this.noIsbnFormat = item diff --git a/utils/kongfz.js b/utils/kongfz.js index 420afc0..2f53104 100644 --- a/utils/kongfz.js +++ b/utils/kongfz.js @@ -372,39 +372,46 @@ export function searchPresses(keyword, options = {}) { } /** - * 获取孔网作者列表(根据书名) + * 获取孔网作者列表(根据书名,可选按出版社过滤) * @param {string} keyword 书名 - * @param {object} options { phpsessid, userArea } + * @param {object} options { phpsessid, userArea, publisher } * @returns {Promise>} 作者列表 */ export function searchAuthors(keyword, options = {}) { - const { phpsessid = '', userArea = '1006000000' } = options + const { phpsessid = '', userArea = '1006000000', publisher = '' } = options return new Promise((resolve) => { if (!keyword || !keyword.trim()) { resolve([]) return } + var reqData = { + requestId: Math.random().toString(36).substring(2, 10), + platform: 'web', + searchType: 'keyword', + dataType: 0, + keyword: keyword.trim(), + hasStock: 'true', + isNewBook: 'false', + searchMode: 0, + userArea: userArea, + page: 1, + size: 50, + tplParams: '{}', + sortType: 0, + abGroup: 'B', + filterType: 'author' + } + if (publisher) { + reqData.press = publisher + reqData.actionPath = 'press' + reqData.notSelectSearchMode = 'false' + } else { + reqData.notSelectSearchMode = 'true' + } uni.request({ url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/more/author/facet', method: 'GET', - data: { - requestId: Math.random().toString(36).substring(2, 10), - platform: 'web', - searchType: 'keyword', - dataType: 0, - keyword: keyword.trim(), - hasStock: 'true', - isNewBook: 'false', - searchMode: 0, - userArea: userArea, - page: 1, - size: 50, - tplParams: '{}', - sortType: 0, - abGroup: 'B', - notSelectSearchMode: 'true', - filterType: 'author' - }, + data: reqData, header: { 'Cookie': phpsessid ? `PHPSESSID=${phpsessid}` : '' },