feat:选择出版社时按出版社过滤更新作者
This commit is contained in:
parent
9e54df4fa2
commit
78d1aaca90
@ -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
|
||||
|
||||
@ -372,22 +372,19 @@ export function searchPresses(keyword, options = {}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取孔网作者列表(根据书名)
|
||||
* 获取孔网作者列表(根据书名,可选按出版社过滤)
|
||||
* @param {string} keyword 书名
|
||||
* @param {object} options { phpsessid, userArea }
|
||||
* @param {object} options { phpsessid, userArea, publisher }
|
||||
* @returns {Promise<Array<{showName:string}>>} 作者列表
|
||||
*/
|
||||
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
|
||||
}
|
||||
uni.request({
|
||||
url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/more/author/facet',
|
||||
method: 'GET',
|
||||
data: {
|
||||
var reqData = {
|
||||
requestId: Math.random().toString(36).substring(2, 10),
|
||||
platform: 'web',
|
||||
searchType: 'keyword',
|
||||
@ -402,9 +399,19 @@ export function searchAuthors(keyword, options = {}) {
|
||||
tplParams: '{}',
|
||||
sortType: 0,
|
||||
abGroup: 'B',
|
||||
notSelectSearchMode: 'true',
|
||||
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: reqData,
|
||||
header: {
|
||||
'Cookie': phpsessid ? `PHPSESSID=${phpsessid}` : ''
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user