feat:订阅Recall、日期查询

This commit is contained in:
吉浩茹
2025-10-11 10:03:58 +08:00
parent 4e66592cf8
commit 8b1a84f739
7 changed files with 777 additions and 349 deletions

View File

@ -122,6 +122,9 @@ const initEventHandleMqtt = (topicUrl) => {
duration: 3000
});
} else {
sendMqttDataRecall({
command: 'Upload immediately',
})
// console.log("✅ MQTT订阅主题成功:", topicUrl);
}
});
@ -299,6 +302,57 @@ const sendMqttData = (data) => {
}
};
// 发送MQTT数据单独订阅HDYDCJ_01_RECALL
const sendMqttDataRecall = (data) => {
try {
if (!client || !client.connected) {
console.error('❌ MQTT客户端未连接无法发送数据');
uni.showToast({
title: 'MQTT未连接',
icon: 'error',
duration: 2000
});
return false;
}
const message = JSON.stringify(data);
// 先订阅HDYDCJ_01_RECALL主题如果还没有订阅
client.subscribe("HDYDCJ_01_RECALL", (err) => {
if (err) {
console.error('❌ 订阅HDYDCJ_01_RECALL失败:', err);
} else {
console.log('✅ 订阅HDYDCJ_01_RECALL成功');
}
});
// 发送数据到HDYDCJ_01_RECALL主题
client.publish("HDYDCJ_01_RECALL", message, (err) => {
if (err) {
uni.showToast({
title: '数据发送失败',
icon: 'error',
duration: 2000
});
} else {
uni.showToast({
title: '数据发送成功',
icon: 'success',
duration: 1500
});
}
});
return true;
} catch (error) {
uni.showToast({
title: '发送数据异常',
icon: 'error',
duration: 2000
});
return false;
}
};
export {
createMqtt,
closeMqtt,
@ -306,5 +360,6 @@ export {
getConnectionStatus,
manualReconnect,
sendMqttData,
sendMqttDataRecall,
client,
}