UI优化:我的页面和设置页面

1. 我的页面:
   - 头像可点击修改(支持修改头像和昵称)
   - 用户ID截短显示
   - 创业伙伴标签移到用户名旁边,不再拥挤
   - 整体布局更加舒适

2. 设置页面:
   - 去掉"联系客服"
   - 去掉"清除缓存"
   - 去掉"当前版本"
   - 只保留账号绑定和退出登录
This commit is contained in:
卡若
2026-01-29 11:20:12 +08:00
parent 395501e961
commit 8b2c3f4661
4 changed files with 188 additions and 45 deletions

View File

@@ -73,9 +73,14 @@ Page({
title: `章节 ${id}`
}))
// 截短用户ID显示
const userId = userInfo.id || ''
const userIdShort = userId.length > 20 ? userId.slice(0, 10) + '...' + userId.slice(-6) : userId
this.setData({
isLoggedIn: true,
userInfo,
userIdShort,
purchasedCount: hasFullBook ? this.data.totalSections : (purchasedSections?.length || 0),
referralCount: userInfo.referralCount || 0,
earnings: userInfo.earnings || 0,
@@ -87,6 +92,7 @@ Page({
this.setData({
isLoggedIn: false,
userInfo: null,
userIdShort: '',
purchasedCount: 0,
referralCount: 0,
earnings: 0,
@@ -95,6 +101,77 @@ Page({
})
}
},
// 编辑用户资料(头像和昵称)
editProfile() {
wx.showActionSheet({
itemList: ['修改头像', '修改昵称'],
success: (res) => {
if (res.tapIndex === 0) {
this.chooseAvatar()
} else if (res.tapIndex === 1) {
this.editNickname()
}
}
})
},
// 选择头像
chooseAvatar() {
wx.chooseMedia({
count: 1,
mediaType: ['image'],
sourceType: ['album', 'camera'],
success: async (res) => {
const tempFilePath = res.tempFiles[0].tempFilePath
wx.showLoading({ title: '上传中...', mask: true })
try {
// 更新本地显示
const userInfo = this.data.userInfo
userInfo.avatar = tempFilePath
this.setData({ userInfo })
app.globalData.userInfo = userInfo
wx.setStorageSync('userInfo', userInfo)
// TODO: 上传到服务器
wx.hideLoading()
wx.showToast({ title: '头像已更新', icon: 'success' })
} catch (e) {
wx.hideLoading()
wx.showToast({ title: '上传失败', icon: 'none' })
}
}
})
},
// 修改昵称
editNickname() {
wx.showModal({
title: '修改昵称',
editable: true,
placeholderText: '请输入新昵称',
success: async (res) => {
if (res.confirm && res.content) {
const newNickname = res.content.trim()
if (newNickname.length < 1 || newNickname.length > 20) {
wx.showToast({ title: '昵称1-20个字符', icon: 'none' })
return
}
// 更新本地
const userInfo = this.data.userInfo
userInfo.nickname = newNickname
this.setData({ userInfo })
app.globalData.userInfo = userInfo
wx.setStorageSync('userInfo', userInfo)
// TODO: 上传到服务器
wx.showToast({ title: '昵称已更新', icon: 'success' })
}
}
})
},
// 切换Tab
switchTab(e) {