function snowId(type) {
let id = ''
let idEx = ''
let len = 4
switch (type) {
case 'building':
idEx = 'BD'
len = 4
break
case 'user':
idEx = 'US'
len = 6
break
case 'order':
idEx = 'OD'
len = 10
break
default:
break
}
let timeStampSuffix = ''
// id = 前缀 + 时间戳后缀
let timeStamp = new Date().getTime().toString()
timeStampSuffix = timeStamp.slice(timeStamp.length-1-len, timeStamp.length-1)
id = idEx + timeStampSuffix
return id
}
console.log(snowId('building'))
console.log(snowId('user'))
console.log(snowId('order'))
console