lowMoneyToUp : function(money){//小寫數字金額
var u = App.base.Utils,
cnNums = new Array("零", "壹", "貳", "叁", "肆", "伍", "陸", "柒", "捌", "玖"),
cnIntRadice = new Array("", "拾", "佰", "仟"), //基本機關
cnIntUnits = new Array("", "萬", "億", "兆"), //對應整數部分擴充機關
cnDecUnits = new Array("角", "分", "毫", "厘"), //對應小數部分機關
cnInteger = "整", //整數金額時後面跟的字元
cnIntLast = "圓", //整型完以後的機關
maxNum = , //最大處理的數字
IntegerNum, //金額整數部分
DecimalNum,//金額小數部分
ChineseStr = "", //輸出的中文金額字元串
parts; //分離金額後用的數組,預定義
if(!!money)
money = parseFloat(money);
else
return "";
if (money >= maxNum) {
u.toast('超出最大處理數字');
return "";
}
if (money == ) {
ChineseStr = cnNums[] + cnIntLast + cnInteger;
return ChineseStr;
}
money = money.toString(); //轉換為字元串
if (money.indexOf(".") == -) {
IntegerNum = money;
DecimalNum = '';
} else {
parts = money.split(".");
IntegerNum = parts[];
DecimalNum = parts[].substr(, );
}
if (parseInt(IntegerNum, ) > ) { //擷取整型部分轉換
var zeroCount = ,
IntLen = IntegerNum.length;
for (var i = ; i < IntLen; i++) {
var n = IntegerNum.substr(i, );
var p = IntLen - i - ;
var q = p / ;
var m = p % ;
if (n == "0") {
zeroCount++;
} else {
if (zeroCount > ) {
ChineseStr += cnNums[];
}
zeroCount = ; //歸零
ChineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
}
if (m == && zeroCount < ) {
ChineseStr += cnIntUnits[q];
}
}
ChineseStr += cnIntLast;
//整型部分處理完畢
}
if (DecimalNum != '') { //小數部分
var decLen = DecimalNum.length;
for (var i = ; i < decLen; i++) {
var n = DecimalNum.substr(i, );
if (n != '0') {
ChineseStr += cnNums[Number(n)] + cnDecUnits[i];
}
}
}
if (ChineseStr == '') {
ChineseStr += cnNums[] + cnIntLast + cnInteger;
} else if (DecimalNum == '') {
ChineseStr += cnInteger;
}
return ChineseStr;//傳回大寫人民币金額
}