| | |
| | | import { getMyTasks, changeTaskStatus } from '@/api/task' |
| | | import { getUserProfile } from '@/api/system/user' |
| | | import { getUserBoundVehicle } from '@/api/vehicle' |
| | | import { getUnreadCount } from '@/api/message' |
| | | |
| | | export default { |
| | | data() { |
| | |
| | | |
| | | // 消息数据 |
| | | messages: [], |
| | | unreadMessageCount: 0, |
| | | |
| | | // 正在运行的任务列表 |
| | | taskList: [], |
| | |
| | | // 包含待处理、出发中、已到达、返程中等所有未完成的状态 |
| | | return ['PENDING', 'DEPARTING', 'ARRIVED', 'RETURNING', 'IN_PROGRESS'].includes(task.taskStatus) |
| | | }); |
| | | }, |
| | | |
| | | // 未读消息数量 |
| | | unreadMessageCount() { |
| | | return this.messages.filter(message => !message.read).length; |
| | | } |
| | | }, |
| | | onLoad() { |
| | |
| | | this.loadUserVehicle() |
| | | // 加载正在运行的任务 |
| | | this.loadRunningTasks() |
| | | // 加载未读消息数量 |
| | | this.loadUnreadMessageCount() |
| | | }, |
| | | onShow() { |
| | | // 每次显示页面时刷新任务列表和绑定车辆 |
| | | // 每次显示页面时刷新任务列表、绑定车辆和消息数量 |
| | | this.loadUserVehicle() |
| | | this.loadRunningTasks() |
| | | this.loadUnreadMessageCount() |
| | | }, |
| | | onPullDownRefresh() { |
| | | // 下拉刷新 |
| | |
| | | }) |
| | | }, |
| | | |
| | | // 加载未读消息数量 |
| | | loadUnreadMessageCount() { |
| | | getUnreadCount().then(response => { |
| | | if (response.code === 200) { |
| | | this.unreadMessageCount = response.data || 0 |
| | | } |
| | | }).catch(error => { |
| | | console.error('获取未读消息数量失败:', error) |
| | | }) |
| | | }, |
| | | |
| | | // 加载用户信息(保留以兼容之前的代码) |
| | | loadUserProfile() { |
| | | const userId = this.currentUser.userId |