...
|
...
|
@@ -16,6 +16,7 @@ const serviceAPI = global.yoho.ServiceAPI; |
|
|
const api = global.yoho.API;
|
|
|
|
|
|
/**
|
|
|
* TODO: remove
|
|
|
* 商品搜索接口请求
|
|
|
* @param {[object]} params
|
|
|
* @return {[array]}
|
...
|
...
|
@@ -66,6 +67,7 @@ const getNewFocus = (channel) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* TODO remove
|
|
|
* 获取商品数据
|
|
|
*/
|
|
|
const getSearchData = (params) => {
|
...
|
...
|
@@ -88,6 +90,7 @@ const getSearchData = (params) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* TODO remove
|
|
|
* 获取筛选数据
|
|
|
* @param {[object]} params
|
|
|
* @return {[array]}
|
...
|
...
|
@@ -103,8 +106,129 @@ const getFilterData = (params) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* method=app.newproduct.recshop 推荐店铺
|
|
|
* http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/BigData/新品到着.md
|
|
|
*/
|
|
|
const recommendShops = (uid, channel, limit, page) => {
|
|
|
limit = limit || 20;
|
|
|
page = page || 1;
|
|
|
|
|
|
let params = {
|
|
|
method: 'app.newproduct.recshop',
|
|
|
channel,
|
|
|
limit,
|
|
|
page,
|
|
|
uid
|
|
|
};
|
|
|
|
|
|
return api.get('', params, {cache: true})
|
|
|
.then(result=> {
|
|
|
let shopData = _.get(result, 'data', {});
|
|
|
|
|
|
return shopData;
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* method=app.newproduct.recbrand 推荐品牌
|
|
|
* http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/BigData/新品到着.md
|
|
|
*/
|
|
|
const recbrand = (uid, channel, limit, page) => {
|
|
|
limit = limit || 20;
|
|
|
page = page || 1;
|
|
|
|
|
|
let params = {
|
|
|
method: 'app.newproduct.recbrand',
|
|
|
channel,
|
|
|
limit,
|
|
|
page,
|
|
|
uid
|
|
|
};
|
|
|
|
|
|
return api.get('', params, {cache: true})
|
|
|
.then(result => {
|
|
|
let data = _.get(result, 'data', {});
|
|
|
|
|
|
return data;
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
};
|
|
|
|
|
|
const newGoodsAPI = (params) => {
|
|
|
let method = 'app.newproduct.reclist';
|
|
|
|
|
|
// 排除基本筛选项默认值为0的对象
|
|
|
for (let str in params) {
|
|
|
if ((str !== 'order' && params[str] === '0') || params[str] === null) {
|
|
|
delete params[str];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
params.yh_channel = searchProcess.getChannelType(params.channel);
|
|
|
|
|
|
delete params.channel;
|
|
|
|
|
|
params = _.assign({
|
|
|
limit: '60'
|
|
|
}, params);
|
|
|
|
|
|
params.order = params.order === '0' ? 's_t_desc' : 's_t_asc';
|
|
|
|
|
|
return api.get('', _.assign({
|
|
|
method: method
|
|
|
}, params), {
|
|
|
cache: true
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* method:app.newproduct.reclist 新品上架
|
|
|
* http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/BigData/新品到着.md
|
|
|
*/
|
|
|
const reclist = (uid, channel, searchOptions) => {
|
|
|
let params = Object.assign({}, {uid, channel}, searchOptions);
|
|
|
|
|
|
return newGoodsAPI(params).then(result => {
|
|
|
if (result && result.code === 200) {
|
|
|
let newList = {};
|
|
|
|
|
|
newList.list = productProcess.processProductList(result.data.product_list || [], {showTags: true});
|
|
|
|
|
|
if (parseInt(params.page, 10) === 1) {
|
|
|
newList.total = result.data.total;
|
|
|
}
|
|
|
|
|
|
return newList;
|
|
|
} else {
|
|
|
logger.error('get product search api return code is not 200');
|
|
|
return [];
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const reclistFilter = (uid, channel) => {
|
|
|
let params = Object.assign({}, {uid, channel});
|
|
|
|
|
|
return newGoodsAPI(params).then(result => {
|
|
|
if (result && result.code === 200) {
|
|
|
return productProcess.processFilter(result.data.filter || []);
|
|
|
} else {
|
|
|
logger.error('get filter data api return code is not 200');
|
|
|
return [];
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getNewFocus,
|
|
|
getSearchData,
|
|
|
getFilterData
|
|
|
getSearchData, // TODO remove
|
|
|
getFilterData, // TODO remove
|
|
|
|
|
|
recommendShops,
|
|
|
recbrand,
|
|
|
reclist,
|
|
|
reclistFilter
|
|
|
}; |
...
|
...
|
|