From 0fd8db25232647ea69150dab84e162ea5c4a72f8 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Wed, 3 Jun 2026 16:41:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=80=BB=E4=BB=B7/=E4=B9=A6?= =?UTF-8?q?=E4=BB=B7=E5=88=87=E6=8D=A2=E6=97=B6=E9=87=8D=E6=96=B0=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=AD=94=E5=A4=AB=E5=AD=90=E6=8E=A5=E5=8F=A3(?= =?UTF-8?q?=E5=B8=A6sortType=3D5=E6=8E=92=E5=BA=8F=E5=8F=82=E6=95=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 7 +++++-- utils/kongfz.js | 18 +++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 65af109..7cd8ad5 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -979,9 +979,11 @@ export default { // 2. 搜索孔夫子 - 获取在售商品信息 const phpsessid = this.kongfzToken || uni.getStorageSync('kongfz_phpsessid') || '' + // 排序参数:5=价格低到高 7=综合 + const sortType = this.sortBy !== 'total' && this.sortBy !== 'book' ? '' : '5' // 并行请求:商品列表 + 品相统计(在售)+ 品相统计(已售) Promise.all([ - searchProducts(keyword, { phpsessid }), + searchProducts(keyword, { phpsessid, sortType }), searchFacet(keyword, { phpsessid, dataType: 0 }), searchFacet(keyword, { phpsessid, dataType: 1 }) ]).then(([productsData, onSaleFacet, soldFacet]) => { @@ -1212,9 +1214,10 @@ export default { this.searchISBN() }, - // 排序 + // 排序 - 切换后重新请求孔夫子接口 sortProducts(by) { this.sortBy = by + this.searchISBN() }, // 筛选 diff --git a/utils/kongfz.js b/utils/kongfz.js index 02fa92d..0138e21 100644 --- a/utils/kongfz.js +++ b/utils/kongfz.js @@ -190,17 +190,21 @@ export function fetchItems(token, params = {}, onProgress) { * list中每项: {id, title, author, press, priceText, imgBigUrl, shopName, qualityText, pubDateText, postage} */ export function searchProducts(keyword, options = {}) { - const { phpsessid = '', page = 1 } = options + const { phpsessid = '', page = 1, sortType = '' } = options return new Promise((resolve, reject) => { + const reqData = { + dataType: 0, + keyword: keyword, + page: page, + userArea: '13003000000' + } + if (sortType) { + reqData.sortType = sortType + } uni.request({ url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list', method: 'GET', - data: { - dataType: 0, - keyword: keyword, - page: page, - userArea: '13003000000' - }, + data: reqData, header: { 'Cookie': phpsessid ? `PHPSESSID=${phpsessid}` : '' },