注册修改为绑定

This commit is contained in:
2025-10-21 21:51:51 +08:00
parent 5ee4e077fb
commit be2323074b
28 changed files with 729 additions and 211 deletions

View File

@@ -3,7 +3,9 @@ import { LoginModule } from './loginModule';
import { MapModule } from './mapModule';
import { OrderModule } from './orderModule';
import { WarehouseModule } from './warehouseModule';
import { EmployeeModule } from './deliveryPersonModule';
import { EmployeeModule } from './employeeModule';
import { AdminModule } from './adminModule';
import { DeliveryPersonModule } from './deliveryPersonModule';
import { LocationModule } from './locationModule';
import { DataModule } from './dataModule';
import { showToast } from '../../../utils/helpers';
@@ -29,6 +31,8 @@ export class MainPageModule {
private orderModule: OrderModule;
private warehouseModule: WarehouseModule;
private employeeModule: EmployeeModule;
private adminModule: AdminModule;
private deliveryPersonModule: DeliveryPersonModule;
private locationModule: LocationModule;
constructor(pageContext: any) {
@@ -40,7 +44,9 @@ export class MainPageModule {
this.mapModule = new MapModule(pageContext, this.dataModule);
this.orderModule = new OrderModule(pageContext, this.dataModule);
this.warehouseModule = new WarehouseModule(pageContext, this.dataModule);
this.employeeModule = new EmployeeModule(pageContext, this.dataModule);
this.employeeModule = new EmployeeModule(this.pageContext, this.dataModule);
this.adminModule = new AdminModule(this.pageContext, this.dataModule);
this.deliveryPersonModule = new DeliveryPersonModule(this.pageContext, this.dataModule);
this.locationModule = new LocationModule(pageContext, this.dataModule);
}
@@ -107,13 +113,8 @@ export class MainPageModule {
// 加载公开数据(不需要登录)
await this.loadPublicData();
// 检查是否已登录,只有已登录用户才能加载业务数据
const app = getApp<any>();
if (app.globalData.isLoggedIn) {
await this.loadBusinessData();
} else {
console.log('用户未登录,不加载业务数据');
}
// 业务数据(订单和员工数据)在用户签到后单独加载
console.log('公开数据加载完成,业务数据将在用户签到后加载');
} catch (error) {
console.error('加载数据失败:', error);
@@ -139,22 +140,44 @@ export class MainPageModule {
}
/**
* 加载业务数据
* 加载业务数据(仅在用户签到后调用)
*/
private async loadBusinessData(): Promise<void> {
public async loadBusinessData(): Promise<void> {
console.log('加载业务数据');
try {
// 并行加载各种业务数据(需要登录
await Promise.all([
this.orderModule.loadPendingOrders(),
this.employeeModule.loadAllEmployees()
]);
// 加载待处理订单(所有登录用户都可以看到
await this.orderModule.loadPendingOrders();
console.log('所有业务数据加载完成');
console.log('业务数据加载完成');
} catch (error) {
console.error('加载业务数据失败:', error);
showToast('业务数据加载失败');
throw error; // 重新抛出错误,让调用方处理
}
}
/**
* 加载员工数据(仅在管理员签到后调用)
*/
public async loadEmployeeData(): Promise<void> {
console.log('加载员工数据');
try {
// 获取用户信息
const app = getApp<any>();
const userInfo = app.globalData.userInfo;
// 只有管理员才加载员工列表
if (userInfo && userInfo.role === 'ADMIN') {
console.log('管理员用户,加载员工列表');
await this.employeeModule.loadAllEmployees();
console.log('员工数据加载完成');
} else {
console.log('非管理员用户,跳过员工列表加载');
}
} catch (error) {
console.error('加载员工数据失败:', error);
throw error; // 重新抛出错误,让调用方处理
}
}
@@ -260,9 +283,16 @@ export class MainPageModule {
case 'warehouse':
this.warehouseModule.onWarehouseMarkerClick(marker.data, e);
break;
case 'delivery_person':
this.employeeModule.onDeliveryPersonMarkerClick(marker.data, e);
break;
case 'employee':
// 员工标记点点击 - 根据角色分发到不同模块
if (marker.data.role === 'ADMIN') {
// 管理员 - 由adminModule处理
this.adminModule.onAdminMarkerClick(marker.data, e);
} else {
// 货运人员 - 由deliveryPersonModule处理包含订单列表
this.deliveryPersonModule.onDeliveryPersonMarkerClick(marker.data, e);
}
break;
default:
this.mapModule.onMarkerTap(e);
break;
@@ -304,6 +334,13 @@ export class MainPageModule {
return this.employeeModule;
}
/**
* 获取管理员模块
*/
getAdminModule(): AdminModule {
return this.adminModule;
}
/**
* 获取位置模块
*/
@@ -345,6 +382,10 @@ export class MainPageModule {
// 清理位置模块
this.locationModule.cleanup();
// 清理员工和管理员模块
this.employeeModule.cleanup();
this.adminModule.cleanup();
// 这里可以添加其他需要清理的资源
console.log('✅ 主页面模块清理完成');
}