点击总价/书价切换时重新请求孔夫子接口(带sortType=5排序参数)
This commit is contained in:
parent
d3d9b80789
commit
0fd8db2523
@ -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()
|
||||
},
|
||||
|
||||
// 筛选
|
||||
|
||||
@ -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}` : ''
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user