feat: MBTI头像与用户规则链路升级,三端页面与接口同步

Made-with: Cursor
This commit is contained in:
卡若
2026-03-24 01:22:50 +08:00
parent fa3da12b16
commit 1d56d0336c
71 changed files with 3848 additions and 1621 deletions

View File

@@ -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 })
},
// 退出登录

View File

@@ -22,7 +22,7 @@
<view class="profile-top-row">
<view class="avatar-wrap" bindtap="tapAvatar">
<view class="avatar-inner {{isVip ? 'avatar-vip' : ''}}">
<image wx:if="{{userInfo.avatar && userInfo.avatar.length > 5}}" class="avatar-img" src="{{userInfo.avatar}}" mode="aspectFill"/>
<image wx:if="{{profileAvatarDisplay}}" class="avatar-img" src="{{profileAvatarDisplay}}" mode="aspectFill"/>
<text wx:else class="avatar-text">{{userInfo.nickname ? userInfo.nickname[0] : '?'}}</text>
</view>
<view class="vip-badge" wx:if="{{isVip}}">VIP</view>
@@ -32,7 +32,7 @@
<view class="profile-name-row">
<text class="user-name" bindtap="editNickname">{{userInfo.nickname || '点击设置昵称'}}</text>
</view>
<view class="profile-actions-row" wx:if="{{!auditMode}}">
<view class="profile-actions-row profile-actions-under-name" wx:if="{{!auditMode}}">
<view class="profile-action-btn" catchtap="goToMySuperCard">{{mpUiCardLabel}}</view>
<view class="profile-action-btn" catchtap="goToVip">{{isVip ? mpUiVipLabelVip : mpUiVipLabelGuest}}</view>
</view>
@@ -43,7 +43,7 @@
<text class="profile-stat-val">{{readCountText || '0'}}</text>
<text class="profile-stat-label">{{mpUiReadStatLabel}}</text>
</view>
<view class="profile-stat" wx:if="{{referralEnabled}}" bindtap="goToReferral">
<view class="profile-stat" wx:if="{{referralEnabled}}" bindtap="goToReferral" data-focus="bindings">
<text class="profile-stat-val">{{referralCount}}</text>
<text class="profile-stat-label">推荐好友</text>
</view>
@@ -51,7 +51,7 @@
<text class="profile-stat-val">{{matchHistoryText}}</text>
<text class="profile-stat-label">匹配伙伴</text>
</view>
<view class="profile-stat" wx:if="{{!auditMode}}" bindtap="goToReferral">
<view class="profile-stat" wx:if="{{!auditMode}}" bindtap="goToReferral" data-focus="earnings">
<text class="profile-stat-val">{{pendingEarnings || '0.00'}}</text>
<text class="profile-stat-label">我的收益</text>
</view>

View File

@@ -79,6 +79,8 @@
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.profile-actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12rpx; }
/* 名片/会员中心:紧挨昵称下方(在 profile-meta 内) */
.profile-actions-under-name { margin-top: 4rpx; }
/* 名片 / 会员中心:统一品牌青,与 tabBar 选中色一致 */
.profile-action-btn {
padding: 12rpx 28rpx; border: 2rpx solid #4FD1C5; color: #4FD1C5;