Explorar o código

提交优化后的代码

wangming07 hai 1 mes
pai
achega
b434f97bcd

+ 1 - 1
src/components/component/alarModel.vue

@@ -476,7 +476,7 @@ export default {
                         );
                     }
                 });
-                console.log(this.clientIdProp);
+                // console.log(this.clientIdProp);
                 // if (this.clientIdProp !== null) {
                 //     client.subscribe(
                 //         `/dev/${this.clientIdProp}/dsp_data`,

+ 0 - 3
src/manifest.json

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

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

@@ -890,7 +890,10 @@ export default {
                 clean: true,
                 connectTimeout: 30 * 1000,
                 clientId:
-                    "wx_mqtt_" + Math.random().toString(16).substring(2, 8),
+                    "wx_mqtt_" +
+                    Date.now() +
+                    "_" +
+                    Math.random().toString(16).substring(2, 8),
                 username: "admin",
                 password: "public",
                 // 微信小程序特定配置
@@ -916,16 +919,8 @@ export default {
                         "wxs://data.radar-power.com:8084/mqtt",
                         params
                     );
-                    // clientTwo = mqtt.connect(
-                    //     "wxs://radar-power.cn:8084/mqtt",
-                    //     params
-                    // );
                 }
                 if (__wxConfig.envVersion == "trial") {
-                    // clientTwo = mqtt.connect(
-                    //     "wxs://data.radar-power.com:8084/mqtt",
-                    //     params
-                    // );
                     clientTwo = mqtt.connect(
                         "wxs://radar-power.cn:8084/mqtt",
                         params
@@ -940,7 +935,7 @@ export default {
                 let userId = uni.getStorageSync("userId");
                 if (this.clientIdProp !== null) {
                     clientTwo.subscribe(
-                        `/dev/${this.clientIdProp}/dsp_data`,
+                        `/dev/${this.clientIdProp}/tracker_targets`,
                         (err) => {
                             if (err) {
                                 console.error("订阅clientId失败", err);

+ 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>

+ 160 - 72
src/pagesA/healthAlarm/healthAlarm.vue

@@ -1,96 +1,184 @@
 <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">
+                    <view
+                        class="info-box"
+                        v-for="(item, index) in modules"
+                        :key="index"
+                    >
+                        <view class="info-text">
+                            <text>{{ item.name }}</text>
+                            <text>({{ item.width }}*{{ item.length }})cm</text>
+                        </view>
+                        <view class="edit_del">
+                            <image
+                                @click="deleteItem(index)"
+                                src="../../static/delete.png"
+                                alt=""
+                            ></image>
+                            <image
+                                @click="editItem(index)"
+                                style="margin-left: 10rpx"
+                                src="../../static/edit.png"
+                                alt=""
+                            ></image>
+                        </view>
+                    </view>
+                </view>
             </view>
         </view>
+        <view class="bottomTwo" @click="saveRoom">
+            <view class="addNewAlarm">新增设备告警计划</view>
+            <view class="previousTip">保存</view>
+        </view>
     </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" }],
-                },
-            ],
-        };
+        return { modules: [] };
     },
+    computed: {},
     methods: {
-        handleSwitchChange(index, newValue) {
-            this.switchItems[index].value = newValue;
-        },
-        updateTimeRanges(index, newTimeRanges) {
-            this.switchItems[index].timeRanges = newTimeRanges;
+        saveRoom() {
+            console.log("保存");
         },
     },
+    onLoad(options) {},
+    onShow() {},
 };
 </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 {
+        background: #ffffff;
         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;
+                }
+            }
+        }
+    }
+    .bottomTwo {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        position: fixed;
+        bottom: 0;
+        left: 0;
+        width: 750rpx;
+        height: 120rpx;
+        background: #f3e2dd;
+        .addNewAlarm {
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            width: 400rpx;
+            height: 94rpx;
+            background: #ffebe4;
+            border-radius: 28rpx;
+            font-weight: 500;
+            color: #111111;
+            font-size: 32rpx;
+            text-align: center;
+        }
+        .previousTip {
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            width: 328rpx;
+            height: 94rpx;
+            background: linear-gradient(105.95deg, #a27867 0%, #74483d 100%);
+            border-radius: 28rpx;
+            box-shadow: 0rpx 4.69rpx 18.75rpx rgba(72, 41, 29, 0.15),
+                0rpx 9.38rpx 9.38rpx rgba(154, 132, 89, 0.2),
+                0rpx -4.69rpx 28.13rpx 4.69rpx #a16647 inset;
+            font-family: MiSans;
+            font-weight: 500;
+            color: #ffffff;
+            font-size: 32rpx;
         }
     }
 }

+ 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([
                 {

+ 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"