新增置顶人功能,允许在小程序首页展示特定用户信息(昵称、头像)。更新相关 API 接口以支持获取和设置置顶人,优化用户体验。调整小程序页面以动态显示置顶人信息,确保一致性和可用性。

This commit is contained in:
Alex-larget
2026-03-20 15:58:18 +08:00
parent f7e7552eb1
commit 1b87fa92f7
12 changed files with 389 additions and 30 deletions

View File

@@ -85,6 +85,8 @@ App({
lastVipContactCheck: 0,
// 头像昵称检测上次检测时间戳onShow 节流 5 分钟
lastAvatarNicknameCheck: 0,
// 登录过期401 后用户点「去登录」时设为 true我的页 onShow 会检测并自动弹登录
pendingLoginAfterExpire: false,
},
@@ -875,7 +877,29 @@ App({
}
if (res.statusCode === 401) {
this.logout()
showError('未授权,请重新登录')
if (!silent) {
wx.showModal({
title: '登录已过期',
content: '请重新登录后继续使用',
confirmText: '去登录',
cancelText: '稍后',
success: (modalRes) => {
if (modalRes.confirm) {
const pages = getCurrentPages()
const cur = pages[pages.length - 1]
const route = (cur && cur.route) || ''
if (route === 'pages/my/my' && typeof cur.showLogin === 'function') {
cur.showLogin()
} else {
this.globalData.pendingLoginAfterExpire = true
wx.switchTab({ url: '/pages/my/my' })
}
}
}
})
} else {
showError('未授权,请重新登录')
}
reject(new Error('未授权'))
return
}

View File

@@ -135,7 +135,7 @@ Component({
'run-in': '\ue6a7',
'pin': '\ue6a8',
'save': '\ue6a9',
'search': '\ue6aa',
'search': '', // 强制走 SVG
'share': '\ue6ab',
'scanning': '\ue6ac',
'security': '\ue6ad',
@@ -157,19 +157,19 @@ Component({
'chevron-right': '\ue6c6',
'chevron-down': '\ue6c4',
'chevron-up': '\ue6c2',
'x': '\ue6c3',
'check': '\ue6c7',
'x': '', // 强制走 SVG
'check': '', // 强制走 SVG
'trash-2': '\ue66a',
'pencil': '\ue685',
'zap': '\ue75c',
'zap': '', // 强制走 SVG找伙伴页等统一用 Lucide 风格
'info': '\ue69c',
'map-pin': '\ue6a8',
'message-circle': '\ue678',
'smartphone': '\ue6a0',
'message-circle': '', // 强制走 SVG
'smartphone': '', // 强制走 SVG
'refresh-cw': '\ue6a4',
'shield': '\ue6ad',
'star': '\ue689',
'heart': '\ue68e',
'star': '', // 强制走 SVG
'heart': '', // 强制走 SVG
'bar-chart': '\ue672',
'clock': '\ue6b5',
}
@@ -224,7 +224,9 @@ Component({
'corner-down-left': s + '<polyline points="9 10 4 15 9 20"/><path d="M20 4v7a4 4 0 0 1-4 4H4"/></svg>',
'folder': s + '<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/><line x1="12" y1="11" x2="12" y2="17"/></svg>',
'bar-chart': s + '<line x1="12" y1="20" x2="12" y2="10"/><line x1="18" y1="20" x2="18" y2="4"/><line x1="6" y1="20" x2="6" y2="16"/></svg>',
'link': s + '<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>'
'link': s + '<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>',
'zap': s + '<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>',
'x': s + '<path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>'
}
return svgMap[name] || ''
},

View File

@@ -73,7 +73,10 @@ Page({
searchEnabled: true,
// 审核模式:隐藏支付相关入口
auditMode: false
auditMode: false,
// 置顶人(链接人与事,管理端设置,小程序首页展示)
pinnedPerson: null // { nickname, avatar, token } 或 null
},
onLoad(options) {
@@ -98,7 +101,10 @@ Page({
onShow() {
console.log('[Index] onShow 触发')
const app = getApp()
this.setData({ auditMode: app.globalData.auditMode || false })
// 每次展示时刷新置顶人(管理端可能已更换置顶)
this.loadPinnedPerson()
// 设置TabBar选中状态
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
@@ -131,6 +137,21 @@ Page({
this.loadBookData()
this.loadFeaturedAndLatest()
this.loadSuperMembers()
this.loadPinnedPerson()
},
async loadPinnedPerson() {
const app = getApp()
try {
const res = await app.request({ url: '/api/miniprogram/ckb/pinned-person', silent: true })
if (res && res.success && res.data) {
this.setData({ pinnedPerson: res.data })
} else {
this.setData({ pinnedPerson: null })
}
} catch (e) {
this.setData({ pinnedPerson: null })
}
},
async loadSuperMembers() {

View File

@@ -18,8 +18,8 @@
</view>
<view class="header-right">
<view class="contact-btn" bindtap="onLinkKaruo">
<image class="contact-avatar" src="/assets/images/author-avatar.png" mode="aspectFill"/>
<text class="contact-text">点击链接卡若</text>
<image class="contact-avatar" src="{{pinnedPerson && pinnedPerson.avatar ? pinnedPerson.avatar : '/assets/images/author-avatar.png'}}" mode="aspectFill"/>
<text class="contact-text">点击链接{{pinnedPerson && pinnedPerson.nickname ? pinnedPerson.nickname : '卡若'}}</text>
</view>
</view>
</view>

View File

@@ -107,6 +107,11 @@ Page({
}
}
this.initUserStatus()
// 登录过期后用户点「去登录」跳转过来,自动弹出登录弹窗
if (app.globalData.pendingLoginAfterExpire) {
app.globalData.pendingLoginAfterExpire = false
setTimeout(() => this.showLogin(), 100)
}
},
async loadFeatureConfig() {