From 4c9fbc4a8856fa6318e3f0f0c3e55e39a4623d8e Mon Sep 17 00:00:00 2001 From: Blizzard Date: Fri, 31 Jul 2026 15:11:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(fe+be):=20=E6=88=91=E7=9A=84=E9=A1=B5?= =?UTF-8?q?=E5=8E=BB=E9=87=8D=E5=AE=A0=E7=89=A9=E5=A2=99=20+=20=E5=85=BB?= =?UTF-8?q?=E5=AE=A0=E5=A4=A9=E6=95=B0=E6=8C=89=E5=88=B0=E5=AE=B6=E6=97=A5?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 养宠天数原来按建档日算,重新建档会被重置成 1(和首页「第869天」矛盾); 改成按最早那只的到家日算(无到家日退建档日),和首页口径一致 - 「我的」页 profile-head 传 hideWall,藏掉社交宠物墙(下面「我的毛孩子」 卡更详细,重复了);宠物墙只在别人访问/预览时出现,受「展示我的毛孩子」 开关控制,语义更对(那开关本来就是给别人看的) Co-Authored-By: Claude Opus 5 --- pets-be/internal/service/user_profile.go | 16 +++++++++++++--- pets-fe/components/profile-head/index.js | 1 + pets-fe/components/profile-head/index.wxml | 6 ++++-- pets-fe/pages/mine/mine.wxml | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/pets-be/internal/service/user_profile.go b/pets-be/internal/service/user_profile.go index 3d4ae2d..e330f2f 100644 --- a/pets-be/internal/service/user_profile.go +++ b/pets-be/internal/service/user_profile.go @@ -123,9 +123,19 @@ func (s *Service) keepStats(userID string, withPets bool) (*KeepStats, []PetCard cards = nil } - // 养宠天数按最早那只的建档日算。用建档日而不是生日:这里要表达的是 - // 「你在这个 App 上照顾它多久了」,不是宠物活了多久 - st.Days = int(time.Since(pets[0].CreatedAt).Hours()/24) + 1 + // 养宠天数按最早那只的到家日算(没填到家日就退回建档日),和首页 + // 「一起生活的第 N 天」口径一致。用建档日会因为重新建档而被重置成 1,很怪 + earliest := time.Now() + for _, p := range pets { + start := p.CreatedAt + if p.ArrivedAt != nil && !p.ArrivedAt.IsZero() { + start = *p.ArrivedAt + } + if start.Before(earliest) { + earliest = start + } + } + st.Days = int(time.Since(earliest).Hours()/24) + 1 var total int64 s.db.Model(&model.HealthRecord{}).Where("pet_id IN ?", ids).Count(&total) diff --git a/pets-fe/components/profile-head/index.js b/pets-fe/components/profile-head/index.js index e02950b..9b32445 100644 --- a/pets-fe/components/profile-head/index.js +++ b/pets-fe/components/profile-head/index.js @@ -7,6 +7,7 @@ Component({ card: { type: Object, value: null }, // 装扮页的实时预览:只看效果,不要底部那排按钮 preview: { type: Boolean, value: false }, + hideWall: { type: Boolean, value: false }, // 「我的」页藏掉社交宠物墙,避免和「我的毛孩子」卡重复 }, data: { initial: '', theme: 'warm' }, observers: { diff --git a/pets-fe/components/profile-head/index.wxml b/pets-fe/components/profile-head/index.wxml index 4507357..bc4210d 100644 --- a/pets-fe/components/profile-head/index.wxml +++ b/pets-fe/components/profile-head/index.wxml @@ -29,8 +29,10 @@ {{card.stats.streak || 0}}连续打卡 - - + diff --git a/pets-fe/pages/mine/mine.wxml b/pets-fe/pages/mine/mine.wxml index 85a0d33..f3b9ec1 100644 --- a/pets-fe/pages/mine/mine.wxml +++ b/pets-fe/pages/mine/mine.wxml @@ -3,7 +3,7 @@ -