fix: 修复评论/资料/导航胶囊/宠物档案/定位等多处问题,补全相关云函数

- 新增 addComment/getComments/getFollowList/followUser/getUser/updateProfile/updatePet/deletePet 云函数并完成部署
- 统一通过 app.globalData.navBarInfo 避让系统胶囊按钮(编辑资料/编辑宠物等页面保存按钮被遮挡问题)
- 编辑资料页所在城市改为省份 picker 选择
- 修复"我的"页动态为空(getUserPosts 应传 openid 而非数据库 _id)
- 重构编辑宠物页:品种改用 picker 滚轮(替代有数量上限的 actionSheet),标签改用 selectedTagSet 映射 + 自定义标签输入(5字以内、仅中英文/数字、最多8个)
- 接通宠物保存/删除真实云函数调用并同步本地缓存
- 移除 feed 页对不存在的 getStories 云函数调用,修复模拟器卡死
- 移除 post 页对不存在的 wx.reverseGeocoder API 的调用
- 统一扩展 AppGlobalData 类型并修正所有 getApp 调用的泛型,解决 TS 报错
This commit is contained in:
2026-06-07 15:59:21 +08:00
parent 24891d9004
commit 3d21a9d297
49 changed files with 937 additions and 195 deletions

View File

@@ -1,12 +1,14 @@
import { Post } from '../../types/index'
import { Post, AppGlobalData } from '../../types/index'
import { api } from '../../utils/api'
import { getAvatarGradient, getPetEmoji, formatCount } from '../../utils/format'
const app = getApp<{ userInfo: any; isLoggedIn: boolean }>()
const app = getApp<{ globalData: AppGlobalData }>()
Page({
data: {
statusBarHeight: 0,
navbarHeight: 44,
navbarPaddingRight: 0,
tabBarHeight: 56,
userInfo: {
nickName: '',
@@ -26,7 +28,13 @@ Page({
onLoad() {
const info = wx.getSystemInfoSync()
this.setData({ statusBarHeight: info.statusBarHeight })
const { statusBarHeight, navbarHeight, navbarPaddingRight } = app.globalData.navBarInfo
this.setData({
statusBarHeight,
navbarHeight,
navbarPaddingRight,
tabBarHeight: info.windowHeight - (info.safeArea?.bottom ?? info.windowHeight) + 56,
})
this.loadProfile()
},
@@ -59,7 +67,7 @@ Page({
try {
const [_user, postsRes] = await Promise.all([
api.getUserProfile(app.globalData?.userInfo?._id || '').catch(() => null),
api.getUserPosts(app.globalData?.userInfo?._id || '').catch(() => ({ list: [], total: 0 })),
api.getUserPosts(app.globalData?.userInfo?.openid || '').catch(() => ({ list: [], total: 0 })),
])
if (_user) {
app.globalData.userInfo = _user

View File

@@ -1,5 +1,12 @@
<view class="profile-page">
<view class="safe-top" style="height: {{statusBarHeight}}px"></view>
<!-- 状态栏占位 -->
<view style="height: {{statusBarHeight}}px; flex-shrink: 0;"></view>
<!-- 主导航栏:与胶囊等高,右侧避让胶囊,放置设置按钮 -->
<view class="navbar" style="height: {{navbarHeight}}px; padding-right: {{navbarPaddingRight}}px;">
<view class="navbar-title">我的</view>
<view class="settings-btn" bindtap="onSettings">⚙️</view>
</view>
<scroll-view
scroll-y="true"
@@ -10,12 +17,8 @@
bindrefresherrefresh="onRefresh"
refresher-triggered="{{refreshing}}"
>
<!-- 用户信息区 -->
<!-- 用户信息区(移除原来的 header-topbar已移至 navbar-->
<view class="profile-header">
<!-- 头部操作栏 -->
<view class="header-topbar">
<view class="settings-btn" bindtap="onSettings">⚙️</view>
</view>
<!-- 头像 + 基本信息 -->
<view class="user-top">

View File

@@ -1,20 +1,24 @@
.profile-page {
min-height: 100vh;
background: linear-gradient(180deg, #fff8f2 0%, #fff4fb 50%, #f5f0ff 100%);
}
.profile-scroll { min-height: 100vh; }
/* 用户信息区 */
.profile-header {
padding: 0 28rpx 28rpx;
background: linear-gradient(180deg, rgba(255, 225, 90, 0.18), transparent);
}
.header-topbar {
display: flex;
justify-content: flex-end;
padding: 16rpx 0 12rpx;
flex-direction: column;
}
/* 主导航栏:与胶囊等高,右侧避让胶囊 */
.navbar {
display: flex;
align-items: center;
justify-content: space-between;
padding-left: 28rpx;
flex-shrink: 0;
box-sizing: border-box;
}
.navbar-title {
font-size: 36rpx;
font-weight: 900;
color: #272235;
}
.settings-btn {
@@ -29,6 +33,14 @@
font-size: 30rpx;
}
.profile-scroll { flex: 1; }
/* 用户信息区 */
.profile-header {
padding: 16rpx 28rpx 28rpx;
background: linear-gradient(180deg, rgba(255, 225, 90, 0.18), transparent);
}
.user-top {
display: flex;
align-items: flex-start;