25f655a6fc
关注之前只做了一半:能从帖子上点「+关注」,也有「关注」信息流,但 关注完就石沉大海——没有用户主页、看不到自己关注了谁、也不知道谁关注 了自己。功能是通的,路是断的。 后端新增: - 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>
40 lines
4.4 KiB
Plaintext
40 lines
4.4 KiB
Plaintext
<nav-bar title="我的" show-back="{{true}}"></nav-bar>
|
||
|
||
<scroll-view class="page-scroll" scroll-y="{{true}}" enhanced="{{true}}" show-scrollbar="{{false}}">
|
||
<view class="page-body">
|
||
<view class="profile-header">
|
||
<view class="avatar ph-avatar" bindtap="onPickAvatar">
|
||
<image wx:if="{{user.avatar_url}}" class="ph-avatar-img" src="{{user.avatar_url}}" mode="aspectFill"></image>
|
||
<block wx:else>{{pet.emoji}}</block>
|
||
<view class="ph-avatar-cam"><pt-icon name="photo" size="{{28}}"></pt-icon></view>
|
||
</view>
|
||
<view class="ph-name">{{pet.name}}</view>
|
||
<view class="muted ph-meta">{{pet.age}}|{{pet.weight}}|{{pet.stage}}</view>
|
||
<view wx:if="{{pet.breed || pet.color}}" class="muted ph-meta">{{pet.breed}}{{pet.breed && pet.color ? ' · ' : ''}}{{pet.color}}</view>
|
||
</view>
|
||
|
||
<button class="btn btn-ghost btn-block" style="margin-bottom:28rpx" bindtap="onAddPet"><pt-icon name="plus" size="{{30}}"></pt-icon>添加毛孩子</button>
|
||
|
||
<view class="profile-list">
|
||
<view class="profile-row" bindtap="onEditPet"><view class="pr-ic"><pt-icon name="user" size="{{34}}"></pt-icon></view><text class="pr-label">宠物档案(编辑)</text><text class="pr-val">已完善 {{profilePct}}%</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
<view class="profile-row" data-type="reminders" bindtap="openSheet"><view class="pr-ic"><pt-icon name="bell" size="{{34}}"></pt-icon></view><text class="pr-label">提醒设置</text><text class="pr-val">{{summary.reminders}} 条</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
<view class="profile-row" bindtap="goRecord"><view class="pr-ic"><pt-icon name="note" size="{{34}}"></pt-icon></view><text class="pr-label">健康记录</text><text class="pr-val">{{summary.records}} 条</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
<view class="profile-row" data-type="managePets" bindtap="openSheet"><view class="pr-ic"><pt-icon name="community" size="{{34}}"></pt-icon></view><text class="pr-label">多宠物管理</text><text class="pr-val">{{summary.pets}} 只</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
<view class="profile-row" data-kind="following" bindtap="goRelations"><view class="pr-ic"><pt-icon name="community" size="{{34}}"></pt-icon></view><text class="pr-label">我的关注</text><text class="pr-val">{{summary.following || 0}} 人</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
<view class="profile-row" data-kind="followers" bindtap="goRelations"><view class="pr-ic"><pt-icon name="user" size="{{34}}"></pt-icon></view><text class="pr-label">我的粉丝</text><text class="pr-val">{{summary.followers || 0}} 人</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
</view>
|
||
|
||
<view class="profile-list">
|
||
<view class="profile-row" data-type="pro" bindtap="openSheet"><view class="pr-ic"><pt-icon name="like" size="{{34}}"></pt-icon></view><text class="pr-label">会员权益</text><text class="pr-val">{{summary.pro_status === 'active' ? '已开通' : '未开通'}}</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
<view class="profile-row" data-type="exportData" bindtap="openSheet"><view class="pr-ic"><pt-icon name="doc" size="{{34}}"></pt-icon></view><text class="pr-label">数据导出</text><text class="pr-val">文本</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
<view class="profile-row" data-type="feedback" bindtap="openSheet"><view class="pr-ic"><pt-icon name="comment" size="{{34}}"></pt-icon></view><text class="pr-label">意见反馈</text><text class="pr-val">去填写</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
<view class="profile-row" data-type="about" bindtap="openSheet"><view class="pr-ic"><pt-icon name="book" size="{{34}}"></pt-icon></view><text class="pr-label">关于我们</text><text class="pr-val">v0.2</text><view class="pr-arrow"><pt-icon name="next" size="{{28}}"></pt-icon></view></view>
|
||
</view>
|
||
|
||
<button class="btn btn-ghost btn-block" data-type="pro" bindtap="openSheet">Pro 会员(即将开放)</button>
|
||
</view>
|
||
</scroll-view>
|
||
|
||
<fab bind:tap="onFab"></fab>
|
||
<bottom-sheet show="{{sheetShow}}" type="{{sheetType}}" bind:close="closeSheet"></bottom-sheet>
|