Authored by 郭成尧

Merge branch 'release/4.6' of git.yoho.cn:fe/yohobuy-node into release/4.6

... ... @@ -12,9 +12,11 @@
<a href="{{url}}" target="_blank">
{{productName}}
<p class="price">
<span class="sale-price">{{salesPrice}}</span>
<span class="market-price">{{marketPrice}}</span>
<label class="discount">{{discount}}</label>
<span class="sale-price">¥{{round salesPrice 2}}</span>
{{#if marketPrice}}
<span class="market-price">¥{{round marketPrice 2}}</span>
<label class="discount">{{discount}}</label>
{{/if}}
</p>
</a>
</div>
... ...
... ... @@ -17,8 +17,10 @@
<div class="detail-text">
<a class="name" href="{{url}}" target="_blank">{{productName}}</a>
<p>
<span class="price">¥{{salesPrice}}</span>
<label class="discount">{{discount}}</label>
<span class="price">¥{{round salesPrice 2}}</span>
{{# discount}}
<label class="discount">{{.}}</label>
{{/ discount}}
</p>
</div>
</div>
... ...
... ... @@ -56,10 +56,10 @@
{{/if}}
<p class="price">
{{# marketPrice}}
<span class="market-price">¥{{.}}</span>
<span class="market-price">¥{{round . 2}}</span>
{{/ marketPrice}}
<span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">
¥{{salesPrice}}
¥{{round salesPrice 2}}
</span>
{{# discount}}
... ...
... ... @@ -93,6 +93,18 @@ exports.upperCase = (str) => {
};
/**
* 四舍五入
* @param {[type]} num 数字
* @param {[type]} precision 精度
* @return {[type]}
*/
exports.round = (num, precision) => {
precision = _.isNumber(precision) ? precision : 2;
num = _.isInteger(num) ? (+num).toFixed(precision) : _.round(num, precision);
return num;
};
/**
* 时间格式化
* @param format 格式化token @see{http://momentjs.cn/docs/#/displaying/format/}
* @param date 日期或者数字
... ...
... ... @@ -92,23 +92,6 @@ exports.processProductList = (list, options) => {
thumb: product.defaultImages
});
if (options.showPoint) {
product.marketPrice += '.00';
product.salesPrice += '.00';
if (product.vip1Price) {
product.vip1Price = parseInt(product.vip1Price, 10) + '.00';
}
if (product.vip2Price) {
product.vip2Price = parseInt(product.vip2Price, 10) + '.00';
}
if (product.vip3Price) {
product.vip3Price = parseInt(product.vip3Price, 10) + '.00';
}
}
product.isSoonSoldOut = product.isSoonSoldOut === 'Y';
product.url = helpers.urlFormat(`/product/pro_${product.productId}_${product.goodsList[0].goodsId}/${product.cnAlphabet}.html`); // eslint-disable-line
... ...