优化:我的页面展示账号头像昵称
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
function cleanText(value) {
|
||||
return String(value || '').trim()
|
||||
}
|
||||
|
||||
function buildProfileCard(userInfo, fallbackShopName) {
|
||||
const user = userInfo || {}
|
||||
const nickname = cleanText(user.nickname) || cleanText(user.account) || '未设置昵称'
|
||||
const shopName = cleanText(user.shopName) || cleanText(fallbackShopName) || '未设置门店'
|
||||
|
||||
return {
|
||||
avatar: cleanText(user.avatar),
|
||||
avatarText: Array.from(nickname)[0] || '用',
|
||||
nickname,
|
||||
shopName
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { buildProfileCard }
|
||||
Reference in New Issue
Block a user