This commit is contained in:
2026-09-15 17:18:15 +08:00
parent 26c392d612
commit 469a361a2b
8 changed files with 78 additions and 34 deletions
+19 -18
View File
@@ -3,7 +3,7 @@ import * as auth from '../../utils/auth'
import { UserInfo, QuotaItem } from '../../types/models'
import { QuotaType, STORAGE_KEYS } from '../../utils/config'
import { formatDate } from '../../utils/format'
import { setTabBarSelected, setTabBarUnread } from '../../utils/tabbar'
import { setTabBarSelected, setTabBarUnread, setTabBarHidden } from '../../utils/tabbar'
import { navScroll } from '../../utils/nav'
import { logger } from '../../utils/logger'
@@ -49,12 +49,6 @@ Page({
quotaStats: [] as Array<{ key: number; label: string; remain: number; total: number }>,
// 滚动收缩:由 utils/nav.ts 的共享 handler 驱动
navScrolled: false,
// 性别选择:v2 玻璃动作表
sexVisible: false,
sexItems: [
{ text: '男', value: 1 },
{ text: '女', value: 2 },
],
},
// scroll-view 滚动 → 导航收缩为玻璃小标题
@@ -74,6 +68,8 @@ Page({
onShow() {
this.syncTabBar()
this.setToday()
// 回到本页时按抽屉状态校准标签栏,防止切前后台/切 tab 后残留隐藏
setTabBarHidden(!!this.data.editVisible)
// 未登录直接回登录页(幂等跳转),不再发出必然 401 的请求
if (!auth.isLoggedIn()) {
redirectToLogin()
@@ -85,6 +81,11 @@ Page({
this.fetchUnread()
},
// 离开本页时恢复标签栏:此时抽屉不再可见,标签栏不能残留隐藏
onHide() {
setTabBarHidden(false)
},
// 拉取未读数:与 tabBar 红点同源(/notification/unread),保证两处数量一致
fetchUnread() {
request<{ unread_count: number }>({ url: '/notification/unread', showError: false, silentAuth: true })
@@ -148,6 +149,8 @@ Page({
onEdit() {
const u = this.data.userInfo
// 抽屉打开期间隐藏悬浮标签栏:tabBar 由框架渲染在页面之上,否则会压住抽屉底部按钮
setTabBarHidden(true)
this.setData({
editVisible: true,
avatarChanged: false,
@@ -163,6 +166,7 @@ Page({
onCloseEdit() {
this.setData({ editVisible: false })
setTabBarHidden(false)
},
noop() {},
@@ -175,18 +179,11 @@ Page({
this.setData({ 'editForm.username': e.detail.value })
},
onSexSelect() {
this.setData({ sexVisible: true })
},
onSexPick(e: WechatMiniprogram.CustomEvent) {
const sex = Number(e.detail.value) || 0
// 性别为两选一字段:抽屉内联胶囊直接选中,不再弹动作表(避免两层玻璃叠加)
onSexTap(e: WechatMiniprogram.TouchEvent) {
const sex = Number((e.currentTarget.dataset as any).value) || 0
logger.debug(LOG, '选择性别, sex=', sex)
this.setData({ 'editForm.sex': sex, sexVisible: false })
},
onSexCancel() {
this.setData({ sexVisible: false })
this.setData({ 'editForm.sex': sex })
},
onBirthChange(e: WechatMiniprogram.CustomEvent) {
@@ -212,6 +209,8 @@ Page({
saving: false,
avatarChanged: false,
})
// 抽屉关闭,恢复悬浮标签栏
setTabBarHidden(false)
this.fetchUser()
}
@@ -224,7 +223,9 @@ Page({
if (f.birth_day && f.birth_day !== u.birth_day) body.birth_day = f.birth_day
if (!Object.keys(body).length && !this.data.avatarChanged) {
// 无变更直接关闭:同样要恢复标签栏,否则会残留隐藏
this.setData({ editVisible: false })
setTabBarHidden(false)
return
}