Forráskód Böngészése

提交弹窗告警

wangming 2 hónapja
szülő
commit
001975e473

+ 39 - 32
src/components/component/alarModel.vue

@@ -14,11 +14,8 @@
                 {{ nowTime }}
             </view>
             <view class="alarm-info">
-                检测到
                 <text style="color: #ff6d6d">{{ devName }}</text>
-                可能发生跌倒事件,已通知
-                <text style="color: #ff6d6d">{{ localPhone }}</text>
-                用户,请立即处理!
+                检测到可能发生跌倒事件,请立即处理!
             </view>
             <view class="backImg">
                 <image src="../../static/actionRed.png" mode="" />
@@ -34,13 +31,16 @@
                 <view class="alarm-voice" v-else @click="authorizeIot">
                     语音确认
                 </view>
-                <view class="alarm-handle" @click="handleAlarm"> 已知晓 </view>
+                <view class="alarm-handle" @click="handleAlarm()">
+                    已知晓
+                </view>
             </view>
         </view>
     </view>
 </template>
 <script>
 import config from "../../data/config.js";
+import mqtt from "../../utils/mqtt";
 import {
     getSnTicket,
     authorize,
@@ -80,18 +80,18 @@ export default {
     },
     data() {
         return {
-            alarmModel: true,
-            nowTime: "2025-06-20 10:30:00",
-            devName: "我的第一台设备",
-            localPhone: "13888888888",
+            alarmModel: false,
+            nowTime: "",
+            devName: "",
             authorizeFlag: true,
-            clientId: "30EDA036351C",
-            dev_id: "30EDA036351C",
+            clientId: "",
+            dev_id: "",
+            mqttClient: "",
             // voip相关
             isWmpf: isWmpf,
             name: "用户",
             voipDevices: [],
-            sn: "30EDA036351C",
+            sn: "",
             isShowPopUp: false,
             contactList: [],
             isWmpf,
@@ -405,7 +405,18 @@ export default {
             let client = "";
             let selectedService = uni.getStorageSync("sercviceChoice");
             if (!selectedService || selectedService == "aloneServe") {
-                client = mqtt.connect("wxs://radar-power.cn:8084/mqtt", params);
+                if (__wxConfig.envVersion == "develop") {
+                    client = mqtt.connect(
+                        "wxs://api.radar-power.asia:8084/mqtt",
+                        params
+                    );
+                }
+                if (__wxConfig.envVersion == "trial") {
+                    client = mqtt.connect(
+                        "wxs://radar-power.cn:8084/mqtt",
+                        params
+                    );
+                }
             }
             // 存储client引用以便后续操作
             this.mqttClient = client;
@@ -416,7 +427,7 @@ export default {
                     if (err) {
                         console.error("订阅失败", err);
                     } else {
-                        console.log(`成功订阅设备主题: device/${clientId}`);
+                        console.log(`成功订阅设备主题: device/mps`);
                     }
                 });
             });
@@ -425,7 +436,7 @@ export default {
             });
             client.on("error", (err) => {
                 setTimeout(() => {
-                    this.connectMQTT(clientId, devId);
+                    this.connectMQTT();
                 }, 5000);
             });
 
@@ -434,24 +445,24 @@ export default {
             client.on("close", () => {});
 
             client.on("message", (topic, message) => {
-                // clearTimeout(this.inactivityTimer);
-                // this.inactivityTimer = setTimeout(() => {
-                //     this.targetPoints = {};
-                // }, 1500);
-                // if (!match) return;
+                this.alarmModel = true;
                 const data = JSON.parse(message.toString());
+                this.clientId = data.clientId;
+                this.devName = data.devName;
+                this.sn = data.clientId;
+                const now = new Date();
+                const year = now.getFullYear();
+                const month = (now.getMonth() + 1).toString().padStart(2, "0");
+                const day = now.getDate().toString().padStart(2, "0");
+                const hours = now.getHours().toString().padStart(2, "0");
+                const minutes = now.getMinutes().toString().padStart(2, "0");
+                const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}`;
+                this.nowTime = formattedTime;
                 console.log("接收到消息:", topic, data);
             });
         },
     },
-    attached() {
-        console.log("子组件打印了");
-        if (!isWmpf) {
-            this.getVoipDevices();
-        }
-        this.connectMQTT();
-    },
-    onLoad() {
+    beforeMount() {
         console.log("子组件打印了");
         if (!isWmpf) {
             this.getVoipDevices();
@@ -463,10 +474,6 @@ export default {
         clearInterval(this.autoPlayinterval);
         clearInterval(this.inactivityTimer);
     },
-    // onHide() {
-    //     if (this.mqttClient) this.mqttClient.end(true);
-    // },
-    onShareAppMessage() {},
 };
 </script>
 

+ 0 - 9
src/pages.json

@@ -158,15 +158,6 @@
                     }
                 },
                 {
-                    "path": "myHome/myHome",
-                    "style": {
-                        "enablePullDownRefresh": true,
-                        "navigationBarTitleText": "网络配置",
-                        "navigationBarBackgroundColor": "#faede2",
-                        "navigationBarTextStyle": "black"
-                    }
-                },
-                {
                     "path": "homeManage/homeManage",
                     "style": {
                         "enablePullDownRefresh": true,

+ 1 - 0
src/pagesA/OTA/OTA.vue

@@ -69,6 +69,7 @@
             v-if="devsClientId.length > 0 && otaList.length > 0"
             >更新OTA</view
         >
+        <alarModel />
     </view>
 </template>
 

+ 1 - 0
src/pagesA/adDevice/adDevice.vue

@@ -222,6 +222,7 @@
                 </view>
             </view>
         </view>
+        <alarModel />
     </view>
 </template>
 <script>

+ 1 - 0
src/pagesA/deviceDetail/deviceDetail.vue

@@ -261,6 +261,7 @@
                 </view>
             </view>
         </view>
+        <alarModel />
     </view>
 </template>
 <script>

+ 1 - 0
src/pagesA/deviceSetting/deviceSetting.vue

@@ -38,6 +38,7 @@
                 <view class="btn2" @click="unbindDevice">解绑设备</view>
             </view>
         </view>
+        <alarModel />
     </view>
 </template>
 <script>

+ 1 - 0
src/pagesA/devices/devices.vue

@@ -59,6 +59,7 @@
                     <image src="../../static/ln_small.png" mode="" />
                 </view>
             </view>
+            <alarModel />
         </view>
     </view>
 </template>

+ 1 - 0
src/pagesA/homeDetail/homeDetail.vue

@@ -18,6 +18,7 @@
                 >
             </view>
         </view>
+        <alarModel />
     </view>
 </template>
 

+ 1 - 0
src/pagesA/homeManage/homeManage.vue

@@ -82,6 +82,7 @@
                 </view>
             </view>
         </view>
+        <alarModel />
     </view>
 </template>
 

+ 1 - 0
src/pagesA/linkShare/linkShare.vue

@@ -73,6 +73,7 @@
             确认分享
         </button>
         <button class="btn1" v-else @click="unShare()">暂不可分享</button>
+        <alarModel />
     </view>
 </template>
 <script>

+ 1 - 0
src/pagesA/loginNew/loginNew.vue

@@ -35,6 +35,7 @@
                 ></text
             >
         </view>
+        <alarModel />
     </view>
 </template>
 <script>

+ 1 - 0
src/pagesA/my/my.vue

@@ -48,6 +48,7 @@
         </view>
 
         <view class="logoutBtn" @click="goLogout">退出登录</view>
+        <alarModel />
     </view>
 </template>
 

+ 0 - 45
src/pagesA/myHome/myHome.vue

@@ -1,45 +0,0 @@
-<template>
-    <view class="my-home">
-        <view class="header">
-            <text class="title">我的主页</text>
-        </view>
-        <view class="content">
-            <!-- 这里添加你的内容 -->
-        </view>
-    </view>
-</template>
-
-<script>
-export default {
-    name: "MyHome",
-    data() {
-        return {
-            // 这里添加你的数据
-        };
-    },
-    methods: {
-        // 这里添加你的方法
-    },
-};
-</script>
-
-<style scoped>
-.my-home {
-    min-height: 100vh;
-    background: #f5f5f5;
-}
-.header {
-    padding: 32rpx 0;
-    background: #fff;
-    text-align: center;
-    box-shadow: 0 2rpx 8rpx #eee;
-}
-.title {
-    font-size: 36rpx;
-    font-weight: bold;
-    color: #333;
-}
-.content {
-    padding: 32rpx;
-}
-</style>

+ 1 - 0
src/pagesA/roomSetting/roomSetting.vue

@@ -230,6 +230,7 @@
                 </view>
             </view>
         </view>
+        <alarModel />
     </view>
 </template>
 <script>

+ 1 - 0
src/pagesA/serChange/serChange.vue

@@ -21,6 +21,7 @@
                 <button class="btn" @click="confirm">确认</button>
             </view>
         </view>
+        <alarModel />
     </view>
 </template>
 

+ 1 - 0
src/pagesA/shareList/shareList.vue

@@ -60,6 +60,7 @@
                 </view>
             </view>
         </template>
+        <alarModel />
     </view>
 </template>
 

+ 1 - 0
src/pagesA/sharePages/sharePages.vue

@@ -54,6 +54,7 @@
                 <view class="meanRight" @click="refuseDevice(item)">拒绝</view>
             </view>
         </view>
+        <alarModel />
     </view>
 </template>
 <script>