fix(mine): replace hardcoded user info and stats with dynamic store data
This commit is contained in:
@@ -23,11 +23,11 @@
|
||||
<view class="stats-grid">
|
||||
<view class="stat-card">
|
||||
<text class="stat-label">觉醒深度</text>
|
||||
<text class="stat-value">Lv.4</text>
|
||||
<text class="stat-value">{{ awakenLevel }}</text>
|
||||
</view>
|
||||
<view class="stat-card">
|
||||
<text class="stat-label">星历契合</text>
|
||||
<text class="stat-value">98%</text>
|
||||
<text class="stat-value">{{ harmonyPercent }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -72,13 +72,43 @@ const avatarUrl = computed(() => {
|
||||
return `https://api.dicebear.com/7.x/avataaars/svg?seed=${encodeURIComponent(seed)}&backgroundColor=b982ff`
|
||||
})
|
||||
|
||||
const displayName = computed(() => profile.value.nickname || '张义明')
|
||||
const displayName = computed(() => profile.value.nickname || '未设置昵称')
|
||||
|
||||
const metaLine = computed(() => {
|
||||
const mbti = profile.value.mbti || 'ENFJ'
|
||||
const zodiac = profile.value.zodiac || '狮子座'
|
||||
const identity = profile.value.profession || '星民'
|
||||
return `${mbti} · ${zodiac} · ${identity}`
|
||||
const mbti = profile.value.mbti
|
||||
const zodiac = profile.value.zodiac
|
||||
const identity = profile.value.profession
|
||||
if (!mbti && !zodiac && !identity) {
|
||||
return '点击设置个人档案'
|
||||
}
|
||||
return `${mbti || ''} · ${zodiac || ''} · ${identity || ''}`.replace(/(^ · | · $)/g, '').replace(/ · · /g, ' · ')
|
||||
})
|
||||
|
||||
const awakenLevel = computed(() => {
|
||||
const count = store.events?.length || 0
|
||||
if (count >= 10) return 'Lv.5'
|
||||
if (count >= 6) return 'Lv.4'
|
||||
if (count >= 3) return 'Lv.3'
|
||||
if (count >= 1) return 'Lv.2'
|
||||
return 'Lv.1'
|
||||
})
|
||||
|
||||
const harmonyPercent = computed(() => {
|
||||
const hasLifeStory = profile.value.childhood?.text ||
|
||||
profile.value.joy?.text ||
|
||||
profile.value.low?.text ||
|
||||
profile.value.future?.ideal
|
||||
const fields = [
|
||||
profile.value.nickname,
|
||||
profile.value.gender,
|
||||
profile.value.zodiac,
|
||||
profile.value.mbti,
|
||||
profile.value.profession,
|
||||
profile.value.hobbies?.length,
|
||||
hasLifeStory
|
||||
]
|
||||
const filled = fields.filter(Boolean).length
|
||||
return Math.round((filled / 7) * 100) + '%'
|
||||
})
|
||||
|
||||
const openProfileSettings = () => {
|
||||
|
||||
Reference in New Issue
Block a user