feat:分类接口支持传author/press/pressNum过滤

This commit is contained in:
ShenQiLun 2026-07-02 16:00:23 +08:00
parent 36845e6657
commit b5d4a54340
2 changed files with 51 additions and 20 deletions

View File

@ -970,6 +970,7 @@ export default {
noIsbnCategoryIndex: 0, noIsbnCategoryIndex: 0,
noIsbnCategoryLoading: false, noIsbnCategoryLoading: false,
noIsbnSelectedCategoryValue: '', noIsbnSelectedCategoryValue: '',
noIsbnSelectedPublisherValue: '',
_noIsbnCategoryTimer: null, _noIsbnCategoryTimer: null,
_reSearchTimer: null, _reSearchTimer: null,
@ -1905,16 +1906,22 @@ export default {
this.noIsbnCategoryLoading = true this.noIsbnCategoryLoading = true
try { try {
// //
var catOpts = { phpsessid: this.kongfzToken || '' }
var pressOpts = { phpsessid: this.kongfzToken || '' } var pressOpts = { phpsessid: this.kongfzToken || '' }
var authorOpts = { phpsessid: this.kongfzToken || '' } var authorOpts = { phpsessid: this.kongfzToken || '' }
// //
if (this.noIsbnAuthor) pressOpts.author = this.noIsbnAuthor if (this.noIsbnAuthor) {
// catOpts.author = this.noIsbnAuthor
if (this.noIsbnPublisher) authorOpts.publisher = this.noIsbnPublisher pressOpts.author = this.noIsbnAuthor
}
//
if (this.noIsbnPublisher) {
catOpts.press = this.noIsbnPublisher
catOpts.pressNum = this.noIsbnSelectedPublisherValue
authorOpts.publisher = this.noIsbnPublisher
}
var results = await Promise.all([ var results = await Promise.all([
searchCategories(bookName, { searchCategories(bookName, catOpts),
phpsessid: this.kongfzToken || ''
}),
searchPresses(bookName, pressOpts), searchPresses(bookName, pressOpts),
searchAuthors(bookName, authorOpts) searchAuthors(bookName, authorOpts)
]) ])
@ -3499,6 +3506,7 @@ export default {
// ISBN - // ISBN -
selectNoIsbnPublisher(item) { selectNoIsbnPublisher(item) {
this.noIsbnPublisher = typeof item === 'string' ? item : (item.showName || '') this.noIsbnPublisher = typeof item === 'string' ? item : (item.showName || '')
this.noIsbnSelectedPublisherValue = typeof item === 'object' && item.value ? item.value : ''
this.noIsbnPublisherDropdownVisible = false this.noIsbnPublisherDropdownVisible = false
// //() + // //() +
this.fetchNoIsbnBookData() this.fetchNoIsbnBookData()

View File

@ -255,32 +255,55 @@ export function searchProducts(keyword, options = {}) {
} }
/** /**
* 获取孔网图书分类根据书名搜索孔网 facet 接口 * 获取孔网图书分类根据书名搜索孔网 facet 接口可选带作者/出版社过滤
* @param {string} keyword 书名 * @param {string} keyword 书名
* @param {object} options { phpsessid, userArea } * @param {object} options { phpsessid, userArea, author, press, pressNum }
* @returns {Promise<Array<{value:string, showName:string}>>} 图书分类列表normal组 * @returns {Promise<Array<{value:string, showName:string, showValue:string}>>} 图书分类列表normal组
*/ */
export function searchCategories(keyword, options = {}) { export function searchCategories(keyword, options = {}) {
const { phpsessid = '', userArea = '1006000000' } = options const { phpsessid = '', userArea = '1006000000', author = '', press = '', pressNum = '' } = 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',
userArea: userArea,
abGroup: 'B',
notSelectSearchMode: 'true',
page: 1
}
var actionPathParts = []
if (author) {
reqData.author = author
actionPathParts.push('author')
}
if (press) {
reqData.press = press
if (pressNum) {
reqData.tplParams = JSON.stringify({ pressNum: pressNum })
}
actionPathParts.push('press')
}
if (actionPathParts.length > 0) {
reqData.actionPath = actionPathParts.join(',')
}
uni.request({ uni.request({
url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/normal/facet', url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/normal/facet',
method: 'GET', method: 'GET',
data: { data: reqData,
dataType: 0,
keyword: keyword.trim(),
page: 1,
userArea: userArea
},
header: { header: {
'Cookie': phpsessid ? `PHPSESSID=${phpsessid}` : '' 'Cookie': phpsessid ? `PHPSESSID=${phpsessid}` : ''
}, },
success: (res) => { success: (res) => {
console.log('【孔网分类搜索】URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/normal/facet?dataType=0&keyword=' + encodeURIComponent(keyword) + '&page=1&userArea=' + userArea, '| 响应:', JSON.stringify(res.data)) console.log('【孔网分类搜索】keyword:', keyword, '| author:', author, '| press:', press, '| 响应:', JSON.stringify(res.data))
if (res.statusCode === 200 && res.data && res.data.status === 1 && res.data.data) { if (res.statusCode === 200 && res.data && res.data.status === 1 && res.data.data) {
var categories = res.data.data.categories || [] var categories = res.data.data.categories || []
// 找到 normal 组(图书分类) // 找到 normal 组(图书分类)
@ -313,7 +336,7 @@ export function searchCategories(keyword, options = {}) {
* 获取孔网出版社列表根据书名可选按作者过滤 * 获取孔网出版社列表根据书名可选按作者过滤
* @param {string} keyword 书名 * @param {string} keyword 书名
* @param {object} options { phpsessid, userArea, author } * @param {object} options { phpsessid, userArea, author }
* @returns {Promise<Array<{showName:string, showValue:string}>>} 出版社列表 * @returns {Promise<Array<{showName:string, showValue:string, value:string}>>} 出版社列表
*/ */
export function searchPresses(keyword, options = {}) { export function searchPresses(keyword, options = {}) {
const { phpsessid = '', userArea = '1006000000', author = '' } = options const { phpsessid = '', userArea = '1006000000', author = '' } = options
@ -358,7 +381,7 @@ export function searchPresses(keyword, options = {}) {
if (res.statusCode === 200 && res.data && res.data.status === 1 && res.data.data) { if (res.statusCode === 200 && res.data && res.data.status === 1 && res.data.data) {
var labels = res.data.data.labels || [] var labels = res.data.data.labels || []
resolve(labels.map(function(item) { resolve(labels.map(function(item) {
return { showName: item.showName, showValue: item.showValue } return { showName: item.showName, showValue: item.showValue, value: item.value }
})) }))
} else { } else {
resolve([]) resolve([])