...
|
...
|
@@ -8,6 +8,39 @@ const helpers = global.yoho.helpers; |
|
|
const productPrcs = require('./product-process');
|
|
|
|
|
|
/**
|
|
|
* 高度差必须在 30 以上
|
|
|
*/
|
|
|
const _differenceHeight = (param, item) => {
|
|
|
return Math.abs(item - param) < 30;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 检测产生的值是否符合条件
|
|
|
*/
|
|
|
const _isUnSuitable = (param, alreadyNumsArray, suitabelCall) => {
|
|
|
return _.find(alreadyNumsArray, item => {
|
|
|
return suitabelCall(param, item);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 随机生成标签位置
|
|
|
*/
|
|
|
const _randomNumForLabel = (max, alreadyNumsArray) => {
|
|
|
let result = 0;
|
|
|
let isUnSuitable = false;
|
|
|
|
|
|
do {
|
|
|
result = _.parseInt(_.random(1, max));
|
|
|
if (alreadyNumsArray && alreadyNumsArray.length) {
|
|
|
isUnSuitable = _isUnSuitable(result, alreadyNumsArray, _differenceHeight);
|
|
|
}
|
|
|
} while (isUnSuitable);
|
|
|
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 将商品转化成以 product_skn 为键名的对象
|
|
|
* @param {*} goodsArray
|
|
|
*/
|
...
|
...
|
@@ -221,9 +254,25 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW |
|
|
|
|
|
// 一张图片
|
|
|
if (_.get(value, 'singleImage.data.length', false)) {
|
|
|
let tagList = _.get(value, 'singleImage.data[0].tagList', []);
|
|
|
let height = _.get(value, 'singleImage.data[0].height', '100');
|
|
|
let alreadyTop = [];
|
|
|
let alreadyLeft = [];
|
|
|
|
|
|
if (tagList.length > 0) {
|
|
|
_.forEach(tagList, (tag, tagIndex) => {
|
|
|
tagList[tagIndex].top = _randomNumForLabel(height / 2,
|
|
|
alreadyTop);
|
|
|
alreadyTop.push(tagList[tagIndex].top);
|
|
|
tagList[tagIndex].left = _randomNumForLabel(175);
|
|
|
alreadyLeft.push(tagList[tagIndex].left);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
finalDetail.push({
|
|
|
bigImage: helpers.image(_.get(value, 'singleImage.data[0].src', ''), 640, 640),
|
|
|
noLazy: index <= 3
|
|
|
noLazy: index <= 3,
|
|
|
tagList: tagList
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
|