全面优化:小程序 + 后台管理

## 小程序优化
1. 我的页面:
   - 头像点击获取微信头像(button open-type="chooseAvatar")
   - 昵称点击直接修改
   - 去掉"创业伙伴"图标
   - ID优先显示微信号

2. 设置页面:
   - 一键获取微信手机号
   - 微信号/支付宝绑定优化

## 后台管理优化
1. 内容管理:
   - 章节编辑增加"免费章节"开关
   - 保存时自动去重标题(如#1.2重复)

2. 用户管理:
   - 修复绑定关系显示(优先查referral_bindings表)
This commit is contained in:
卡若
2026-01-29 11:58:07 +08:00
parent a228911170
commit d17150154c
8 changed files with 199 additions and 182 deletions

View File

@@ -206,8 +206,10 @@ Page({
}
},
// 获取微信手机号(需要button组件配合
async getPhoneNumber(e) {
// 一键获取微信手机号button组件回调
async onGetPhoneNumber(e) {
console.log('[Settings] 获取手机号回调:', e.detail)
if (e.detail.errMsg !== 'getPhoneNumber:ok') {
wx.showToast({ title: '授权失败', icon: 'none' })
return
@@ -217,30 +219,44 @@ Page({
// 需要将code发送到服务器解密获取手机号
const code = e.detail.code
if (!code) {
wx.showToast({ title: '获取失败,请手动输入', icon: 'none' })
// 如果没有code弹出手动输入
this.bindPhone()
return
}
wx.showLoading({ title: '获取中...', mask: true })
// 调用服务器解密手机号
const res = await app.request('/api/wechat/phone', {
const res = await app.request('/api/miniprogram/phone', {
method: 'POST',
data: { code }
})
wx.hideLoading()
if (res.success && res.phoneNumber) {
wx.setStorageSync('user_phone', res.phoneNumber)
this.setData({ phoneNumber: res.phoneNumber })
// 更新用户信息
if (app.globalData.userInfo) {
app.globalData.userInfo.phone = res.phoneNumber
wx.setStorageSync('userInfo', app.globalData.userInfo)
}
// 同步到服务器
this.syncProfileToServer()
wx.showToast({ title: '手机号绑定成功', icon: 'success' })
} else {
wx.showToast({ title: '获取失败,手动输入', icon: 'none' })
// 获取失败,弹出手动输入
this.bindPhone()
}
} catch (e) {
wx.hideLoading()
console.log('[Settings] 获取手机号失败:', e)
wx.showToast({ title: '获取失败,手动输入', icon: 'none' })
// 获取失败,弹出手动输入
this.bindPhone()
}
},