1 function moneyConversionUnit(money){ 2 if(money == null){ 3 return null; 4 } 5 money = parseInt(money); 6 if(money >= 1000000){ 7 money = money / 10000; 8 return moneyFormatting(money) + '万' 9 }else{ 10 return moneyFormatting(money); 11 } 12 } 13 //金额格式化 14 function moneyFormatting(money){ 15 if(money == null){ 16 return null; 17 } 18 var str = (money/100).toFixed(2) + ''; 19 var intSum = str.substring(0,str.indexOf(".")).replace( /\B(?=(?:\d{3})+$)/g, ',' );//取到整数部分 20 var dot = str.substring(str.length,str.indexOf("."))//取到小数部分搜索 21 var ret = intSum + dot; 22 return ret; 23 } 24 25 module.exports ={ 26 27 moneyFormatting: moneyFormatting, 28 moneyConversionUnit: moneyConversionUnit 29 30 }
每个你讨厌的现在,都有一个不努力的曾经