Commit d15ea41f by 姜雷

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

parent 6b94a9f1
......@@ -354,6 +354,7 @@ export const allowLetterNumber = value => {
export const formatterMoneyToDouble = val => {
return val ? Number(val).toFixed(2) : Number(0).toFixed(2);
};
export const formatPrice = price => {
var result = [],
counter = 0;
......@@ -361,6 +362,9 @@ export const formatPrice = price => {
result.push(price.slice(-3).join(''));
for (var i = price.length - 4; i >= 0; i--) {
counter++;
if (i == 0 && isNaN(Number(price[i])) && result[0] === ',') {
result.shift();
}
result.unshift(price[i]);
if (!(counter % 3) && i != 0) {
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