Authored by 周少峰

Merge branch 'master' into hotfix/detail-error

... ... @@ -118,7 +118,9 @@ const getListData = (params, channel) => {
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
Object.assign({showDiscount: false}, params, {
from: {type: 'list', params: params}
})),
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// 最近浏览记录
... ... @@ -194,7 +196,8 @@ const getListNewData = (params, channel) => {
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false, showNew: false}, params)),
Object.assign({showDiscount: false, showNew: false,
from: {type: 'listNew', params: params}}, params)),
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// 最近浏览记录
... ... @@ -304,7 +307,7 @@ const getBrandData = (params, extra, channel) => {
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
Object.assign({showDiscount: false, from: {type: 'brand', params: params}}, params)),
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// 最近浏览记录
... ...
... ... @@ -379,7 +379,8 @@ exports.getSaleDiscountData = (params, channel) => {
// 处理分页等筛选信息
if (subResult[0].code === 200) {
Object.assign(finalResult, {
leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort, params, 'discount'),
leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort,
params, 'discount'),
saleList: {
footPager: publicHandler.handlePagerData(subResult[0].data.total, params),
opts: publicHandler.handleSaleOptsData(params, subResult[0].data.total, 'default')
... ... @@ -580,7 +581,8 @@ exports.getSaleSpecialData = (id, params, channel) => {
Object.assign(resData, {
filters: searchHandler.handleFilterDataAll(_.get(result[2], 'data', {}), params),
opts: searchHandler.handleOptsData(params, tip.total),
goods: productProcess.processProductList(_.get(result[2], 'data.product_list', [])),
goods: productProcess.processProductList(_.get(result[2], 'data.product_list', []),
{from: {type: 'saleSpecial', params: params}}),
footPager: {tip: tip}
});
... ...
... ... @@ -582,6 +582,9 @@ exports.handleFilterData = (origin, params, total) => {
if (params.price === key) {
priceRangechecked = true;
}
if (_.isString(value)) {
value = _.replace(value, '¥', '¥');
}
let price = {
checked: params.price === key,
href: handleFilterUrl(params, {price: key}),
... ...
... ... @@ -68,7 +68,7 @@ exports.getSearchData = (params, channel) => {
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)),
latestWalk: 6,
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
shopEntry: result[3]
... ...
... ... @@ -78,7 +78,7 @@
</p>
<div class="hideList hide">
{{#goods_list}}
<li data-src="{{image images_url 280 374}}" data-url="{{../url}}" data-status="{{status}}"></li>
<li data-src="{{image images_url 280 382}}" data-url="{{../url}}" data-status="{{status}}"></li>
{{/goods_list}}
</div>
</div>
... ...
... ... @@ -300,6 +300,7 @@
.ud-price-range {
margin-top: 2px;
display: inline-block;
}
.limit {
... ...
... ... @@ -64,7 +64,7 @@ exports.setPager = (total, params)=>{
for (i = 1; i <= len; i++) {
let p = currentPage + i + 2;
if (i > total) {
if (p > total) {
break;
}
... ... @@ -78,7 +78,7 @@ exports.setPager = (total, params)=>{
for (i = 1; i <= len; i++) {
let p = currentPage - i - 2;
if (i < 1) {
if (p < 1) {
break;
}
... ...
... ... @@ -7,6 +7,15 @@ const helpers = global.yoho.helpers;
// const images = require(`${global.utils}/images`);
const itemFromBase = {
search: {domain: 'search', module: 's'}, // 搜索页search.yohobuy.com
list: {domain: 'list', module: 'c'}, // list.yohobuy.com
listSale: {domain: 'list', module: 's'}, // list.yohobuy.com/sale
listNew: {domain: 'list', module: 'n'}, // list.yohobuy.com/new
brand: {domain: 'brand', module: 'b'}, // xxx.yohobuy.com[品牌域名]
saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com
};
// NOTE: 这里修改了图片质量的参数
helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90'));
... ... @@ -105,6 +114,8 @@ const procProductImgs = (item, gender) => {
*/
exports.processProductList = (list, options) => {
const pruductList = [];
let itemNum = 0,
itemFrom;
options = Object.assign({
showTags: true,
... ... @@ -118,11 +129,30 @@ exports.processProductList = (list, options) => {
height: 388,
isApp: false,
showPoint: true,
gender: '2,3'
gender: '2,3',
from: {} // 来源
}, options);
_.forEach(list, (product) => {
// 处理item from
if (!_.isEmpty(options.from) && itemFromBase[options.from.type]) {
let f = {domain: '', module: '', key: ''};
let params = options.from.params || {};
f.page = params.page || 1;
Object.assign(f, itemFromBase[options.from.type], {
page: params.page || 1,
key: params.misort || params.msort || ''
});
if (options.from.type === 'search') {
f.key = params.query || '';
}
itemFrom = `from=${f.domain}-${f.module}-${f.key}_${f.page}_`;
}
_.forEach(list, (product) => {
// 商品信息有问题,则不显示
if (!product || !product.product_skn || !product.goods_list.length) {
... ... @@ -166,7 +196,7 @@ exports.processProductList = (list, options) => {
});
product.is_few = product.is_soon_sold_out === 'Y';
product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`); // eslint-disable-line
product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`, '', 'item'); // eslint-disable-line
// tar add 1606071146 品牌链接处理
product.brandUrl = helpers.urlFormat('', '', product.brand_domain);
... ... @@ -175,6 +205,10 @@ exports.processProductList = (list, options) => {
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if (options.isApp) {
product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.product_id}'}}`; // eslint-disable-line
} else if (itemFrom) {
// 累加商品数量
itemNum++;
product.url += `?${itemFrom}${itemNum}`;
}
if (options.showTags) {
... ...