feat(wish-tree): 许愿树页面微调七项
1. 背景图 aspectFill 撑满全屏,挂载点坐标按裁剪比例重算,便签不再落在图外 2. 写下心愿按钮单行不换行,缩小尺寸 3. 移除页面内许愿树标题/数量/最近心愿,点击便签弹出便签式详情卡 4. 默认请求100条:最新50条挂树,其余以弹幕形式缓缓飘过 5. MAKE A WISH 下方增加顶级位置轮播(购买后24小时内展示),点击弹出金色便签详情,与普通便签区分 6. 多棵树分屏轮播(swiper),背景图从服务器获取,带指示点 7. 后端:WishTree新增image字段,Wish新增isTop运行时标记,图片用go:embed内嵌随二进制部署,/images路由提供访问
This commit is contained in:
@@ -97,15 +97,21 @@ func (s *WishService) CreateWish(wish *model.Wish) error {
|
||||
return s.db.Create(wish).Error
|
||||
}
|
||||
|
||||
// GetTreeWishes 获取指定树的许愿列表
|
||||
// GetTreeWishes 获取指定树的许愿列表(最新100条,标记顶级位置)
|
||||
func (s *WishService) GetTreeWishes(treeID uint) ([]*model.Wish, error) {
|
||||
var wishes []*model.Wish
|
||||
if err := s.db.Where("tree_id = ? AND status = 1", treeID).
|
||||
Order("position DESC, created_at DESC").
|
||||
Order("created_at DESC").
|
||||
Limit(100).
|
||||
Find(&wishes).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 计算顶级位置:高位置付费许愿且购买后24小时内
|
||||
for _, w := range wishes {
|
||||
w.IsTop = w.Position >= 100 && time.Since(w.CreatedAt) <= 24*time.Hour
|
||||
}
|
||||
|
||||
return wishes, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user