From 767c0c37041190366ba52e9b74c9fb372db209e0 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Wed, 3 Jun 2026 16:27:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E5=94=AE=E7=BB=9F=E8=AE=A1=E6=8E=A5?= =?UTF-8?q?=E5=85=A5dataType=3D1=E7=9A=84facet=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 13 +++++++------ utils/kongfz.js | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 2a0069a..f02f103 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -993,11 +993,12 @@ export default { // 2. 搜索孔夫子 - 获取在售商品信息 const phpsessid = this.kongfzToken || uni.getStorageSync('kongfz_phpsessid') || '' - // 并行请求:商品列表 + 品相统计 + // 并行请求:商品列表 + 品相统计(在售)+ 品相统计(已售) Promise.all([ searchProducts(this.isbn, { phpsessid }), - searchFacet(this.isbn, { phpsessid }) - ]).then(([productsData, facetData]) => { + searchFacet(this.isbn, { phpsessid, dataType: 0 }), + searchFacet(this.isbn, { phpsessid, dataType: 1 }) + ]).then(([productsData, onSaleFacet, soldFacet]) => { this.isLoading = false if (productsData && productsData.total > 0) { // 在售商品列表(最多12条) @@ -1018,9 +1019,9 @@ export default { // 市场统计:使用facet接口的真实数据 this.marketData = { onSale: productsData ? productsData.total : 0, - old: facetData ? facetData.oldCount : 0, - new: facetData ? facetData.newCount : 0, - sold: 0 + old: onSaleFacet ? onSaleFacet.oldCount : 0, + new: onSaleFacet ? onSaleFacet.newCount : 0, + sold: soldFacet ? (soldFacet.oldCount + soldFacet.newCount) : 0 } }).catch(() => { this.isLoading = false diff --git a/utils/kongfz.js b/utils/kongfz.js index ab4375b..02fa92d 100644 --- a/utils/kongfz.js +++ b/utils/kongfz.js @@ -80,17 +80,17 @@ export function login(username, password) { /** * 搜索孔夫子商品品相统计(全新/古旧等) * @param {string} keyword ISBN或书名 - * @param {object} options {phpsessid, userArea} + * @param {object} options {phpsessid, userArea, dataType} dataType=0在售 / 1已售 * @returns {Promise<{newCount: number, oldCount: number, totalFound: number}>} */ export function searchFacet(keyword, options = {}) { - const { phpsessid = '', userArea = '1006000000' } = options + const { phpsessid = '', userArea = '1006000000', dataType = 0 } = options return new Promise((resolve, reject) => { uni.request({ url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/normal/facet', method: 'GET', data: { - dataType: 0, + dataType: dataType, keyword: keyword, page: 1, userArea: userArea