ui库合并版本完成
This commit is contained in:
		
							
								
								
									
										20
									
								
								ui/lib/js/coin.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ui/lib/js/coin.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| export default { | ||||
|   cny(money) { | ||||
|     if (money) { | ||||
|       money.toLocaleString('zh-Hans-CN', {style: 'currency', currency: "CNY"}) | ||||
|     } | ||||
|     return money | ||||
|   }, | ||||
|   cn(money) { | ||||
|     let num = parseFloat(money), cnMoney = '', | ||||
|         units = '仟佰拾亿仟佰拾万仟佰拾元角分', | ||||
|         cnNum = '零壹贰叁肆伍陆柒捌玖' | ||||
|     num = num.toFixed(2).replace(/\./g,'') | ||||
|     units = units.substring(units.length - num.length) | ||||
|     console.log(num, units.length, num.length) | ||||
|     Array.from(num).map((e, i) => { | ||||
|       cnMoney += cnNum.charAt(e) + units.charAt(i) | ||||
|     }) | ||||
|     return cnMoney.replace(/零角零分$/, '整').replace(/零[仟佰拾]/g, '零').replace(/零{2,}/g, '零').replace(/零([亿|万])/g, '$1').replace(/零+元/, '元').replace(/亿零{0,3}万/, '亿').replace(/^元/, "零元") | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user