|
|
@@ -164,6 +164,10 @@ Page({
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 根据医院生成地图轨迹数据
|
|
|
+ const hospitalLocation = this.getHospitalLocation(this.data.selectedHospital.name)
|
|
|
+ const mapTracking = this.generateMapTracking(hospitalLocation)
|
|
|
+
|
|
|
// 创建订单数据
|
|
|
const order = {
|
|
|
id: Date.now(),
|
|
|
@@ -175,7 +179,8 @@ Page({
|
|
|
droneTracking: {
|
|
|
status: '配送中',
|
|
|
steps: ['订单确认', '药品准备', '无人机起飞', '配送中', '待送达']
|
|
|
- }
|
|
|
+ },
|
|
|
+ mapTracking: mapTracking
|
|
|
}
|
|
|
|
|
|
// 保存订单到全局变量和本地存储
|
|
|
@@ -199,6 +204,62 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ // 获取医院位置
|
|
|
+ getHospitalLocation(hospitalName) {
|
|
|
+ const locations = {
|
|
|
+ '北京协和医院': { latitude: 39.9139, longitude: 116.3917 },
|
|
|
+ '上海瑞金医院': { latitude: 31.2304, longitude: 121.4737 },
|
|
|
+ '广州中山医院': { latitude: 23.1291, longitude: 113.2644 }
|
|
|
+ }
|
|
|
+ return locations[hospitalName] || { latitude: 39.9042, longitude: 116.4074 }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 生成地图轨迹数据
|
|
|
+ generateMapTracking(hospitalLocation) {
|
|
|
+ const points = []
|
|
|
+ const numPoints = 5
|
|
|
+
|
|
|
+ for (let i = 0; i < numPoints; i++) {
|
|
|
+ const latOffset = (i * 0.004) / numPoints
|
|
|
+ const lngOffset = (i * 0.007) / numPoints
|
|
|
+ points.push({
|
|
|
+ latitude: hospitalLocation.latitude + latOffset,
|
|
|
+ longitude: hospitalLocation.longitude + lngOffset
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ polyline: [
|
|
|
+ {
|
|
|
+ points: points,
|
|
|
+ color: '#007AFF',
|
|
|
+ width: 4,
|
|
|
+ dottedLine: false
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ markers: [
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ latitude: hospitalLocation.latitude,
|
|
|
+ longitude: hospitalLocation.longitude,
|
|
|
+ iconPath: '/images/hospital-marker.png',
|
|
|
+ width: 30,
|
|
|
+ height: 30,
|
|
|
+ title: '医院位置'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 2,
|
|
|
+ latitude: points[points.length - 1].latitude,
|
|
|
+ longitude: points[points.length - 1].longitude,
|
|
|
+ iconPath: '/images/drone-marker.png',
|
|
|
+ width: 30,
|
|
|
+ height: 30,
|
|
|
+ title: '无人机位置'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 选择热门药品
|
|
|
selectHotMedicine(e) {
|
|
|
const medicineName = e.currentTarget.dataset.medicine
|
|
|
@@ -223,6 +284,10 @@ Page({
|
|
|
content: `确认在${priceInfo.hospital}购买${medicineName},价格:¥${priceInfo.price}`,
|
|
|
success: (res) => {
|
|
|
if (res.confirm) {
|
|
|
+ // 根据医院生成地图轨迹数据
|
|
|
+ const hospitalLocation = this.getHospitalLocation(priceInfo.hospital)
|
|
|
+ const mapTracking = this.generateMapTracking(hospitalLocation)
|
|
|
+
|
|
|
// 创建订单数据
|
|
|
const order = {
|
|
|
id: Date.now(),
|
|
|
@@ -234,7 +299,8 @@ Page({
|
|
|
droneTracking: {
|
|
|
status: '配送中',
|
|
|
steps: ['订单确认', '药品准备', '无人机起飞', '配送中', '待送达']
|
|
|
- }
|
|
|
+ },
|
|
|
+ mapTracking: mapTracking
|
|
|
}
|
|
|
|
|
|
// 保存订单到全局变量和本地存储
|