更新页面
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/main_page_controller.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
|
||||
class GlobalModel {
|
||||
List deviceList = [];
|
||||
@@ -138,16 +140,11 @@ class GlobalController extends GetControllerEx<GlobalModel> {
|
||||
deviceUpdateTimerCreated() {
|
||||
if (getDeviceListTimer == null) {
|
||||
getDeviceListTimer = Timer.periodic(const Duration(seconds: 10), (t) {
|
||||
if (userInfoController.model.token != null) {
|
||||
|
||||
}
|
||||
if (userInfoController.model.token != null) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
getDeviceGroupName(device) {
|
||||
return "${device['roomName']}/${device["deviceType"]?["name"]}/${device["name"]}";
|
||||
}
|
||||
@@ -169,4 +166,49 @@ class GlobalController extends GetControllerEx<GlobalModel> {
|
||||
model.deviceType = rs.where((d) => d["page"] != null).toList();
|
||||
updateAll();
|
||||
}
|
||||
|
||||
getDeviceList({int time = 1}) async {
|
||||
await EasyDartModule.dio.get("/api/device/info/list").then((d) {
|
||||
Map d_ = {};
|
||||
d.data?["data"]?.forEach((item) {
|
||||
if (d_[item["roomName"]] == null) {
|
||||
d_[item["roomName"]] = [];
|
||||
}
|
||||
d_[item["roomName"]].add(item);
|
||||
});
|
||||
List res_ = [];
|
||||
d_.keys.forEach((key) {
|
||||
res_.addAll(d_[key]);
|
||||
});
|
||||
model.deviceList = res_;
|
||||
if (model.deviceMain != null && model.deviceMain["mac"] != null) {
|
||||
bool isClose = false;
|
||||
model.deviceList.forEach((item) {
|
||||
if (item["mac"] == model.deviceMain["mac"]) {
|
||||
model.deviceMain = item;
|
||||
isClose = true;
|
||||
updateAll();
|
||||
}
|
||||
});
|
||||
if (!isClose) {
|
||||
model.deviceMain = {};
|
||||
updateAll();
|
||||
showCustomConfirmAndCancelDialog(Get.context!, "设备已经被解绑,是否回到主界面?")
|
||||
.then((e) {
|
||||
if (e == "confirm") {
|
||||
Get.find<MainPageController>().model.currentIndex = 0;
|
||||
Get.offAllNamed("/mianPageBottomChange");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
updateAll();
|
||||
}
|
||||
}).catchError((e) {
|
||||
print("$e");
|
||||
if (time > 0) {
|
||||
getDeviceList(time: time - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user