Files
sundynix-pets/pets-fe/pages/community/community.wxml
T
Blizzard 25f655a6fc feat: 补齐关注的入口——用户主页 + 关注/粉丝列表
关注之前只做了一半:能从帖子上点「+关注」,也有「关注」信息流,但
关注完就石沉大海——没有用户主页、看不到自己关注了谁、也不知道谁关注
了自己。功能是通的,路是断的。

后端新增:
- GET /api/users/:id/profile  公开资料 + 帖子/关注/粉丝三个计数 + 我是否已关注
- GET /api/users/:id/posts    TA 发布的帖子
- GET /api/users/:id/relations?kind=following|followers
- /api/user/summary 补 following / followers,否则「我的」页那两行永远是 0

关系列表里「我是否关注了这批人」用一次 IN 查询查完,不是每行一次。

小程序端新增两个页面:
- pages/user/user      用户主页:头像/昵称/三项计数/关注按钮 + TA 的帖子
- pages/relations      关注列表与粉丝列表(同一页,kind 区分)

入口:
- 社区点头像或昵称 → TA 的主页
- 主页点「关注/粉丝」数字 → 对应列表
- 「我的」页新增「我的关注」「我的粉丝」两行

关注按钮先本地翻转再发请求,失败回滚——等接口返回按钮才变会显得很迟钝。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-29 17:13:04 +08:00

63 lines
3.1 KiB
Plaintext

<wxs module="im">
module.exports.isUrl = function (s) { return s && s.indexOf('http') === 0; }
</wxs>
<nav-bar title="宠友圈"></nav-bar>
<view class="top-bar feed-bar">
<seg-tabs items="{{feedTabs}}" current="{{feedIdx}}" bind:change="switchFeedTab"></seg-tabs>
<view class="feed-post" bindtap="openSheet" data-type="createPost">
<pt-icon name="plus" size="{{28}}"></pt-icon>发布
</view>
</view>
<scroll-view class="page-scroll" scroll-y="{{true}}" scroll-into-view="{{intoView}}" bindscroll="onFeedScroll" enhanced="{{true}}" show-scrollbar="{{false}}">
<view class="page-body">
<view id="feed-top"></view>
<view wx:for="{{posts}}" wx:key="id" class="post-card" bindlongpress="onLongPressPost" data-index="{{index}}">
<view class="post-head">
<view class="post-avatar" catchtap="goUser" data-id="{{item.user_id}}">{{item.author_emoji}}</view>
<view class="post-user" catchtap="goUser" data-id="{{item.user_id}}">
<view class="pu-b">{{item.author_name}}<text wx:if="{{item.is_ai}}" class="ai-tag">AI</text></view>
<view class="pu-s">{{item.timeText}}</view>
</view>
<view wx:if="{{!item.is_self && item.user_id}}" class="follow-btn {{item.followed ? 'on' : ''}}"
catchtap="toggleFollow" data-index="{{index}}">{{item.followed ? '已关注' : '+ 关注'}}</view>
<view wx:if="{{item.tag}}" class="tag {{item.tagClass}}">{{item.tag}}</view>
</view>
<view class="post-content">{{item.content}}</view>
<view wx:if="{{item.images.length}}" class="photo-grid">
<block wx:for="{{item.images}}" wx:for-item="img" wx:key="*this">
<image wx:if="{{im.isUrl(img)}}" class="photo-tile" src="{{img}}" mode="aspectFill"></image>
<view wx:else class="photo-tile">{{img}}</view>
</block>
</view>
<view class="post-actions">
<view class="pa-btn {{item.liked ? 'liked' : ''}}" data-index="{{index}}" bindtap="likePost">
<pt-icon name="{{item.liked ? 'like-on' : 'like'}}" size="{{32}}"></pt-icon>
<text class="pa-n">{{item.like_count || '点赞'}}</text>
</view>
<view class="pa-btn" data-id="{{item.id}}" bindtap="openComments">
<pt-icon name="comment" size="{{32}}"></pt-icon>
<text class="pa-n">{{item.comment_count || '评论'}}</text>
</view>
<button class="pa-btn pa-share" open-type="share" data-content="{{item.content}}">
<pt-icon name="share" size="{{32}}"></pt-icon>
<text class="pa-n">分享</text>
</button>
</view>
</view>
<view wx:if="{{loadErr}}" class="empty lg">
{{loadErr}}
<view class="retry-btn" bindtap="loadPosts">点击重试</view>
</view>
<view wx:elif="{{loaded && posts.length === 0}}" class="empty lg">
{{feedTabs[feedIdx] === '关注' ? '还没有关注的人,去「推荐」里关注几个宠友吧 🐾' : '还没有帖子,来发第一条吧 🐾'}}
</view>
</view>
</scroll-view>
<fab bind:tap="onFab"></fab>
<bottom-sheet show="{{sheetShow}}" type="{{sheetType}}" post-id="{{sheetPostId}}"
bind:close="closeSheet" bind:posted="onPosted" bind:commented="onCommented"></bottom-sheet>