feat:选择作者/出版社/分类时联动刷新并重搜在售商品

This commit is contained in:
ShenQiLun 2026-07-01 15:08:45 +08:00
parent bb7f104231
commit 88af858483
2 changed files with 49 additions and 7 deletions

View File

@ -969,6 +969,7 @@ export default {
noIsbnCategoryLoading: false, noIsbnCategoryLoading: false,
noIsbnSelectedCategoryValue: '', noIsbnSelectedCategoryValue: '',
_noIsbnCategoryTimer: null, _noIsbnCategoryTimer: null,
_reSearchTimer: null,
// ISBN - / // ISBN - /
noIsbnProductList: [], noIsbnProductList: [],
@ -1960,6 +1961,16 @@ export default {
this.noIsbnCategoryIndex = index this.noIsbnCategoryIndex = index
var item = this.noIsbnCategoryList[index] var item = this.noIsbnCategoryList[index]
this.noIsbnSelectedCategoryValue = item ? item.value : '' 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.noIsbnLoading = true
this.noIsbnProductList = [] this.noIsbnProductList = []
const keyword = this.noIsbnBookName 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 productsData = result[0]
var onSaleFacet = result[1] var onSaleFacet = result[1]
var soldFacet = result[2] var soldFacet = result[2]
@ -3449,14 +3463,36 @@ export default {
// ISBN - // ISBN -
selectNoIsbnAuthor(item) { selectNoIsbnAuthor(item) {
this.noIsbnAuthor = item this.noIsbnAuthor = typeof item === 'string' ? item : (item.showName || '')
this.noIsbnAuthorDropdownVisible = false 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 - // ISBN -
selectNoIsbnPublisher(item) { selectNoIsbnPublisher(item) {
this.noIsbnPublisher = typeof item === 'string' ? item : (item.showName || '') this.noIsbnPublisher = typeof item === 'string' ? item : (item.showName || '')
this.noIsbnPublisherDropdownVisible = false this.noIsbnPublisherDropdownVisible = false
//
this.debouncedReSearch()
}, },
// ISBN - // ISBN -

View File

@ -310,13 +310,13 @@ export function searchCategories(keyword, options = {}) {
} }
/** /**
* 获取孔网出版社列表根据书名 * 获取孔网出版社列表根据书名可选按作者过滤
* @param {string} keyword 书名 * @param {string} keyword 书名
* @param {object} options { phpsessid, userArea } * @param {object} options { phpsessid, userArea, author }
* @returns {Promise<Array<{showName:string, showValue:string}>>} 出版社列表 * @returns {Promise<Array<{showName:string, showValue:string}>>} 出版社列表
*/ */
export function searchPresses(keyword, options = {}) { export function searchPresses(keyword, options = {}) {
const { phpsessid = '', userArea = '1006000000' } = options const { phpsessid = '', userArea = '1006000000', author = '' } = options
return new Promise((resolve) => { return new Promise((resolve) => {
if (!keyword || !keyword.trim()) { if (!keyword || !keyword.trim()) {
resolve([]) resolve([])
@ -337,8 +337,14 @@ export function searchPresses(keyword, options = {}) {
tplParams: '{}', tplParams: '{}',
sortType: 0, sortType: 0,
abGroup: 'B', abGroup: 'B',
filterType: 'press', filterType: 'press'
notSelectSearchMode: 'true' }
if (author) {
reqData.author = author
reqData.actionPath = 'author'
reqData.notSelectSearchMode = 'false'
} else {
reqData.notSelectSearchMode = 'true'
} }
uni.request({ uni.request({
url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/more/press/facet', url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/more/press/facet',