feat:选择作者/出版社/分类时联动刷新并重搜在售商品
This commit is contained in:
parent
bb7f104231
commit
88af858483
@ -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 - 选择开本
|
||||
|
||||
@ -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',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user