Initial commit

This commit is contained in:
2026-06-05 17:46:51 +08:00
commit c04c890186
96 changed files with 6477 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
const app = getApp<{ userInfo: any }>()
Page({
data: {
statusBarHeight: 0,
form: { nickName: '', bio: '', location: '' },
},
onLoad() {
const info = wx.getSystemInfoSync()
this.setData({ statusBarHeight: info.statusBarHeight })
const user = app.globalData?.userInfo
if (user) {
this.setData({
form: { nickName: user.nickName || '', bio: user.bio || '', location: user.location || '' },
})
}
},
onField(e: WechatMiniprogram.CustomEvent) {
this.setData({ [`form.${e.currentTarget.dataset.key}`]: e.detail.value })
},
async onSave() {
const { form } = this.data
if (!form.nickName.trim()) {
wx.showToast({ title: '昵称不能为空', icon: 'none' })
return
}
wx.showLoading({ title: '保存中...' })
try {
await wx.cloud.callFunction({ name: 'updateProfile', data: form })
if (app.globalData.userInfo) {
Object.assign(app.globalData.userInfo, form)
}
wx.hideLoading()
wx.showToast({ title: '保存成功', icon: 'success' })
setTimeout(() => wx.navigateBack(), 800)
} catch {
wx.hideLoading()
wx.showToast({ title: '保存失败', icon: 'none' })
}
},
onBack() { wx.navigateBack() },
})