function getAccountArgs (uAccount) {
let aArgs = uAccount.split('@')
let aEx = ''
let aSuffix = ''
if (aArgs.length >= 2 && aArgs[1] !== '') {
aArgs.map((item, index) => {
if (index < (aArgs.length - 1)) {
aEx = aEx + item + '@'
} else {
return false
}
})
aSuffix = aArgs[aArgs.length - 1]
} else {
aEx = aArgs[0]
}
let AccountArgs = []
AccountArgs[0] = aEx
AccountArgs[1] = aSuffix
return AccountArgs
}
// 账号转邮箱
function emailTransition (uAccount) {
let email = ''
let emailRules = [
{
accountSuffix: 'hq.cmcc',
emailSuffix: 'chinamobile.com'
},
{
accountSuffix: 'di.cmcc',
emailSuffix: 'cmdi.chinamobile.com'
},
{
accountSuffix: 'mg.cmcc',
emailSuffix: 'migu.chinamobile.com'
},
{
accountSuffix: 'ECO_COMPANY.cmcc',
emailSuffix: 'aspirecn.com'
}
]
// 其他 之后的.cmcc替换为.chinamobile.com
let uAccountArgs = getAccountArgs(uAccount)
console.log('1', uAccountArgs)
let uAccountEx = uAccountArgs[0]
let uAccountSuffix = uAccountArgs[1]
let flag = false
emailRules.map(rule => {
if (uAccountSuffix === rule.accountSuffix) {
email = uAccountEx + rule.emailSuffix
console.log('2', email)
flag = true
return true
}
})
console.log('3', flag, uAccountEx)
if (!flag && uAccountEx !== '') {
email = uAccountSuffix === '' ? uAccountEx + '@chinamobile.com' : uAccountEx + uAccountSuffix.replace('cmcc', 'chinamobile.com')
}
return email
}
let u = 'yaojinbao@bj.cmcc'
console.log(emailTransition(u))
console