feat:MineView 新增个人档案字段 computed 属性
This commit is contained in:
@@ -111,6 +111,29 @@ const harmonyPercent = computed(() => {
|
|||||||
return Math.round((filled / 7) * 100) + '%'
|
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 = () => {
|
const openProfileSettings = () => {
|
||||||
uni.navigateTo({ url: '/pages/onboarding/index?edit=1' })
|
uni.navigateTo({ url: '/pages/onboarding/index?edit=1' })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user