|
|
|
@ -12,6 +12,7 @@ Component({ |
|
|
|
selected: 'index', |
|
|
|
show: true, |
|
|
|
badges: {}, |
|
|
|
navigating: false, |
|
|
|
tabBarItems: [ |
|
|
|
{ key: 'index', route: 'pages/index/index' }, |
|
|
|
{ key: 'chat', route: 'pages/chat/index', badgeKey: 'chat' }, |
|
|
|
@ -26,6 +27,19 @@ Component({ |
|
|
|
* 组件的方法列表 |
|
|
|
*/ |
|
|
|
methods: { |
|
|
|
// 导航锁机制,防止多次点击导致多次跳转
|
|
|
|
navigateLock: function(cb) { |
|
|
|
if (this.data.navigating) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
this.setData({ navigating: true }); |
|
|
|
cb(); |
|
|
|
// 延迟重置导航锁,确保导航操作有足够时间完成
|
|
|
|
setTimeout(() => { |
|
|
|
this.setData({ navigating: false }); |
|
|
|
}, 5000); |
|
|
|
return true; |
|
|
|
}, |
|
|
|
// 切换tab页面的方法 - 增强版,改进状态管理
|
|
|
|
switchTab(e) { |
|
|
|
try { |
|
|
|
@ -117,51 +131,53 @@ Component({ |
|
|
|
|
|
|
|
// 跳转到tab页面的通用方法
|
|
|
|
navigateToTabPage(url) { |
|
|
|
// 定义tabBar页面列表
|
|
|
|
const tabBarPages = [ |
|
|
|
'pages/index/index', |
|
|
|
'pages/chat/index', |
|
|
|
'pages/evaluate2/one', |
|
|
|
'pages/eggbar/eggbar', |
|
|
|
'pages/favorites/index', |
|
|
|
'pages/profile/index' |
|
|
|
]; |
|
|
|
|
|
|
|
// 检查是否为tabBar页面
|
|
|
|
if (tabBarPages.includes(url)) { |
|
|
|
console.log('使用switchTab跳转到tabbar页面:', url) |
|
|
|
wx.switchTab({ |
|
|
|
url: '/' + url, |
|
|
|
success: (res) => { |
|
|
|
console.log('switchTab成功:', url, res) |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('switchTab失败:', url, err) |
|
|
|
console.log('尝试使用reLaunch跳转...') |
|
|
|
wx.reLaunch({ |
|
|
|
url: '/' + url, |
|
|
|
success: (res) => { |
|
|
|
console.log('reLaunch成功:', url, res) |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('reLaunch也失败:', url, err) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 非tabBar页面,使用navigateTo跳转
|
|
|
|
console.log('使用navigateTo跳转到非tabbar页面:', url) |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/' + url, |
|
|
|
success: (res) => { |
|
|
|
console.log('navigateTo成功:', url, res) |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('navigateTo失败:', url, err) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
this.navigateLock(() => { |
|
|
|
// 定义tabBar页面列表
|
|
|
|
const tabBarPages = [ |
|
|
|
'pages/index/index', |
|
|
|
'pages/chat/index', |
|
|
|
'pages/evaluate2/one', |
|
|
|
'pages/eggbar/eggbar', |
|
|
|
'pages/favorites/index', |
|
|
|
'pages/profile/index' |
|
|
|
]; |
|
|
|
|
|
|
|
// 检查是否为tabBar页面
|
|
|
|
if (tabBarPages.includes(url)) { |
|
|
|
console.log('使用switchTab跳转到tabbar页面:', url) |
|
|
|
wx.switchTab({ |
|
|
|
url: '/' + url, |
|
|
|
success: (res) => { |
|
|
|
console.log('switchTab成功:', url, res) |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('switchTab失败:', url, err) |
|
|
|
console.log('尝试使用reLaunch跳转...') |
|
|
|
wx.reLaunch({ |
|
|
|
url: '/' + url, |
|
|
|
success: (res) => { |
|
|
|
console.log('reLaunch成功:', url, res) |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('reLaunch也失败:', url, err) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 非tabBar页面,使用navigateTo跳转
|
|
|
|
console.log('使用navigateTo跳转到非tabbar页面:', url) |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/' + url, |
|
|
|
success: (res) => { |
|
|
|
console.log('navigateTo成功:', url, res) |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('navigateTo失败:', url, err) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 强制更新选中状态
|
|
|
|
@ -198,74 +214,78 @@ Component({ |
|
|
|
|
|
|
|
// 跳转到收藏页面
|
|
|
|
goToFavoritesPage() { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/favorites/index' |
|
|
|
}) |
|
|
|
this.navigateLock(() => { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/favorites/index' |
|
|
|
}) |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 跳转到估价页面
|
|
|
|
goToEvaluatePage() { |
|
|
|
console.log('点击了估价按钮,跳转到evaluate2/one页面') |
|
|
|
this.navigateLock(() => { |
|
|
|
console.log('点击了估价按钮,跳转到evaluate2/one页面') |
|
|
|
|
|
|
|
// 判断partnerstatus是否为approved
|
|
|
|
const app = getApp() |
|
|
|
const userInfo = app.globalData.userInfo || wx.getStorageSync('userInfo') || {} |
|
|
|
const partnerstatus = userInfo.partnerstatus |
|
|
|
|
|
|
|
console.log('用户partnerstatus:', partnerstatus) |
|
|
|
// 判断idcardstatus是否为1
|
|
|
|
const app = getApp() |
|
|
|
const userInfo = app.globalData.userInfo || wx.getStorageSync('userInfo') || {} |
|
|
|
const idcardstatus = userInfo.idcardstatus |
|
|
|
|
|
|
|
// 如果partnerstatus不是approved,提示用户并跳转到入驻页面
|
|
|
|
if (partnerstatus !== 'approved') { |
|
|
|
wx.showToast({ |
|
|
|
title: '该功能需要入驻之后才能使用', |
|
|
|
icon: 'none', |
|
|
|
duration: 5000 |
|
|
|
}) |
|
|
|
console.log('用户idcardstatus:', idcardstatus) |
|
|
|
|
|
|
|
// 5秒后自动跳转到入驻页面
|
|
|
|
setTimeout(() => { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/settlement/index' |
|
|
|
// 如果idcardstatus不是1,提示用户并跳转到入驻页面
|
|
|
|
if (idcardstatus !== 1) { |
|
|
|
wx.showToast({ |
|
|
|
title: '请先完成身份认证', |
|
|
|
icon: 'none', |
|
|
|
duration: 3000 |
|
|
|
}) |
|
|
|
}, 5000) |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
// 3秒后自动跳转到认证页面
|
|
|
|
setTimeout(() => { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/profile/authentication/index' |
|
|
|
}) |
|
|
|
}, 3000) |
|
|
|
|
|
|
|
wx.switchTab({ |
|
|
|
url: '/pages/evaluate2/one', |
|
|
|
success: (res) => { |
|
|
|
console.log('switchTab到evaluate2/one成功:', res) |
|
|
|
// 更新选中状态
|
|
|
|
this.setData({ selected: 'evaluate' }) |
|
|
|
// 更新全局数据
|
|
|
|
const app = getApp() |
|
|
|
if (app && app.globalData) { |
|
|
|
app.globalData.currentTab = 'evaluate' |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('switchTab到evaluate2/one失败:', err) |
|
|
|
// 失败时尝试使用reLaunch
|
|
|
|
console.log('尝试使用reLaunch跳转到evaluate2/one...') |
|
|
|
wx.reLaunch({ |
|
|
|
url: '/pages/evaluate2/one', |
|
|
|
success: (res) => { |
|
|
|
console.log('reLaunch到evaluate2/one成功:', res) |
|
|
|
// 更新选中状态
|
|
|
|
this.setData({ selected: 'evaluate' }) |
|
|
|
// 更新全局数据
|
|
|
|
const app = getApp() |
|
|
|
if (app && app.globalData) { |
|
|
|
app.globalData.currentTab = 'evaluate' |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('reLaunch到evaluate2/one也失败:', err) |
|
|
|
} |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
wx.switchTab({ |
|
|
|
url: '/pages/evaluate2/one', |
|
|
|
success: (res) => { |
|
|
|
console.log('switchTab到evaluate2/one成功:', res) |
|
|
|
// 更新选中状态
|
|
|
|
this.setData({ selected: 'evaluate' }) |
|
|
|
// 更新全局数据
|
|
|
|
const app = getApp() |
|
|
|
if (app && app.globalData) { |
|
|
|
app.globalData.currentTab = 'evaluate' |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('switchTab到evaluate2/one失败:', err) |
|
|
|
// 失败时尝试使用reLaunch
|
|
|
|
console.log('尝试使用reLaunch跳转到evaluate2/one...') |
|
|
|
wx.reLaunch({ |
|
|
|
url: '/pages/evaluate2/one', |
|
|
|
success: (res) => { |
|
|
|
console.log('reLaunch到evaluate2/one成功:', res) |
|
|
|
// 更新选中状态
|
|
|
|
this.setData({ selected: 'evaluate' }) |
|
|
|
// 更新全局数据
|
|
|
|
const app = getApp() |
|
|
|
if (app && app.globalData) { |
|
|
|
app.globalData.currentTab = 'evaluate' |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.error('reLaunch到evaluate2/one也失败:', err) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 从全局数据同步状态的方法 - 增强版
|
|
|
|
|