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
+1 -2
View File
@@ -1,6 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar",
"v2-overlay": "/components/v2-overlay/index"
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
+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
}
+4 -12
View File
@@ -137,11 +137,11 @@
placeholder-class="input-ph"
/>
</view>
<view class="form-field" bindtap="onSexSelect">
<view class="form-field">
<text class="form-label">性别</text>
<view class="form-value">
<text class="{{editForm.sex ? '' : 'input-ph'}}">{{editForm.sex === 1 ? '男' : editForm.sex === 2 ? '女' : '请选择'}}</text>
<view class="icon icon-chevron-right form-arrow"></view>
<view class="sex-pick">
<view class="sex-pill {{editForm.sex === 1 ? 'is-on' : ''}}" data-value="1" bindtap="onSexTap">男</view>
<view class="sex-pill {{editForm.sex === 2 ? 'is-on' : ''}}" data-value="2" bindtap="onSexTap">女</view>
</view>
</view>
<view class="form-field">
@@ -164,12 +164,4 @@
</view>
</view>
<!-- 性别选择:底部动作表 -->
<v2-overlay
visible="{{sexVisible}}"
type="actionsheet"
items="{{sexItems}}"
bind:select="onSexPick"
bind:cancel="onSexCancel"
/>
</view>
+24
View File
@@ -220,3 +220,27 @@
height: 26rpx;
color: var(--ink-4);
}
/* 性别:行内两选一胶囊(选中实心黑,零彩色) */
.sex-pick {
flex: 1;
display: flex;
gap: 16rpx;
}
.sex-pill {
height: 60rpx;
padding: 0 40rpx;
border-radius: var(--r-pill);
background: var(--fill);
color: var(--ink-2);
font-size: 26rpx;
display: flex;
align-items: center;
transition: background .18s var(--ease), color .18s var(--ease);
}
.sex-pill.is-on {
background: var(--ink);
color: #fff;
}