地址路径修改

This commit is contained in:
2025-10-26 13:15:04 +08:00
parent be2323074b
commit 271b88232c
77 changed files with 13254 additions and 228 deletions

254
dist/pages/index/modules/dataModule.js vendored Normal file
View File

@@ -0,0 +1,254 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataModule = void 0;
/**
* 页面数据管理模块
* 负责管理index页面的所有数据状态
*/
class DataModule {
constructor(pageContext) {
this.pageContext = pageContext;
}
/**
* 初始化页面数据
*/
async initializeData() {
// 检查是否已静默登录,如果是则尝试获取真实位置
let initialLongitude = 102.833722;
let initialLatitude = 24.880095;
const app = getApp();
if (app.globalData.isLoggedIn) {
try {
// 导入地图服务
const mapService = require('../../../services/mapService').default;
const location = await mapService.getCurrentLocation();
if (location && !isNaN(location.latitude) && !isNaN(location.longitude)) {
initialLongitude = location.longitude;
initialLatitude = location.latitude;
console.log('[DATA MODULE] 静默登录后使用真实位置:', location);
}
}
catch (error) {
console.warn('[DATA MODULE] 获取真实位置失败,使用默认位置:', error);
}
}
this.pageContext.setData({
// 地图相关数据
longitude: initialLongitude,
latitude: initialLatitude,
scale: 13,
markers: [],
polyline: null,
showRoute: false,
routeDistance: 0,
routeDuration: 0,
currentRoute: null,
// 用户相关数据
userInfo: null,
isLoggedIn: false,
showUserPanel: false,
// 订单相关数据
pendingOrders: [],
showOrderPanel: false,
currentOrder: null,
// 货运人员相关数据
showDeliveryPersonModal: false,
deliveryPersonModalState: 'bottom',
currentDeliveryPerson: null,
// 仓库相关数据
showWarehouseModal: false,
warehouseModalState: 'bottom',
currentWarehouse: null,
// 面板位置数据
currentPanelPosition: { x: 0, y: 0 },
// 对话框相关数据
showNickNameDialog: false,
tempNickName: ''
});
}
/**
* 更新用户信息
*/
updateUserInfo(userInfo) {
this.pageContext.setData({
userInfo,
isLoggedIn: !!userInfo
});
// 更新按钮显示状态
if (this.pageContext.updateButtonDisplayStatus) {
this.pageContext.updateButtonDisplayStatus();
}
}
/**
* 设置登录状态
*/
setLoginStatus(isLoggedIn) {
this.pageContext.setData({
isLoggedIn
});
}
/**
* 设置地图缩放级别
*/
setMapScale(scale) {
this.pageContext.setData({
scale
});
}
/**
* 更新用户位置信息
*/
updateUserLocation(latitude, longitude) {
this.pageContext.setData({
latitude,
longitude
});
}
/**
* 更新地图标记点
*/
updateMarkers(markers) {
// 验证每个标记点的坐标
const validatedMarkers = markers.map((marker) => {
// 检查经纬度是否为有效数字
if (isNaN(marker.longitude) || isNaN(marker.latitude)) {
// 为无效坐标设置默认值
return {
...marker,
longitude: 102.833722, // 默认经度
latitude: 24.880095 // 默认纬度
};
}
else {
return marker;
}
});
// 执行更新
this.pageContext.setData({ markers: validatedMarkers });
}
/**
* 更新待分配订单列表
*/
updatePendingOrders(orders) {
this.pageContext.setData({ pendingOrders: orders });
}
/**
* 设置当前选中订单
*/
setCurrentOrder(order) {
this.pageContext.setData({ currentOrder: order });
}
/**
* 设置当前选中货运人员
*/
setCurrentDeliveryPerson(person) {
this.pageContext.setData({ currentDeliveryPerson: person });
}
/**
* 设置当前选中仓库
*/
setCurrentWarehouse(warehouse) {
this.pageContext.setData({ currentWarehouse: warehouse });
}
/**
* 设置面板位置
*/
setPanelPosition(position) {
this.pageContext.setData({ currentPanelPosition: position });
}
/**
* 显示/隐藏用户面板
*/
toggleUserPanel(show) {
this.pageContext.setData({ showUserPanel: show });
}
/**
* 显示/隐藏订单面板
*/
toggleOrderPanel(show) {
this.pageContext.setData({ showOrderPanel: show });
}
/**
* 显示/隐藏仓库弹窗
*/
toggleWarehouseModal(show, state = 'bottom') {
this.pageContext.setData({
showWarehouseModal: show,
warehouseModalState: state
});
}
/**
* 显示/隐藏货运人员弹窗
*/
toggleDeliveryPersonModal(show, state = 'bottom') {
this.pageContext.setData({
showDeliveryPersonModal: show,
deliveryPersonModalState: state
});
}
/**
* 显示/隐藏昵称修改对话框
*/
toggleNickNameDialog(show, tempNickName = '') {
this.pageContext.setData({
showNickNameDialog: show,
tempNickName
});
}
/**
* 更新路线信息
*/
updateRouteInfo(polyline, distance, duration) {
this.pageContext.setData({
polyline,
routeDistance: distance,
routeDuration: duration,
showRoute: true
});
}
/**
* 清除路线信息
*/
clearRouteInfo() {
this.pageContext.setData({
polyline: null,
showRoute: false,
routeDistance: 0,
routeDuration: 0,
currentRoute: null
});
}
/**
* 获取当前数据状态
*/
getData() {
return this.pageContext.data;
}
/**
* 重置所有数据到初始状态
*/
resetAllData() {
this.initializeData();
}
/**
* 获取位置模块(用于其他模块访问位置模块)
*/
getLocationModule() {
// 通过页面上下文获取位置模块
if (this.pageContext.data.mainPageModule) {
return this.pageContext.data.mainPageModule.getLocationModule();
}
return null;
}
/**
* 获取地图模块(用于其他模块访问地图模块)
*/
getMapModule() {
// 通过页面上下文获取地图模块
if (this.pageContext.data.mainPageModule) {
return this.pageContext.data.mainPageModule.getMapModule();
}
return null;
}
}
exports.DataModule = DataModule;