| | |
| | | } |
| | | }, |
| | | onLoad() { |
| | | // 检查用户是否已登录 |
| | | const userId = this.currentUser.userId |
| | | if (!userId) { |
| | | console.log('用户未登录,跳过加载数据') |
| | | return |
| | | } |
| | | |
| | | // 加载用户绑定车辆信息 |
| | | this.loadUserVehicle() |
| | | // 加载正在运行的任务 |
| | |
| | | this.loadUnreadMessageCount() |
| | | }, |
| | | onShow() { |
| | | // 检查用户是否已登录 |
| | | const userId = this.currentUser.userId |
| | | if (!userId) { |
| | | console.log('用户未登录,跳过加载数据') |
| | | return |
| | | } |
| | | |
| | | // 每次显示页面时刷新任务列表、绑定车辆和消息数量 |
| | | this.loadUserVehicle() |
| | | this.loadRunningTasks() |
| | |
| | | |
| | | // 加载未读消息数量 |
| | | loadUnreadMessageCount() { |
| | | // 检查用户是否已登录 |
| | | const userId = this.currentUser.userId |
| | | if (!userId) { |
| | | console.log('用户未登录,跳过获取未读消息数量') |
| | | return |
| | | } |
| | | |
| | | getUnreadCount().then(response => { |
| | | if (response.code === 200) { |
| | | this.unreadMessageCount = response.data || 0 |
| | |
| | | // 查看任务详情 |
| | | viewTaskDetail(task) { |
| | | // 跳转到任务详情页面 - 使用taskId |
| | | this.$tab.navigateTo(`/pages/task/detail?id=${task.taskId || task.id}`); |
| | | this.$tab.navigateTo(`/pagesTask/detail?id=${task.taskId || task.id}`); |
| | | }, |
| | | |
| | | // 处理任务操作 |