SOURCE

let phones = '幺鸡'
let uniCodeArr = [
    { code: '\u96f6', num: 0 },
    { code: '\u4e00', num: 1 },
    { code: '\u5e7a', num: 1 },
    { code: '\u4e8c', num: 2 },
    { code: '\u4e09', num: 3 },
    { code: '\u56db', num: 4 },
    { code: '\u4e94', num: 5 },
    { code: '\u516d', num: 6 },
    { code: '\u4e03', num: 7 },
    { code: '\u516b', num: 8 },
    { code: '\u4e5d', num: 9 },
    { code: '\u5341', num: 10 },
]
let resPhones = ''
uniCodeArr.forEach((item, index) => {
    let rules = new RegExp(item.code, 'g');
    if (index === 0) {
        resPhones = phones.replace(rules, item.num)
    }else {
        resPhones = resPhones.replace(rules, item.num)
    }
})
let num = resPhones.replace(/[^0-9]/ig,"");

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

                    
>
console