Commit d15ea41f by 姜雷

修改负数情况下格式化价格问题

parent 6b94a9f1
...@@ -354,6 +354,7 @@ export const allowLetterNumber = value => { ...@@ -354,6 +354,7 @@ export const allowLetterNumber = value => {
export const formatterMoneyToDouble = val => { export const formatterMoneyToDouble = val => {
return val ? Number(val).toFixed(2) : Number(0).toFixed(2); return val ? Number(val).toFixed(2) : Number(0).toFixed(2);
}; };
export const formatPrice = price => { export const formatPrice = price => {
var result = [], var result = [],
counter = 0; counter = 0;
...@@ -361,6 +362,9 @@ export const formatPrice = price => { ...@@ -361,6 +362,9 @@ export const formatPrice = price => {
result.push(price.slice(-3).join('')); result.push(price.slice(-3).join(''));
for (var i = price.length - 4; i >= 0; i--) { for (var i = price.length - 4; i >= 0; i--) {
counter++; counter++;
if (i == 0 && isNaN(Number(price[i])) && result[0] === ',') {
result.shift();
}
result.unshift(price[i]); result.unshift(price[i]);
if (!(counter % 3) && i != 0) { if (!(counter % 3) && i != 0) {
result.unshift(','); result.unshift(',');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment