Authored by biao

optimise

... ... @@ -13,9 +13,7 @@ const ServiceAPI = require(`${global.library}/api`).ServiceAPI;
const SearchAPI = require(`${global.library}/api`).SearchAPI;
const sign = require(`${global.library}/sign`);
const helpers = require(`${global.library}/helpers`);
const images = require(`${global.utils}/images`);
// const processProduct = require(`${global.utils}/product-process`).processProductList;
const processProduct = require(`${global.utils}/product-process`).processProduct;
const log = require(`${global.library}/logger`);
... ... @@ -52,153 +50,19 @@ const channelMap = dataMap.channel;
const sortMap = dataMap.sort;
/**
* 获取导航信息
* @param {[Object]} 原始数据
* @return {[Object]} 转换后的数据
*/
const getNavs = rawNavs => {
const navs = rawNavs;
let list = [];
_.forEach(navs, it => {
let obj = {};
obj.name = it.name;
obj.href = it.url;
list.push(obj);
});
return list;
};
// 构建url
const httpBuildQuery = data => {
return searchApi.get('/search.json', data);
};
/**
* 格式化商品信息
*
* @param array $productData 需要格式化的商品数据
* @param bool $showTags 控制是否显示标签
* @param bool $showNew 控制是否显示NEW图标
* @param bool $showSale 控制是否显示SALE图标
* @param int $width 图片的宽度
* @param int $height 图片的高度
* @param bool $isApp 判断是不是APP访问
* @param bool $showPoint 商品价格是否显示小数位,默认显示
* @return array | false
*/
const formatProduct = (productData, showTags, showNew, showSale, width, height, isApp, showPoint) => {
let result = {};
// 默认值
if (!showTags) {
showTags = true;
}
if (!showNew) {
showNew = true;
}
if (!showSale) {
showSale = true;
}
if (!width) {
width = 290;
}
if (!height) {
height = 388;
}
if (!isApp) {
isApp = false;
}
if (!showPoint) {
showPoint = true;
}
// 商品信息有问题,则不显示
if (!productData.product_skn || !productData.goods_list[0]) {
return false;
}
// 市场价和售价一样,则不显示市场价
if (parseInt(productData.market_price, 0) === parseInt(productData.sales_price, 0)) {
productData.market_price = false;
}
// 设置默认图片
_.forEach(productData.goods_list, item => {
if (item.is_default === 'Y') {
productData.default_images = item.images_url;
}
});
if (!productData.default_images) {
productData.default_images = productData.goods_list[0].images_url;
}
result.id = productData.product_skn;
result.product_id = productData.product_id;
result.thumb = images.getImageUrl(productData.default_images, width, height);
result.name = productData.product_name;
result.price = !productData.market_price ? false : productData.market_price;
result.salePrice = productData.sales_price;
if (showPoint) {
result.price += '.00';
result.salePrice += '.00';
}
result.is_soon_sold_out = (productData.is_soon_sold_out === 'Y');
result.url = 'http://item.yohobuy.com/product/pro_' +
productData.product_id + '_' +
productData.goods_list[0].goods_id + '/' +
productData.cn_alphabet + '.html';
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if (isApp) {
result.url += '?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":' +
productData.product_skn + '}}';
}
if (showTags) {
result.tags = {};
result.tags.is_new = showNew && productData.is_new && productData.is_new === 'Y'; // 新品
result.tags.is_discount = showSale && productData.is_discount && productData.is_discount === 'Y'; // 在售
result.tags.is_limited = productData.is_limited && productData.is_limited === 'Y'; // 限量
result.tags.is_yohood = productData.is_yohood && productData.is_yohood === 'Y'; // YOHOOD
result.tags.midYear = productData['mid-year'] && productData['mid-year'] === 'Y'; // 年中
result.tags.yearEnd = productData['year-end'] && productData['year-end'] === 'Y'; // 年末
result.tags.is_advance = productData.is_advance && productData.is_advance === 'Y'; // 再到着
if (result.is_soon_sold_out && result.tags.is_discount) {
result.tags.is_new = false;// 打折与即将售完组合显示打折
} else if (result.tags.is_discount &&
(result.tags.is_new || result.tags.is_limited || result.tags.is_yohood || result.tags.is_advance)) {
result.tags.is_discount = false;// 打折与其它组合则隐藏打折
} else if (result.tags.is_yohood && result.tags.is_new) {
result.tags.is_new = false;// YOHOOD和新品组合显示YOHOOD
}
}
return result;
};
/**
* 获取普通banner
* @param {[Object]} data 原始数据
* @return {[Object]} 转换后的数据
*/
const getBannerList = data => {
return _.map(data, item => {
return Object.assign(item, {
href: item.url,
img: item.src,
name: item.title
});
});
return data;
};
... ... @@ -218,12 +82,7 @@ const getDebrisSlide = data => {
_.mapKeys(data, (value, key) => {
_.forEach(value, slideData => {
let obj = {};
obj.href = slideData.url;
obj.img = slideData.img;
floorData.debrisSlider[key].push(obj);
floorData.debrisSlider[key].push(slideData);
});
});
... ... @@ -237,19 +96,10 @@ const getDebrisSlide = data => {
* @return {Object} 转换后的数据
*/
const getadbannerData = data => {
const obj = {
adbanner: {
href: '',
img: '',
name: ''
}
};
obj.adbanner.href = data.url;
obj.adbanner.img = data.src;
obj.adbanner.name = data.title;
return obj;
return {
adbanner: data
};
};
/**
... ... @@ -294,7 +144,6 @@ const getNewReportFloorData = args => {
let forthItem = args[4];
let list = [];
let obj = {};
const data = {
newReport: {
... ... @@ -308,24 +157,13 @@ const getNewReportFloorData = args => {
let floorDatas = [];
obj.href = item[0].url;
obj.img = item[0].src;
list.push(obj);
list.push(item[0]);
_.forEach(secondItem, (floorData) => {
let o = {};
o.href = floorData.url;
o.img = floorData.src;
list.push(o);
list.push(floorData);
});
obj.href = thirdItem[0].url;
obj.img = thirdItem[0].src;
list.push(obj);
list.push(thirdItem[0]);
data.newReport.list = list;
... ... @@ -368,14 +206,7 @@ const getPreBrandTopData = (args, type) => {
}
};
_.forEach(item, (topData) => {
let o = {};
o.href = topData.url;
o.img = topData.src;
data.preferenceBrands.imgBrand.push(o);
});
data.preferenceBrands.imgBrand = item;
setChannelType(data.preferenceBrands, type);
... ... @@ -407,54 +238,27 @@ const getHotGoodsFloorData = (args, type) => {
}
};
_.forEach(item.data.menuNav.list, it => {
let obj = {};
category = item.data.menuNav.list;
obj.name = it.name;
obj.href = it.url;
category.push(obj);
});
_.forEach(item.data.menuNav.blocks, it => {
let obj = {};
obj.name = it.title;
obj.href = it.url;
obj.img = it.img;
keyword.push(obj);
});
keyword = item.data.menuNav.blocks;
_.forEach(item.data.imgs, (it, idx) => {
let obj = {};
obj.name = it.title;
obj.href = it.url;
obj.img = it.img;
if (idx === 0 || (idx === 4 && type === 'boys')) {
brands.push(obj);
brands.push(it);
} else {
types.push(obj);
types.push(it);
}
});
_.forEach(nextItem.data, (it) => {
let obj = {};
obj.name = it.title;
obj.href = it.url;
obj.img = it.src;
products.push(obj);
});
products = nextItem.data;
object.name = item.data.name;
object.keyword = keyword;
object.category = category;
object.brands = brands;
object.types = types;
object.navs = getNavs(item.data.navs.list);
object.navs = item.data.navs.list;
object.products = products;
list.push(object);
... ... @@ -489,7 +293,6 @@ const getBoysSingleHot = (args, type) => {
for (let i = 0; i < len; i++) {
let pos = i;
let val = {};
let obj = {};
if (i === 1) {
val = args[1].data[0]; // 第二个是大图
... ... @@ -501,9 +304,7 @@ const getBoysSingleHot = (args, type) => {
}
val = args[2].data[pos];
}
obj.href = val.url;
obj.img = val.src;
list.push(obj);
list.push(val);
}
data.singlehot.imgHot = list;
... ... @@ -568,7 +369,7 @@ const getSingleHotFloorData = (args, type) => {
* @param {String} type 频道类型
* @return {Object}
*/
const getAsyncSingleHot = (args, queryResult, type) => {
const getSingehotViaResult = (args, queryResult, type) => {
const data = {
singlehot: {
name: args[0].data.text,
... ... @@ -579,40 +380,28 @@ const getAsyncSingleHot = (args, queryResult, type) => {
};
if (args[3].template_name === 'app_icon_list') {
_.forEach(args[3].data, it => {
let obj = {};
obj.href = it.url;
obj.name = it.title;
obj.img = it.src;
data.singlehot.brands.push(obj);
});
data.singlehot.brands = args[3].data;
}
if (queryResult.data) {
_.forEach(queryResult.data.product_list || [], (it, index) => {
let obj = {};
const formatData = formatProduct(it, true, true, true, 280, 373);
const formatData = processProduct(it, {
width: 280,
height: 373
});
if (index > 12) {
return;
}
obj.price = formatData.salePrice;
obj.href = formatData.url;
obj.img = formatData.thumb;
obj.name = formatData.name;
if (index < 3) {
obj.tip = 'TOP' + (index + 1);
formatData.tip = 'TOP' + (index + 1);
}
data.singlehot.imgHot.push(obj);
data.singlehot.imgHot.push(formatData);
});
}
data.singlehot.navs = getNavs(args[1].data);
data.singlehot.navs = args[1].data;
setChannelType(data.singlehot, type);
return data;
};
... ... @@ -626,14 +415,14 @@ const getAsyncSingleHot = (args, queryResult, type) => {
* @param {Type} type 人气单品楼层的类型
* @return {Object}
*/
const processFloorDataWithQueryReusult = (rawData, floorData, queryResult, title, type) => {
const processFloorDataWithQueryReusult = (rawData, queryResult, title, type) => {
let data = {};
_.forEach(rawData, (subData, index) => {
const text = subData.data.text && getText(subData.data.text);
if (text === title) {
data = getAsyncSingleHot(rawData.slice(index, index + 4), queryResult, type);
data = getSingehotViaResult(rawData.slice(index, index + 4), queryResult, type);
}
});
... ... @@ -654,7 +443,7 @@ const getNewGoodsFloorData = args => {
}
};
data.newArrivls.navs = getNavs(args[1].data);
data.newArrivls.navs = args[1].data;
return data;
};
... ... @@ -700,7 +489,10 @@ exports.getNewArrival = channel => {
});
_.forEach(data, (item) => {
result.push(formatProduct(item, true, true, true, 280, 373));
result.push(processProduct(item, {
width: 280,
height: 373
}));
});
return result;
... ... @@ -712,27 +504,23 @@ const getCategoryFloorData = args => {
const data = {
category: {
name: args[0].data.text,
navs: getNavs(args[1].data),
navs: args[1].data,
list: []
}
};
_.forEach(args[2].data, (it, index) => {
let obj = {};
obj.href = it.url;
obj.img = it.src;
// 设置图片大小
if (index === 1) {
obj.w = '377;';
obj.h = '504;';
it.w = '377;';
it.h = '504;';
} else {
obj.w = '185';
obj.h = '510';
it.w = '185';
it.h = '510';
}
data.category.list.push(obj);
data.category.list.push(it);
});
return data;
... ... @@ -742,20 +530,12 @@ const getAccordionFloorData = args => {
let data = {
accordion: {
name: args[0].data.text,
navs: getNavs(args[1].data),
navs: args[1].data,
slide: []
}
};
_.forEach(args[2].data, it => {
let obj = {};
obj.name = it.title;
obj.img = it.src;
obj.href = it.url;
data.accordion.slide.push(obj);
});
data.accordion.slide = args[2].data;
return data;
};
... ... @@ -912,8 +692,12 @@ exports.getContent = type => {
_.forEach(res, (data, index) => {
result.floorData.channel
.splice(result.singlehotFloorIndex[index], 0,
processFloorDataWithQueryReusult(result.rawData,
result.floorData, data, result.singlehotFloorTitle[index], result.channelType));
processFloorDataWithQueryReusult(
result.rawData,
data,
result.singlehotFloorTitle[index],
result.channelType
));
});
return result.floorData;
... ...
<div class="floor-ad">
<a href="{{href}}" target= "_blank"><img class="lazy" data-original="{{image img 1150 129}}"/></a>
<a href="{{url}}" target= "_blank"><img class="lazy" data-original="{{image src 1150 129}}"/></a>
</div>
... ...
<div class="debris-slider clearfix">
<div class="left-col col">
{{# left}}
<a href="{{href}}" target="_blank">
<a href="{{url}}" target="_blank">
<img class="lazy" data-original="{{image img 200 265}}">
</a>
{{/ left}}
... ... @@ -10,7 +10,7 @@
<ul class="slide-wrapper">
{{# center}}
<li>
<a href="{{href}}" target="_blank">
<a href="{{url}}" target="_blank">
<img class="lazy" data-original="{{image img 570 633}}">
</a>
</li>
... ... @@ -18,16 +18,16 @@
</ul>
<div class="slide-switch">
<a class="prev" href="javascript:;">
<span class="iconfont">&#xe60c;</span>
<span class="iconfont">&#xe60f;</span>
</a>
<a class="next" href="javascript:;">
<span class="iconfont">&#xe60b;</span>
<span class="iconfont">&#xe60e;</span>
</a>
</div>
</div>
<div class="right-col col">
{{# right}}
<a href="{{href}}" target="_blank">
<a href="{{url}}" target="_blank">
<img class="lazy" data-original="{{image img 200 265}}">
</a>
{{/ right}}
... ...
... ... @@ -3,18 +3,18 @@
<ul class="img-list imgopacity clearfix">
{{# imgBrand}}
<li class="img-item">
<a href="{{href}}" target= "_blank">
<img src="{{image img 378 175}}" alt="">
<a href="{{url}}" target= "_blank">
<img src="{{image src 378 175}}" alt="">
</a>
</li>
{{/ imgBrand}}
</ul>
<div class="img-brand-switch">
<a class="prev" href="javascript:;">
<span class="iconfont">&#xe60c;</span>
<span class="iconfont">&#xe60f;</span>
</a>
<a class="next" href="javascript:;">
<span class="iconfont">&#xe60b;</span>
<span class="iconfont">&#xe60e;</span>
</a>
</div>
</div>
... ...
... ... @@ -5,26 +5,26 @@
<div class="tpl-nav">
<div class="tpl-keywords">
{{#each keyword}}
<a class="keywords{{@index}}" title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 185 152}}"/></a>
<a class="keywords{{@index}}" title="{{title}}" href="{{url}}" target= "_blank"><img class="lazy" src="{{image img 185 152}}"/></a>
{{/each}}
</div>
<div class="tpl-category clearfix">
{{#each category}}
<a href="{{href}}" target= "_blank">{{name}}</a>
<a href="{{url}}" target= "_blank">{{title}}</a>
{{/each}}
</div>
</div>
<div class="tpl-brands imgopacity clearfix">
<ul>
{{#each brands}}
<li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 378 248}}"/></a></li>
<li><a title="{{title}}" href="{{url}}" target= "_blank"><img class="lazy" src="{{image img 378 248}}"/></a></li>
{{/each}}
</ul>
</div>
<div class="tpl-types imgopacity clearfix">
<ul>
{{#each types}}
<li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 185 248}}"/></a></li>
<li><a title="{{title}}" href="{{url}}" target= "_blank"><img class="lazy" src="{{image img 185 248}}"/></a></li>
{{/each}}
</ul>
</div>
... ... @@ -32,7 +32,7 @@
<div class="tpl-products imgopacity clearfix">
<ul>
{{#each products}}
<li><a href="{{href}}" title="{{name}}" target= "_blank"><img class="lazy" src="{{image img 222 298}}"/></a></li>
<li><a href="{{url}}" title="{{title}}" target= "_blank"><img class="lazy" src="{{image src 222 298}}"/></a></li>
{{/each}}
</ul>
</div>
... ...
... ... @@ -3,9 +3,9 @@
<ul class="g-list imgopacity">
{{#each imgHot}}
{{#if @last}}
<li><a class="impo{{@index}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 378 248}}"/></a></li>
<li><a class="impo{{@index}}" href="{{url}}" target= "_blank"><img class="lazy" src="{{image src 378 248}}"/></a></li>
{{^}}
<li><a class="impo{{@index}}" href="{{href}}" target= "_blank"><img class="lazy" src="{{image img 185 248}}"/></a></li>
<li><a class="impo{{@index}}" href="{{url}}" target= "_blank"><img class="lazy" src="{{image src 185 248}}"/></a></li>
{{/if}}
{{/each}}
</ul>
... ...
... ... @@ -3,8 +3,8 @@
<ul class="clearfix">
{{# list}}
<li class="cate-item{{@index}}">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{image img w h}}" alt="">
<a href="{{url}}" target= "_blank">
<img class="lazy" data-original="{{image src w h}}" alt="">
</a>
</li>
{{/ list}}
... ...
... ... @@ -4,6 +4,6 @@
<div class="goods-container clearfix">
</div>
<div class="loading">
<a href="{{href}}" target= "_blank">Loading...</a>
<a href="{{url}}" target= "_blank">Loading...</a>
</div>
</div>
... ...
... ... @@ -8,7 +8,7 @@
<ul class="img-list">
{{# imgBrand}}
<li class="img-item">
<a href="{{href}}" target= "_blank"> <img src="{{image img 320 430}}" alt="{{alt}}"></a>
<a href="{{url}}" target= "_blank"> <img src="{{image src 320 430}}" alt="{{alt}}"></a>
</li>
{{/ imgBrand}}
</ul>
... ...
... ... @@ -5,24 +5,24 @@
<div class="tpl-nav">
<div class="tpl-keywords">
{{#each keyword}}
<a class="keywords{{@index}}" title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{image img 185 76}}"/></a>
<a class="keywords{{@index}}" title="{{title}}" href="{{url}}" target= "_blank"><img class="lazy" data-original="{{image img 185 76}}"/></a>
{{/each}}
</div>
<div class="tpl-category clearfix">
{{#each category}}
<a href="{{href}}" target= "_blank">{{name}}</a>
<a href="{{url}}" target= "_blank">{{title}}</a>
{{/each}}
</div>
</div>
<div class="tpl-brands imgopacity clearfix">
{{#each brands}}
<a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{image img 377 504}}"/></a>
<a title="{{title}}" href="{{url}}" target= "_blank"><img class="lazy" data-original="{{image img 377 504}}"/></a>
{{/each}}
</div>
<div class="tpl-types imgopacity clearfix">
<ul>
{{#each types}}
<li><a title="{{name}}" href="{{href}}" target= "_blank"><img class="lazy" data-original="{{image img 185 504}}"/></a></li>
<li><a title="{{title}}" href="{{url}}" target= "_blank"><img class="lazy" data-original="{{image img 185 504}}"/></a></li>
{{/each}}
</ul>
</div>
... ...
... ... @@ -4,13 +4,13 @@
<ul class="g-list imgopacity clearfix">
{{#each imgHot}}
<li>
<a href="{{href}}" target= "_blank"><div class="commodity-img">
<a href="{{url}}" target= "_blank"><div class="commodity-img">
{{# tip}}
<i class="top">{{.}}</i>
{{/ tip}}
<img class="lazy" data-original="{{image img 280 373}}"/></div>
<img class="lazy" data-original="{{image thumb 280 373}}"/></div>
<p class="commodity-name">{{name}}</p>
<p class="commodity-price"><span>¥{{price}}</span></p>
<p class="commodity-price"><span>¥{{salePrice}}</span></p>
</a>
</li>
{{/each}}
... ... @@ -18,7 +18,7 @@
</div>
<div class="commodity-brands imgopacity clearfix">
{{#each brands}}
<a href="{{href}}" title="{{name}}" target= "_blank"><img class="lazy" data-original="{{image img 185 86}}"/></a>
<a href="{{url}}" title="{{title}}" target= "_blank"><img class="lazy" data-original="{{image src 185 86}}"/></a>
{{/each}}
</div>
</div>
... ...
... ... @@ -6,11 +6,11 @@
{{#unless @last}}
<li>
<a href="{{href}}" target= "_blank">
<a href="{{url}}" target= "_blank">
{{#if @first}}
<img class="lazy" data-original="{{image img 377 504}}" alt="" >
<img class="lazy" data-original="{{image src 377 504}}" alt="" >
{{^}}
<img class="lazy" data-original="{{image img 185 248}}" alt="" >
<img class="lazy" data-original="{{image src 185 248}}" alt="" >
{{/if}}
</a>
</li>
... ... @@ -21,8 +21,8 @@
{{# list}}
{{#if @last}}
<div class="last-item">
<a href="{{href}}" target= "_blank">
<img class="lazy" data-original="{{image img 377 504}}" alt="">
<a href="{{url}}" target= "_blank">
<img class="lazy" data-original="{{image src 377 504}}" alt="">
</a>
</div>
{{/if}}
... ...
... ... @@ -2,7 +2,7 @@
<div class="slide-accordion clearfix">
<ul>
{{#each slide}}
<li><a title="{{name}}" href="{{href}}" target= "_blank"><div class="g-mask"></div><img class="lazy" data-original="{{image img 650 400}}"/></a></li>
<li><a title="{{title}}" href="{{url}}" target= "_blank"><div class="g-mask"></div><img class="lazy" data-original="{{image src 650 400}}"/></a></li>
{{/each}}
</ul>
</div>
... ...
... ... @@ -3,11 +3,11 @@
<ul>
{{# list}}
<li style="{{#if bgColor}}background:{{bgColor}}{{/if}}">
<a href="{{href}}" target= "_blank">
<a href="{{url}}" target= "_blank">
{{#if @first}}
<img src="{{image img 1150 450}}">
<img src="{{image src 1150 450}}">
{{^}}
<img class="lazy" data-original="{{image img 1150 450}}" alt="">
<img class="lazy" data-original="{{image src 1150 450}}" alt="">
{{/if}}
</a>
{{# tips}}
... ... @@ -26,8 +26,8 @@
<ul class="clearfix">
{{# pagination}}
<li>
<a href="{{href}}" target="_blank"></a>
<img src="{{image img 138 54}}" alt="">
<a href="{{url}}" target="_blank"></a>
<img src="{{image src 138 54}}" alt="">
</li>
{{/ pagination}}
</ul>
... ...
... ... @@ -6,7 +6,7 @@
<ul class="header-navs">
{{# navs}}
<li data-classify="{{id}}">
<a target="_blank" href="{{href}}">{{name}}</a>
<a target="_blank" href="{{url}}">{{name}}</a>
</li>
{{/ navs}}
</ul>
... ...
... ... @@ -2,6 +2,7 @@
const _ = require('lodash');
const camelCase = require('../library/camel-case');
const helpers = require('../library/helpers');
const images = require(`${global.utils}/images`);
/**
* 根据性别来决定 默认图片获取字段 如果是 2、3
... ... @@ -52,12 +53,14 @@ exports.processProductList = (list, options) => {
showPoint: true,
gender: '2,3'
}, options);
list = camelCase(list);
_.forEach(list, (product) => {
// 商品信息有问题,则不显示
if (!product.productId || !product.goodsList.length) {
if (!product.productSkn || !product.goodsList.length) {
return;
}
... ... @@ -266,3 +269,76 @@ exports.processFilter = (list, options) => {
return filters;
};
// 处理单个商品
exports.processProduct = (productData, options) => {
let result = {};
options = Object.assign({
showTags: true,
showNew: true,
showSale: true,
width: 290,
height: 388,
showPoint: true
}, options);
// 商品信息有问题,则不显示
if (!productData.product_skn || !productData.goods_list[0]) {
return false;
}
// 市场价和售价一样,则不显示市场价
if (parseInt(productData.market_price, 0) === parseInt(productData.sales_price, 0)) {
productData.market_price = false;
}
// 设置默认图片
_.forEach(productData.goods_list, item => {
if (item.is_default === 'Y') {
productData.default_images = item.images_url;
}
});
if (!productData.default_images) {
productData.default_images = productData.goods_list[0].images_url;
}
result.id = productData.product_skn;
result.product_id = productData.product_id;
result.thumb = images.getImageUrl(productData.default_images, options.width, options.height);
result.name = productData.product_name;
result.price = !productData.market_price ? false : productData.market_price;
result.salePrice = productData.sales_price;
if (options.showPoint) {
result.price += '.00';
result.salePrice += '.00';
}
result.is_soon_sold_out = (productData.is_soon_sold_out === 'Y');
result.url = helpers.urlFormat(`/product/pro_${productData.product_id}_${productData.goods_list[0].goods_id}/${productData.cn_alphabet}.html`, null, 'list'); // eslint-disable-line
if (options.showTags) {
result.tags = {};
result.tags.is_new = options.showNew && productData.is_new && productData.is_new === 'Y'; // 新品
result.tags.is_discount = options.showSale && productData.is_discount && productData.is_discount === 'Y'; // 在售
result.tags.is_limited = productData.is_limited && productData.is_limited === 'Y'; // 限量
result.tags.is_yohood = productData.is_yohood && productData.is_yohood === 'Y'; // YOHOOD
result.tags.midYear = productData['mid-year'] && productData['mid-year'] === 'Y'; // 年中
result.tags.yearEnd = productData['year-end'] && productData['year-end'] === 'Y'; // 年末
result.tags.is_advance = productData.is_advance && productData.is_advance === 'Y'; // 再到着
if (result.is_soon_sold_out && result.tags.is_discount) {
result.tags.is_new = false;// 打折与即将售完组合显示打折
} else if (result.tags.is_discount &&
(result.tags.is_new || result.tags.is_limited || result.tags.is_yohood || result.tags.is_advance)) {
result.tags.is_discount = false;// 打折与其它组合则隐藏打折
} else if (result.tags.is_yohood && result.tags.is_new) {
result.tags.is_new = false;// YOHOOD和新品组合显示YOHOOD
}
}
return result;
};
... ...