Browse Source

Merge branch 'twoMqtt'

wangming 1 month ago
parent
commit
19820842bd

+ 0 - 7
src/App.vue

@@ -1,10 +1,3 @@
-<template>
-    <view>
-        <slot></slot>
-        <alarModel />
-    </view>
-</template>
-
 <script>
 import Vue from "vue";
 

+ 26 - 146
src/components/component/alarModel.vue

@@ -427,9 +427,11 @@ export default {
                 clean: true,
                 connectTimeout: 30 * 1000,
                 clientId:
-                    "wx_mqtt_" + Math.random().toString(16).substring(2, 8),
-                username: "admin",
-                password: "public",
+                    "xcx_mqtt_cmd1" +
+                    uni.getStorageSync("userId") +
+                    Math.random().toString(16).substring(2, 8),
+                username: "lnradar",
+                password: "lnradar",
                 // 微信小程序特定配置
                 wsOptions: {
                     WebSocket: function (url) {
@@ -449,18 +451,23 @@ export default {
             let selectedService = uni.getStorageSync("sercviceChoice");
             if (!selectedService || selectedService == "aloneServe") {
                 if (__wxConfig.envVersion == "develop") {
+<<<<<<< HEAD
                     // client = mqtt.connect(
                     //     "wxs://api.radar-power.asia:8084/mqtt",
                     //     params
                     // );
                     client = mqtt.connect(
                         "wxs://radar-power.cn:8084/mqtt",
+=======
+                    client = mqtt.connect(
+                        "wxs://cmd.radar-power.cn/mqtt/",
+>>>>>>> twoMqtt
                         params
                     );
                 }
                 if (__wxConfig.envVersion == "trial") {
                     client = mqtt.connect(
-                        "wxs://radar-power.cn:8084/mqtt",
+                        "wxs://cmd.radar-power.cn/mqtt/",
                         params
                     );
                 }
@@ -480,21 +487,21 @@ export default {
                         );
                     }
                 });
-                console.log(this.clientIdProp);
-                if (this.clientIdProp !== null) {
-                    client.subscribe(
-                        `/dev/${this.clientIdProp}/dsp_data`,
-                        (err) => {
-                            if (err) {
-                                console.error("订阅clientId失败", err);
-                            } else {
-                                console.log(
-                                    `成功订阅设备主题: /dev/${this.clientIdProp}/dsp_data`
-                                );
-                            }
-                        }
-                    );
-                }
+                // console.log(this.clientIdProp);
+                // if (this.clientIdProp !== null) {
+                //     client.subscribe(
+                //         `/dev/${this.clientIdProp}/dsp_data`,
+                //         (err) => {
+                //             if (err) {
+                //                 console.error("订阅clientId失败", err);
+                //             } else {
+                //                 console.log(
+                //                     `成功订阅设备主题: /dev/${this.clientIdProp}/dsp_data`
+                //                 );
+                //             }
+                //         }
+                //     );
+                // }
             });
             client.on("disconnect", () => {
                 console.log("MQTT不在连接");
@@ -513,10 +520,6 @@ export default {
             client.on("message", (topic, message) => {
                 console.log(JSON.parse(message.toString()), "8870");
                 // 处理点位消息
-                if (this.clientIdProp !== null) {
-                    this.handleMessage(topic, message, this.clientIdProp);
-                }
-
                 let userId = uni.getStorageSync("userId");
                 const noticeMatch = /^\/mps\/wx_(.+)\/notice$/;
                 const match = topic.match(noticeMatch);
@@ -611,132 +614,9 @@ export default {
                     }
                 });
         },
-
-        // 处理点位消息
-        handleMessage(topic, message, clientId) {
-            // 清除不活动定时器
-            clearTimeout(this.inactivityTimer);
-            this.inactivityTimer = setTimeout(() => {
-                this.targetPoints = {};
-                console.log("长时间没有点位,清除数据");
-                this.sendChange();
-                this.$emit("sendHealth", 0);
-            }, 1500);
-
-            // 验证topic格式
-            const match = topic.match(/^\/dev\/(.+)\/dsp_data$/);
-            if (!match || match[1] !== clientId) return;
-
-            try {
-                const data = JSON.parse(message.toString());
-                if (data.health) {
-                    if (
-                        data.health.breath_rpm ||
-                        data.health.breath_rpm === 0
-                    ) {
-                        this.$emit(
-                            "sendHealth",
-                            Math.floor(data.health.breath_rpm)
-                        );
-                    } else {
-                        this.$emit("sendHealth", 0);
-                    }
-                }
-                this.processTrackerData(data.tracker_targets);
-            } catch (e) {
-                console.error("MQTT消息解析失败", e);
-            }
-        },
-
-        processTrackerData(arr) {
-            if (Array.isArray(arr) && arr.length > 0 && Array.isArray(arr[0])) {
-                this.targetPoints = {};
-                const currentIds = new Set();
-                const newTargetPoints = {};
-                // 处理每个追踪目标
-                arr.forEach((item) => {
-                    if (!Array.isArray(item) || item.length < 4) return;
-
-                    const [x, y, z, id] = item;
-                    currentIds.add(id.toString());
-
-                    // 处理新点或更新现有点
-                    if (!this.targetPoints[id]) {
-                        newTargetPoints[id] = this.createNewTargetPoint(
-                            x,
-                            y,
-                            z,
-                            id
-                        );
-                    } else {
-                        newTargetPoints[id] = this.updateExistingTargetPoint(
-                            this.targetPoints[id],
-                            x,
-                            y,
-                            z,
-                            2
-                        );
-                    }
-                });
-
-                // 移除不存在的点
-                Object.keys(this.targetPoints).forEach((id) => {
-                    if (!currentIds.has(id)) {
-                        delete this.targetPoints[id];
-                    }
-                });
-
-                // 更新目标点
-                this.targetPoints = {
-                    ...this.targetPoints,
-                    ...newTargetPoints,
-                };
-                if (Array.isArray(this.targetPoints)) {
-                    this.targetPoints = this.targetPoints.filter(
-                        (item) => item !== null && item !== undefined
-                    );
-                }
-                console.log("当前目标点11111", this.targetPoints);
-                this.sendChange();
-            }
-        },
         sendChange() {
             this.$emit("sendChange", this.targetPoints);
         },
-        // 创建新目标点
-        createNewTargetPoint(x, y, z, id) {
-            return {
-                x,
-                y,
-                z,
-                id,
-                displayX: x,
-                displayY: y,
-                lastX: x,
-                lastY: y,
-            };
-        },
-        // 更新现有目标点
-        updateExistingTargetPoint(existingPoint, x, y, z, THRESHOLD) {
-            const dx = x - existingPoint.lastX;
-            const dy = y - existingPoint.lastY;
-            const distance = Math.sqrt(dx * dx + dy * dy);
-
-            if (distance > THRESHOLD) {
-                return {
-                    ...existingPoint,
-                    x,
-                    y,
-                    z,
-                    lastX: x,
-                    lastY: y,
-                    displayX: x,
-                    displayY: y,
-                };
-            }
-
-            return existingPoint;
-        },
     },
     mounted() {
         this.connectMQTTwo();

+ 0 - 1
src/components/component/tenMinutes.vue

@@ -477,7 +477,6 @@ export default {
                 })
                 .then((res) => {
                     if (res.data.data) {
-                        console.log(res.data.data, 9999);
                         if (res.data.data.length > 0) {
                             this.hanledLists = res.data.data;
                             this.selectHanled = this.hanledLists[0];

+ 2 - 2
src/components/js_sdk/index.js

@@ -5,9 +5,9 @@ http.setConfig(config => {
     if (__wxConfig.envVersion == 'develop') {
         let selectedService = uni.getStorageSync("sercviceChoice")
         if (!selectedService || selectedService == 'aloneServe') {
-            // config.baseUrl = "https://api.radar-power.asia:4443/portal-service-server/";
+            config.baseUrl = "https://api.radar-power.asia:4443/portal-service-server/";
         }
-        config.baseUrl = "https://radar-power.cn/portal-service-server/";
+        // config.baseUrl = "https://radar-power.cn/portal-service-server/";
     }
     if (__wxConfig.envVersion == 'trial') {
         let selectedService = uni.getStorageSync("sercviceChoice")

+ 0 - 3
src/manifest.json

@@ -54,9 +54,6 @@
             "connectSocket": 60000
         },
         "permission": {
-            "scope.websocket": {
-                "desc": "用于设备通信"
-            },
             "scope.userLocation": {
                 "desc": "你的位置信息将用于小程序定位"
             }

+ 10 - 1
src/pages.json

@@ -191,7 +191,7 @@
                     "path": "healthAlarm/healthAlarm",
                     "style": {
                         "enablePullDownRefresh": true,
-                        "navigationBarTitleText": "健康闹钟",
+                        "navigationBarTitleText": "守护计划",
                         "navigationBarBackgroundColor": "#faede2",
                         "navigationBarTextStyle": "black"
                     }
@@ -204,6 +204,15 @@
                         "navigationBarBackgroundColor": "#faede2",
                         "navigationBarTextStyle": "black"
                     }
+                },
+                {
+                    "path": "playSetting/playSetting",
+                    "style": {
+                        "enablePullDownRefresh": true,
+                        "navigationBarTitleText": "计划配置",
+                        "navigationBarBackgroundColor": "#faede2",
+                        "navigationBarTextStyle": "black"
+                    }
                 }
             ]
         }

+ 24 - 8
src/pages/home/home.vue

@@ -26,7 +26,7 @@
                 </view>
                 <view
                     class="rightItem"
-                    @click="gotoDevice('/pagesA/devices/devices')"
+                    @click="gotoDevice('/pagesA/homeManage/homeManage')"
                 >
                     <view class="rightTitle">我的家庭</view>
                     <view class="rightContent"
@@ -58,7 +58,10 @@
                     <image src="../../static/smalLn.png" mode="" />
                 </view>
             </view>
-            <view class="card" @click="gotoDevice('/pagesA/devices/devices')">
+            <view
+                class="card"
+                @click="gotoDevice('/pagesA/homeManage/homeManage')"
+            >
                 <view class="contentTitle">
                     <text>我的家庭</text>
                     <image src="../../static/rightArrow.png" />
@@ -75,8 +78,7 @@
             <!-- <button>联系客服</button> -->
             <button open-type="contact">联系客服</button>
         </view>
-        <view class="bot_version"> v3.0.7 </view>
-
+        <view class="bot_version"> v3.0.9 </view>
         <view
             class="shareInfo"
             @click="goDeviceShare()"
@@ -121,6 +123,7 @@
                         }}
                     </view>
                 </view>
+<<<<<<< HEAD
                 <view
                     class="shareTitleTwo"
                     v-if="alarmRetentionLists.length == 1"
@@ -130,11 +133,24 @@
                             getEventTypeName(alarmRetentionLists[0].eventType)
                         }}
                     </view>
+=======
+                <view class="shareTitleTwo" v-else>
+                    <template v-if="alarmRetentionLists.length == 1">
+                        <view class="shareTitle">
+                            {{ alarmRetentionLists[0].devName }}检测到有{{
+                                getEventTypeName(
+                                    alarmRetentionLists[0].eventType
+                                )
+                            }}
+                        </view>
+                    </template>
+>>>>>>> twoMqtt
                 </view>
             </view>
             <image src="../../static/arrFour.png" class="warmImage"></image>
         </view>
         <tenMinutes v-if="isIniTenMinutes" />
+        <alarModel v-if="isInitAlarm" />
     </view>
 </template>
 <script>
@@ -147,7 +163,7 @@ export default {
             shareNum: 0,
             devNum: 0,
             warnNum: 0,
-            imageUrl: "../../static/headerInfo.png",
+            imageUrl: "../../static/headerInfo.jpg",
             devDevice: "",
             warmNum: "",
             warmDetail: [],
@@ -230,6 +246,9 @@ export default {
             });
         },
         getperSonInfo() {
+            uni.showLoading({
+                title: "查询中...",
+            });
             this.$http
                 .get("wap/home/homeInfo", {
                     userId: uni.getStorageSync("userId"),
@@ -306,9 +325,6 @@ export default {
     onLoad() {},
     onShow() {
         if (uni.getStorageSync("userId")) {
-            uni.showLoading({
-                title: "雷能为您守护中...",
-            });
             this.getperSonInfo();
             this.getShareNum();
             this.getwarmType();

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

@@ -88,6 +88,7 @@
             </view>
         </template>
         <view style="height: 20rpx"></view>
+        <alarModel v-if="isInitAlarm" />
     </view>
 </template>
 

+ 32 - 31
src/pagesA/adDevice/adDevice.vue

@@ -359,38 +359,38 @@ export default {
                 });
                 return;
             }
-            if (
-                -200 > this.xxStart ||
-                this.xxEnd > 200 ||
-                -200 > this.yyStart ||
-                this.yyEnd > 200
-            ) {
-                uni.showModal({
-                    content: "检测范围在-200~200之间",
-                    showCancel: false,
-                });
-                return;
-            }
-            if (
-                5 < this.zzStart ||
-                this.zzStart < 0 ||
-                300 < this.zzEnd ||
-                this.zzEnd < 200
-            ) {
-                uni.showModal({
-                    content: "Z轴检测范围不正确",
-                    showCancel: false,
-                });
-                return;
-            }
+            // if (
+            //     -200 > this.xxStart ||
+            //     this.xxEnd > 200 ||
+            //     -200 > this.yyStart ||
+            //     this.yyEnd > 200
+            // ) {
+            //     uni.showModal({
+            //         content: "检测范围在-200~200之间",
+            //         showCancel: false,
+            //     });
+            //     return;
+            // }
+            // if (
+            //     5 < this.zzStart ||
+            //     this.zzStart < 0 ||
+            //     300 < this.zzEnd ||
+            //     this.zzEnd < 200
+            // ) {
+            //     uni.showModal({
+            //         content: "Z轴检测范围不正确",
+            //         showCancel: false,
+            //     });
+            //     return;
+            // }
 
-            if (200 > this.height || this.height > 370) {
-                uni.showModal({
-                    content: "安装高度在200~270之间",
-                    showCancel: false,
-                });
-                return;
-            }
+            // if (200 > this.height || this.height > 370) {
+            //     uni.showModal({
+            //         content: "安装高度在200~270之间",
+            //         showCancel: false,
+            //     });
+            //     return;
+            // }
 
             let deviceBandingParams = {
                 clientId: this.clientId,
@@ -602,6 +602,7 @@ export default {
         } else {
             console.log("没有参数");
         }
+        // this.$refs.alarModel.connectMQTTwo();
     },
 
     onUnload(options) {

+ 252 - 16
src/pagesA/deviceDetail/deviceDetail.vue

@@ -91,7 +91,7 @@
         <view class="switchBox">
             <text class="name">呼吸灯</text>
             <switch
-                :value="statusLight"
+                :checked="statusLight == 1"
                 @change="handleLightChange"
                 :active-value="1"
                 :inactive-value="0"
@@ -246,7 +246,7 @@
             <view class="handle-btn">
                 <view class="btn1" @click="shareDevice">分享</view>
                 <view class="btn1" @click="gotoSetting">设置</view>
-                <view class="btn2" @click="healthAlarm"> 健康闹钟 </view>
+                <view class="btn2" @click="healthAlarm">守护计划</view>
             </view>
         </view>
 
@@ -361,17 +361,25 @@
             ></l-echart>
         </view>
 
-        <alarModel
+        <!-- <alarModel
             v-if="isInitAlarm"
             :clientIdProp="clientIdProp"
             @sendChange="receptionChange"
             @sendHealth="receptHealth"
-        />
+        /> -->
+
+        <!-- <alarModel
+            v-if="isInitAlarm"
+            @sendChange="receptionChange"
+            @sendHealth="receptHealth"
+        /> -->
     </view>
 </template>
 <script>
 import * as echarts from "../../uni_modules/lime-echart/static/echarts.min";
 
+import mqtt from "../../utils/mqtt";
+
 export default {
     data() {
         return {
@@ -473,6 +481,8 @@ export default {
             },
             index: 0,
             loopTimer: null,
+            mqttClienTwoFlag: false,
+            mqttClientOne: false,
         };
     },
     computed: {},
@@ -631,6 +641,13 @@ export default {
             this.voipFlag = !this.voipFlag;
         },
         gotoSetting() {
+            if (this.devInfo.online == 0) {
+                uni.showToast({
+                    title: "离线设备不支持设置",
+                    icon: "none",
+                });
+                return;
+            }
             uni.navigateTo({
                 url:
                     "/pagesA/deviceSetting/deviceSetting?devInfo=" +
@@ -735,13 +752,7 @@ export default {
             this.breathRate = val;
             this.setEcharts(val);
         },
-        getToday() {
-            const today = new Date();
-            const year = today.getFullYear();
-            const month = today.getMonth() + 1;
-            const day = today.getDate();
-            this.todayDate = `${year}年${month}月${day}日`;
-        },
+
         // echarts图表模块
 
         getOption(list) {
@@ -836,9 +847,6 @@ export default {
                 this.breathRpmList = [];
             }
             this.breathRpmList.push(val);
-            // if (this.breathRpmList.length > 60) {
-            //     this.breathRpmList = this.breathRpmList.shift();
-            // }
             if (!this.chartInstance) return;
             const option = this.getOption(this.breathRpmList);
             this.chartInstance.setOption(option, { notMerge: true });
@@ -877,12 +885,235 @@ export default {
                 },
             });
         },
-    },
+        // 订阅mqtt实时点位
+        connectMqtt() {
+            this.mqttClienTwoFlag = false;
+            if (this.mqttClienTwoFlag) {
+                console.log("主题已订阅");
+                return;
+            }
+            const THRESHOLD = 2;
+            const params = {
+                keepalive: 6000,
+                clean: true,
+                connectTimeout: 30 * 1000,
+                clientId:
+                    "xcx_mqtt_data1" +
+                    this.clientIdProp +
+                    Date.now() +
+                    "_" +
+                    Math.random().toString(16).substring(2, 8),
+                username: "lnradar",
+                password: "lnradar",
+                // 微信小程序特定配置
+                wsOptions: {
+                    WebSocket: function (url) {
+                        return wx.connectSocket({
+                            url: url,
+                            header: {
+                                "content-type": "application/json",
+                            },
+                            protocols: ["mqtt"],
+                        });
+                    },
+                },
+                reconnectPeriod: 0,
+                rejectUnauthorized: false,
+            };
+            let clientTwo = "";
+            let selectedService = uni.getStorageSync("sercviceChoice");
+            if (!selectedService || selectedService == "aloneServe") {
+                if (__wxConfig.envVersion == "develop") {
+                    clientTwo = mqtt.connect(
+                        "wxs://data.radar-power.cn/mqtt/",
+                        params
+                    );
+                }
+                if (__wxConfig.envVersion == "trial") {
+                    clientTwo = mqtt.connect(
+                        "wxs://data.radar-power.cn/mqtt/",
+                        params
+                    );
+                }
+            }
+            console.log("主题开始订阅5555");
+            // 存储client引用以便后续操作
+            this.mqttClientOne = clientTwo;
+            clientTwo.on("connect", () => {
+                console.log("MQTT_DATA连接成功");
+                this.mqttClienTwoFlag = true;
+                if (this.clientIdProp !== null) {
+                    clientTwo.subscribe(
+                        `/dev/${this.clientIdProp}/tracker_targets`,
+                        (err) => {
+                            if (err) {
+                                console.error("订阅clientId失败", err);
+                            } else {
+                                console.log(
+                                    `成功订阅设备主题: /dev/${this.clientIdProp}/dsp_data`
+                                );
+                            }
+                        }
+                    );
+                }
+                console.log(this.clientIdProp);
+            });
+            clientTwo.on("disconnect", () => {
+                console.log("MQTT不在连接");
+            });
+            clientTwo.on("error", (err) => {
+                this.mqttClienTwoFlag = false;
+                setTimeout(() => {
+                    this.connectMqtt();
+                }, 1000);
+            });
+
+            clientTwo.on("reconnect", () => {});
+
+            clientTwo.on("close", () => {});
+
+            clientTwo.on("message", (topic, message) => {
+                // 处理点位消息
+                if (this.clientIdProp !== null) {
+                    this.handleMessage(topic, message, this.clientIdProp);
+                }
+            });
+        },
+
+        handleMessage(topic, message, clientId) {
+            // 清除不活动定时器
+            clearTimeout(this.inactivityTimer);
+            this.inactivityTimer = setTimeout(() => {
+                this.targetPoints = {};
+            }, 1500);
 
+            console.log(topic, 99999);
+            console.log(JSON.parse(message.toString()), "99999999");
+
+            // 验证topic格式
+            const match = topic.match(/^\/dev\/(.+)\/tracker_targets$/);
+            if (!match || match[1] !== clientId) return;
+
+            try {
+                const data = JSON.parse(message.toString());
+                if (data.health) {
+                    if (
+                        data.health.breath_rpm ||
+                        data.health.breath_rpm === 0
+                    ) {
+                        this.receptHealth(Math.floor(data.health.breath_rpm));
+                        // this.$emit(
+                        //     "sendHealth",
+                        //     Math.floor(data.health.breath_rpm)
+                        // );
+                    } else {
+                        // this.$emit("sendHealth", 0);
+                    }
+                }
+                this.processTrackerData(data.tracker_targets);
+                console.log(data.tracker_targets, "MQTT消息解析成功22222");
+            } catch (e) {
+                console.error("MQTT消息解析失败", e);
+            }
+        },
+
+        processTrackerData(arr) {
+            if (Array.isArray(arr) && arr.length > 0 && Array.isArray(arr[0])) {
+                this.targetPoints = {};
+                const currentIds = new Set();
+                const newTargetPoints = {};
+                // 处理每个追踪目标
+                arr.forEach((item) => {
+                    if (!Array.isArray(item) || item.length < 4) return;
+
+                    const [x, y, z, id] = item;
+                    currentIds.add(id.toString());
+
+                    // 处理新点或更新现有点
+                    if (!this.targetPoints[id]) {
+                        newTargetPoints[id] = this.createNewTargetPoint(
+                            x,
+                            y,
+                            z,
+                            id
+                        );
+                    } else {
+                        newTargetPoints[id] = this.updateExistingTargetPoint(
+                            this.targetPoints[id],
+                            x,
+                            y,
+                            z,
+                            2
+                        );
+                    }
+                });
+
+                // 移除不存在的点
+                Object.keys(this.targetPoints).forEach((id) => {
+                    if (!currentIds.has(id)) {
+                        delete this.targetPoints[id];
+                    }
+                });
+
+                // 更新目标点
+                this.targetPoints = {
+                    ...this.targetPoints,
+                    ...newTargetPoints,
+                };
+                if (Array.isArray(this.targetPoints)) {
+                    this.targetPoints = this.targetPoints.filter(
+                        (item) => item !== null && item !== undefined
+                    );
+                }
+                console.log("当前目标点11111", this.targetPoints);
+            }
+        },
+        createNewTargetPoint(x, y, z, id) {
+            return {
+                x,
+                y,
+                z,
+                id,
+                displayX: x,
+                displayY: y,
+                lastX: x,
+                lastY: y,
+            };
+        },
+        updateExistingTargetPoint(existingPoint, x, y, z, THRESHOLD) {
+            const dx = x - existingPoint.lastX;
+            const dy = y - existingPoint.lastY;
+            const distance = Math.sqrt(dx * dx + dy * dy);
+
+            if (distance > THRESHOLD) {
+                return {
+                    ...existingPoint,
+                    x,
+                    y,
+                    z,
+                    lastX: x,
+                    lastY: y,
+                    displayX: x,
+                    displayY: y,
+                };
+            }
+
+            return existingPoint;
+        },
+
+        closemqtTwo() {
+            this.mqttClienTwoFlag = false;
+            if (this.mqttClientOne) {
+                this.mqttClientOne.end();
+                this.mqttClientOne = null;
+                console.log("MQTT连接已断开");
+            }
+        },
+    },
     onShow() {
         this.clientIdProp = uni.getStorageSync("clientIDetail");
         this.isInitAlarm = true;
-        this.getToday();
+        this.todayDate = this.$time(new Date(), 2);
     },
     onLoad(options) {
         const devItem = this.parseDeviceItem(options.devItem);
@@ -895,15 +1126,20 @@ export default {
         }, 3000);
         this.getCurrentDate();
     },
+    onReady() {
+        this.connectMqtt();
+    },
     onUnload() {
         this.isInitAlarm = false;
         this.inactivityTimer = null;
         this.autoPlayinterval = null;
+        this.closemqtTwo();
     },
     onHide() {
         this.inactivityTimer = null;
         this.autoPlayinterval = null;
         this.isInitAlarm = false;
+        this.closemqtTwo();
     },
 };
 </script>

+ 46 - 22
src/pagesA/devices/devices.vue

@@ -30,19 +30,19 @@
                     <image src="../../static/arrTwo.png" mode="" />
                 </view>
                 <view v-if="item.online == 1">
-                    <view class="online" v-if="item.judge">
+                    <view class="online" v-if="item.existFlag == 1">
                         <view class="cardInfo">当前有人</view>
                         <view class="wcTimes" v-if="item.wcTimes"
                             >今日卫生间使用频率{{ item.wcTimes }}次</view
                         >
                     </view>
                     <view class="cardTwo" v-else>
-                        <view class="cardError" v-if="item.lastTargetTime"
+                        <view class="cardError" v-if="item.presenceChangeTime"
                             >当前无人</view
                         >
-                        <view class="endTime" v-if="item.lastTargetTime"
+                        <view class="endTime" v-if="item.presenceChangeTime"
                             >离开时间
-                            {{ forMateTime(item.lastTargetTime) }}</view
+                            {{ forMateTime(item.presenceChangeTime) }}</view
                         >
                         <view class="cardError" v-else>当前无人</view>
                     </view>
@@ -51,6 +51,14 @@
                     <text style="color: #8b939f; font-size: 24rpx"
                         >设备离线</text
                     >
+                    <view
+                        style="
+                            margin-top: 18rpx;
+                            color: chocolate;
+                            font-size: 24rpx;
+                        "
+                        >离线时间 {{ forMateTime(item.onoffTime) }}</view
+                    >
                 </view>
                 <view class="cardImage" v-if="item.online == 0">
                     <image src="../../static/offline_small.png" mode="" />
@@ -60,7 +68,12 @@
                 </view>
             </view>
         </view>
+<<<<<<< HEAD
         <tenMinutes v-if="isIniTenMinutes" />
+=======
+
+        <alarModel v-if="isInitAlarm" />
+>>>>>>> twoMqtt
     </view>
 </template>
 
@@ -72,7 +85,11 @@ export default {
             option: ["全部", "离线", "在线", "报警"],
             selectValue: 0,
             devs: [],
+<<<<<<< HEAD
             isIniTenMinutes: "",
+=======
+            isInitAlarm: false,
+>>>>>>> twoMqtt
         };
     },
     methods: {
@@ -124,7 +141,7 @@ export default {
                     status: status,
                 })
                 .then((res) => {
-                    console.log("设备列表", res);
+                    uni.hideLoading();
                     if (res.data.code == 200) {
                         let devs = res.data.data;
                         for (let i = 0; i < devs.length; i++) {
@@ -136,24 +153,24 @@ export default {
                             } else {
                                 devs[i].wcTimes = 0;
                             }
-                            if (devs[i].lastTargetTime) {
-                                const signalTimeStr = devs[
-                                    i
-                                ].lastTargetTime.replace(/-/g, "/");
-                                const signalTime = new Date(
-                                    signalTimeStr
-                                ).getTime();
+                            // if (devs[i].lastTargetTime) {
+                            //     const signalTimeStr = devs[
+                            //         i
+                            //     ].lastTargetTime.replace(/-/g, "/");
+                            //     const signalTime = new Date(
+                            //         signalTimeStr
+                            //     ).getTime();
 
-                                if (isNaN(signalTime)) {
-                                    devs[i].judge = false;
-                                } else {
-                                    const currentTime = Date.now();
-                                    const diff = Math.abs(
-                                        currentTime - signalTime
-                                    );
-                                    devs[i].judge = diff <= 5000; // 10秒内为 true
-                                }
-                            }
+                            //     if (isNaN(signalTime)) {
+                            //         devs[i].judge = false;
+                            //     } else {
+                            //         const currentTime = Date.now();
+                            //         const diff = Math.abs(
+                            //             currentTime - signalTime
+                            //         );
+                            //         devs[i].judge = diff <= 5000; // 10秒内为 true
+                            //     }
+                            // }
                         }
                         this.devs = devs;
                     }
@@ -182,12 +199,19 @@ export default {
         this.isInitAlarm = true;
     },
     onShow() {
+        this.isInitAlarm = true;
         this.queryList();
         this.isInitAlarm = true;
     },
     onHide() {
         this.isInitAlarm = false;
     },
+<<<<<<< HEAD
+=======
+    onHide() {
+        this.isInitAlarm = false;
+    },
+>>>>>>> twoMqtt
     onUnload() {
         this.isInitAlarm = false;
     },

+ 0 - 215
src/pagesA/healthAlarm/SwitchItem.vue

@@ -1,215 +0,0 @@
-<template>
-    <view class="switchBox">
-        <text class="name">{{ label }}</text>
-        <switch
-            :value="status"
-            @change="handleChange"
-            :active-value="1"
-            :inactive-value="0"
-            size="24px"
-            active-color="#07c160"
-            inactive-color="#eeeff1"
-            style="transform: scale(0.8)"
-        />
-
-        <!-- 时间范围选择 -->
-        <view class="timeRanges">
-            <view
-                v-for="(timeRange, index) in timeRanges"
-                :key="index"
-                class="timeRangeBox"
-            >
-                <view class="timeItem">
-                    <text class="timeLabel">开始时间</text>
-                    <picker
-                        mode="time"
-                        :value="timeRange.startTime"
-                        @change="handleStartTimeChange(index, $event)"
-                    >
-                        <view class="pickerButton">{{
-                            timeRange.startTime
-                        }}</view>
-                    </picker>
-                </view>
-                <view class="timeItem">
-                    <text class="timeLabel">结束时间</text>
-                    <picker
-                        mode="time"
-                        :value="timeRange.endTime"
-                        @change="handleEndTimeChange(index, $event)"
-                    >
-                        <view class="pickerButton">{{
-                            timeRange.endTime
-                        }}</view>
-                    </picker>
-                </view>
-                <view class="removeBtn" @click="removeTimeRange(index)"
-                    >删除</view
-                >
-            </view>
-        </view>
-
-        <!-- 单独保存按钮 -->
-        <view class="addTimeRangeBtn" @click="addTimeRange">+ 添加时间段</view>
-        <view class="saveBtn" @click="saveSettings">保存配置</view>
-    </view>
-</template>
-
-<script>
-export default {
-    name: "SwitchItem",
-    props: {
-        label: {
-            type: String,
-            required: true,
-        },
-        value: {
-            type: Number,
-            default: 1,
-        },
-        timeRanges: {
-            type: Array,
-            default: () => [{ startTime: "00:00", endTime: "00:00" }],
-        },
-    },
-    data() {
-        return {
-            status: this.value,
-        };
-    },
-    methods: {
-        handleChange(newValue) {
-            this.$emit("update:value", newValue.detail.value);
-        },
-
-        handleStartTimeChange(index, event) {
-            const newTimeRange = [...this.timeRanges];
-            newTimeRange[index].startTime = event.detail.value;
-            this.$emit("update:timeRanges", newTimeRange);
-        },
-
-        handleEndTimeChange(index, event) {
-            const newTimeRange = [...this.timeRanges];
-            newTimeRange[index].endTime = event.detail.value;
-            this.$emit("update:timeRanges", newTimeRange);
-        },
-
-        addTimeRange() {
-            const newTimeRange = [
-                ...this.timeRanges,
-                { startTime: "00:00", endTime: "00:00" },
-            ];
-            this.$emit("update:timeRanges", newTimeRange);
-        },
-
-        removeTimeRange(index) {
-            const newTimeRange = [...this.timeRanges];
-            newTimeRange.splice(index, 1);
-            this.$emit("update:timeRanges", newTimeRange);
-        },
-
-        saveSettings() {
-            console.log(`配置已保存:${this.label}`, {
-                status: this.status,
-                timeRanges: this.timeRanges,
-            });
-
-            uni.showToast({
-                title: `${this.label} 配置已保存`,
-                icon: "success",
-                duration: 2000,
-            });
-        },
-    },
-};
-</script>
-
-<style lang="less" scoped>
-.switchBox {
-    width: 100%;
-    display: flex;
-    flex-direction: column;
-    align-items: flex-start;
-    justify-content: flex-start;
-    padding-top: 20rpx;
-    padding-bottom: 20rpx;
-    border-bottom: 2rpx solid #eef2f6;
-    background: #ffffff;
-    margin-bottom: 20rpx;
-
-    .name {
-        margin-left: 18rpx;
-        color: #111111;
-        font-size: 32rpx;
-        margin-bottom: 10rpx;
-    }
-}
-
-.timeRanges {
-    margin-top: 20rpx;
-    width: 100%;
-}
-
-.timeRangeBox {
-    padding: 10rpx;
-    background-color: #f4f4f4;
-    margin-bottom: 10rpx;
-    border-radius: 10rpx;
-}
-
-.timeItem {
-    display: flex;
-    justify-content: space-between;
-    margin-bottom: 20rpx;
-}
-
-.timeLabel {
-    font-size: 28rpx;
-    color: #333;
-}
-
-.pickerButton {
-    padding: 10rpx;
-    border: 1rpx solid #ccc;
-    border-radius: 5rpx;
-    font-size: 28rpx;
-    color: #666;
-}
-
-.removeBtn {
-    text-align: center;
-    color: #111111;
-    font-size: 32rpx;
-    padding: 20rpx;
-    margin-top: 20rpx;
-    background-color: #f9eee4;
-    border-radius: 28rpx;
-    transition: background-color 0.3s;
-}
-
-.addTimeRangeBtn {
-    width: 93%;
-    text-align: center;
-    color: #111111;
-    font-size: 32rpx;
-    padding: 20rpx;
-    cursor: pointer;
-    border: 2rpx solid #feece5;
-    border-radius: 28rpx;
-    background-color: #feece5;
-    transition: background-color 0.3s, color 0.3s;
-}
-
-.saveBtn {
-    width: 93%;
-    text-align: center;
-    color: #fff;
-    font-size: 32rpx;
-    padding: 20rpx;
-    margin-top: 20rpx;
-    cursor: pointer;
-    background-color: #7d5246;
-    border-radius: 28rpx;
-    transition: background-color 0.3s;
-}
-</style>

+ 385 - 69
src/pagesA/healthAlarm/healthAlarm.vue

@@ -1,96 +1,412 @@
 <template>
-    <view class="container">
-        <view class="nomalNotice">
-            <view class="nomalTitle">异常提醒</view>
-            <view class="nomal_contain">
-                <SwitchItem
-                    v-for="(item, index) in switchItems"
-                    :key="index"
-                    :label="item.label"
-                    :value="item.value"
-                    :timeRanges="item.timeRanges"
-                    @update:value="handleSwitchChange(index, $event)"
-                    @update:timeRanges="updateTimeRanges(index, $event)"
-                />
+    <view class="home-warpTwo">
+        <view class="airbody">
+            <view class="module">
+                <view class="device-bottom" v-if="selectedPlan.length > 0">
+                    <view
+                        class="info-box"
+                        v-for="(item, index) in selectedPlan"
+                        :key="index"
+                    >
+                        <view class="info-text">
+                            <text>{{ item.name }}</text>
+                        </view>
+                        <view class="edit_del">
+                            <image
+                                @click="deleteItem(item)"
+                                src="../../static/delete.png"
+                                alt=""
+                            ></image>
+                            <image
+                                @click="editItem(item)"
+                                style="margin-left: 30rpx"
+                                src="../../static/edit.png"
+                                alt=""
+                            ></image>
+                        </view>
+                    </view>
+                </view>
+                <view v-else>
+                    <view class="noPlan">暂无守护计划</view>
+                </view>
             </view>
         </view>
+        <view class="bottomTwo">
+            <picker
+                mode="selector"
+                :range="planListName"
+                @change="bindPickerChange"
+                :value="selectedIndex"
+            >
+                <text>新增守护计划 </text>
+            </picker>
+        </view>
+
+        <alarModel v-if="isInitAlarm" />
     </view>
 </template>
-
 <script>
-import SwitchItem from "./SwitchItem.vue"; // 引入 SwitchItem 组件
-
 export default {
-    name: "MyPage",
-    components: {
-        SwitchItem,
-    },
     data() {
         return {
-            switchItems: [
-                {
-                    label: "起夜频次",
-                    value: 1,
-                    timeRanges: [{ startTime: "08:00", endTime: "09:00" }],
-                },
-                {
-                    label: "如厕频次",
-                    value: 1,
-                    timeRanges: [{ startTime: "08:00", endTime: "09:00" }],
-                },
-                {
-                    label: "卫生间频次",
-                    value: 1,
-                    timeRanges: [{ startTime: "08:00", endTime: "09:00" }],
-                },
-                {
-                    label: "夜间如厕频次",
-                    value: 1,
-                    timeRanges: [{ startTime: "08:00", endTime: "09:00" }],
-                },
-                {
-                    label: "如厕频次异常",
-                    value: 1,
-                    timeRanges: [{ startTime: "08:00", endTime: "09:00" }],
-                },
-            ],
+            devInfo: {},
+            planList: [],
+            planListName: [],
+            selectedIndex: null,
+            // 已经新增的守护计划
+            selectedPlan: [],
+            changFlage: false,
+            isInitAlarm: false,
         };
     },
+    computed: {},
     methods: {
-        handleSwitchChange(index, newValue) {
-            this.switchItems[index].value = newValue;
+        getPlanList() {
+            this.$http
+                .post("wap/alarm/plan/queryTpl", {
+                    eventVal: "",
+                    name: "",
+                })
+                .then((res) => {
+                    if (res.data.code == 200) {
+                        if (res.data.data.length > 0) {
+                            this.planList = res.data.data;
+                            this.planListName = res.data.data.map(
+                                (ele) => ele.name
+                            );
+                        }
+                    }
+                });
+        },
+        confirmSelect() {
+            if (this.selectedIndex !== null) {
+                let selectePlans = this.planList.find(
+                    (plan) => plan.name == this.planListName[this.selectedIndex]
+                );
+                let selectedPlan = {};
+                selectedPlan.clientId = this.devInfo.clientId;
+                if (!selectedPlan.alarmTimePlan) {
+                    this.$set(selectedPlan, "alarmTimePlan", {});
+                }
+                selectedPlan.alarmTimePlan.startDate = this.$time(
+                    new Date(),
+                    1
+                );
+                selectedPlan.alarmTimePlan.stopDate = this.$time(
+                    new Date(
+                        new Date().setFullYear(new Date().getFullYear() + 1)
+                    ),
+                    1
+                );
+                selectedPlan.alarmTimePlan.timeRange =
+                    selectePlans.alarmTimePlanTpl.timeRange;
+                selectedPlan.alarmTimePlan.monthDays =
+                    selectePlans.alarmTimePlanTpl.monthDays;
+                selectedPlan.alarmTimePlan.weekdays =
+                    selectePlans.alarmTimePlanTpl.weekdays;
+                selectedPlan.name = selectePlans.name;
+                selectedPlan.enable = 1;
+                selectedPlan.linkagePushWechatService = 1;
+                selectedPlan.eventVal = selectePlans.eventVal;
+
+                // selectedPlan.alarmPlanId = selectePlans.id;
+
+                // console.log(selectedPlan, 888888888);
+                this.$http
+                    .post(
+                        "wap/alarm/plan/save",
+                        {
+                            ...selectedPlan,
+                        },
+                        {
+                            header: {
+                                "Content-Type":
+                                    "application/json;charset=UTF-8",
+                                token: uni.getStorageSync("tokenValue") || "",
+                            },
+                        }
+                    )
+                    .then((res) => {
+                        if (res.data.code == 200) {
+                            uni.showToast({
+                                title: "添加计划成功",
+                                icon: "success",
+                                duration: 1500,
+                            });
+                        } else {
+                            uni.showToast({
+                                title: res.data.message,
+                                icon: "none",
+                                duration: 1500,
+                            });
+                        }
+                        this.getSelectPlan();
+                    });
+            }
+            this.changFlage = true;
+        },
+        bindPickerChange(e) {
+            this.selectedIndex = e.detail.value;
+            this.confirmSelect();
+        },
+        getSelectPlan() {
+            this.$http
+                .post(
+                    "wap/alarm/plan/query",
+                    {
+                        clientId: this.devInfo.clientId,
+                    },
+                    {
+                        header: {
+                            "Content-Type": "application/json;charset=UTF-8",
+                            token: uni.getStorageSync("tokenValue") || "",
+                        },
+                    }
+                )
+                .then((res) => {
+                    if (res.data.code == 200) {
+                        this.selectedPlan = res.data.data;
+                        if (this.changFlage) {
+                            this.changFlage = false;
+                            this.editItem(
+                                this.selectedPlan[this.selectedPlan.length - 1]
+                            );
+                        }
+                    }
+                });
+        },
+        deleteItem(item) {
+            uni.showModal({
+                content: "是否删除该计划",
+                complete: (res) => {
+                    if (res.confirm) {
+                        this.$http
+                            .post(
+                                "wap/alarm/plan/del",
+                                {
+                                    id: item.id,
+                                },
+                                {
+                                    header: {
+                                        "Content-Type":
+                                            "application/json;charset=UTF-8",
+                                        token:
+                                            uni.getStorageSync("tokenValue") ||
+                                            "",
+                                    },
+                                }
+                            )
+                            .then((res) => {
+                                if (res.data.code == 200) {
+                                    uni.showToast({
+                                        title: "守护计划删除成功",
+                                        icon: "success",
+                                        duration: 1500,
+                                    });
+                                } else {
+                                    uni.showToast({
+                                        title: res.data.message,
+                                        icon: "none",
+                                        duration: 1500,
+                                    });
+                                }
+                                this.getSelectPlan();
+                            });
+                    }
+                    if (res.cancel) {
+                    }
+                    return;
+                },
+            });
         },
-        updateTimeRanges(index, newTimeRanges) {
-            this.switchItems[index].timeRanges = newTimeRanges;
+        editItem(item) {
+            uni.navigateTo({
+                url:
+                    "/pagesA/playSetting/playSetting?planInfo=" +
+                    JSON.stringify(item),
+            });
         },
     },
+    onLoad(options) {
+        this.devInfo = JSON.parse(options.devInfo);
+    },
+    onShow() {
+        this.getPlanList();
+        this.getSelectPlan();
+        this.isInitAlarm = true;
+    },
+    onHide() {
+        this.isInitAlarm = false;
+    },
+    onUnload() {
+        this.isInitAlarm = false;
+    },
 };
 </script>
-
 <style lang="less" scoped>
-.container {
+.home-warpTwo {
+    position: relative;
     height: 100vh;
-    background: linear-gradient(180deg, #faede2 0%, #f4f4f4 100%);
+    background: linear-gradient(180deg, #ffdfdf 0%, #ffffff 30.3%);
     box-sizing: border-box;
-    padding-top: 20rpx;
-
-    .nomalNotice {
-        width: 712rpx;
-        margin: 0 auto;
+    width: 750rpx;
+    border-bottom-left-radius: 35rpx;
+    border-bottom-right-radius: 35rpx;
+    background: linear-gradient(180deg, #faede2 0%, #ffffff 100%);
+    .airCantInfo {
+        margin: 30rpx auto 0 auto;
+        border: 18rpx solid #1f1f1f;
+        position: relative;
+    }
+    .airbody {
         box-sizing: border-box;
-
-        .nomalTitle {
-            padding-left: 38rpx;
-            font-family: MiSans;
-            color: #9d8179;
-            font-size: 28rpx;
+        .header_top {
+            // padding: 0rpx 40rpx;
+            display: flex;
+            justify-content: space-between;
+            align-items: center;
+            .airTitle {
+                font-weight: 500;
+                color: #784c41;
+                font-size: 32rpx;
+                padding-left: 20rpx;
+                padding-top: 20rpx;
+            }
+            .addfnt {
+                display: flex;
+                align-items: center;
+                image {
+                    margin-top: 7rpx;
+                    width: 25rpx;
+                    height: 25rpx;
+                }
+                .add_btn {
+                    margin-left: 10rpx;
+                    font-size: 32rpx;
+                }
+            }
         }
 
-        .nomal_contain {
-            padding: 10rpx 37rpx;
-            margin-top: 18rpx;
+        .module {
+            bottom: 0;
+            box-sizing: border-box;
+            width: 100%;
             background: #ffffff;
-            border-radius: 37rpx;
+            border-radius: 20rpx 20rpx 20rpx 20rpx;
+            .device-bottom {
+                .no-data {
+                    text-align: center;
+                }
+                .info-box {
+                    display: flex;
+                    align-items: center;
+                    // width: 620rpx;
+                    padding: 0 30rpx;
+                    height: 110rpx;
+                    background: #f8f8f8;
+                    border-radius: 38rpx;
+                    border-radius: 20rpx 20rpx 20rpx 20rpx;
+                    font-family: PingFang SC, PingFang SC;
+                    font-weight: 400;
+                    font-size: 26rpx;
+                    .info-text {
+                        display: flex;
+                        flex-direction: column;
+                        margin-left: 20rpx;
+                    }
+                    image {
+                        margin-bottom: 10rpx;
+                        width: 75rpx;
+                        height: 75rpx;
+                    }
+                    .edit_del {
+                        margin-left: auto;
+                        image {
+                            width: 40rpx;
+                            height: 40rpx;
+                        }
+                    }
+                }
+                .info-box:not(:first-child) {
+                    margin-top: 20rpx;
+                }
+            }
+            .noPlan {
+                background-color: #f9efe5;
+                padding-top: 30rpx;
+                color: #999;
+                font-size: 28rpx;
+                text-align: center;
+            }
+        }
+    }
+    .bottomTwo {
+        width: 750rpx;
+        height: 120rpx;
+        position: fixed;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        bottom: 0;
+        left: 0;
+        line-height: 120rpx;
+        background: #f3e2dd;
+    }
+
+    .mask {
+        position: fixed;
+        top: 0;
+        left: 0;
+        right: 0;
+        bottom: 0;
+        background: rgba(0, 0, 0, 0.4);
+        z-index: 99;
+    }
+    .popup {
+        position: fixed;
+        left: 50%;
+        top: 50%;
+        transform: translate(-50%, -50%);
+        width: 500rpx;
+        background: #fff;
+        border-radius: 16rpx;
+        padding: 20rpx;
+        z-index: 100;
+        .popup-body {
+            text-align: center;
+            margin-bottom: 20rpx;
+
+            .picker-text {
+                padding: 20rpx;
+                border-radius: 8rpx;
+            }
+        }
+        .popup-footer {
+            display: flex;
+            justify-content: space-around;
+            margin-top: 40rpx;
+            .cancel-btn {
+                width: 200rpx;
+                height: 75rpx;
+                background: #ffebe4;
+                line-height: 75rpx;
+                border-radius: 28rpx;
+                font-weight: 500;
+                color: #111111;
+                font-size: 32rpx;
+                text-align: center;
+            }
+            .sure-btn {
+                width: 200rpx;
+                height: 75rpx;
+                background: #4f372e;
+                line-height: 75rpx;
+                border-radius: 28rpx;
+                font-weight: 500;
+                color: #ffffff;
+                font-size: 32rpx;
+                text-align: center;
+            }
         }
     }
 }

+ 15 - 8
src/pagesA/homeManage/homeManage.vue

@@ -15,6 +15,9 @@
                             ><image src="../../static/delete.png"></image
                         ></view>
                         <view class="imgItem"
+                            ><image src="../../static/edit.png"></image
+                        ></view>
+                        <view class="imgItem"
                             ><image
                                 src="../../static/shareTwo.png"
                             ></image></view
@@ -143,9 +146,13 @@ export default {
         },
 
         getgroupList() {
+            uni.showLoading({
+                title: "加载中",
+            });
             this.$http
                 .get(`wap/group/groupList`, { user_id: this.userId })
                 .then((res) => {
+                    uni.hideLoading();
                     if (res.data.data) {
                         this.groupList = res.data.data;
                     }
@@ -195,13 +202,13 @@ export default {
         // shareItem(item) {
         //     console.log(item, 99999);
         // },
-        goGroupDetail(item) {
-            uni.navigateTo({
-                url: `/pagesA/homeDetail/homeDetail?groupInfo=${JSON.stringify(
-                    item
-                )}`,
-            });
-        },
+        // goGroupDetail(item) {
+        //     uni.navigateTo({
+        //         url: `/pagesA/homeDetail/homeDetail?groupInfo=${JSON.stringify(
+        //             item
+        //         )}`,
+        //     });
+        // },
     },
     onShow() {
         this.getgroupList();
@@ -264,7 +271,7 @@ export default {
                     letter-spacing: 1.8rpx;
                 }
                 .itemOption {
-                    width: 20%;
+                    width: 35%;
                     display: flex;
                     justify-content: space-between;
                     align-items: center;

+ 474 - 0
src/pagesA/playSetting/playSetting.vue

@@ -0,0 +1,474 @@
+<template>
+    <view class="container">
+        <!-- 计划名称输入框 -->
+        <view class="input-container">
+            <text class="input-label">计划名称:</text>
+            <input
+                class="input-field"
+                type="text"
+                v-model="planInfo.name"
+                placeholder="请输入计划名称"
+            />
+        </view>
+        <!-- <view class="input-container">
+            <text class="input-label">触发阈值:</text>
+            <input
+                class="input-field"
+                type="number"
+                v-model="thresholdTime"
+                placeholder="请输入触发阈值"
+            />
+        </view>
+
+        <view class="input-container">
+            <text class="input-label">归并时间:</text>
+            <input
+                class="input-field"
+                type="number"
+                v-model="mergeTime"
+                placeholder="请输入归并时间"
+            />
+        </view> -->
+
+        <!-- 事件类型选择 -->
+        <view class="select-container">
+            <text class="input-label">事件类型:</text>
+            <input
+                class="input-field"
+                type="text"
+                v-model="eventType.eventDesc"
+                placeholder="请选择计划类型"
+                disabled="true"
+            />
+        </view>
+
+        <!-- 计划时间 -->
+        <view class="time-container" style="margin-bottom: 20rpx">
+            <text class="input-label">计划时间:</text>
+            <view class="time-picker-container">
+                <picker
+                    mode="date"
+                    v-model="startDate"
+                    start="2000-01-01"
+                    end="2099-12-31"
+                    @change="bindStartChange"
+                >
+                    <view class="picker-content">{{ startDate }}</view>
+                </picker>
+                ~
+                <picker
+                    mode="date"
+                    v-model="stopDate"
+                    start="2000-01-01"
+                    end="2099-12-31"
+                    @change="bindEndChange"
+                >
+                    <view class="picker-content">{{ stopDate }}</view>
+                </picker>
+            </view>
+        </view>
+
+        <!-- 生效时段 -->
+        <view class="time-container" v-if="judgeFlage != 'noneFlag'">
+            <text class="input-label">生效时段:</text>
+            <view class="time-picker-container">
+                <picker
+                    mode="time"
+                    v-model="effectiveStart"
+                    @change="bindEffectiveStartChange"
+                >
+                    <view class="picker-content" style="width: 170rpx">{{
+                        effectiveStart
+                    }}</view>
+                </picker>
+                ~
+                <picker
+                    mode="time"
+                    v-model="effectiveEnd"
+                    @change="bindEffectiveEndChange"
+                >
+                    <view class="picker-content" style="width: 170rpx">{{
+                        effectiveEnd
+                    }}</view>
+                </picker>
+            </view>
+        </view>
+        <view class="time-range-wrapper" v-if="timeRange.length > 0">
+            <view
+                class="time-item"
+                v-for="(item, index) in timeRange"
+                :key="index"
+            >
+                <text class="time-text"
+                    >{{ item.start_time }} - {{ item.end_time }}</text
+                >
+                <text class="delete-btn" @click="removeTime(index)">×</text>
+            </view>
+        </view>
+
+        <!-- 告警提醒 -->
+        <view class="switch-container" style="margin-top: 20rpx">
+            <text class="input-label">告警联动(服务号推送):</text>
+            <switch
+                :checked="linkagePushWechatService == 1"
+                @change="onChangeLian"
+                :active-value="1"
+                :inactive-value="0"
+                size="24px"
+                active-color="#07c160"
+                inactive-color="#eeeff1"
+                style="transform: scale(0.8)"
+            />
+        </view>
+
+        <!-- 是否启用 -->
+        <view class="switch-container">
+            <text class="input-label">是否启用:</text>
+            <switch
+                :checked="enable == 1"
+                @change="onChangeQi"
+                :active-value="1"
+                :inactive-value="0"
+                size="24px"
+                active-color="#07c160"
+                inactive-color="#eeeff1"
+                style="transform: scale(0.8)"
+            />
+        </view>
+
+        <!-- 保存按钮 -->
+        <view class="save-button" @click="saveTemplate">
+            <text class="save-button-text">保存</text>
+        </view>
+    </view>
+</template>
+
+<script>
+export default {
+    data() {
+        return {
+            planName: "",
+            selectedEventType: 0,
+            startDate: "2025-01-01",
+            stopDate: "2025-11-01",
+            effectiveStart: "00:00",
+            effectiveEnd: "23:59",
+            isAlarmActive: true,
+            isEnabled: true,
+            planInfo: {},
+            warmTypeList: [],
+            eventType: "",
+            linkagePushWechatService: 1,
+            enable: 1,
+            timeRange: [],
+            thresholdTime: 300,
+            mergeTime: 30,
+            judgeFlage: "",
+            remark: "",
+        };
+    },
+    methods: {
+        saveTemplate() {
+            // 1 2 3 9
+            // 允许多个时间
+            // 5 7
+            // 只有一个时间
+            // 4 6 8
+            // 不配生效时间
+
+            if (this.judgeFlage == "noneFlag") {
+                this.timeRange = [
+                    {
+                        start_time: "00:00",
+                        end_time: "23:59",
+                    },
+                ];
+            } else if (this.judgeFlage == "one" && this.timeRange.length > 1) {
+                uni.showModal({
+                    title: "提示",
+                    content: "此事件类型只能选择一个生效时段",
+                    showCancel: false,
+                });
+                return;
+            }
+            if (this.enable == true) {
+                this.enable = 1;
+            } else {
+                this.enable = 0;
+            }
+            if (this.linkagePushWechatService == true) {
+                this.linkagePushWechatService = 1;
+            } else {
+                this.linkagePushWechatService = 0;
+            }
+
+            let planInfo = {
+                alarmPlanId: this.planInfo.id,
+                name: this.planInfo.name,
+                clientId: this.planInfo.clientId,
+                eventVal: this.planInfo.eventVal,
+                thresholdTime: this.thresholdTime,
+                mergeTime: this.mergeTime,
+                linkagePushWechatService: this.linkagePushWechatService,
+                enable: this.enable,
+                alarmTimePlan: {
+                    id: this.planInfo.alarmTimePlan.id,
+                    startDate: this.startDate,
+                    stopDate: this.stopDate,
+                    timeRange: JSON.stringify(this.timeRange),
+                    monthDays: this.planInfo.alarmTimePlan.monthDays,
+                    weekdays: this.planInfo.alarmTimePlan.weekdays,
+                },
+            };
+            if (
+                this.planInfo.eventVal == 5 ||
+                this.planInfo.eventVal == 4 ||
+                this.planInfo.eventVal == 8
+            ) {
+                planInfo.param = JSON.stringify(this.timeRange);
+            }
+
+            console.log(planInfo, 9999);
+
+            this.$http
+                .post(
+                    "wap/alarm/plan/save",
+                    { ...planInfo },
+                    {
+                        header: {
+                            "Content-Type": "application/json",
+                            token: uni.getStorageSync("tokenValue") || "",
+                        },
+                    }
+                )
+                .then((res) => {
+                    if (res.data.code == 200) {
+                        uni.showToast({
+                            title: "修改成功",
+                            icon: "success",
+                        });
+                        setTimeout(() => {
+                            uni.navigateBack({
+                                delta: 1,
+                            });
+                        }, 1000);
+                    } else {
+                        uni.showToast({
+                            title: res.data.message,
+                            icon: "none",
+                            duration: 1500,
+                        });
+                    }
+                    if (
+                        this.planInfo.eventVal == 1 ||
+                        this.planInfo.eventVal == 2 ||
+                        this.planInfo.eventVal == 3 ||
+                        this.planInfo.eventVal == 9
+                    ) {
+                        uni.showModal({
+                            title: "提示",
+                            content: "该计划需要到web端配置区域",
+                            success: (res) => {
+                                if (res.confirm) {
+                                }
+                                if (res.cancel) {
+                                }
+                            },
+                        });
+                    }
+                });
+        },
+        handlePlanInfo() {
+            console.log(this.planInfo, 9999999);
+        },
+        getWarnType() {
+            this.$http.get("wap/stats/queryEventType").then((res) => {
+                if (res.data.data) {
+                    this.warmTypeList = res.data.data;
+                    this.eventType = this.warmTypeList.find(
+                        (item) => item.eventVal == this.planInfo.eventVal
+                    );
+                }
+            });
+        },
+        bindStartChange(val) {
+            this.startDate = val.detail.value;
+            this.planInfo.startDate = this.startDate + " 00:00:00";
+        },
+        bindEndChange(val) {
+            this.stopDate = val.detail.value;
+            this.planInfo.stopDate = this.stopDate + " 23:59:59";
+        },
+        bindEffectiveStartChange(val) {
+            this.effectiveStart = val.detail.value;
+            console.log(this.effectiveStart, val.detail.value, 88887);
+        },
+        bindEffectiveEndChange(val) {
+            this.effectiveEnd = val.detail.value;
+            console.log(this.effectiveEnd, 9999);
+            this.timeRange.push({
+                start_time: this.effectiveStart,
+                end_time: this.effectiveEnd,
+            });
+        },
+        removeTime(index) {
+            this.timeRange.splice(index, 1);
+        },
+        onChangeLian(e) {
+            let newValue = e.detail.value == true ? 1 : 0;
+            this.linkagePushWechatService = newValue.toString();
+        },
+        onChangeQi(e) {
+            let newValue = e.detail.value == true ? 1 : 0;
+            this.enable = newValue.toString();
+        },
+    },
+    onLoad(options) {
+        this.planInfo = JSON.parse(options.planInfo);
+
+        console.log(this.planInfo, 9999999);
+        this.startDate =
+            this.planInfo?.alarmTimePlan.startDate?.slice(0, 10) || "";
+        this.stopDate =
+            this.planInfo?.alarmTimePlan.stopDate?.slice(0, 10) || "";
+
+        if (this.planInfo.alarmTimePlan.timeRange) {
+            this.timeRange = JSON.parse(this.planInfo.alarmTimePlan.timeRange);
+        }
+        this.eventType = this.planInfo.eventVal;
+        this.linkagePushWechatService = this.planInfo.linkagePushWechatService;
+        this.enable = this.planInfo.enable;
+
+        if (this.eventType == 4 || this.eventType == 6 || this.eventType == 8) {
+            this.judgeFlage = "noneFlag";
+        } else if (this.eventType == 5 || this.eventType == 7) {
+            this.judgeFlage = "one";
+        } else if (
+            this.eventType == 1 ||
+            this.eventType == 2 ||
+            this.eventType == 3 ||
+            this.eventType == 9
+        ) {
+            this.judgeFlage = "more";
+        }
+    },
+    onShow() {
+        this.linkagePushWechatService =
+            this.planInfo.linkagePushWechatService == 1 ? true : false;
+        this.enable = this.planInfo.enable == 1 ? true : false;
+        this.getWarnType();
+    },
+};
+</script>
+
+<style scoped>
+.container {
+    padding: 20px;
+    height: 100vh;
+    background-color: #f9eee3;
+    border-radius: 12px;
+}
+.input-container {
+    margin-bottom: 25px;
+}
+.input-label {
+    font-size: 16px;
+    color: #333;
+    margin-bottom: 8px;
+    font-weight: 600;
+}
+.time-picker-container {
+    margin-top: 20rpx;
+    align-items: center;
+    display: flex;
+    justify-content: space-between;
+}
+.input-field {
+    width: 92%;
+    padding: 14px;
+    margin-top: 20rpx;
+    border: 1px solid #ccc;
+    border-radius: 10px;
+    font-size: 16px;
+    background-color: #fff;
+}
+.input-counter {
+    font-size: 12px;
+    color: #999;
+    text-align: right;
+    margin-top: 4px;
+}
+.select-container {
+    margin-bottom: 25px;
+}
+.picker-content {
+    padding: 14px;
+    border: 1px solid #ccc;
+    border-radius: 10px;
+    font-size: 16px;
+    color: #333;
+    background-color: #fff;
+}
+.time-range-wrapper {
+    margin-top: 20rpx;
+    display: flex;
+    flex-wrap: wrap; /* 多行换行显示 */
+    gap: 10rpx; /* 间距 */
+    padding: 10rpx;
+}
+
+.time-item {
+    position: relative;
+    display: flex;
+    align-items: center;
+    padding: 10rpx 20rpx;
+    background-color: #f5f5f5;
+    border-radius: 12rpx;
+}
+
+.time-text {
+    font-size: 28rpx;
+    color: #333;
+}
+
+.delete-btn {
+    position: absolute;
+    top: -6rpx;
+    right: -6rpx;
+    width: 30rpx;
+    height: 30rpx;
+    line-height: 30rpx;
+    text-align: center;
+    background-color: #ff4d4f;
+    color: #fff;
+    border-radius: 50%;
+    font-weight: bold;
+    font-size: 20rpx;
+}
+
+.switch-container {
+    margin-bottom: 25px;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+}
+
+/* 新的保存按钮样式 */
+.save-button {
+    width: 750rpx;
+    height: 120rpx;
+    position: fixed;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    bottom: 0;
+    left: 0;
+    line-height: 120rpx;
+    background: #f3e2dd;
+    border-radius: 12px;
+}
+.save-button-text {
+    font-size: 18px;
+    /* font-weight: bold; */
+}
+</style>

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

@@ -73,19 +73,22 @@ export default {
     },
     methods: {
         getShareList() {
+            uni.showLoading({
+                title: "加载中",
+            });
             this.$http
                 .post("wap/share/queryDevShare", {
                     userId: uni.getStorageSync("userId"),
                     state: null,
                 })
                 .then((res) => {
+                    uni.hideLoading();
                     if (res.data.data) {
                         this.shareList = res.data.data;
                         if (this.shareList && this.status != null) {
                             const hasStatusZero = this.shareList.some(
                                 (item) => item.state === 0
                             );
-                            console.log(hasStatusZero);
                             if (!hasStatusZero) {
                                 this.state = null;
                                 this.getShareList();

BIN
src/static/headerInfo.jpg


BIN
src/static/headerInfo.png


+ 2 - 0
src/vue.config.js

@@ -2,7 +2,9 @@ const path = require('path')
 const CopyWebpackPlugin = require('copy-webpack-plugin')
 
 module.exports = {
+    productionSourceMap: true,
     configureWebpack: {
+        devtool: 'source-map',
         plugins: [
             new CopyWebpackPlugin([
                 {

+ 25 - 0
www.json

@@ -0,0 +1,25 @@
+{
+    "id": 2107846690,
+    "uuid": "73c41f7c-4740-4f6e-81a3-69ea90e9610d",
+    "name": "wm测试告警计划",
+    "clientId": "94A9900B0B51",
+    "enable": null,
+    "region": null,
+    "eventVal": null,
+    "alarmTimePlanId": 908238896,
+    "thresholdTime": null,
+    "mergeTime": null,
+    "param": null,
+    "linkagePushWechatService": null,
+    "createTime": "2025-09-10 10:18:20",
+    "updateTime": "2025-09-10 10:18:20",
+    "remark": null,
+    "alarmTimePlan": {
+        "id": 908238896,
+        "startDate": "2025-09-10 10:18:18",
+        "stopDate": "2026-09-10 10:18:18",
+        "timeRange": "[{\"start_time\":\"01:01\",\"end_time\":\"04:03\"},{\"start_time\":\"01:01\",\"end_time\":\"04:03\"},{\"start_time\":\"01:01\",\"end_time\":\"04:03\"},{\"start_time\":\"04:03\",\"end_time\":\"20:03\"}]",
+        "monthDays": "[]",
+        "weekdays": "[1,2,3,4,5,6,7]"
+    }
+}

+ 0 - 20
yarn.lock

@@ -5085,14 +5085,6 @@ ecc-jsbn@~0.1.1:
     jsbn "~0.1.0"
     safer-buffer "^2.1.0"
 
-echarts@^6.0.0:
-  version "6.0.0"
-  resolved "https://registry.npmjs.org/echarts/-/echarts-6.0.0.tgz"
-  integrity sha512-Tte/grDQRiETQP4xz3iZWSvoHrkCQtwqd6hs+mifXcjrCuo2iKWbajFObuLJVBlDIJlOzgQPd1hsaKt/3+OMkQ==
-  dependencies:
-    tslib "2.3.0"
-    zrender "6.0.0"
-
 ee-first@1.1.1:
   version "1.1.1"
   resolved "https://registry.npmmirror.com/ee-first/-/ee-first-1.1.1.tgz"
@@ -11276,11 +11268,6 @@ tslib@^2.0.1, tslib@^2.0.3, tslib@^2.3.0:
   resolved "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz"
   integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==
 
-tslib@2.3.0:
-  version "2.3.0"
-  resolved "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz"
-  integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==
-
 tsscmp@1.0.6:
   version "1.0.6"
   resolved "https://registry.npmmirror.com/tsscmp/-/tsscmp-1.0.6.tgz"
@@ -12256,10 +12243,3 @@ ylru@^1.2.0:
   version "1.4.0"
   resolved "https://registry.npmmirror.com/ylru/-/ylru-1.4.0.tgz"
   integrity sha512-2OQsPNEmBCvXuFlIni/a+Rn+R2pHW9INm0BxXJ4hVDA8TirqMj+J/Rp9ItLatT/5pZqWwefVrTQcHpixsxnVlA==
-
-zrender@6.0.0:
-  version "6.0.0"
-  resolved "https://registry.npmjs.org/zrender/-/zrender-6.0.0.tgz"
-  integrity sha512-41dFXEEXuJpNecuUQq6JlbybmnHaqqpGlbH1yxnA5V9MMP4SbohSVZsJIwz+zdjQXSSlR1Vc34EgH1zxyTDvhg==
-  dependencies:
-    tslib "2.3.0"