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)
    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(/^元/, "零元")
  }
}
