Browse Source

更新自定义tab-bar逻辑

pull/19/head
徐飞洋 1 month ago
parent
commit
5958aec908
  1. 43
      custom-tab-bar/index.js

43
custom-tab-bar/index.js

@ -15,7 +15,7 @@ Component({
tabBarItems: [ tabBarItems: [
{ key: 'index', route: 'pages/index/index' }, { key: 'index', route: 'pages/index/index' },
{ key: 'chat', route: 'pages/chat/index', badgeKey: 'chat' }, { key: 'chat', route: 'pages/chat/index', badgeKey: 'chat' },
{ key: 'evaluate', route: 'pages/evaluate/index' }, { key: 'evaluate', route: 'pages/evaluate1/index' },
{ key: 'settlement', route: 'pages/settlement/index' }, { key: 'settlement', route: 'pages/settlement/index' },
{ key: 'favorites', route: 'pages/favorites/index' }, { key: 'favorites', route: 'pages/favorites/index' },
{ key: 'profile', route: 'pages/profile/index' } { key: 'profile', route: 'pages/profile/index' }
@ -176,9 +176,44 @@ Component({
}) })
}, },
// 跳转到估价页面
goToEvaluatePage() {
console.log('点击了估价按钮,跳转到evaluate1页面')
wx.switchTab({
url: '/pages/evaluate1/index',
success: (res) => {
console.log('switchTab到evaluate1成功:', res)
// 更新选中状态
this.setData({ selected: 'evaluate' })
// 更新全局数据
const app = getApp()
if (app && app.globalData) {
app.globalData.currentTab = 'evaluate'
}
},
fail: (err) => {
console.error('switchTab到evaluate1失败:', err)
// 失败时尝试使用reLaunch
console.log('尝试使用reLaunch跳转到evaluate1...')
wx.reLaunch({
url: '/pages/evaluate1/index',
success: (res) => {
console.log('reLaunch到evaluate1成功:', res)
// 更新选中状态
this.setData({ selected: 'evaluate' })
// 更新全局数据
const app = getApp()
if (app && app.globalData) {
app.globalData.currentTab = 'evaluate'
}
},
fail: (err) => {
console.error('reLaunch到evaluate1也失败:', err)
}
})
}
})
},
// 从全局数据同步状态的方法 - 增强版 // 从全局数据同步状态的方法 - 增强版
syncFromGlobalData() { syncFromGlobalData() {

Loading…
Cancel
Save