Переглянути джерело

1.小程序新增,非主绑人不可分享,离线设备不可设置,2。修复重新进入小程序时,跌倒事件主题未订阅bug

wangming 4 тижнів тому
батько
коміт
dfcf0407dc

+ 35 - 70
src/components/component/alarModel.vue

@@ -639,85 +639,50 @@ export default {
     mounted() {
         const userId = uni.getStorageSync("userId");
         const topic = `/mps/wx_${userId}/notice`;
-        this.unsubscribeFnNotice = MqttService.subscribe(
-            "DATA",
-            topic,
-            (message, msgTopic) => {
-                console.log(`接收到 ${msgTopic} 消息:`, message);
-                // 处理消息
-                const data = JSON.parse(message);
-                let userId = uni.getStorageSync("userId");
-                const noticeMatch = /^\/mps\/wx_(.+)\/notice$/;
-                const match = topic.match(noticeMatch);
-                if (!match) return;
-                // 更新页面数据
-                this.alarmModel = true;
-                this.clientId = data.clientId;
-                this.devName = data.devName;
-                this.sn = data.clientId;
-                this.eventListId = data.eventListId;
-                // VOIP 相关逻辑
-                this.getVoipAuthor(this.clientId, userId);
-                // 格式化时间
-                const now = new Date();
-                this.nowTime = `${now.getFullYear()}-${String(
-                    now.getMonth() + 1
-                ).padStart(2, "0")}-${String(now.getDate()).padStart(
-                    2,
-                    "0"
-                )} ${String(now.getHours()).padStart(2, "0")}:${String(
-                    now.getMinutes()
-                ).padStart(2, "0")}`;
-                if (!isWmpf) {
-                    this.getVoipDevices();
-                }
-                console.log("处理后的 CMD 数据:", data);
-            },
-            (err) => {
-                if (!err) console.log(`✅ 页面组件 已订阅 ${topic}`);
+
+        // 抽取处理消息的方法
+        const handleMessage = (message, msgTopic) => {
+            console.log(`接收到 ${msgTopic} 消息:`, message);
+            const data = JSON.parse(message);
+            const noticeMatch = /^\/mps\/wx_(.+)\/notice$/;
+            if (!topic.match(noticeMatch)) return;
+            // 更新页面数据
+            this.alarmModel = true;
+            this.clientId = data.clientId;
+            this.devName = data.devName;
+            this.sn = data.clientId;
+            this.eventListId = data.eventListId;
+            // VOIP 相关逻辑
+            this.getVoipAuthor(this.clientId, userId);
+            // 格式化时间
+            const now = new Date();
+            this.nowTime = `${now.getFullYear()}-${String(
+                now.getMonth() + 1
+            ).padStart(2, "0")}-${String(now.getDate()).padStart(
+                2,
+                "0"
+            )} ${String(now.getHours()).padStart(2, "0")}:${String(
+                now.getMinutes()
+            ).padStart(2, "0")}`;
+            if (!isWmpf) {
+                this.getVoipDevices();
             }
-        );
+        };
 
-        uni.$on("mqttDataReadyOnce", (client) => {
+        // 抽取订阅的方法
+        const subscribeNotice = () => {
             this.unsubscribeFnNotice = MqttService.subscribe(
                 "DATA",
                 topic,
-                (message, msgTopic) => {
-                    console.log(`接收到 ${msgTopic} 消息:`, message);
-                    // 处理消息
-                    const data = JSON.parse(message);
-                    let userId = uni.getStorageSync("userId");
-                    const noticeMatch = /^\/mps\/wx_(.+)\/notice$/;
-                    const match = topic.match(noticeMatch);
-                    if (!match) return;
-                    // 更新页面数据
-                    this.alarmModel = true;
-                    this.clientId = data.clientId;
-                    this.devName = data.devName;
-                    this.sn = data.clientId;
-                    this.eventListId = data.eventListId;
-                    // VOIP 相关逻辑
-                    this.getVoipAuthor(this.clientId, userId);
-                    // 格式化时间
-                    const now = new Date();
-                    this.nowTime = `${now.getFullYear()}-${String(
-                        now.getMonth() + 1
-                    ).padStart(2, "0")}-${String(now.getDate()).padStart(
-                        2,
-                        "0"
-                    )} ${String(now.getHours()).padStart(2, "0")}:${String(
-                        now.getMinutes()
-                    ).padStart(2, "0")}`;
-                    if (!isWmpf) {
-                        this.getVoipDevices();
-                    }
-                    console.log("处理后的 CMD 数据:", data);
-                },
+                handleMessage,
                 (err) => {
                     if (!err) console.log(`✅ 页面组件 已订阅 ${topic}`);
                 }
             );
-        });
+        };
+        // 初始订阅
+        subscribeNotice();
+        uni.$on("mqttDataReadyOnce", subscribeNotice);
     },
 
     beforeDestroy() {

+ 63 - 10
src/pagesA/deviceDetail/deviceDetail.vue

@@ -11,6 +11,7 @@
                     height: `${width / 200}px`,
                     position: 'relative',
                     transform: `scale(${zoomTimes})`,
+                    border: `${9 / zoomTimes}rpx solid #333333`,
                 }"
                 :class="[
                     width < 25500 && length < 25000 ? 'tranStyle' : 'center',
@@ -235,8 +236,21 @@
         </view>
         <view class="box" v-if="!breathShow">
             <view class="handle-btn">
-                <view class="btn1" @click="shareDevice">分享</view>
-                <view class="btn1" @click="gotoSetting">设置</view>
+                <view class="btn1" @click="shareDevice" v-if="shareJudge"
+                    >分享</view
+                >
+                <view class="noShareFlag" @click="noShareFlag" v-else
+                    >分享</view
+                >
+                <view
+                    class="btn1"
+                    @click="gotoSetting"
+                    v-if="devInfo.online == 1"
+                    >设置</view
+                >
+                <view class="noShareFlag" @click="gotoSetting" v-else
+                    >设置</view
+                >
                 <view class="btn2" @click="healthAlarm">守护计划</view>
             </view>
         </view>
@@ -459,6 +473,8 @@ export default {
             showModle: false,
             unsubscribeFn: null,
             zoomTimes: "",
+            // 设备分享权限判断
+            shareJudge: false,
         };
     },
     computed: {},
@@ -488,6 +504,11 @@ export default {
                             -(this.devInfo.yyStart + this.devInfo.yyEnd) * 50;
                         this.statusLight = this.devInfo.statusLight;
                         this.calculate(this.width, this.length);
+                        // 设备分享权限判断
+                        this.shareJudge =
+                            this.devInfo.userId == uni.getStorageSync("userId")
+                                ? true
+                                : false;
                     }
                 })
 
@@ -531,6 +552,12 @@ export default {
         shareDevice() {
             this.choiceVisible = true;
         },
+        noShareFlag() {
+            uni.showToast({
+                title: "您没有分享权限",
+                icon: "none",
+            });
+        },
         onShareConfirm() {
             if (!this.sharedPhone) {
                 uni.showModal({
@@ -1078,11 +1105,17 @@ export default {
             position: absolute;
             overflow: hidden;
             border: none;
-            outline: 10rpx solid #333333;
-            background-image: url("https://hflnxx.oss-cn-shanghai.aliyuncs.com/IMAGE/20250919/toilet_bg.png");
             background-repeat: no-repeat;
             background-position: center;
-            // transform: scale(1.3);
+            &::before {
+                content: "";
+                position: absolute;
+                inset: 0;
+                background: url("https://hflnxx.oss-cn-shanghai.aliyuncs.com/IMAGE/20250919/toilet_bg.png")
+                    no-repeat center;
+                background-size: 100% 100%;
+                z-index: 0;
+            }
 
             .moduleContent {
                 position: relative;
@@ -1098,18 +1131,24 @@ export default {
                 }
             }
         }
-
         .tranStyle {
             position: absolute;
             overflow: hidden;
             background-color: #fff;
             border: none;
-            outline: 10rpx solid #333333;
-            background-image: url("https://hflnxx.oss-cn-shanghai.aliyuncs.com/IMAGE/20250919/toilet_bg.png");
+            // outline: 10rpx solid #333333;
+            // background-image: url("https://hflnxx.oss-cn-shanghai.aliyuncs.com/IMAGE/20250919/toilet_bg.png");
             background-repeat: no-repeat;
             background-position: center;
-            // transform: scale(2.3);
-
+            &::before {
+                content: "";
+                position: absolute;
+                inset: 0;
+                background: url("https://hflnxx.oss-cn-shanghai.aliyuncs.com/IMAGE/20250919/toilet_bg.png")
+                    no-repeat center;
+                background-size: 100% 100%;
+                z-index: 0; // 在最底层
+            }
             .moduleContent {
                 // overflow: hidden;
 
@@ -1270,6 +1309,20 @@ export default {
                 font-size: 32rpx;
                 text-align: center;
             }
+            .noShareFlag {
+                display: flex;
+                align-items: center;
+                justify-content: center;
+                width: 155rpx;
+                height: 94rpx;
+                border-radius: 28rpx;
+                font-weight: 500;
+                font-size: 32rpx;
+                text-align: center;
+                background: #f0f0f0;
+                color: #999999;
+                opacity: 0.6;
+            }
 
             .btn2 {
                 display: flex;

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

@@ -66,7 +66,9 @@
                                         item.displayX / 2
                                     }px, ${
                                         -item.displayY / 2
-                                    }px, 0) translate(-50%, -50%)`,
+                                    }px, 0) translate(-50%, -50%) scale(${
+                                        1.5 / 2
+                                    })`,
                                     zIndex: 9999,
                                     transition: 'transform 1s linear',
                                     willChange: 'transform',

+ 1 - 1
src/utils/globalMqtt.js

@@ -46,7 +46,7 @@ class MqttService {
     // 连接 DATA
     connectData(userId) {
         uni.showToast({
-            title: "正在连接平台中...",
+            title: "平台连接中...",
             icon: "loading",
             duration: 1500, //持续的时间
         });