function to(num){
const zh = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
let unit = ['' ,'十' ,'百' ,'千' ,'万' , '十', '百', '千','亿'];
var last = '';
var mdlast = '';
var zheng = 0;
var xiao = 0;
if(num.indexOf('.') > -1){
mdlast += '点';
zheng = num.split('.')[0];
xiao = num.split('.')[1];
for(var i = 0; i < xiao.length; i++){
mdlast += zh[Number(xiao[i])]
}
}
var da = 0;
if(zheng.length > 4){
da = zheng.substr(0 ,zheng.length - 4);
zheng = zheng.substr(zheng.length - 4 ,zheng.length);
}
if(zheng.length == 1){
last = zh[Number(zheng)] + last;
}
if(zheng.length <= 4 && zheng.length != 1){
for(var i = 0; i < zheng.length; i++){
if(i){
if(Number(zheng[i])){
last += zh[Number(zheng[i])] + unit[zheng.length - 1 - i];
}else{
last += '零';
}
}else{
if(Number(zheng[i])){
last += zh[Number(zheng[i])] + unit[zheng.length - 1];
}else{
last += '零';
}
}
}
var temp = '';
for(var k = 0; k < last.length; k++){
if(last[k] != '零'){
temp += last[k];
}else if(last[k] == '零'){
if(k < last.length - 1 && last[k + 1] != '零'){
temp += last[k];
}
}
}
last = temp;
}
if(da){
var md = '';
for(var i = 0; i < da.length; i++){
if(i){
if(Number(da[i])){
md += zh[Number(da[i])] + unit[da.length - 1 - i];
}else{
md += '零';
}
}else{
md += zh[Number(da[i])] + unit[da.length - 1];
}
}
var temp = '';
for(var k = 0; k < md.length; k++){
if(md[k] != '零'){
temp += md[k];
}else if(md[k] == '零'){
if(k < last.length - 1 && md[k + 1] != '零'){
temp += md[k];
}
}
}
md = temp + '万';
}
console.log(md + last + mdlast + '元');
}
to('60060103.24');
console