...
|
...
|
@@ -8,7 +8,7 @@ const utils = '../../../utils'; |
|
|
const api = global.yoho.API;
|
|
|
const Promise = require('bluebird');
|
|
|
const co = Promise.coroutine;
|
|
|
const saleApi = require('./sale-api');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const searchApi = require('./search-api');
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
const productProcess = require(`${utils}/product-process`);
|
...
|
...
|
@@ -23,6 +23,16 @@ exports.getKeyActivity = (query) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 转换价格
|
|
|
*
|
|
|
* @param float|string $price 价格
|
|
|
* @return float|string 转换之后的价格
|
|
|
*/
|
|
|
const transPrice = (price) => {
|
|
|
return price ? (price * 1).toFixed(2) : '0.00';
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取搜索数据
|
|
|
* @param {[type]} origin [description]
|
|
|
* @return {[type]} [description]
|
...
|
...
|
@@ -98,27 +108,13 @@ exports.getSearchData = (params, channel) => { |
|
|
Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)),
|
|
|
latestWalk: 6,
|
|
|
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
|
|
|
shopEntry: result[3]
|
|
|
shopEntry: result[3],
|
|
|
name: params.query,
|
|
|
// suggest: result[2].data.suggestion.terms_suggestion,
|
|
|
suggest: (['vans,vans8,vans9,vans10,vans11'].join(",")).split(",").splice(0,3),
|
|
|
href:`${searchHandler.handleFilterUrl(params)}`
|
|
|
});
|
|
|
|
|
|
// if (params.page === 1 && (result[2].data.total <= 20 || params.needSuggestion === 'Y')) {
|
|
|
|
|
|
// finalResult.isNeedSuggestion = params.needSuggestion === 'Y'; // 是否是关键词搜索判断
|
|
|
|
|
|
// finalResult.termsSuggestion = productProcess.termsSuggestion(result[2].data.suggestion &&
|
|
|
|
|
|
// result[2].data.suggestion.terms_suggestion ||
|
|
|
|
|
|
// ['新款', '卫衣', 'vans', 'VANS 卫衣', '拼接设计新款夹克'], params);
|
|
|
|
|
|
|
|
|
// finalResult.isMaybeLike = params.needSuggestion === 'Y' &&
|
|
|
|
|
|
// result[2].data.total > 0 ? false : true; // 猜你喜欢显示不显示判断
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
|
|
|
}
|
|
|
return finalResult;
|
...
|
...
|
@@ -268,9 +264,7 @@ exports.getSearchLessProduct = (channel, uid, udid, page) => { |
|
|
break;
|
|
|
}
|
|
|
if (!_.isNumber(page)) {
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -280,108 +274,89 @@ exports.getSearchLessProduct = (channel, uid, udid, page) => { |
|
|
page = 1;
|
|
|
}
|
|
|
|
|
|
together.data = {
|
|
|
goods: [
|
|
|
{
|
|
|
'id': '77',
|
|
|
'skn': '6666',
|
|
|
'market_price': '',
|
|
|
'price': '¥1.00',
|
|
|
'product_name': 'hongzhuang男T恤',
|
|
|
'url': '//item.yohobuy.com/p508144.html',
|
|
|
'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
},
|
|
|
{
|
|
|
'id': '77',
|
|
|
'skn': '6666',
|
|
|
'market_price': '',
|
|
|
'price': '¥1.00',
|
|
|
'product_name': 'hongzhuang男T恤',
|
|
|
'url': '//item.yohobuy.com/p508144.html',
|
|
|
'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
},
|
|
|
{
|
|
|
'id': '77',
|
|
|
'skn': '6666',
|
|
|
'market_price': '',
|
|
|
'price': '¥1.00',
|
|
|
'product_name': 'hongzhuang男T恤',
|
|
|
'url': '//item.yohobuy.com/p508144.html',
|
|
|
'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
},
|
|
|
{
|
|
|
'id': '77',
|
|
|
'skn': '6666',
|
|
|
'market_price': '',
|
|
|
'price': '¥1.00',
|
|
|
'product_name': 'hongzhuang男T恤',
|
|
|
'url': '//item.yohobuy.com/p508144.html',
|
|
|
'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
},
|
|
|
{
|
|
|
'id': '77',
|
|
|
'skn': '6666',
|
|
|
'market_price': '',
|
|
|
'price': '¥1.00',
|
|
|
'product_name': 'hongzhuang男T恤',
|
|
|
'url': '//item.yohobuy.com/p508144.html',
|
|
|
'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
},
|
|
|
{
|
|
|
'id': '77',
|
|
|
'skn': '6666',
|
|
|
'market_price': '',
|
|
|
'price': '¥1.00',
|
|
|
'product_name': 'hongzhuang男T恤',
|
|
|
'url': '//item.yohobuy.com/p508144.html',
|
|
|
'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
}
|
|
|
],
|
|
|
'message': 'Product List'
|
|
|
};
|
|
|
|
|
|
if (!_.get(together, 'data.goods')) {
|
|
|
|
|
|
// together.data.product_list = {
|
|
|
// goods_list: [
|
|
|
// {
|
|
|
// 'id': '77',
|
|
|
// 'skn': '6666',
|
|
|
// 'market_price': '',
|
|
|
// 'price': '¥1.00',
|
|
|
// 'product_name': 'hongzhuang男T恤',
|
|
|
// 'url': '//item.yohobuy.com/p508144.html',
|
|
|
// 'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
// },
|
|
|
// {
|
|
|
// 'id': '77',
|
|
|
// 'skn': '6666',
|
|
|
// 'market_price': '',
|
|
|
// 'price': '¥1.00',
|
|
|
// 'product_name': 'hongzhuang男T恤',
|
|
|
// 'url': '//item.yohobuy.com/p508144.html',
|
|
|
// 'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
// },
|
|
|
// {
|
|
|
// 'id': '77',
|
|
|
// 'skn': '6666',
|
|
|
// 'market_price': '',
|
|
|
// 'price': '¥1.00',
|
|
|
// 'product_name': 'hongzhuang男T恤',
|
|
|
// 'url': '//item.yohobuy.com/p508144.html',
|
|
|
// 'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
// },
|
|
|
// {
|
|
|
// 'id': '77',
|
|
|
// 'skn': '6666',
|
|
|
// 'market_price': '',
|
|
|
// 'price': '¥1.00',
|
|
|
// 'product_name': 'hongzhuang男T恤',
|
|
|
// 'url': '//item.yohobuy.com/p508144.html',
|
|
|
// 'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
// },
|
|
|
// {
|
|
|
// 'id': '77',
|
|
|
// 'skn': '6666',
|
|
|
// 'market_price': '',
|
|
|
// 'price': '¥1.00',
|
|
|
// 'product_name': 'hongzhuang男T恤',
|
|
|
// 'url': '//item.yohobuy.com/p508144.html',
|
|
|
// 'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
// },
|
|
|
// {
|
|
|
// 'id': '77',
|
|
|
// 'skn': '6666',
|
|
|
// 'market_price': '',
|
|
|
// 'price': '¥1.00',
|
|
|
// 'product_name': 'hongzhuang男T恤',
|
|
|
// 'url': '//item.yohobuy.com/p508144.html',
|
|
|
// 'pic_url': '//img10.static.yhbimg.com/goodsimg/2017/03/02/19/01784d258adeab1c87e4b49eee3f771691.jpg?imageMogr2/thumbnail/280x382/extent/280x382/background/d2hpdGU=/position/center/quality/90'
|
|
|
// }
|
|
|
// ],
|
|
|
// 'message': 'Product List'
|
|
|
// };
|
|
|
|
|
|
if (!_.get(together, 'data.product_list')) {
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result.data.hasPrev = true;
|
|
|
|
|
|
result.data.hasNext = true;
|
|
|
|
|
|
|
|
|
result.data.item = _.map(together.data.goods, it => {
|
|
|
|
|
|
result.data.item = _.map(together.data.product_list, it => {
|
|
|
|
|
|
let item = {
|
|
|
|
|
|
id: it.id,
|
|
|
|
|
|
id: it.product_id,
|
|
|
skn: it.product_skn,
|
|
|
|
|
|
|
|
|
href: it.url,
|
|
|
|
|
|
title: it.product_name,
|
|
|
|
|
|
img: it.default_pic ? helpers.image(it.default_pic, 100, 100) : '',
|
|
|
|
|
|
img: it.default_images ? helpers.image(it.default_pic, 100, 100) : '',
|
|
|
alt: it.product_name,
|
|
|
|
|
|
price: Number(it.price.sales_price)
|
|
|
|
|
|
price: '¥' + transPrice(it.sales_price),
|
|
|
marketPrice: '¥' + transPrice(it.market_price)
|
|
|
};
|
|
|
|
|
|
let firstGoods = it.goods_list && it.goods_list[0];
|
|
|
let productSkc = firstGoods && firstGoods.product_skc;
|
|
|
|
|
|
if (item.price !== Number(it.price.market_price)) {
|
|
|
|
|
|
it.marketPrice = Number(it.price.market_price);
|
|
|
|
|
|
}
|
|
|
|
|
|
item.href = helpers.getUrlBySkc(it.product_id, productSkc, it.cn_alphabet);
|
|
|
|
|
|
return item;
|
|
|
|
...
|
...
|
@@ -391,19 +366,14 @@ exports.getSearchLessProduct = (channel, uid, udid, page) => { |
|
|
// 当数据量不足6个时,判定为没有下一页
|
|
|
|
|
|
if (page === 1) {
|
|
|
|
|
|
result.data.hasPrev = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!result.data.item || result.data.item.length < 6) {
|
|
|
|
|
|
result.data.hasNext = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
})();
|
...
|
...
|
|