Ver Fonte

提交设备详情页面问题

wangming há 2 meses atrás
pai
commit
48a4158165
3 ficheiros alterados com 46 adições e 13 exclusões
  1. 7 1
      src/pages.json
  2. 34 9
      src/pages/home/home.vue
  3. 5 3
      src/pagesA/deviceDetail/deviceDetail.vue

+ 7 - 1
src/pages.json

@@ -254,5 +254,11 @@
             "van-picker": "/wxcomponents/vant/picker/index"
         }
     },
-    "usingComponts": true
+    "usingComponts": true,
+    "requiredPrivateInfos": [
+        "getLocation"
+    ],
+    "scripts": {
+        "build": "gulp"
+    }
 }

+ 34 - 9
src/pages/home/home.vue

@@ -18,7 +18,11 @@
                 <view class="rightItem">
                     <view class="rightTitle">今日天气</view>
                     <view class="rightPng">
-                        <view class="rightContent">暂无</view>
+                        <view
+                            class="rightContent"
+                            style="text-align: center; font-size: 40rpx"
+                            >{{ weatherText }}</view
+                        >
                     </view>
                 </view>
                 <view
@@ -146,6 +150,7 @@ export default {
             warmNum: "",
             warmDetail: [],
             warmList: [],
+            weatherText: "",
         };
     },
     computed: {},
@@ -192,14 +197,14 @@ export default {
         },
         goAbnormalInfo() {
             if (uni.getStorageSync("userId")) {
-                // if (this.warnNum <= 0) {
-                //     uni.showToast({
-                //         title: "暂无异常信息",
-                //         icon: "none",
-                //         duration: 1500,
-                //     });
-                //     return;
-                // }
+                if (this.warnNum <= 0) {
+                    uni.showToast({
+                        title: "暂无异常信息",
+                        icon: "none",
+                        duration: 1500,
+                    });
+                    return;
+                }
                 uni.navigateTo({
                     url: "/pagesA/abnormalInfo/abnormalInfo",
                 });
@@ -243,6 +248,25 @@ export default {
                     this.shareNum = res.data.data?.length || 0;
                 });
         },
+        // 获取天气接口
+        async getWeather() {
+            uni.request({
+                url: "https://kp36x7gr79.re.qweatherapi.com/v7/weather/now", // 使用官方域名
+                data: {
+                    location: "101220101", // 城市ID
+                    key: "72afe228cd7f436ebea7caa1345956f2", // 你的API Key
+                },
+                method: "GET",
+                success: (res) => {
+                    if (res.statusCode === 200) {
+                        this.weatherText = res.data.now.text;
+                    }
+                },
+                fail: (err) => {
+                    console.error("网络错误:", err);
+                },
+            });
+        },
 
         // 需要跟车对接一下,换一个接口
         getWarmList() {
@@ -301,6 +325,7 @@ export default {
             this.getShareNum();
             this.getWarmList();
         }
+        this.getWeather();
         // 配置服务器
         let selectedService = uni.getStorageSync("sercviceChoice");
         if (!selectedService) {

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

@@ -264,7 +264,7 @@
                 </view>
             </view>
         </view>
-        <alarModel />
+        <!-- <alarModel /> -->
     </view>
 </template>
 <script>
@@ -505,10 +505,12 @@ export default {
                                 delete this.targetPoints[id];
                             }
                         });
-
+                        this.targetPoints = [...this.targetPoints];
                         console.log("🚀🚀🚀🚀targets", this.targetPoints);
                     } else {
-                        this.targetPoints.forEach((key) => delete targets[key]);
+                        this.targetPoints.forEach(
+                            (key) => delete this.targetPoints[key]
+                        );
                     }
                 } catch (e) {
                     // console.error("MQTT消息解析失败", e);