| | |
| | | import { getUserProfile } from '@/api/system/user' |
| | | import { getUserBoundVehicle } from '@/api/vehicle' |
| | | import { getUnreadCount } from '@/api/message' |
| | | import { formatDateTime } from '@/utils/common' |
| | | |
| | | export default { |
| | | data() { |
| | |
| | | |
| | | // 加载未读消息数量 |
| | | loadUnreadMessageCount() { |
| | | // 检查用户是否已登录 |
| | | const userId = this.currentUser.userId |
| | | if (!userId) { |
| | | console.log('用户未登录,跳过获取未读消息数量') |
| | | return |
| | | } |
| | | |
| | | getUnreadCount().then(response => { |
| | | if (response.code === 200) { |
| | | this.unreadMessageCount = response.data || 0 |
| | | // 更新TabBar徽标 |
| | | this.updateTabBarBadge(this.unreadMessageCount) |
| | | } |
| | | }).catch(error => { |
| | | console.error('获取未读消息数量失败:', error) |
| | | }) |
| | | }, |
| | | |
| | | // 更新TabBar徽标 |
| | | updateTabBarBadge(count) { |
| | | if (count > 0) { |
| | | uni.setTabBarBadge({ |
| | | index: 3, // 消息页面在tabBar中的索引 |
| | | text: count > 99 ? '99+' : count.toString() |
| | | }) |
| | | } else { |
| | | uni.removeTabBarBadge({ |
| | | index: 3 |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | // 加载用户信息(保留以兼容之前的代码) |
| | |
| | | vehicleList: task.assignedVehicles || [], |
| | | startLocation: this.formatAddress(task.departureAddress || task.startLocation || '未设置'), |
| | | endLocation: this.formatAddress(task.destinationAddress || task.endLocation || '未设置'), |
| | | startTime: task.plannedStartTime ? this.formatDateTime(task.plannedStartTime) : '未设置', |
| | | startTime: task.plannedStartTime ? formatDateTime(task.plannedStartTime, 'YYYY-MM-DD HH:mm') : '未设置', |
| | | assignee: task.assigneeName || '未分配', |
| | | taskNo: task.taskCode || '未知编号', |
| | | status: this.convertStatus(task.taskStatus) // 转换状态格式以兼容旧UI |
| | |
| | | }).catch(error => { |
| | | this.loading = false |
| | | console.error('加载任务列表失败:', error) |
| | | }) |
| | | }, |
| | | |
| | | // 格式化日期时间 |
| | | formatDateTime(dateTime) { |
| | | if (!dateTime) return '' |
| | | const date = new Date(dateTime) |
| | | return date.toLocaleString('zh-CN', { |
| | | year: 'numeric', |
| | | month: '2-digit', |
| | | day: '2-digit', |
| | | hour: '2-digit', |
| | | minute: '2-digit' |
| | | }) |
| | | }, |
| | | |
| | |
| | | 'MAINTENANCE': '维修保养', |
| | | 'FUEL': '加油', |
| | | 'OTHER': '其他', |
| | | 'EMERGENCY_TRANSFER': '急救转运', |
| | | 'EMERGENCY_TRANSFER': '转运任务', |
| | | 'WELFARE': '福祉车', |
| | | // 旧格式(UI类型) |
| | | 'maintenance': '维修保养', |
| | | 'refuel': '加油', |
| | | 'inspection': '巡检', |
| | | 'emergency': '急救转运', |
| | | 'emergency': '转运任务', |
| | | 'welfare': '福祉车' |
| | | } |
| | | return typeMap[type] || '未知类型' |