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