UI优化,红包领取后缺少头像,名称字段
This commit is contained in:
@@ -29,3 +29,20 @@ export const formatRMB = amount => {
|
||||
|
||||
return `${formattedInteger}.${decimal}`
|
||||
}
|
||||
|
||||
/** 积分格式化 */
|
||||
export const formatNumberWithWan = num => {
|
||||
if (num < 10000) {
|
||||
return num.toString()
|
||||
}
|
||||
|
||||
// 保留小数:根据需求可调整 toFixed 的位数
|
||||
let wan = num / 10000
|
||||
|
||||
// 如果是整数万,不显示小数;否则保留两位小数(或你想要的位数)
|
||||
if (wan % 1 === 0) {
|
||||
return wan + '万'
|
||||
} else {
|
||||
return wan.toFixed(2).replace(/\.?0+$/, '') + '万' // 去掉不必要的尾随零
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user