Files
wxapp_escort/custom-tab-bar/index.js
T
2026-10-02 11:56:08 +08:00

43 lines
1.3 KiB
JavaScript

// 自定义 tabBar:固定在底部,选中态只换颜色、不换图形。
// 「首页 / 我的」走 TDesign 线性图标字体;「AI客服」用品牌 AI 图标
// (气泡内 AI 字位图):灰色版 ai.png 为未选中态,暖橙版 ai-ink.png 为选中态,
// 与文字颜色同步切换,保持选中可辨
Component({
data: {
selected: 0, // 当前选中项,由各 tab 页在 onShow 里同步
activeColor: '#C2410C', // 选中:暖橙深一档,白底 4.69:1,过 WCAG AA 正文标准
inactiveColor: '#7A7068', // 未选中:暖灰,白底 4.83:1,过 WCAG AA 正文标准
list: [{
pagePath: '/pages/home/index',
text: '首页',
icon: 'home'
}, {
pagePath: '/pages/ai/aichat',
text: 'AI客服',
// 图片图标:配置了 imgPath 时优先于 icon 渲染
imgPath: '/images/ai.png',
imgActivePath: '/images/ai-ink.png'
}, {
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
})
}
}
})