feat:MineView 新增个人档案字段 computed 属性

This commit is contained in:
2026-06-15 10:49:11 +08:00
parent 83d3f87cf6
commit d1e223ad23
+23
View File
@@ -111,6 +111,29 @@ const harmonyPercent = computed(() => {
return Math.round((filled / 7) * 100) + '%'
})
const genderText = computed(() => {
const map = { male: '男', female: '女', other: '其他' }
return map[profile.value.gender] || null
})
const age = computed(() => {
const birthday = profile.value.birthday
if (!birthday) return null
const birthYear = Number(String(birthday).slice(0, 4))
if (!birthYear) return null
return new Date().getFullYear() - birthYear
})
const hobbyText = computed(() => {
const hobbies = profile.value.hobbies
if (Array.isArray(hobbies) && hobbies.length) return hobbies.slice(0, 4).join(' · ')
return null
})
const goEditProfile = () => {
uni.navigateTo({ url: '/pages/onboarding/index?edit=1' })
}
const openProfileSettings = () => {
uni.navigateTo({ url: '/pages/onboarding/index?edit=1' })
}