Merge branch 'release/4.6' of git.yoho.cn:fe/yohobuy-node into release/4.6
Showing
5 changed files
with
22 additions
and
23 deletions
@@ -12,9 +12,11 @@ | @@ -12,9 +12,11 @@ | ||
12 | <a href="{{url}}" target="_blank"> | 12 | <a href="{{url}}" target="_blank"> |
13 | {{productName}} | 13 | {{productName}} |
14 | <p class="price"> | 14 | <p class="price"> |
15 | - <span class="sale-price">{{salesPrice}}</span> | ||
16 | - <span class="market-price">{{marketPrice}}</span> | 15 | + <span class="sale-price">¥{{round salesPrice 2}}</span> |
16 | + {{#if marketPrice}} | ||
17 | + <span class="market-price">¥{{round marketPrice 2}}</span> | ||
17 | <label class="discount">{{discount}}折</label> | 18 | <label class="discount">{{discount}}折</label> |
19 | + {{/if}} | ||
18 | </p> | 20 | </p> |
19 | </a> | 21 | </a> |
20 | </div> | 22 | </div> |
@@ -17,8 +17,10 @@ | @@ -17,8 +17,10 @@ | ||
17 | <div class="detail-text"> | 17 | <div class="detail-text"> |
18 | <a class="name" href="{{url}}" target="_blank">{{productName}}</a> | 18 | <a class="name" href="{{url}}" target="_blank">{{productName}}</a> |
19 | <p> | 19 | <p> |
20 | - <span class="price">¥{{salesPrice}}</span> | ||
21 | - <label class="discount">{{discount}}折</label> | 20 | + <span class="price">¥{{round salesPrice 2}}</span> |
21 | + {{# discount}} | ||
22 | + <label class="discount">{{.}}折</label> | ||
23 | + {{/ discount}} | ||
22 | </p> | 24 | </p> |
23 | </div> | 25 | </div> |
24 | </div> | 26 | </div> |
@@ -56,10 +56,10 @@ | @@ -56,10 +56,10 @@ | ||
56 | {{/if}} | 56 | {{/if}} |
57 | <p class="price"> | 57 | <p class="price"> |
58 | {{# marketPrice}} | 58 | {{# marketPrice}} |
59 | - <span class="market-price">¥{{.}}</span> | 59 | + <span class="market-price">¥{{round . 2}}</span> |
60 | {{/ marketPrice}} | 60 | {{/ marketPrice}} |
61 | <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}"> | 61 | <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}"> |
62 | - ¥{{salesPrice}} | 62 | + ¥{{round salesPrice 2}} |
63 | </span> | 63 | </span> |
64 | 64 | ||
65 | {{# discount}} | 65 | {{# discount}} |
@@ -93,6 +93,18 @@ exports.upperCase = (str) => { | @@ -93,6 +93,18 @@ exports.upperCase = (str) => { | ||
93 | }; | 93 | }; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | + * 四舍五入 | ||
97 | + * @param {[type]} num 数字 | ||
98 | + * @param {[type]} precision 精度 | ||
99 | + * @return {[type]} | ||
100 | + */ | ||
101 | +exports.round = (num, precision) => { | ||
102 | + precision = _.isNumber(precision) ? precision : 2; | ||
103 | + num = _.isInteger(num) ? (+num).toFixed(precision) : _.round(num, precision); | ||
104 | + return num; | ||
105 | +}; | ||
106 | + | ||
107 | +/** | ||
96 | * 时间格式化 | 108 | * 时间格式化 |
97 | * @param format 格式化token @see{http://momentjs.cn/docs/#/displaying/format/} | 109 | * @param format 格式化token @see{http://momentjs.cn/docs/#/displaying/format/} |
98 | * @param date 日期或者数字 | 110 | * @param date 日期或者数字 |
@@ -92,23 +92,6 @@ exports.processProductList = (list, options) => { | @@ -92,23 +92,6 @@ exports.processProductList = (list, options) => { | ||
92 | thumb: product.defaultImages | 92 | thumb: product.defaultImages |
93 | }); | 93 | }); |
94 | 94 | ||
95 | - if (options.showPoint) { | ||
96 | - product.marketPrice += '.00'; | ||
97 | - product.salesPrice += '.00'; | ||
98 | - | ||
99 | - if (product.vip1Price) { | ||
100 | - product.vip1Price = parseInt(product.vip1Price, 10) + '.00'; | ||
101 | - } | ||
102 | - | ||
103 | - if (product.vip2Price) { | ||
104 | - product.vip2Price = parseInt(product.vip2Price, 10) + '.00'; | ||
105 | - } | ||
106 | - | ||
107 | - if (product.vip3Price) { | ||
108 | - product.vip3Price = parseInt(product.vip3Price, 10) + '.00'; | ||
109 | - } | ||
110 | - } | ||
111 | - | ||
112 | product.isSoonSoldOut = product.isSoonSoldOut === 'Y'; | 95 | product.isSoonSoldOut = product.isSoonSoldOut === 'Y'; |
113 | product.url = helpers.urlFormat(`/product/pro_${product.productId}_${product.goodsList[0].goodsId}/${product.cnAlphabet}.html`); // eslint-disable-line | 96 | product.url = helpers.urlFormat(`/product/pro_${product.productId}_${product.goodsList[0].goodsId}/${product.cnAlphabet}.html`); // eslint-disable-line |
114 | 97 |
-
Please register or login to post a comment