feat:选择出版社时按出版社过滤更新作者
This commit is contained in:
parent
9e54df4fa2
commit
78d1aaca90
@ -1904,16 +1904,17 @@ export default {
|
|||||||
try {
|
try {
|
||||||
// 并行获取分类、出版社、作者
|
// 并行获取分类、出版社、作者
|
||||||
var pressOpts = { phpsessid: this.kongfzToken || '' }
|
var pressOpts = { phpsessid: this.kongfzToken || '' }
|
||||||
|
var authorOpts = { phpsessid: this.kongfzToken || '' }
|
||||||
// 如果当前已填了作者,查询出版社时带上作者过滤
|
// 如果当前已填了作者,查询出版社时带上作者过滤
|
||||||
if (this.noIsbnAuthor) pressOpts.author = this.noIsbnAuthor
|
if (this.noIsbnAuthor) pressOpts.author = this.noIsbnAuthor
|
||||||
|
// 如果当前已填了出版社,查询作者时带上市出版社过滤
|
||||||
|
if (this.noIsbnPublisher) authorOpts.publisher = this.noIsbnPublisher
|
||||||
var results = await Promise.all([
|
var results = await Promise.all([
|
||||||
searchCategories(bookName, {
|
searchCategories(bookName, {
|
||||||
phpsessid: this.kongfzToken || ''
|
phpsessid: this.kongfzToken || ''
|
||||||
}),
|
}),
|
||||||
searchPresses(bookName, pressOpts),
|
searchPresses(bookName, pressOpts),
|
||||||
searchAuthors(bookName, {
|
searchAuthors(bookName, authorOpts)
|
||||||
phpsessid: this.kongfzToken || ''
|
|
||||||
})
|
|
||||||
])
|
])
|
||||||
var catList = results[0]
|
var catList = results[0]
|
||||||
var pressList = results[1]
|
var pressList = results[1]
|
||||||
@ -3499,10 +3500,28 @@ export default {
|
|||||||
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.fetchNoIsbnAuthorsByPublisher(this.noIsbnPublisher)
|
||||||
this.debouncedReSearch()
|
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 - 选择开本
|
// 无ISBN - 选择开本
|
||||||
selectNoIsbnFormat(item) {
|
selectNoIsbnFormat(item) {
|
||||||
this.noIsbnFormat = item
|
this.noIsbnFormat = item
|
||||||
|
|||||||
@ -372,39 +372,46 @@ export function searchPresses(keyword, options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取孔网作者列表(根据书名)
|
* 获取孔网作者列表(根据书名,可选按出版社过滤)
|
||||||
* @param {string} keyword 书名
|
* @param {string} keyword 书名
|
||||||
* @param {object} options { phpsessid, userArea }
|
* @param {object} options { phpsessid, userArea, publisher }
|
||||||
* @returns {Promise<Array<{showName:string}>>} 作者列表
|
* @returns {Promise<Array<{showName:string}>>} 作者列表
|
||||||
*/
|
*/
|
||||||
export function searchAuthors(keyword, options = {}) {
|
export function searchAuthors(keyword, options = {}) {
|
||||||
const { phpsessid = '', userArea = '1006000000' } = options
|
const { phpsessid = '', userArea = '1006000000', publisher = '' } = options
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (!keyword || !keyword.trim()) {
|
if (!keyword || !keyword.trim()) {
|
||||||
resolve([])
|
resolve([])
|
||||||
return
|
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: 'author'
|
||||||
|
}
|
||||||
|
if (publisher) {
|
||||||
|
reqData.press = publisher
|
||||||
|
reqData.actionPath = 'press'
|
||||||
|
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/author/facet',
|
url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/more/author/facet',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
data: {
|
data: 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',
|
|
||||||
notSelectSearchMode: 'true',
|
|
||||||
filterType: 'author'
|
|
||||||
},
|
|
||||||
header: {
|
header: {
|
||||||
'Cookie': phpsessid ? `PHPSESSID=${phpsessid}` : ''
|
'Cookie': phpsessid ? `PHPSESSID=${phpsessid}` : ''
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user