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,
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 -

View File

@ -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<Array<{showName:string, showValue:string}>>} 出版社列表
*/
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',