|
|
|
@ -805,8 +805,6 @@ |
|
|
|
// 获取用户当前位置 |
|
|
|
// this.getUserLocation(); |
|
|
|
this.getUserOrders(); |
|
|
|
// 建立WebSocket连接或定时请求获取配送员位置 |
|
|
|
this.getDeliveryLocation(); |
|
|
|
if (!uni.getStorageSync('area')) { |
|
|
|
this.checkArea() |
|
|
|
} else { |
|
|
|
@ -1300,44 +1298,6 @@ |
|
|
|
phoneNumber: phone |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 获取配送员位置,这里假设使用WebSocket |
|
|
|
getDeliveryLocation() { |
|
|
|
// WebSocket连接,需要时放开 |
|
|
|
// uni.connectSocket({ |
|
|
|
// url: "wss://www.example.com/socket", |
|
|
|
// header: { |
|
|
|
// "content-type": "application/json", |
|
|
|
// }, |
|
|
|
// protocols: ["protocol1"], |
|
|
|
// method: "GET", |
|
|
|
// }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 假设我们有一个WebSocket连接,这里用setInterval模拟定时获取 |
|
|
|
// this.deliveryTimer = setInterval(() => { |
|
|
|
// 实际开发中,这里应该是从WebSocket推送或后端API获取 |
|
|
|
// 模拟数据 |
|
|
|
const deliveryLat = this.latitude; |
|
|
|
const deliveryLng = this.longitude; |
|
|
|
// 更新配送员位置标记 |
|
|
|
// 先清除之前的配送员标记,假设配送员标记id为1 |
|
|
|
this.markers = this.markers.filter(marker => marker.id !== 1); |
|
|
|
// 添加新的配送员标记 |
|
|
|
this.markers.push({ |
|
|
|
id: 1, |
|
|
|
latitude: deliveryLat, |
|
|
|
longitude: deliveryLng, |
|
|
|
title: '张三', |
|
|
|
iconPath: '/static/images/tabbar/fabu1.png', // 配送员图标 |
|
|
|
width: 30, |
|
|
|
height: 30 |
|
|
|
}); |
|
|
|
// 将地图中心移动到配送员位置 |
|
|
|
this.latitude = deliveryLat; |
|
|
|
this.longitude = deliveryLng; |
|
|
|
// }, 5000); |
|
|
|
}, |
|
|
|
// 页面卸载时清除定时器 |
|
|
|
onUnload() { |
|
|
|
if (this.deliveryTimer) { |
|
|
|
|