diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index ed0cc41..e7a63de 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -3445,6 +3445,26 @@ export default { selectNoIsbnAuthor(item) { this.noIsbnAuthor = item this.noIsbnAuthorDropdownVisible = false + // 选择作者后重新获取出版社(按作者过滤) + this.fetchNoIsbnPressesByAuthor(item) + }, + + // 选择作者后按作者过滤重新获取出版社 + 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.map(function(item) { return item.showName }) + this.noIsbnPublisherDropdownVisible = true + } + } catch (e) { + console.error('按作者获取出版社失败:', e) + } }, // 无ISBN - 选择出版社 diff --git a/utils/kongfz.js b/utils/kongfz.js index 9ea9e93..1c7bf76 100644 --- a/utils/kongfz.js +++ b/utils/kongfz.js @@ -309,39 +309,46 @@ 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([]) 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: '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', 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: 'press' - }, + data: reqData, header: { 'Cookie': phpsessid ? `PHPSESSID=${phpsessid}` : '' },