浏览代码

redis历史数据查询修改

bobo04052021@163.com 2 天之前
父节点
当前提交
2bc6fa3bd9
共有 1 个文件被更改,包括 13 次插入9 次删除
  1. 13 9
      pages/history/history.vue

+ 13 - 9
pages/history/history.vue

@@ -85,7 +85,7 @@
           :class="{ emptyhistory: historyData.length === 0 }"
           class="historycontainer"
         >
-          <template v-if="historyData && historyData.length > 0">
+          <template v-if="historyData.length > 0">
             <u-list-item
               class="itemback"
               v-for="(item, index) in historyData"
@@ -411,12 +411,12 @@ export default {
     },
     //查询历史数据 getDeviceHistory
     checkHistory() {
-      if (this.stationType !== "redis") {
-        this.getHistoryData();
-      } else {
-        this.getHistoryData2();
-      }
-      // this.getHistoryData2();
+      // if (this.stationType !== "redis") {
+      //   this.getHistoryData();
+      // } else {
+      //   this.getHistoryData2();
+      // }
+      this.getHistoryData2();
     },
     // 查询历史数据
     getHistoryData() {
@@ -466,7 +466,11 @@ export default {
           .getDeviceHistory2(params)
           .then((response) => {
             if (response.data.code == 200) {
-              this.historyData = response.data.result.records;
+              this.historyData =
+                (response.data &&
+                  response.data.result &&
+                  response.data.result.records) ||
+                [];
               // this.pageNo = response.data.result.datalist.current;
             } else {
               resolve(response);
@@ -520,7 +524,7 @@ export default {
   onReachBottom() {
     // uni-app提供的页面滚动到底部钩子函数
     console.log("上拉加载更多数据");
-    this.loadMoreData();
+    // this.loadMoreData();
   },
 };
 </script>