feat:出版社改为根据书名从孔网press/facet接口自动获取

This commit is contained in:
ShenQiLun 2026-07-01 14:05:49 +08:00
parent e68122a587
commit 5067a283a6
2 changed files with 84 additions and 11 deletions

View File

@ -891,7 +891,7 @@
<script>
import { getWarehouseList, getLocationList, searchBookByIsbn, calculateSign, buildFormBodyWithImages } from '@/utils/api.js'
import { login as kongfzLogin, searchProducts, searchFacet, searchCategories } from '@/utils/kongfz.js'
import { login as kongfzLogin, searchProducts, searchFacet, searchCategories, searchPresses } from '@/utils/kongfz.js'
import { uploadImages } from '@/utils/minio.js'
export default {
@ -1891,22 +1891,31 @@ export default {
onNoIsbnBookNameInput() {
if (this._noIsbnCategoryTimer) clearTimeout(this._noIsbnCategoryTimer)
this._noIsbnCategoryTimer = setTimeout(() => {
this.fetchNoIsbnCategories()
this.fetchNoIsbnBookData()
}, 600)
},
//
async fetchNoIsbnCategories() {
//
async fetchNoIsbnBookData() {
var bookName = (this.noIsbnBookName || '').trim()
if (!bookName) return
this.noIsbnCategoryLoading = true
try {
var list = await searchCategories(bookName, {
phpsessid: this.kongfzToken || ''
})
this.noIsbnCategoryList = list
if (list.length > 0) {
this.noIsbnCategoryNames = list.map(function(item) { return item.showName + '' + item.showValue + '' })
//
var results = await Promise.all([
searchCategories(bookName, {
phpsessid: this.kongfzToken || ''
}),
searchPresses(bookName, {
phpsessid: this.kongfzToken || ''
})
])
var catList = results[0]
var pressList = results[1]
//
this.noIsbnCategoryList = catList
if (catList.length > 0) {
this.noIsbnCategoryNames = catList.map(function(item) { return item.showName + '' + item.showValue + '' })
this.noIsbnCategoryIndex = 0
this.onNoIsbnCategorySelect(0)
} else {
@ -1914,6 +1923,15 @@ export default {
this.noIsbnCategoryIndex = 0
this.noIsbnSelectedCategoryValue = ''
}
//
if (pressList.length > 0) {
this.noIsbnPublisherOptions = pressList.map(function(item) { return item.showName })
//
this.noIsbnPublisherDropdownVisible = true
} else {
// API退
this.noIsbnPublisherOptions = []
}
} catch (e) {
console.error('获取孔网分类失败:', e)
this.noIsbnCategoryNames = ['获取分类失败']

View File

@ -308,10 +308,65 @@ export function searchCategories(keyword, options = {}) {
})
}
/**
* 获取孔网出版社列表根据书名
* @param {string} keyword 书名
* @param {object} options { phpsessid, userArea }
* @returns {Promise<Array<{showName:string}>>} 出版社列表
*/
export function searchPresses(keyword, options = {}) {
const { phpsessid = '', userArea = '1006000000' } = 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/press/facet',
method: 'GET',
data: {
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: 'press'
},
header: {
'Cookie': phpsessid ? `PHPSESSID=${phpsessid}` : ''
},
success: (res) => {
if (res.statusCode === 200 && res.data && res.data.status === 1 && res.data.data) {
var labels = res.data.data.labels || []
resolve(labels.map(function(item) {
return { showName: item.showName }
}))
} else {
resolve([])
}
},
fail: () => {
resolve([])
}
})
})
}
export default {
login,
searchFacet,
fetchItems,
searchProducts,
searchCategories
searchCategories,
searchPresses
}