添加管理员逻辑
This commit is contained in:
@@ -1,34 +1,48 @@
|
||||
// index.ts
|
||||
|
||||
// 引入服务和工具函数
|
||||
import { showToast } from '../../utils/helpers';
|
||||
|
||||
import userService from '../../services/userService';
|
||||
import locationTrackingService from '../../services/locationTrackingService';
|
||||
|
||||
// 引入主页面模块
|
||||
import { MainPageModule } from './modules/mainPageModule';
|
||||
|
||||
// 主页面组件接口定义
|
||||
interface IndexPageComponent {
|
||||
data: {
|
||||
mainPageModule: MainPageModule | null;
|
||||
// 核心UI状态
|
||||
showUserPanel: boolean;
|
||||
showOrderPanel: boolean;
|
||||
showDeliveryPersonModal: boolean;
|
||||
showWarehouseModal: boolean;
|
||||
};
|
||||
}
|
||||
// 导入类型定义
|
||||
import { IndexPageComponent } from '../../types';
|
||||
|
||||
// 主页面组件
|
||||
Component<IndexPageComponent>({
|
||||
Component<IndexPageComponent['data'], any, any, any, false>({
|
||||
data: {
|
||||
mainPageModule: null as MainPageModule | null,
|
||||
// 核心UI状态
|
||||
longitude: 116.397428,
|
||||
latitude: 39.90923,
|
||||
scale: 16,
|
||||
markers: [],
|
||||
userInfo: null,
|
||||
authStatus: {
|
||||
hasWxCode: false,
|
||||
userStatus: 'unknown'
|
||||
},
|
||||
showUserPanel: false,
|
||||
showOrderPanel: false,
|
||||
currentOrder: null,
|
||||
currentDeliveryPerson: null,
|
||||
currentWarehouse: null,
|
||||
currentPanelPosition: { x: 0, y: 0 },
|
||||
polyline: null,
|
||||
pendingOrders: [],
|
||||
currentRoute: null,
|
||||
showRoute: false,
|
||||
routeDistance: 0,
|
||||
routeDuration: 0,
|
||||
showWarehouseModal: false,
|
||||
showDeliveryPersonModal: false,
|
||||
showWarehouseModal: false
|
||||
warehouseModalState: 'bottom',
|
||||
deliveryPersonModalState: 'bottom',
|
||||
showSignOutButton: false,
|
||||
showSignInButton: false,
|
||||
showRegisterButton: false,
|
||||
showAuthButton: true,
|
||||
// mainPageModule: null as MainPageModule | null
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
@@ -45,21 +59,21 @@ Component<IndexPageComponent>({
|
||||
}
|
||||
},
|
||||
|
||||
show() {
|
||||
console.log('index page show');
|
||||
// 页面显示时调用主页面模块的onShow方法
|
||||
if (this.data.mainPageModule) {
|
||||
this.data.mainPageModule.onShow();
|
||||
}
|
||||
},
|
||||
// show() {
|
||||
// console.log('index page show');
|
||||
// // 页面显示时调用主页面模块的onShow方法
|
||||
// if (this.data.mainPageModule) {
|
||||
// this.data.mainPageModule.onShow();
|
||||
// }
|
||||
// },
|
||||
|
||||
hide() {
|
||||
console.log('index page hide');
|
||||
// 页面隐藏时调用主页面模块的onHide方法
|
||||
if (this.data.mainPageModule) {
|
||||
this.data.mainPageModule.onHide();
|
||||
}
|
||||
}
|
||||
// hide() {
|
||||
// console.log('index page hide');
|
||||
// // 页面隐藏时调用主页面模块的onHide方法
|
||||
// if (this.data.mainPageModule) {
|
||||
// this.data.mainPageModule.onHide();
|
||||
// }
|
||||
// }
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -82,26 +96,17 @@ Component<IndexPageComponent>({
|
||||
|
||||
// 初始化页面
|
||||
async initPage() {
|
||||
const app = getApp<any>();
|
||||
|
||||
// 初始化主页面模块
|
||||
this.setData({
|
||||
mainPageModule: new MainPageModule(this)
|
||||
});
|
||||
|
||||
// 设置globalData中的loginModule引用,用于废弃方法的重定向
|
||||
if (this.data.mainPageModule) {
|
||||
app.globalData.loginModule = this.data.mainPageModule.getLoginModule();
|
||||
}
|
||||
|
||||
// 异步检查登录状态
|
||||
await this.checkAndUpdateLoginStatus();
|
||||
},
|
||||
|
||||
// 异步检查并更新登录状态
|
||||
async checkAndUpdateLoginStatus() {
|
||||
const app = getApp<any>();
|
||||
|
||||
try {
|
||||
// 获取登录模块
|
||||
if (!this.data.mainPageModule) {
|
||||
@@ -154,7 +159,9 @@ Component<IndexPageComponent>({
|
||||
},
|
||||
|
||||
// 异步检查登录状态
|
||||
async asyncCheckLoginStatus(loginModule: any): Promise<boolean> {
|
||||
async asyncCheckLoginStatus(loginModule: any): Promise<boolean> {
|
||||
getApp<any>();
|
||||
|
||||
const app = getApp<any>();
|
||||
|
||||
// 首先检查本地是否有登录状态
|
||||
@@ -181,9 +188,11 @@ Component<IndexPageComponent>({
|
||||
try {
|
||||
const loginResult = await userService.wxLogin();
|
||||
if (loginResult.success && loginResult.userInfo) {
|
||||
// 登录成功,更新全局用户信息
|
||||
app.globalData.userInfo = loginResult.userInfo;
|
||||
app.globalData.isLoggedIn = true;
|
||||
const app = getApp<any>();
|
||||
|
||||
// 登录成功,更新全局用户信息
|
||||
app.globalData.userInfo = loginResult.userInfo;
|
||||
app.globalData.isLoggedIn = true;
|
||||
|
||||
// 登录成功后,此时已经有token,可以安全获取用户状态
|
||||
const userStatus = await loginModule.determineUserStatus(loginResult.userInfo);
|
||||
@@ -243,18 +252,19 @@ Component<IndexPageComponent>({
|
||||
},
|
||||
|
||||
// 登录成功后统一刷新页面
|
||||
async refreshPageAfterLogin() {
|
||||
if (!this.data.mainPageModule) {
|
||||
console.error('mainPageModule未初始化');
|
||||
return;
|
||||
}
|
||||
|
||||
const loginModule = this.data.mainPageModule.getLoginModule();
|
||||
const app = getApp<any>();
|
||||
async refreshPageAfterLogin() {
|
||||
if (!this.data.mainPageModule) {
|
||||
console.error('mainPageModule未初始化');
|
||||
return;
|
||||
}
|
||||
|
||||
const loginModule = this.data.mainPageModule.getLoginModule();
|
||||
getApp<any>();
|
||||
|
||||
console.log('🔄 === 全局登录流程完成,执行统一页面刷新 ===');
|
||||
|
||||
// 1. 更新页面登录状态
|
||||
const app = getApp<any>();
|
||||
loginModule.updatePageAfterLogin(app.globalData.userInfo);
|
||||
|
||||
// 2. 更新按钮显示状态
|
||||
@@ -265,7 +275,7 @@ Component<IndexPageComponent>({
|
||||
|
||||
// 4. 登录成功后只加载公开数据(仓库等),不加载业务数据
|
||||
// 业务数据(员工位置等)只有在用户签到后才应该加载
|
||||
if (app.globalData.isLoggedIn) {
|
||||
if (app.globalData.isLoggedIn && this.data.authStatus.userStatus === 'signed_in') {
|
||||
console.log('🔍 登录成功,开始加载公开数据...');
|
||||
await this.data.mainPageModule.loadPublicData();
|
||||
console.log('✅ 公开数据加载完成');
|
||||
@@ -307,6 +317,8 @@ Component<IndexPageComponent>({
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 处理授权登录 - 已迁移到LoginModule
|
||||
async handleAuthLogin() {
|
||||
if (!this.data.mainPageModule) {
|
||||
@@ -335,107 +347,24 @@ Component<IndexPageComponent>({
|
||||
}
|
||||
},
|
||||
|
||||
// 处理退出登录
|
||||
async handleLogout() {
|
||||
try {
|
||||
wx.showLoading({
|
||||
title: '正在退出...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
// 调用loginModule的logout方法
|
||||
if (!this.data.mainPageModule) {
|
||||
console.error('mainPageModule未初始化');
|
||||
return;
|
||||
}
|
||||
const loginModule = this.data.mainPageModule.getLoginModule();
|
||||
await loginModule.logout();
|
||||
|
||||
// 更新页面状态
|
||||
this.setData({
|
||||
userInfo: null,
|
||||
'authStatus.hasWxCode': false,
|
||||
'authStatus.userStatus': 'unknown',
|
||||
showUserPanel: false
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 处理签退 - 已迁移到LoginModule
|
||||
async handleSignOut() {
|
||||
if (!this.data.mainPageModule) {
|
||||
console.error('mainPageModule未初始化');
|
||||
return;
|
||||
}
|
||||
|
||||
const loginModule = this.data.mainPageModule.getLoginModule();
|
||||
const success = await loginModule.handleSignOut();
|
||||
|
||||
if (success) {
|
||||
// 更新按钮显示状态
|
||||
this.updateButtonDisplayStatus();
|
||||
|
||||
wx.hideLoading();
|
||||
showToast('已退出登录');
|
||||
console.log('用户已退出登录');
|
||||
} catch (error) {
|
||||
wx.hideLoading();
|
||||
console.error('退出登录失败:', error);
|
||||
showToast('退出登录失败');
|
||||
}
|
||||
},
|
||||
|
||||
// 处理签退
|
||||
async handleSignOut() {
|
||||
try {
|
||||
console.log('调试信息 - 开始执行签退流程');
|
||||
wx.showLoading({
|
||||
title: '正在签退...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
// 停止位置追踪服务
|
||||
try {
|
||||
await locationTrackingService.stopTracking();
|
||||
console.log('调试信息 - 位置追踪服务已停止');
|
||||
} catch (trackingError) {
|
||||
console.warn('调试信息 - 停止位置追踪失败:', trackingError);
|
||||
}
|
||||
|
||||
// 停止位置模块的实时跟踪
|
||||
try {
|
||||
if (this.data.mainPageModule) {
|
||||
const locationModule = this.data.mainPageModule.getLocationModule();
|
||||
if (locationModule) {
|
||||
await locationModule.stopRealTimeTracking();
|
||||
console.log('调试信息 - 位置模块实时跟踪已停止');
|
||||
}
|
||||
}
|
||||
} catch (trackingError) {
|
||||
console.warn('调试信息 - 停止位置模块实时跟踪失败:', trackingError);
|
||||
}
|
||||
|
||||
// 保存签退状态到本地存储,防止自动重新登录
|
||||
console.log('调试信息 - 保存签退状态到本地存储');
|
||||
wx.setStorageSync('userStatus', 'signed_out');
|
||||
|
||||
// 验证签退状态是否保存成功
|
||||
const savedStatus = wx.getStorageSync('userStatus');
|
||||
console.log('调试信息 - 验证保存的签退状态:', savedStatus);
|
||||
|
||||
// 更新用户状态为已签退(不调用doGlobalLogout,保持登录状态)
|
||||
this.setData({
|
||||
'authStatus.userStatus': 'signed_out',
|
||||
showSignOutButton: false,
|
||||
showSignInButton: true
|
||||
});
|
||||
|
||||
// 清除所有员工图标
|
||||
if (this.data.mainPageModule) {
|
||||
const employeeModule = this.data.mainPageModule.getEmployeeModule();
|
||||
if (employeeModule) {
|
||||
// 清除员工标记点
|
||||
const { markers } = this.data;
|
||||
const filteredMarkers = markers.filter((marker: any) => marker.type !== 'employee');
|
||||
this.setData({ markers: filteredMarkers });
|
||||
console.log('调试信息 - 已清除所有员工图标');
|
||||
}
|
||||
}
|
||||
|
||||
wx.hideLoading();
|
||||
showToast('签退成功');
|
||||
console.log('调试信息 - 用户签退完成');
|
||||
} catch (error) {
|
||||
wx.hideLoading();
|
||||
console.error('调试信息 - 签退失败:', error);
|
||||
showToast('签退失败');
|
||||
// 刷新页面数据
|
||||
await this.data.mainPageModule.refreshAllData();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -503,6 +432,26 @@ Component<IndexPageComponent>({
|
||||
this.setData({ showUserPanel: true });
|
||||
},
|
||||
|
||||
// 跳转到管理界面(基于用户角色)
|
||||
goToManagementPage() {
|
||||
if (this.data.userInfo && this.data.userInfo.role) {
|
||||
if (this.data.userInfo.role === 'ADMIN') {
|
||||
// 管理员跳转到管理员界面 - 使用navigateTo保持当前页面状态
|
||||
wx.navigateTo({
|
||||
url: '/pages/staff/admin-dashboard'
|
||||
});
|
||||
} else {
|
||||
// 员工跳转到员工界面 - 使用navigateTo保持当前页面状态
|
||||
wx.navigateTo({
|
||||
url: '/pages/staff/employee-dashboard'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// 未登录用户显示用户面板
|
||||
this.setData({ showUserPanel: true });
|
||||
}
|
||||
},
|
||||
|
||||
// 隐藏用户面板
|
||||
hideUserPanel() {
|
||||
this.setData({ showUserPanel: false });
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<!-- 右侧控制按钮组 -->
|
||||
<view class="right-controls-container">
|
||||
<!-- 签到、注册、授权登录按钮 -->
|
||||
<!-- 签到/签退按钮 -->
|
||||
<view class="auth-buttons">
|
||||
<!-- 签到按钮 - 已授权用户 -->
|
||||
<button
|
||||
@@ -30,30 +30,6 @@
|
||||
<text class="btn-text">签到</text>
|
||||
</button>
|
||||
|
||||
<!-- 注册按钮 - 游客用户 -->
|
||||
<button
|
||||
wx:if="{{showRegisterButton}}"
|
||||
class="control-btn register-btn"
|
||||
bindtap="showApplyForm"
|
||||
type="default"
|
||||
size="mini"
|
||||
>
|
||||
<text class="btn-icon">📝</text>
|
||||
<text class="btn-text">注册</text>
|
||||
</button>
|
||||
|
||||
<!-- 授权登录按钮 - 未授权用户 -->
|
||||
<button
|
||||
wx:if="{{showAuthButton}}"
|
||||
class="control-btn auth-btn"
|
||||
bindtap="handleAuthLogin"
|
||||
type="warn"
|
||||
size="mini"
|
||||
>
|
||||
<text class="btn-icon">🔑</text>
|
||||
<text class="btn-text">登录</text>
|
||||
</button>
|
||||
|
||||
<!-- 签退按钮 - 已签到用户 -->
|
||||
<button
|
||||
wx:if="{{showSignOutButton}}"
|
||||
@@ -76,21 +52,15 @@
|
||||
</view>
|
||||
|
||||
<!-- 用户头像 -->
|
||||
<view wx:if="{{authStatus.hasWxCode}}"
|
||||
<view wx:if="{{authStatus.hasWxCode && authStatus.userStatus === 'signed_in'}}"
|
||||
class="control-btn reset-btn"
|
||||
bindtap="showUserPanel">
|
||||
bindtap="goToManagementPage">
|
||||
<text class="btn-icon">👤</text>
|
||||
<text class="btn-text">我的</text>
|
||||
<view wx:if="{{userInfo.role === 'ADMIN'}}" class="admin-badge"/>
|
||||
</view>
|
||||
|
||||
<!-- 员工管理按钮(仅管理员可见) -->
|
||||
<view wx:if="{{authStatus.hasWxCode && userInfo.role === 'ADMIN'}}"
|
||||
class="control-btn staff-management-btn"
|
||||
bindtap="goToEmployeeManagement">
|
||||
<text class="btn-icon">👥</text>
|
||||
<text class="btn-text">员工</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<!-- 用户信息面板 -->
|
||||
@@ -103,7 +73,7 @@
|
||||
<view class="user-panel-content" bindtap="stopPropagation">
|
||||
<view class="user-avatar">
|
||||
<image
|
||||
src="/images/trucks.png"
|
||||
src="/images/truck.png"
|
||||
mode="aspectFill"
|
||||
class="avatar-image"
|
||||
></image>
|
||||
@@ -114,9 +84,6 @@
|
||||
<text class="user-id">ID: {{userInfo.id || '未获取'}}</text>
|
||||
<text class="user-phone">电话:{{userInfo.phone || '未设置'}}</text>
|
||||
<text class="user-role">角色:{{userInfo.role === 'ADMIN' ? '管理员' : '货运员'}}</text>
|
||||
|
||||
<!-- 退出后台代码 -->
|
||||
<button class="btn-logout" bindtap="handleLogout" size="mini">退出登录</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -257,7 +224,7 @@
|
||||
<view class="modal-header">
|
||||
<view class="delivery-person-header">
|
||||
<view class="delivery-person-avatar">
|
||||
<image src="{{currentDeliveryPerson.avatarUrl || '/images/trucks.png'}}" mode="aspectFill"></image>
|
||||
<image src="{{currentDeliveryPerson.avatarUrl || '/images/truck.png'}}" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="person-info-header">
|
||||
<view class="modal-title">{{currentDeliveryPerson.name}}</view>
|
||||
|
||||
@@ -148,12 +148,16 @@ export class DataModule {
|
||||
this.updateMarkers(updatedMarkers);
|
||||
} else {
|
||||
// 创建新的用户标记点
|
||||
const userInfo = this.pageContext.data.userInfo;
|
||||
const userRole = userInfo?.role || 'employee';
|
||||
const iconPath = userRole === 'ADMIN' ? '/images/crown.png' : '/images/truck.png';
|
||||
|
||||
const newUserMarker = {
|
||||
id: targetUserId,
|
||||
title: markerTitle,
|
||||
longitude: longitude,
|
||||
latitude: latitude,
|
||||
iconPath: '/images/trucks.png',
|
||||
iconPath: iconPath,
|
||||
width: 40,
|
||||
height: 40,
|
||||
zIndex: targetUserId === -1 ? 99 : 98 // 当前用户层级更高
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// 员工模块 - 处理所有员工(管理员和货运人员)管理、位置跟踪、交互
|
||||
import employeeService from '../../../services/employeeService';
|
||||
import { Role } from '../../../utils/roleUtils';
|
||||
|
||||
// getApp是微信小程序全局函数,无需导入
|
||||
|
||||
import { showToast } from '../../../utils/helpers';
|
||||
@@ -30,37 +30,7 @@ export class EmployeeModule {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取员工角色对应的图标
|
||||
*/
|
||||
private getEmployeeIcon(role: string): string {
|
||||
console.log(`获取员工图标,角色: ${role}`);
|
||||
|
||||
// 根据角色使用不同的图标
|
||||
let iconPath = '';
|
||||
|
||||
switch (role) {
|
||||
case Role.ADMIN:
|
||||
// 管理员使用皇冠图标
|
||||
iconPath = '/images/crown.png';
|
||||
console.log('使用管理员图标(👑)');
|
||||
break;
|
||||
case Role.DELIVERY_PERSON:
|
||||
// 货运人员使用货车图标
|
||||
iconPath = '/images/truck.png';
|
||||
console.log('使用货运人员图标(🚚)');
|
||||
break;
|
||||
default:
|
||||
// 默认使用货车图标
|
||||
iconPath = '/images/truck.png';
|
||||
console.log('使用默认图标(🚚)');
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(`最终使用图标路径: ${iconPath}`);
|
||||
|
||||
return iconPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示货运人员详情面板
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// 位置模块 - 处理位置追踪、位置更新和地图标记点更新
|
||||
import { DataModule } from './dataModule';
|
||||
import { showToast } from '../../../utils/helpers';
|
||||
import locationTrackingService from '../../../services/locationTrackingService';
|
||||
import { OnlineUserInfo } from '../../../services/locationTrackingService';
|
||||
import { DataModule } from './dataModule';
|
||||
import locationTrackingService from '../../../services/locationTrackingService';
|
||||
|
||||
// 位置模块接口定义
|
||||
export interface LocationModule {
|
||||
@@ -10,21 +9,15 @@ export interface LocationModule {
|
||||
cleanup(): void;
|
||||
startRealTimeTracking(): Promise<void>;
|
||||
stopRealTimeTracking(): Promise<void>;
|
||||
updateEmployeeLocation(employeeId: number, location: { longitude: number, latitude: number }): Promise<void>;
|
||||
}
|
||||
|
||||
export class LocationModule {
|
||||
private pageContext: any;
|
||||
private dataModule: DataModule;
|
||||
private isTracking: boolean;
|
||||
|
||||
constructor(pageContext: any, dataModule: DataModule) {
|
||||
this.pageContext = pageContext;
|
||||
constructor(_pageContext: any, dataModule: DataModule) {
|
||||
this.dataModule = dataModule;
|
||||
this.isTracking = false;
|
||||
|
||||
// 绑定回调方法
|
||||
this.handleLocationUpdates = this.handleLocationUpdates.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,10 +26,28 @@ export class LocationModule {
|
||||
async initialize(): Promise<void> {
|
||||
console.log('位置模块初始化');
|
||||
|
||||
// 订阅位置更新
|
||||
this.subscribeToLocationUpdates();
|
||||
// 注册位置更新回调,当位置追踪服务有更新时自动刷新地图标记
|
||||
this.setupLocationUpdateCallback();
|
||||
|
||||
console.log('✅ 位置模块初始化完成');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置位置更新回调
|
||||
*/
|
||||
private setupLocationUpdateCallback(): void {
|
||||
console.log('📝 [LocationModule] 设置位置更新回调');
|
||||
|
||||
console.log('位置模块初始化完成');
|
||||
// 注册位置更新回调
|
||||
locationTrackingService.subscribeToLocationUpdates((onlineUsers) => {
|
||||
console.log('🔔 [LocationModule] 收到位置更新通知');
|
||||
console.log('👥 [LocationModule] 在线用户数量:', onlineUsers.length);
|
||||
|
||||
// 调用updateEmployeeMarkers方法更新地图标记
|
||||
this.updateEmployeeMarkers(onlineUsers);
|
||||
});
|
||||
|
||||
console.log('✅ [LocationModule] 位置更新回调设置完成');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,16 +55,15 @@ export class LocationModule {
|
||||
*/
|
||||
cleanup(): void {
|
||||
console.log('清理位置模块');
|
||||
|
||||
// 取消位置更新订阅
|
||||
this.unsubscribeFromLocationUpdates();
|
||||
|
||||
|
||||
// 停止实时跟踪
|
||||
if (this.isTracking) {
|
||||
this.stopRealTimeTracking().catch(error => {
|
||||
console.error('停止实时跟踪失败:', error);
|
||||
});
|
||||
}
|
||||
|
||||
console.log('✅ 位置模块清理完成');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,8 +77,8 @@ export class LocationModule {
|
||||
throw new Error('用户信息获取失败');
|
||||
}
|
||||
|
||||
// 启动位置跟踪订阅
|
||||
await locationTrackingService.startTrackingAfterSignIn();
|
||||
// 启动位置跟踪订阅(WebSocket连接)
|
||||
await locationTrackingService.startTracking();
|
||||
|
||||
this.isTracking = true;
|
||||
showToast('已开始实时跟踪');
|
||||
@@ -104,74 +114,13 @@ export class LocationModule {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新员工位置
|
||||
*/
|
||||
async updateEmployeeLocation(employeeId: number, location: { longitude: number, latitude: number }): Promise<void> {
|
||||
try {
|
||||
console.log(`员工 ${employeeId} 位置更新:`, location);
|
||||
|
||||
// 通过locationTrackingService更新位置
|
||||
await locationTrackingService.updateUserLocation(location);
|
||||
|
||||
console.log(`员工 ${employeeId} 位置更新完成`);
|
||||
} catch (error) {
|
||||
console.error('更新员工位置失败:', error);
|
||||
showToast('更新位置失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅位置更新
|
||||
*/
|
||||
private subscribeToLocationUpdates(): void {
|
||||
console.log('订阅位置更新');
|
||||
locationTrackingService.subscribeToLocationUpdates(this.handleLocationUpdates);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订阅位置更新
|
||||
*/
|
||||
private unsubscribeFromLocationUpdates(): void {
|
||||
console.log('取消订阅位置更新');
|
||||
locationTrackingService.unsubscribeFromLocationUpdates(this.handleLocationUpdates);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理位置更新回调
|
||||
*/
|
||||
private handleLocationUpdates(locationData: any): void {
|
||||
console.log('🔔 [LocationModule] 收到位置更新回调');
|
||||
console.log('📊 [LocationModule] 回调数据类型:', locationData.type || '未知类型');
|
||||
console.log('📋 [LocationModule] 回调数据内容:', JSON.stringify(locationData, null, 2));
|
||||
|
||||
if (locationData.type === 'onlineUserList' && locationData.users) {
|
||||
// 处理在线用户列表更新
|
||||
console.log('👥 [LocationModule] 处理在线用户列表,用户数量:', locationData.users.length);
|
||||
this.updateEmployeeMarkers(locationData.users);
|
||||
} else if (Array.isArray(locationData)) {
|
||||
// 处理位置更新数组(旧格式)
|
||||
console.log('📋 [LocationModule] 处理位置更新数组,用户数量:', locationData.length);
|
||||
this.updateEmployeeMarkers(locationData);
|
||||
} else if (locationData.userId && locationData.latitude && locationData.longitude) {
|
||||
// 处理单个用户位置更新
|
||||
console.log('👤 [LocationModule] 处理单个用户位置更新:', locationData.userId);
|
||||
this.updateSingleEmployeeMarker(locationData);
|
||||
} else {
|
||||
console.warn('❌ [LocationModule] 未知的位置数据格式:', locationData);
|
||||
}
|
||||
|
||||
console.log('🏁 [LocationModule] 位置更新回调处理完成');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新员工标记点
|
||||
*/
|
||||
private updateEmployeeMarkers(onlineUsers: any[]): void {
|
||||
public updateEmployeeMarkers(onlineUsers: any[]): void {
|
||||
console.log('📍 [LocationModule] 开始更新员工标记点');
|
||||
console.log('👥 [LocationModule] 传入用户数量:', onlineUsers.length);
|
||||
console.log('📋 [LocationModule] 用户数据示例:', JSON.stringify(onlineUsers[0], null, 2));
|
||||
|
||||
// 获取地图模块来更新标记点
|
||||
const mapModule = this.dataModule.getMapModule();
|
||||
@@ -180,8 +129,13 @@ export class LocationModule {
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取当前地图上的所有标记点
|
||||
const { markers } = this.dataModule.getData();
|
||||
const currentEmployeeMarkers = markers.filter((marker: any) => marker.type === 'employee');
|
||||
console.log('🗺️ [LocationModule] 当前地图上员工标记点数量:', currentEmployeeMarkers.length);
|
||||
|
||||
// 为每个在线用户创建标记点
|
||||
const employeeMarkers = onlineUsers.map((user, index) => {
|
||||
const newEmployeeMarkers = onlineUsers.map((user, index) => {
|
||||
console.log(`🔍 [LocationModule] 处理第 ${index + 1} 个用户:`, user.userId || '未知ID');
|
||||
|
||||
// 获取用户角色信息
|
||||
@@ -215,55 +169,94 @@ export class LocationModule {
|
||||
return employeeMarker;
|
||||
});
|
||||
|
||||
console.log('📍 [LocationModule] 生成标记点数量:', employeeMarkers.length);
|
||||
console.log('📋 [LocationModule] 标记点数据示例:', JSON.stringify(employeeMarkers[0], null, 2));
|
||||
console.log('📍 [LocationModule] 新生成标记点数量:', newEmployeeMarkers.length);
|
||||
|
||||
// 调用地图模块更新员工标记点
|
||||
mapModule.updateEmployeeMarkers(employeeMarkers);
|
||||
// 对比新旧标记点,精确更新
|
||||
this.updateMarkersPrecisely(mapModule, currentEmployeeMarkers, newEmployeeMarkers);
|
||||
|
||||
console.log('✅ [LocationModule] 员工标记点更新完成');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新单个员工标记点
|
||||
* 精确更新标记点 - 通过对比新旧标记点来添加、更新和删除
|
||||
*/
|
||||
private updateSingleEmployeeMarker(locationUpdate: any): void {
|
||||
console.log('更新单个员工标记点:', locationUpdate.userId);
|
||||
private updateMarkersPrecisely(mapModule: any, currentMarkers: any[], newMarkers: any[]): void {
|
||||
console.log('🎯 [LocationModule] 开始精确更新标记点');
|
||||
|
||||
// 获取地图模块
|
||||
const mapModule = this.dataModule.getMapModule();
|
||||
if (!mapModule) {
|
||||
console.error('地图模块未找到,无法更新员工标记点');
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取用户角色信息
|
||||
const userRole = this.getUserRole(locationUpdate.userId);
|
||||
|
||||
// 创建单个员工标记点
|
||||
const employeeMarker = {
|
||||
id: 10000 + locationUpdate.userId,
|
||||
type: 'employee',
|
||||
title: `员工${locationUpdate.userId}`,
|
||||
longitude: locationUpdate.longitude,
|
||||
latitude: locationUpdate.latitude,
|
||||
iconPath: this.getEmployeeIcon(locationUpdate.userId, userRole),
|
||||
width: 32,
|
||||
height: 32,
|
||||
zIndex: 30,
|
||||
data: {
|
||||
userId: locationUpdate.userId,
|
||||
role: userRole,
|
||||
lastUpdateTime: locationUpdate.timestamp || Date.now()
|
||||
// 创建用户ID到标记点的映射
|
||||
const currentMarkerMap = new Map();
|
||||
currentMarkers.forEach(marker => {
|
||||
if (marker.data && marker.data.userId) {
|
||||
currentMarkerMap.set(marker.data.userId, marker);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// 调用地图模块更新单个标记点
|
||||
mapModule.updateSingleEmployeeMarker(employeeMarker);
|
||||
const newMarkerMap = new Map();
|
||||
newMarkers.forEach(marker => {
|
||||
if (marker.data && marker.data.userId) {
|
||||
newMarkerMap.set(marker.data.userId, marker);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('单个员工标记点更新完成');
|
||||
console.log('📊 [LocationModule] 当前标记点用户ID:', Array.from(currentMarkerMap.keys()));
|
||||
console.log('📊 [LocationModule] 新标记点用户ID:', Array.from(newMarkerMap.keys()));
|
||||
|
||||
// 找出需要删除的标记点(在当前但不在新的)
|
||||
const markersToRemove = currentMarkers.filter(marker => {
|
||||
if (marker.data && marker.data.userId) {
|
||||
return !newMarkerMap.has(marker.data.userId);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// 找出需要添加的标记点(在新的但不在当前的)
|
||||
const markersToAdd = newMarkers.filter(marker => {
|
||||
if (marker.data && marker.data.userId) {
|
||||
return !currentMarkerMap.has(marker.data.userId);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// 找出需要更新的标记点(位置或信息有变化)
|
||||
const markersToUpdate = newMarkers.filter(marker => {
|
||||
if (marker.data && marker.data.userId) {
|
||||
const currentMarker = currentMarkerMap.get(marker.data.userId);
|
||||
if (currentMarker) {
|
||||
// 检查位置是否变化
|
||||
return currentMarker.longitude !== marker.longitude ||
|
||||
currentMarker.latitude !== marker.latitude ||
|
||||
currentMarker.title !== marker.title ||
|
||||
currentMarker.iconPath !== marker.iconPath;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
console.log(`🗑️ [LocationModule] 需要删除的标记点数量: ${markersToRemove.length}`);
|
||||
console.log(`➕ [LocationModule] 需要添加的标记点数量: ${markersToAdd.length}`);
|
||||
console.log(`🔄 [LocationModule] 需要更新的标记点数量: ${markersToUpdate.length}`);
|
||||
|
||||
// 执行删除操作
|
||||
markersToRemove.forEach(marker => {
|
||||
console.log(`🗑️ [LocationModule] 删除标记点: 用户 ${marker.data.userId}`);
|
||||
mapModule.removeEmployeeMarker(marker.id);
|
||||
});
|
||||
|
||||
// 执行添加操作
|
||||
markersToAdd.forEach(marker => {
|
||||
console.log(`➕ [LocationModule] 添加标记点: 用户 ${marker.data.userId}`);
|
||||
mapModule.addEmployeeMarker(marker);
|
||||
});
|
||||
|
||||
// 执行更新操作
|
||||
markersToUpdate.forEach(marker => {
|
||||
console.log(`🔄 [LocationModule] 更新标记点: 用户 ${marker.data.userId}`);
|
||||
mapModule.updateSingleEmployeeMarker(marker);
|
||||
});
|
||||
|
||||
console.log('🎯 [LocationModule] 精确更新标记点完成');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户角色
|
||||
*/
|
||||
@@ -281,12 +274,14 @@ export class LocationModule {
|
||||
/**
|
||||
* 获取员工图标
|
||||
*/
|
||||
private getEmployeeIcon(userId: number, userRole: string): string {
|
||||
private getEmployeeIcon(_userId: number, userRole: string): string {
|
||||
// 根据用户角色返回不同的图标
|
||||
if (userRole === 'ADMIN') {
|
||||
return '/images/crown.png'; // 管理员图标
|
||||
} else if (userRole === 'DRIVER') {
|
||||
return '/images/truck.png'; // 司机图标
|
||||
} else {
|
||||
return '/images/trucks.png'; // 货运人员图标
|
||||
return '👤'; // 普通员工图标(表情符号)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,6 +183,71 @@ export class LoginModule {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理签退流程
|
||||
*/
|
||||
public async handleSignOut(): Promise<boolean> {
|
||||
try {
|
||||
// 显示加载中提示
|
||||
wx.showLoading({
|
||||
title: '签退中...',
|
||||
});
|
||||
|
||||
// 调用签退接口
|
||||
const signOutResult = await userService.signOut();
|
||||
|
||||
wx.hideLoading();
|
||||
|
||||
if (signOutResult.success) {
|
||||
console.log('签退成功:', signOutResult);
|
||||
wx.showToast({
|
||||
title: '签退成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
|
||||
// 停止位置追踪服务
|
||||
try {
|
||||
await locationTrackingService.stopTracking();
|
||||
console.log('位置追踪服务已停止');
|
||||
} catch (trackingError) {
|
||||
console.warn('停止位置追踪失败,但不影响签退:', trackingError);
|
||||
}
|
||||
|
||||
// 设置用户状态为已签退
|
||||
if (this.pageContext && this.pageContext.setData) {
|
||||
this.pageContext.setData({
|
||||
'authStatus.userStatus': 'signed_out'
|
||||
});
|
||||
|
||||
// 更新按钮显示状态
|
||||
if (this.pageContext.updateButtonDisplayStatus) {
|
||||
this.pageContext.updateButtonDisplayStatus();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
console.warn('签退失败:', signOutResult.message);
|
||||
wx.showToast({
|
||||
title: signOutResult.message || '签退失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('签退过程中发生错误:', error);
|
||||
wx.hideLoading();
|
||||
wx.showToast({
|
||||
title: '签退失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理签到流程
|
||||
*/
|
||||
@@ -248,37 +313,11 @@ export class LoginModule {
|
||||
}
|
||||
}
|
||||
|
||||
// 启动位置追踪服务
|
||||
// 启动位置追踪服务(WebSocket连接)
|
||||
try {
|
||||
// 先启动位置追踪服务
|
||||
await locationTrackingService.startTrackingAfterSignIn();
|
||||
// 启动位置追踪服务(建立WebSocket连接)
|
||||
await locationTrackingService.startTracking();
|
||||
console.log('位置追踪服务已启动');
|
||||
|
||||
// 然后调用位置模块的实时跟踪功能
|
||||
const locationModule = this.dataModule.getLocationModule();
|
||||
if (locationModule) {
|
||||
await locationModule.startRealTimeTracking();
|
||||
console.log('位置模块实时跟踪已启动');
|
||||
}
|
||||
|
||||
// 订阅位置更新回调,采用统一方式更新所有用户位置
|
||||
locationTrackingService.subscribeToLocationUpdates((onlineUsers) => {
|
||||
console.log('🚚 位置更新回调 - 在线用户列表已更新,用户数量:', onlineUsers.length);
|
||||
|
||||
// 统一更新所有在线用户的位置标记点
|
||||
onlineUsers.forEach(user => {
|
||||
if (user.lastLocation) {
|
||||
console.log(`📍 更新用户 ${user.userId} 标记点位置:`, user.lastLocation);
|
||||
// 统一调用数据模块更新用户标记点位置
|
||||
this.dataModule.updateUserMarkerPosition(
|
||||
user.lastLocation.longitude,
|
||||
user.lastLocation.latitude,
|
||||
user.userId
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
} catch (trackingError) {
|
||||
console.warn('启动位置追踪失败,但不影响签到:', trackingError);
|
||||
}
|
||||
@@ -355,23 +394,6 @@ export class LoginModule {
|
||||
userInfo.role !== 'GUEST'
|
||||
);
|
||||
|
||||
// 调试信息:打印不满足条件的原因
|
||||
if (!result) {
|
||||
console.log('签到按钮不显示原因:');
|
||||
if (!authStatus.hasWxCode) console.log(' - 未获取微信code');
|
||||
if (authStatus.userStatus === 'signed_in') console.log(' - 用户状态为已签到');
|
||||
if (authStatus.userStatus === 'unregistered') console.log(' - 用户状态为未注册');
|
||||
if (userInfo === null) console.log(' - 用户信息为空');
|
||||
if (userInfo && userInfo.role === 'GUEST') console.log(' - 用户角色为游客');
|
||||
console.log('当前状态:', {
|
||||
hasWxCode: authStatus.hasWxCode,
|
||||
userStatus: authStatus.userStatus,
|
||||
userInfo: userInfo ? { role: userInfo.role } : null
|
||||
});
|
||||
} else {
|
||||
console.log('签到按钮显示条件满足');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -392,21 +414,7 @@ export class LoginModule {
|
||||
userInfo.role === 'GUEST'
|
||||
);
|
||||
|
||||
// 调试信息:打印不满足条件的原因
|
||||
if (!result) {
|
||||
console.log('注册按钮不显示原因:');
|
||||
if (!authStatus.hasWxCode) console.log(' - 未获取微信code');
|
||||
if (authStatus.userStatus !== 'unregistered') console.log(` - 用户状态为${authStatus.userStatus},不是未注册`);
|
||||
if (userInfo === null) console.log(' - 用户信息为空');
|
||||
if (userInfo && userInfo.role !== 'GUEST') console.log(` - 用户角色为${userInfo.role},不是游客`);
|
||||
console.log('当前状态:', {
|
||||
hasWxCode: authStatus.hasWxCode,
|
||||
userStatus: authStatus.userStatus,
|
||||
userInfo: userInfo ? { role: userInfo.role } : null
|
||||
});
|
||||
} else {
|
||||
console.log('注册按钮显示条件满足');
|
||||
}
|
||||
// 调试信息已删除
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ export interface MainPageModule {
|
||||
|
||||
export class MainPageModule {
|
||||
private pageContext: any;
|
||||
private dataModule: DataModule;
|
||||
private loginModule: LoginModule;
|
||||
private mapModule: MapModule;
|
||||
private orderModule: OrderModule;
|
||||
private warehouseModule: WarehouseModule;
|
||||
private employeeModule: EmployeeModule;
|
||||
private locationModule: LocationModule;
|
||||
private dataModule: DataModule;
|
||||
|
||||
constructor(pageContext: any) {
|
||||
this.pageContext = pageContext;
|
||||
@@ -198,13 +198,15 @@ export class MainPageModule {
|
||||
* 重置用户标记点
|
||||
*/
|
||||
private resetUserMarker(): void {
|
||||
const { markers } = this.pageContext.data;
|
||||
const { markers, userInfo } = this.pageContext.data;
|
||||
const userRole = userInfo?.role || 'employee';
|
||||
const iconPath = userRole === 'ADMIN' ? '/images/crown.png' : '/images/truck.png';
|
||||
|
||||
const updatedMarkers = markers.map((marker: any) => {
|
||||
if (marker.id === -1) {
|
||||
return {
|
||||
...marker,
|
||||
iconPath: '/images/trucks.png'
|
||||
iconPath: iconPath
|
||||
};
|
||||
}
|
||||
return marker;
|
||||
@@ -334,6 +336,19 @@ export class MainPageModule {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理资源
|
||||
*/
|
||||
cleanup(): void {
|
||||
console.log('清理主页面模块资源');
|
||||
|
||||
// 清理位置模块
|
||||
this.locationModule.cleanup();
|
||||
|
||||
// 这里可以添加其他需要清理的资源
|
||||
console.log('✅ 主页面模块清理完成');
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理错误
|
||||
*/
|
||||
|
||||
@@ -171,55 +171,17 @@ export class MapModule {
|
||||
|
||||
const markers: Marker[] = [];
|
||||
|
||||
// 获取用户位置
|
||||
const userLocation = this.pageContext.data.userLocation;
|
||||
if (userLocation && userLocation.longitude && userLocation.latitude) {
|
||||
// 添加用户位置标记点
|
||||
markers.push({
|
||||
id: -1,
|
||||
title: '用户位置',
|
||||
longitude: userLocation.longitude,
|
||||
latitude: userLocation.latitude,
|
||||
iconPath: '/images/trucks.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
zIndex: 99
|
||||
});
|
||||
|
||||
console.log('已添加用户位置标记点');
|
||||
}
|
||||
// 地图自带用户位置显示功能,无需手动添加用户位置标记点
|
||||
|
||||
return markers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户标记图标为用户头像
|
||||
* 注意:由于地图自带用户位置显示功能,此方法已不再需要
|
||||
*/
|
||||
updateUserMarkerIcon(): void {
|
||||
const { authStatus, userInfo, markers } = this.pageContext.data;
|
||||
|
||||
if (!authStatus.hasWxCode || !userInfo) {
|
||||
console.warn('未登录或用户信息为空,无法更新头像');
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用默认头像
|
||||
const avatarUrl = '/images/trucks.png';
|
||||
|
||||
const updatedMarkers = markers.map((marker: Marker) => {
|
||||
if (marker.id === -1) {
|
||||
return {
|
||||
...marker,
|
||||
iconPath: avatarUrl
|
||||
};
|
||||
}
|
||||
return marker;
|
||||
});
|
||||
|
||||
// 更新数据模块中的标记点
|
||||
this.dataModule.updateMarkers(updatedMarkers);
|
||||
|
||||
console.log('用户头像已更新');
|
||||
console.log('地图自带用户位置显示功能,无需更新用户标记图标');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,6 +206,91 @@ export class MapModule {
|
||||
console.log('员工标记点更新完成,总标记点数量:', updatedMarkers.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有员工标记点
|
||||
*/
|
||||
clearEmployeeMarkers(): void {
|
||||
console.log('开始清除所有员工标记点');
|
||||
|
||||
const { markers } = this.pageContext.data;
|
||||
|
||||
// 过滤掉员工标记点,只保留其他类型的标记点
|
||||
const filteredMarkers = markers.filter((marker: any) =>
|
||||
marker.type !== 'employee'
|
||||
);
|
||||
|
||||
// 更新数据模块中的标记点
|
||||
this.dataModule.updateMarkers(filteredMarkers);
|
||||
|
||||
console.log('员工标记点清除完成,剩余标记点数量:', filteredMarkers.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个员工标记点
|
||||
*/
|
||||
removeEmployeeMarker(markerId: number): void {
|
||||
console.log('删除单个员工标记点:', markerId);
|
||||
|
||||
const { markers } = this.pageContext.data;
|
||||
|
||||
// 只删除员工类型的标记点,避免误删其他类型标记点
|
||||
const filteredMarkers = markers.filter((marker: any) =>
|
||||
!(marker.id === markerId && marker.type === 'employee')
|
||||
);
|
||||
|
||||
// 检查是否真的删除了标记点
|
||||
const originalCount = markers.length;
|
||||
const newCount = filteredMarkers.length;
|
||||
|
||||
if (originalCount === newCount) {
|
||||
console.warn('未找到员工标记点,可能标记点不存在或不是员工类型:', markerId);
|
||||
} else {
|
||||
console.log('成功删除员工标记点:', markerId);
|
||||
}
|
||||
|
||||
// 更新数据模块中的标记点
|
||||
this.dataModule.updateMarkers(filteredMarkers);
|
||||
|
||||
console.log('单个员工标记点删除完成,剩余标记点数量:', filteredMarkers.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加单个员工标记点
|
||||
*/
|
||||
addEmployeeMarker(employeeMarker: Marker): void {
|
||||
console.log('添加单个员工标记点:', employeeMarker.id);
|
||||
|
||||
// 确保标记点类型为员工
|
||||
const markerWithType = {
|
||||
...employeeMarker,
|
||||
type: 'employee'
|
||||
};
|
||||
|
||||
const { markers } = this.pageContext.data;
|
||||
|
||||
// 检查是否已存在相同ID的标记点
|
||||
const existingIndex = markers.findIndex((marker: any) =>
|
||||
marker.id === markerWithType.id && marker.type === 'employee'
|
||||
);
|
||||
|
||||
let updatedMarkers;
|
||||
if (existingIndex !== -1) {
|
||||
// 如果已存在相同ID的员工标记点,则更新
|
||||
updatedMarkers = [...markers];
|
||||
updatedMarkers[existingIndex] = markerWithType;
|
||||
console.log('员工标记点已存在,执行更新操作');
|
||||
} else {
|
||||
// 如果不存在,则添加新的员工标记点
|
||||
updatedMarkers = [...markers, markerWithType];
|
||||
console.log('员工标记点不存在,执行添加操作');
|
||||
}
|
||||
|
||||
// 更新数据模块中的标记点
|
||||
this.dataModule.updateMarkers(updatedMarkers);
|
||||
|
||||
console.log('单个员工标记点添加完成,总标记点数量:', updatedMarkers.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新单个员工标记点
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user