From 10653edc52c319985c29585751795b1efa4c5e3f Mon Sep 17 00:00:00 2001 From: Peanut Date: Thu, 4 Jun 2026 00:40:11 +0800 Subject: [PATCH] fix(mine): replace hardcoded user info and stats with dynamic store data --- mini-program/src/pages/main/MineView.vue | 44 ++++++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/mini-program/src/pages/main/MineView.vue b/mini-program/src/pages/main/MineView.vue index 719f328..a928024 100644 --- a/mini-program/src/pages/main/MineView.vue +++ b/mini-program/src/pages/main/MineView.vue @@ -23,11 +23,11 @@ 觉醒深度 - Lv.4 + {{ awakenLevel }} 星历契合 - 98% + {{ harmonyPercent }} @@ -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 = () => {