From ecb8f63a6c8aa89ec4203d4adf520d4fbbcb7557 Mon Sep 17 00:00:00 2001 From: lijunjie Date: Wed, 7 Sep 2022 14:55:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E7=8E=AF=E6=B8=B2=E6=9F=93=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/IndexController.php | 18 +- resources/views/http/lora2.blade.php | 53 +- resources/views/http/lora22.blade.php | 618 +++++++++++++++++++++++ 3 files changed, 665 insertions(+), 24 deletions(-) create mode 100644 resources/views/http/lora22.blade.php diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index b1cb1a3..144bb44 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -326,9 +326,21 @@ class IndexController extends BaseController public function loraDeviceList() { return [ - '设备1', - '设备2', - '设备3', + [ + 'name' => '设备1', + 'mac' => '61', + 'online' => 0, + ], + [ + 'name' => '设备2', + 'mac' => '62', + 'online' => 0, + ], + [ + 'name' => '设备3', + 'mac' => '63', + 'online' => 0, + ], ]; } diff --git a/resources/views/http/lora2.blade.php b/resources/views/http/lora2.blade.php index f98bac8..6f4ffb2 100644 --- a/resources/views/http/lora2.blade.php +++ b/resources/views/http/lora2.blade.php @@ -14,7 +14,13 @@
- @{{ device }} +
@{{device.name}}
+
+ 在线 +
+
+ 离线 +
@@ -32,14 +38,14 @@ const app = { data() { return { - device_list: [] + device_list: [], + aaaa:0, } }, mounted() { var _this = this; axios .get('/loraDeviceList') - // .then(response => (this.info = response.data)) .then(function (response) { device_list = response.data _this.device_list = device_list; @@ -51,14 +57,15 @@ // 每隔5分钟定时刷新 this.timer = setInterval(() => { this.getFxItemlist(); - }, 1000 * 5) + }, 1000 * 3) }, beforeDestroy() { clearInterval(this.timer); }, methods: { getFxItemlist() { - + this.device_list = device_list + this.$forceUpdate(); } } } @@ -543,37 +550,41 @@ let special_compare_data = []; setInterval(function () { - if (show_type != 2) { - if (clear == 1) { - special_compare_data = []; - clear = 0; - } - - return; - } + // if (show_type != 2) { + // if (clear == 1) { + // special_compare_data = []; + // clear = 0; + // } + // + // return; + // } let chart_data = []; let expire = 0; $.get('/getSpecialCompare?compare_type=' + compare_type).done(function (rawData) { //追加数据 - device_list.forEach(function (item) { - let device_data = rawData[item]; + device_list.forEach(function (item, key) { + let name = item.name; + let device_data = rawData[name]; if (device_data) { - if (special_compare_data[item]) { - device_data.forEach(value => special_compare_data[item].push(value)); + device_list[key].online = 1 + if (special_compare_data[name]) { + device_data.forEach(value => special_compare_data[name].push(value)); } else { device_data.forEach(function (value) { - special_compare_data[item] = [value] + special_compare_data[name] = [value] }); } - if (special_compare_data[item].length > 5) { - if (special_compare_data[item][0][0] > expire) { - expire = special_compare_data[item][0][0]; + if (special_compare_data[name].length > 5) { + if (special_compare_data[name][0][0] > expire) { + expire = special_compare_data[name][0][0]; } } + } else { + device_list[key].online = 0 } }) diff --git a/resources/views/http/lora22.blade.php b/resources/views/http/lora22.blade.php new file mode 100644 index 0000000..6f4ffb2 --- /dev/null +++ b/resources/views/http/lora22.blade.php @@ -0,0 +1,618 @@ + + + + + + + + + + +
+ +
+
+
@{{device.name}}
+
+ 在线 +
+
+ 离线 +
+
+
+
+
+
+
+ + + + + + + +