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:
@@ -1,22 +1,45 @@
|
||||
const app = getApp<{ userInfo: any }>()
|
||||
import { AppGlobalData } from '../../types/index'
|
||||
|
||||
const PROVINCES = [
|
||||
'北京', '天津', '上海', '重庆',
|
||||
'河北', '山西', '辽宁', '吉林', '黑龙江',
|
||||
'江苏', '浙江', '安徽', '福建', '江西', '山东',
|
||||
'河南', '湖北', '湖南', '广东', '海南',
|
||||
'四川', '贵州', '云南', '陕西', '甘肃', '青海',
|
||||
'内蒙古', '广西', '西藏', '宁夏', '新疆',
|
||||
'香港', '澳门', '台湾',
|
||||
]
|
||||
|
||||
const app = getApp<{ globalData: AppGlobalData }>()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 0,
|
||||
navbarHeight: 44,
|
||||
navbarPaddingRight: 0,
|
||||
form: { nickName: '', bio: '', location: '' },
|
||||
provinces: PROVINCES,
|
||||
locationIndex: -1,
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
const info = wx.getSystemInfoSync()
|
||||
this.setData({ statusBarHeight: info.statusBarHeight })
|
||||
const { statusBarHeight, navbarHeight, navbarPaddingRight } = app.globalData.navBarInfo
|
||||
this.setData({ statusBarHeight, navbarHeight, navbarPaddingRight })
|
||||
const user = app.globalData?.userInfo
|
||||
if (user) {
|
||||
const locationIndex = PROVINCES.indexOf(user.location || '')
|
||||
this.setData({
|
||||
form: { nickName: user.nickName || '', bio: user.bio || '', location: user.location || '' },
|
||||
locationIndex,
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onLocationChange(e: WechatMiniprogram.CustomEvent) {
|
||||
const idx = Number(e.detail.value)
|
||||
this.setData({ locationIndex: idx, 'form.location': PROVINCES[idx] })
|
||||
},
|
||||
|
||||
onField(e: WechatMiniprogram.CustomEvent) {
|
||||
this.setData({ [`form.${e.currentTarget.dataset.key}`]: e.detail.value })
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<view class="page">
|
||||
<view class="safe-top" style="height: {{statusBarHeight}}px"></view>
|
||||
<view class="nav">
|
||||
<view class="nav" style="height: {{navbarHeight}}px; padding-right: {{navbarPaddingRight}}px; box-sizing: border-box;">
|
||||
<view class="nav-back" bindtap="onBack">取消</view>
|
||||
<view class="nav-title">编辑资料</view>
|
||||
<view class="nav-save" bindtap="onSave">保存</view>
|
||||
@@ -17,8 +17,12 @@
|
||||
<textarea class="field-textarea" value="{{form.bio}}" bindinput="onField" data-key="bio" placeholder="介绍一下你和你的宠物..." maxlength="80" auto-height="true" show-confirm-bar="false" />
|
||||
</view>
|
||||
<view class="field-item">
|
||||
<text class="field-label">所在城市</text>
|
||||
<input class="field-input" value="{{form.location}}" bindinput="onField" data-key="location" placeholder="所在城市" maxlength="20" />
|
||||
<text class="field-label">所在省份</text>
|
||||
<picker mode="selector" range="{{provinces}}" value="{{locationIndex}}" bindchange="onLocationChange">
|
||||
<view class="field-picker-val {{locationIndex < 0 ? 'placeholder' : ''}}">
|
||||
{{locationIndex >= 0 ? provinces[locationIndex] : '请选择省份'}}
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
<view style="height: 60rpx;"></view>
|
||||
|
||||
@@ -11,3 +11,5 @@
|
||||
.field-label { font-size: 28rpx; font-weight: 700; color: #272235; flex-shrink: 0; margin-right: 20rpx; }
|
||||
.field-input { flex: 1; font-size: 28rpx; color: #272235; text-align: right; }
|
||||
.field-textarea { width: 100%; min-height: 80rpx; font-size: 28rpx; color: #272235; line-height: 1.6; }
|
||||
.field-picker-val { flex: 1; font-size: 28rpx; color: #272235; text-align: right; }
|
||||
.field-picker-val.placeholder { color: #c4b8d0; }
|
||||
|
||||
Reference in New Issue
Block a user