Files
WXProgram/dist/services/deliveryPersonService.js
2025-10-26 13:15:04 +08:00

89 lines
2.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const apiService_1 = __importDefault(require("./apiService"));
/**
* 货运人员服务类
* 提供货运人员信息管理、状态管理等功能
*/
class DeliveryPersonService {
/**
* 构造函数
*/
constructor() {
// 不再使用模拟数据
}
/**
* 获取所有货运人员
* @returns 货运人员列表
*/
async getDeliveryPersons() {
return apiService_1.default.getDeliveryPersons();
}
/**
* 根据ID获取货运人员
* @param id 货运人员ID
* @returns 货运人员信息或null
*/
async getDeliveryPersonById(id) {
try {
const result = await apiService_1.default.getDeliveryPersonById(id);
return result;
}
catch (error) {
console.error('获取货运人员失败:', error);
return null;
}
}
/**
* 获取空闲的货运人员
* @returns 空闲货运人员列表
*/
async getIdleDeliveryPersons() {
return apiService_1.default.getIdleDeliveryPersons();
}
/**
* 获取忙碌的货运人员
* @returns 忙碌货运人员列表
*/
async getBusyDeliveryPersons() {
return apiService_1.default.getBusyDeliveryPersons();
}
/**
* 获取货运人员当前订单
* @param deliveryPersonId 货运人员ID
* @returns 订单列表
*/
async getDeliveryPersonOrders(deliveryPersonId) {
return apiService_1.default.getDeliveryPersonOrders(deliveryPersonId);
}
/**
* 获取货运人员头像URL
* @param deliveryPersonId 货运人员ID
* @returns 头像URL
*/
async getAvatarUrl(deliveryPersonId) {
try {
// 首先尝试获取货运人员详细信息
const deliveryPerson = await this.getDeliveryPersonById(deliveryPersonId);
if (deliveryPerson && deliveryPerson.avatarUrl) {
return deliveryPerson.avatarUrl;
}
// 如果货运人员信息中没有头像URL尝试使用员工服务获取
const employeeService = require('./employeeService').default;
return await employeeService.getAvatarUrl(deliveryPersonId);
}
catch (error) {
console.error('获取货运人员头像失败:', error);
return '';
}
}
}
/**
* 货运人员服务单例实例
* 导出供应用程序全局使用
*/
exports.default = new DeliveryPersonService();