export function getAmountChinese(val) {
const amount = +val
if (Number.isNaN(amount) || amount < 0) return ''
const NUMBER = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
const N_UNIT1 = ['', '拾', '佰', '仟']
const N_UNIT2 = ['', '万', '亿']
const D_UNIT = ['角', '分', '厘', '毫']
let [integer, decimal] = amount.toString().split('.')
if (integer && integer.length > 12) return '金额过大无法计算'
let res = ''
if (integer) {
for (let i = 0, len = integer.length; i < len; i++) {
const num = integer.charAt(i)
const pos = len - i - 1
if (num === '0') {
if (i === len - 1) {
if (integer.length === 1) res += '零'
break
}
if (integer.charAt(i + 1) === '0') continue
}
res += NUMBER[num]
if (parseInt(num)) res += N_UNIT1[(pos) % 4]
if (pos % 4 === 0) res += N_UNIT2[Math.floor(pos / 4)]
}
}
res += '圆'
if (parseInt(decimal)) {
for (let i = 0; i < 4; i++) {
const num = decimal.charAt(i)
if (parseInt(num)) res += NUMBER[num] + D_UNIT[i]
}
} else {
res += '整'
}
return res
}