feat: MBTI头像与用户规则链路升级,三端页面与接口同步
Made-with: Cursor
This commit is contained in:
@@ -20,6 +20,8 @@ Page({
|
||||
// 用户状态
|
||||
isLoggedIn: false,
|
||||
userInfo: null,
|
||||
/** 我的页头像展示:微信头像或 MBTI 映射图 */
|
||||
profileAvatarDisplay: '',
|
||||
|
||||
// 统计数据
|
||||
totalSections: 62,
|
||||
@@ -142,6 +144,16 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
async _refreshMyAvatarDisplay(safeUser) {
|
||||
if (!safeUser || !app.globalData.isLoggedIn) return
|
||||
try {
|
||||
if (app.loadMbtiAvatarsMap) await app.loadMbtiAvatarsMap()
|
||||
} catch (_) {}
|
||||
const url = app.resolveAvatarWithMbti ? app.resolveAvatarWithMbti(safeUser.avatar, safeUser.mbti) : ''
|
||||
if (!this.data.isLoggedIn) return
|
||||
this.setData({ profileAvatarDisplay: url || '' })
|
||||
},
|
||||
|
||||
async loadFeatureConfig() {
|
||||
try {
|
||||
const res = await app.getConfig()
|
||||
@@ -150,8 +162,9 @@ Page({
|
||||
const referralEnabled = features.referralEnabled !== false
|
||||
const searchEnabled = features.searchEnabled !== false
|
||||
const mp = (res && res.mpConfig) || {}
|
||||
const auditMode = !!mp.auditMode
|
||||
app.globalData.auditMode = auditMode
|
||||
app.globalData.auditMode = !!mp.auditMode
|
||||
await app.getAuditMode()
|
||||
const auditMode = app.globalData.auditMode || false
|
||||
app.globalData.features = { matchEnabled, referralEnabled, searchEnabled }
|
||||
this.setData({ matchEnabled, referralEnabled, searchEnabled, auditMode })
|
||||
this._applyMyMpUiLabels()
|
||||
@@ -181,10 +194,11 @@ Page({
|
||||
this.setData({
|
||||
isLoggedIn: true,
|
||||
userInfo: safeUser,
|
||||
profileAvatarDisplay: '',
|
||||
userIdShort,
|
||||
userWechat,
|
||||
readCount: 0,
|
||||
referralCount: userInfo.referralCount || 0,
|
||||
referralCount: 0,
|
||||
earnings: '-',
|
||||
pendingEarnings: '-',
|
||||
earningsLoading: true,
|
||||
@@ -200,12 +214,14 @@ Page({
|
||||
this.loadPendingConfirm()
|
||||
this.loadVipStatus()
|
||||
this.loadWalletBalance()
|
||||
this._refreshMyAvatarDisplay(safeUser)
|
||||
} else {
|
||||
const guestReadCount = app.getReadCount()
|
||||
const guestRecent = this._mergeRecentChaptersFromLocal([])
|
||||
this.setData({
|
||||
isLoggedIn: false,
|
||||
userInfo: null,
|
||||
profileAvatarDisplay: '',
|
||||
userIdShort: '',
|
||||
readCount: guestReadCount,
|
||||
readCountText: formatStatNum(guestReadCount),
|
||||
@@ -644,6 +660,7 @@ Page({
|
||||
const userInfo = this.data.userInfo
|
||||
userInfo.avatar = avatarUrl
|
||||
this.setData({ userInfo })
|
||||
this._refreshMyAvatarDisplay(userInfo)
|
||||
app.globalData.userInfo = userInfo
|
||||
wx.setStorageSync('userInfo', userInfo)
|
||||
|
||||
@@ -689,9 +706,9 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 点击昵称:跳转资料编辑页(type="nickname" 在弹窗内无法触发微信昵称选择器,需在主页面)
|
||||
// 点击昵称:先进个人资料名片页,再在右上角进入编辑(与需求「编辑收进名片流」一致)
|
||||
editNickname() {
|
||||
wx.navigateTo({ url: '/pages/profile-edit/profile-edit' })
|
||||
wx.navigateTo({ url: '/pages/profile-show/profile-show' })
|
||||
},
|
||||
|
||||
// 关闭昵称弹窗
|
||||
@@ -916,14 +933,17 @@ Page({
|
||||
},
|
||||
|
||||
// 跳转到推广中心(需登录)
|
||||
goToReferral() {
|
||||
trackClick('my', 'nav_click', '推广中心')
|
||||
goToReferral(e) {
|
||||
const focus = e && e.currentTarget && e.currentTarget.dataset ? (e.currentTarget.dataset.focus || '') : ''
|
||||
const action = focus === 'bindings' ? '推荐好友' : focus === 'earnings' ? '我的收益' : '推广中心'
|
||||
trackClick('my', 'nav_click', action)
|
||||
if (!this.data.isLoggedIn) {
|
||||
this.showLogin()
|
||||
return
|
||||
}
|
||||
if (!this.data.referralEnabled) return
|
||||
wx.navigateTo({ url: '/pages/referral/referral' })
|
||||
const url = focus ? `/pages/referral/referral?focus=${focus}` : '/pages/referral/referral'
|
||||
wx.navigateTo({ url })
|
||||
},
|
||||
|
||||
// 退出登录
|
||||
|
||||
Reference in New Issue
Block a user