新增置顶人功能,允许在小程序首页展示特定用户信息(昵称、头像)。更新相关 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

@@ -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() {