Compare commits

..

2 Commits

Author SHA1 Message Date
1443aa9964 Merge branch 'main' of http://47.107.152.87:3000/dyf/APP 2025-08-01 16:36:58 +08:00
6b409f4272 地图动态打点 2025-08-01 16:36:43 +08:00
3 changed files with 232 additions and 219 deletions

View File

@ -702,7 +702,7 @@
this.mqttClient.connect(() => { this.mqttClient.connect(() => {
console.log('MQTT 连接成功,开始订阅主题'); console.log('MQTT 连接成功,开始订阅主题');
// 订阅来自设备的状态更新 // 订阅来自设备的状态更新
const statusTopic = `A/${this.itemInfo.id}`; const statusTopic = `A/${this.itemInfo.deviceImei}`;
this.mqttClient.subscribe(statusTopic, (payload) => { this.mqttClient.subscribe(statusTopic, (payload) => {
console.log(`收到来自 ${statusTopic} 的消息:`, payload); console.log(`收到来自 ${statusTopic} 的消息:`, payload);
// uni.showModal({ // uni.showModal({

View File

@ -307,15 +307,23 @@
}, },
// *******定位****** // *******定位******
gpsPosition(item) { gpsPosition(item) {
// 添加调试日志
uni.navigateTo({ uni.navigateTo({
url: '/pages/common/map/index', url: '/pages/common/map/index',
events: {
ack: function(data) {}
},
success: (res) => { success: (res) => {
res.eventChannel.emit('MapData', { // 确保使用深拷贝
data: item const mapData = {
}); deviceLocation: {
longitude: String(item.longitude), // 强制转为字符串
latitude: String(item.latitude),
deviceImage: item.devicePic || '',
deviceName: item.deviceImei || ''
}
}
res.eventChannel.emit('MapData', JSON.parse(JSON.stringify(mapData)))
},
fail: (err) => {
} }
}) })
}, },
@ -661,12 +669,6 @@
}); });
} }
}) })
// const topic = `device/command/${this.deviceID}/message`;
// this.mqttClient.publish(topic, this.messageToSend);
// uni.showToast({
// title: '消息已发送',
// icon: 'success'
// });
}, },
// 统一处理返回方法 // 统一处理返回方法
handleDeviceData(res, isFromShared = false) { handleDeviceData(res, isFromShared = false) {
@ -745,7 +747,7 @@
this.mqttClient.connect(() => { this.mqttClient.connect(() => {
console.log('MQTT 连接成功,开始订阅主题'); console.log('MQTT 连接成功,开始订阅主题');
// 订阅来自设备的状态更新 // 订阅来自设备的状态更新
const statusTopic = `A/${this.deviceID}`; const statusTopic = `A/${this.itemInfo.deviceImei}`;
this.mqttClient.subscribe(statusTopic, (payload) => { this.mqttClient.subscribe(statusTopic, (payload) => {
console.log(`收到来自 ${statusTopic} 的消息:`, payload); console.log(`收到来自 ${statusTopic} 的消息:`, payload);
// ✅ 发送全局事件通知主页面更新 // ✅ 发送全局事件通知主页面更新
@ -928,12 +930,14 @@
color: rgba(255, 255, 255, 0.6); color: rgba(255, 255, 255, 0.6);
text-align: end; text-align: end;
} }
.locationGPS { .locationGPS {
width: 88%; width: 88%;
text-align: end; text-align: end;
float: right; float: right;
line-height: 50rpx; line-height: 50rpx;
} }
.control-card { .control-card {
background-color: rgb(26, 26, 26); background-color: rgb(26, 26, 26);
border-radius: 16rpx; border-radius: 16rpx;

View File

@ -83,21 +83,26 @@ export default {
this.map.on('complete', () => { this.map.on('complete', () => {
document.getElementById('amapContainer').style.opacity = 1 document.getElementById('amapContainer').style.opacity = 1
this.$ownerInstance.callMethod('hideLoading') this.$ownerInstance.callMethod('hideLoading')
// 添加标记点 // 添加标记点
const wuhanPoints = [ const wuhanPoints = [{
{ lnglat: [114.404, 30.507], name: "华中科技大学" }, lnglat: [114.404, 30.507],
{ lnglat: [114.428, 30.476], name: "光谷金融港" }, name: "华中科技大学"
{ lnglat: [114.433, 30.504], name: "武汉东站" } },
{
lnglat: [114.428, 30.476],
name: "光谷金融港"
},
{
lnglat: [114.433, 30.504],
name: "武汉东站"
}
] ]
wuhanPoints.forEach(point => { wuhanPoints.forEach(point => {
this.addMarker(point.lnglat, point.name) this.addMarker(point.lnglat, point.name)
}) })
}) })
// 创建自定义弹窗 // 创建自定义弹窗
this.createCustomPopup() this.createCustomPopup()
} catch (e) { } catch (e) {
console.error('初始化失败:', e) console.error('初始化失败:', e)
this.$ownerInstance.callMethod('hideLoading') this.$ownerInstance.callMethod('hideLoading')
@ -122,11 +127,9 @@ export default {
map: this.map, map: this.map,
icon: 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png', icon: 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png',
}) })
marker.on('click', () => { marker.on('click', () => {
this.showCustomPopup(position, title) this.showCustomPopup(position, title)
}) })
this.markers.push(marker) this.markers.push(marker)
return marker return marker
}, },
@ -137,7 +140,6 @@ export default {
this.customPopup.style.display = 'block' this.customPopup.style.display = 'block'
this.customPopup.style.left = `${pixel.x}px` this.customPopup.style.left = `${pixel.x}px`
this.customPopup.style.top = `${pixel.y}px` this.customPopup.style.top = `${pixel.y}px`
this.map.on('click', this.hideCustomPopup) this.map.on('click', this.hideCustomPopup)
}, },
@ -149,8 +151,8 @@ export default {
} }
}, },
onLoad(options) { onLoad(options) {
console.log(options,'optionsoptions');
const eventChannel = this.getOpenerEventChannel(); const eventChannel = this.getOpenerEventChannel();
// 监听 'detailData' 事件,获取传过来的数据
eventChannel.on('MapData', (data) => { eventChannel.on('MapData', (data) => {
console.log(data, 'data'); console.log(data, 'data');
}) })
@ -237,7 +239,14 @@ export default {
} }
@keyframes popupFadeIn { @keyframes popupFadeIn {
from { opacity: 0; transform: translate(-50%, -90%); } from {
to { opacity: 1; transform: translate(-50%, -100%); } opacity: 0;
transform: translate(-50%, -90%);
}
to {
opacity: 1;
transform: translate(-50%, -100%);
}
} }
</style> </style>