Files

43 lines
1.4 KiB
JavaScript
Raw Permalink 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 统一走 TDesign 线性图标字体:home / chat-bubble / user。
// 「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: '#7A7068', // 未选中:暖灰,白底 4.83:1,过 WCAG AA 正文标准
list: [{
pagePath: '/pages/home/index',
text: '首页',
icon: 'home'
}, {
pagePath: '/pages/ai/aichat',
text: 'AI客服',
// 标准「聊天」图标:线性,与 home / user 同族
icon: 'chat'
}, {
pagePath: '/pages/mine/mine',
text: '我的',
icon: 'user'
}]
},
methods: {
onTap(e) {
const {
index,
path
} = e.currentTarget.dataset
// 重复点击当前 tab 不做跳转,避免页面被重置
if (index === this.data.selected) {
return
}
wx.switchTab({
url: path
})
}
}
})