feat:作者改为根据书名从孔网author/facet接口自动获取

This commit is contained in:
ShenQiLun 2026-07-01 14:07:39 +08:00
parent 5067a283a6
commit bbad484273
2 changed files with 69 additions and 5 deletions

View File

@ -891,7 +891,7 @@
<script> <script>
import { getWarehouseList, getLocationList, searchBookByIsbn, calculateSign, buildFormBodyWithImages } from '@/utils/api.js' import { getWarehouseList, getLocationList, searchBookByIsbn, calculateSign, buildFormBodyWithImages } from '@/utils/api.js'
import { login as kongfzLogin, searchProducts, searchFacet, searchCategories, searchPresses } from '@/utils/kongfz.js' import { login as kongfzLogin, searchProducts, searchFacet, searchCategories, searchPresses, searchAuthors } from '@/utils/kongfz.js'
import { uploadImages } from '@/utils/minio.js' import { uploadImages } from '@/utils/minio.js'
export default { export default {
@ -1901,17 +1901,21 @@ export default {
if (!bookName) return if (!bookName) return
this.noIsbnCategoryLoading = true this.noIsbnCategoryLoading = true
try { try {
// //
var results = await Promise.all([ var results = await Promise.all([
searchCategories(bookName, { searchCategories(bookName, {
phpsessid: this.kongfzToken || '' phpsessid: this.kongfzToken || ''
}), }),
searchPresses(bookName, { searchPresses(bookName, {
phpsessid: this.kongfzToken || '' phpsessid: this.kongfzToken || ''
}),
searchAuthors(bookName, {
phpsessid: this.kongfzToken || ''
}) })
]) ])
var catList = results[0] var catList = results[0]
var pressList = results[1] var pressList = results[1]
var authorList = results[2]
// //
this.noIsbnCategoryList = catList this.noIsbnCategoryList = catList
if (catList.length > 0) { if (catList.length > 0) {
@ -1926,12 +1930,17 @@ export default {
// //
if (pressList.length > 0) { if (pressList.length > 0) {
this.noIsbnPublisherOptions = pressList.map(function(item) { return item.showName }) this.noIsbnPublisherOptions = pressList.map(function(item) { return item.showName })
//
this.noIsbnPublisherDropdownVisible = true this.noIsbnPublisherDropdownVisible = true
} else { } else {
// API退
this.noIsbnPublisherOptions = [] this.noIsbnPublisherOptions = []
} }
//
if (authorList.length > 0) {
this.noIsbnAuthorOptions = authorList.map(function(item) { return item.showName })
this.noIsbnAuthorDropdownVisible = true
} else {
this.noIsbnAuthorOptions = []
}
} catch (e) { } catch (e) {
console.error('获取孔网分类失败:', e) console.error('获取孔网分类失败:', e)
this.noIsbnCategoryNames = ['获取分类失败'] this.noIsbnCategoryNames = ['获取分类失败']

View File

@ -362,11 +362,66 @@ export function searchPresses(keyword, options = {}) {
}) })
} }
/**
* 获取孔网作者列表根据书名
* @param {string} keyword 书名
* @param {object} options { phpsessid, userArea }
* @returns {Promise<Array<{showName:string}>>} 作者列表
*/
export function searchAuthors(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/author/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: 'author'
},
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 { export default {
login, login,
searchFacet, searchFacet,
fetchItems, fetchItems,
searchProducts, searchProducts,
searchCategories, searchCategories,
searchPresses searchPresses,
searchAuthors
} }