From 6017f46b762663b9393cdae8422e0de1ed3db218 Mon Sep 17 00:00:00 2001
From: guifei zhu <guifeizhu@guifeideiMac.local>
Date: 星期三, 27 十一月 2024 13:30:06 +0800
Subject: [PATCH] 添加mqtt数据接口
---
pages/tabBar/general.vue | 63 ++++++++++++++++++++++++-------
1 files changed, 48 insertions(+), 15 deletions(-)
diff --git a/pages/tabBar/general.vue b/pages/tabBar/general.vue
index ae71ad0..4dd41df 100644
--- a/pages/tabBar/general.vue
+++ b/pages/tabBar/general.vue
@@ -11,9 +11,10 @@
</view>
-->
- <cu-custom bgColor="bg-gradual-blue" :isBack="false">
- <block slot="content">鏅鸿兘涓崏鑽共鐕ヨ澶囬厤濂楃郴缁�</block>
+ <cu-custom bgColor="bg-gradual-blue" :isBack="false">
+ <block slot="content">鏅鸿兘涓崏鑽�</block>
</cu-custom>
+ <mqtt-view ref="mqttView"></mqtt-view>
<u-toast ref="uToast"></u-toast>
<!-- <view class="card-box dynamic shadow cu-list menu">
<view class="title-box">
@@ -232,7 +233,7 @@
</view>
<u-line color="#f1f1f1" margin="15rpx 0 15rpx 0"></u-line>
</view>
-
+
</view>
<!--
<view class="page-box" v-show="false">
@@ -277,11 +278,15 @@
</view>
</view>
</view> -->
+
</view>
</template>
<script>
+
+
export default {
+
data() {
return {
list: [{
@@ -353,22 +358,30 @@
},
onShow() {
console.info('onShow')
+ uni.showTabBarRedDot({
+ index: 2 // 鏄剧ず绗�2涓猼abbar椤癸紙绱㈠紩浠�0寮�濮嬶級鐨勭孩鐐�
+ });
},
+ mounted() {
+
+
+
+ },
onReady() {
- const userinfo = uni.getStorageSync('userinfo');
- const tenantid = userinfo.loginTenantId
- uni.getSystemInfo({
- success: (res) => {
- let deviceId = res.deviceId
- if (!deviceId) {
- deviceId = 'mobile-' + tenantid + '-' + Date.parse(new Date())
- }
- uni.setStorageSync(this.$constant.DEVICE_ID, 'mobile-' + tenantid + '-' + res.deviceId);
- }
- })
- this.startConnect();
+ this.$refs.mqttView.initMqtt()
+
+ // uni.getSystemInfo({
+ // success: (res) => {
+ // let deviceId = res.deviceId
+ // if (!deviceId) {
+ // deviceId = 'mobile-' + this.tenantId + '-' + Date.parse(new Date())
+ // }
+ // uni.setStorageSync(this.$constant.DEVICE_ID, 'mobile-' + this.tenantId + '-' + res.deviceId);
+ // }
+ // })
+ // this.startConnect();
@@ -380,7 +393,11 @@
},
+ onLoad() {
+
+ },
methods: {
+
/* 杩炴帴MQTT */
async startConnect() {
var _this = this
@@ -408,6 +425,14 @@
//璁㈤槄鏌ヨ璁惧鐘舵�佽繑鍥炴暟鎹�
this.$mqttTool.subscribe({
topic: this.$constant.SERVICE_DOWN + '/' + deviceid + '/#',
+ qos: 0
+ }).then(res => {
+ console.error(res)
+ })
+
+ //璁㈤槄璁惧鏁呴殰骞挎挱锛堝箍鎾笉鍦ㄤ箮瀹㈡埛绔痠d锛屽彂閫佺粰绉熸埛涓嬫墍鏈夊湪绾跨殑璁惧锛�
+ this.$mqttTool.subscribe({
+ topic: this.$constant.SERVICE_BROADCAST_TENANT_REAL_FAULT.replace('%s', this.tenantId),
qos: 0
}).then(res => {
console.error(res)
@@ -571,6 +596,14 @@
+ },
+ computed:{
+ tenantId(){
+ const userinfo = uni.getStorageSync('userinfo');
+ const tenantid = userinfo.loginTenantId
+ return tenantid;
+ }
+
}
}
--
Gitblit v1.9.3