wlzboy
2025-11-07 f3a294e8fc21a26a1a1eeebbd569142e236eddb5
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