Authored by hongweigao

根据接口返回tags顺序放置

... ... @@ -103,41 +103,46 @@ const _getProductFavoriteDataAsync = (uid, pid) => {
// 商品标签
const _getTagsDataByProductInfo = (data) => {
let tags = {};
let tags = [];
_.get(data, 'tags', []).forEach((value) => {
let tag = {};
switch (value) {
case 'is_soon_sold_out': // 即将售磬
tags.isFew = true;
tag.isFew = true;
break;
case 'is_new': // 新品NEW
tags.isNew = true;
tag.isNew = true;
break;
case 'is_discount': // SALE
tags.isSale = true;
tag.isSale = true;
break;
case 'is_limited': // 限量
tags.isLimit = true;
tag.isLimit = true;
break;
case 'is_yohood': // YOHOOD
tags.isNewFestival = true;
tag.isNewFestival = true;
break;
case 'is_advance': // 再到着
tags.isReNew = true;
tag.isReNew = true;
break;
case 'mid_year':// 年中热促
tags.isYearMidPromotion = true;
tag.isYearMidPromotion = true;
break;
case 'year_end':// 年终大促
tags.isYearEndPromotion = true;
tag.isYearEndPromotion = true;
break;
case 'is_presell':// 预售
tags.isPresell = true;
tag.isPresell = true;
break;
default:
break;
}
tags.push(tag);
});
return tags;
};
... ...
... ... @@ -211,49 +211,48 @@ exports.processProductList = (list, options) => {
itemNum++;
product.url += `?${itemFrom}${itemNum}`;
}
if (options.showTags) {
let tags = {};
let tags = [];
_.get(product, 'tags', []).forEach((value) => {
let tag = {};
switch (value) {
case 'is_soon_sold_out': // 即将售磬
options.showFew && (tags.is_few = true);
options.showFew && (tag.is_few = true);
break;
case 'is_new': // 新品NEW
options.showNew && (tags.is_new = true);
options.showNew && (tag.is_new = true);
break;
case 'is_discount': // SALE
options.showSale && (tags.is_sale = true);
options.showSale && (tag.is_sale = true);
break;
case 'is_limited': // 限量
options.showLimit && (tags.is_limit = true);
options.showLimit && (tag.is_limit = true);
break;
case 'is_yohood': // YOHOOD
tags.is_new_festival = true;
tag.is_new_festival = true;
break;
case 'is_advance': // 再到着
tags.is_re_new = true;
tag.is_re_new = true;
break;
case 'midYear':// 年中热促
tags.is_year_mid_promotion = true;
tag.is_year_mid_promotion = true;
break;
case 'yearEnd':// 年终大促
tags.is_year_end_promotion = true;
tag.is_year_end_promotion = true;
break;
case 'is_presell':// 预售
tags.is_presell = true;
tag.is_presell = true;
break;
default:
break;
}
tags.push(tag);
product.tags = tags;
product.is_few = tags.is_few;
product.is_few = tag.is_few;
});
}
if (options.query && _.isString(product.product_name)) {
let qreg = new RegExp(options.query, 'ig');
... ...