已售统计接入dataType=1的facet接口
This commit is contained in:
parent
e062725f2d
commit
767c0c3704
@ -993,11 +993,12 @@ export default {
|
|||||||
|
|
||||||
// 2. 搜索孔夫子 - 获取在售商品信息
|
// 2. 搜索孔夫子 - 获取在售商品信息
|
||||||
const phpsessid = this.kongfzToken || uni.getStorageSync('kongfz_phpsessid') || ''
|
const phpsessid = this.kongfzToken || uni.getStorageSync('kongfz_phpsessid') || ''
|
||||||
// 并行请求:商品列表 + 品相统计
|
// 并行请求:商品列表 + 品相统计(在售)+ 品相统计(已售)
|
||||||
Promise.all([
|
Promise.all([
|
||||||
searchProducts(this.isbn, { phpsessid }),
|
searchProducts(this.isbn, { phpsessid }),
|
||||||
searchFacet(this.isbn, { phpsessid })
|
searchFacet(this.isbn, { phpsessid, dataType: 0 }),
|
||||||
]).then(([productsData, facetData]) => {
|
searchFacet(this.isbn, { phpsessid, dataType: 1 })
|
||||||
|
]).then(([productsData, onSaleFacet, soldFacet]) => {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
if (productsData && productsData.total > 0) {
|
if (productsData && productsData.total > 0) {
|
||||||
// 在售商品列表(最多12条)
|
// 在售商品列表(最多12条)
|
||||||
@ -1018,9 +1019,9 @@ export default {
|
|||||||
// 市场统计:使用facet接口的真实数据
|
// 市场统计:使用facet接口的真实数据
|
||||||
this.marketData = {
|
this.marketData = {
|
||||||
onSale: productsData ? productsData.total : 0,
|
onSale: productsData ? productsData.total : 0,
|
||||||
old: facetData ? facetData.oldCount : 0,
|
old: onSaleFacet ? onSaleFacet.oldCount : 0,
|
||||||
new: facetData ? facetData.newCount : 0,
|
new: onSaleFacet ? onSaleFacet.newCount : 0,
|
||||||
sold: 0
|
sold: soldFacet ? (soldFacet.oldCount + soldFacet.newCount) : 0
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
|
|||||||
@ -80,17 +80,17 @@ export function login(username, password) {
|
|||||||
/**
|
/**
|
||||||
* 搜索孔夫子商品品相统计(全新/古旧等)
|
* 搜索孔夫子商品品相统计(全新/古旧等)
|
||||||
* @param {string} keyword ISBN或书名
|
* @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}>}
|
* @returns {Promise<{newCount: number, oldCount: number, totalFound: number}>}
|
||||||
*/
|
*/
|
||||||
export function searchFacet(keyword, options = {}) {
|
export function searchFacet(keyword, options = {}) {
|
||||||
const { phpsessid = '', userArea = '1006000000' } = options
|
const { phpsessid = '', userArea = '1006000000', dataType = 0 } = options
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.request({
|
uni.request({
|
||||||
url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/normal/facet',
|
url: 'https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/normal/facet',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
data: {
|
data: {
|
||||||
dataType: 0,
|
dataType: dataType,
|
||||||
keyword: keyword,
|
keyword: keyword,
|
||||||
page: 1,
|
page: 1,
|
||||||
userArea: userArea
|
userArea: userArea
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user