SOURCE

function dealDigitUnit(num) {
    if (!num) {
        return 0;
    }
    if (typeof num === 'number') {
        num = (num).toString();
    } else if (typeof num !== 'string') {
        console.log('bus.js:28 ' + num);
        return 0;
    }

    let arr = num.split('.');

    if (arr[0].length <= 4) {
        if (arr.length === 1) {// 无小数或小数+整数五位以下
            return num;
        } else {
            if (arr[1].length <= 2) {
                if ((arr[0].length + arr[1].length) < 5) {
                    return num
                } else {
                    return arr[0].length === 3 ? parseFloat(num).toFixed(1).replace('.0', '') : parseFloat(num).toFixed(0)
                }
            } else {
                if (arr[0].length + 2 < 5) {
                    return parseFloat(num).toFixed(2).replace('.00', '')
                } else {
                    return arr[0].length === 3 ? parseFloat(num).toFixed(1).replace('.0', '') : parseFloat(num).toFixed(0)
                }
            }
        }
    } else if (arr[0].length > 4 && arr[0].length <= 8) {
        let w = arr[0].substr(0, arr[0].length - 4);
        let decimal = arr[0].substr(arr[0].length - 4);
        return w.length === 4 ? parseFloat(w + '.' + decimal).toFixed(0) + '万' :
            parseFloat(w + '.' + decimal).toFixed(1).replace('.0', '') + '万';
    } else if (arr[0].length > 8 && arr[0].length <= 12) {
        let billion = arr[0].substr(0, arr[0].length - 8);
        let decimal = arr[0].substr(arr[0].length - 8);
        return billion.length === 4 ? parseFloat(billion + '.' + decimal).toFixed(0) + '亿' :
            parseFloat(billion + '.' + decimal).toFixed(1).replace('.0', '') + '亿';
    } else {
        let billion = arr[0].substr(0, arr[0].length - 12);
        let decimal = arr[0].substr(arr[0].length - 12);
        return billion.length === 4 ? parseFloat(billion).toFixed(0) + '万亿' :
            parseFloat(billion + '.' + decimal).toFixed(1).replace('.0', '') + '万亿';
    }
}

console.log(dealDigitUnit(289922234.917))
console 命令行工具 X clear

                    
>
console