Amount transferred from lowercase to uppercase

handleSmallToCapitalize(price) {
            let fraction = ['Angle'.'points'];
            let digit = ['zero'.'one'.'. '.'叁'.'boss'.'wu'.'land'.'pure'.'捌'.'nine'];
            let unit = [['circle'.'万'.'亿'], [' '.'pick up'.'or'.'仟']].let head = price < 0 ? 'less' : ' ';
            price = Math.abs(price);
            let upper = ' ';
            for (let i = 0; i < fraction.length; i++) {
                upper += (digit[Math.floor(price * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(Zero /. /.' ');
            }
            upper = upper || 'the whole';
            price = Math.floor(price);
            for (let i = 0; i < unit[0].length && price > 0; i++) {
                let p = ' ';
                for (let j = 0; j < unit[1].length && price > 0; j++) {
                    p = digit[price % 10] + unit[1][j] + p;
                    price = Math.floor(price / 10);
                }
                upper = p.replace(/ (zero). * $/ zero.' ').replace($/ / ^.'zero') + unit[0][i] + upper;
            }
            return head + upper.replace(/ (zero). * zero/circle.'circle').replace(/ (zero). +/g.'zero').replace(Whole $/ / ^.'Zero round').replace('. '.' ')}Copy the code

Formatting output currency

/** * Formats the output currency * number numeric number * Places Reserved decimal number * symbol prefix * thousand decimal separator * decimal separator * suffix **/
export const fmtCurrency = (number, places, symbol, thousand, decimal, suffix) = > {
    number = number || 0;
    // we can write formatMoney(542986,3)
    places = !isNaN(places = Math.abs(places)) ? places : 2;
    //symbol: $formatMoney(542986,2,"$")symbol = symbol ! = =undefined ? symbol : "RMB";
    //thousand indicates that each digit is separated by, and is a currency identifier
    thousand = thousand || ",";
    //decimal represents the decimal point
    decimal = decimal || ".";
    //negative means "-" if the money is negative and not negative
    let negative = number < 0 ? "-" : "";
    // I represents the processed part of the numeric integer
    let i = parseInt(number = Math.abs(number || 0).toFixed(places), 10) + "";
    / / the suffix
    suffix = suffix || ' ';
    return symbol + negative +
        i.replace(/ \ d {1, 3} (? =(\d{3})+$)/g.'$&' + thousand) +
        (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "") +
        suffix;
};
Copy the code

Continue above, format output amount

/** * Format output amount *@param number
 * @returns {*}
 * @constructor* /
export const fmtMoney = (number) = > {
    return fmtCurrency(number, 2.' '.', '.'. '.'$');
};
Copy the code