Files
wxapp_escort/custom-tab-bar/index.js
T
2026-11-03 16:58:09 +08:00

49 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 自定义 tabBar:固定在底部,选中态只换颜色、不换图形。
// 三个 tab 全部用自绘圆润线性 SVG(wxss 里 base64 data URI):
// TDesign 字体图标 home 是尖屋顶、chat 带尖角尾巴、user 与另两个不同族,
// 自绘 SVG 描边 4/64(与字体图标 1/16 同粗细)、圆头线帽,选中态换橙色版图。
// 不引 t-icon 组件是有意为之:它会在冷启动时实例化字体图标组件并注入
// icon.wxss(历史体积 485KB、内嵌 278KB 字体),真机实测组件构造 59ms。
// 「陪诊助手」(原「AI客服」)曾用位图(气泡内嵌 AI 字:灰色 ai.png、暖橙 ai-ink.png)当图标,
// 其轮廓笔画比图标字体细一档,与另外两个并排时粗细不搭,故弃用。
// 位图文件仍留在 images/ 下未删(app.json 的 tabBar 项也在引用,见 DESIGN.md §5.2)
Component({
data: {
selected: 0, // 当前选中项,由各 tab 页在 onShow 里同步
activeColor: '#B8520A', // 选中:暖橙(色相 25°、保住原亮度),白底 4.94:1,过 WCAG AA 正文标准
inactiveColor: '#6F655C', // 未选中:与全局 --muted 一致,白底 5.69:1,过 WCAG AA 正文标准
list: [{
pagePath: '/pages/home/index',
text: '首页',
// 圆润小屋(圆弧屋顶 + 圆角屋身),见 index.wxss .ic-home
cls: 'ic-home'
}, {
pagePath: '/pages/ai/aichat',
text: '陪诊助手',
// 圆气泡 + 圆滑尾巴 + 三点,见 index.wxss .ic-chat
cls: 'ic-chat'
}, {
pagePath: '/pages/mine/mine',
text: '我的',
// 圆头 + 圆弧肩,与 .ic-home / .ic-chat 同族描边,见 index.wxss .ic-user
cls: 'ic-user'
}]
},
methods: {
onTap(e) {
const {
index,
path
} = e.currentTarget.dataset
// 重复点击当前 tab 不做跳转,避免页面被重置
if (index === this.data.selected) {
return
}
wx.switchTab({
url: path
})
}
}
})