diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js index 86ff0e5..031c1b2 100644 --- a/custom-tab-bar/index.js +++ b/custom-tab-bar/index.js @@ -15,7 +15,7 @@ Component({ tabBarItems: [ { key: 'index', route: 'pages/index/index' }, { 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: 'favorites', route: 'pages/favorites/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() {