Merge remote-tracking branch 'origin/master'
This commit is contained in:
Binary file not shown.
@@ -1,9 +1,12 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:ef/ef.dart';
|
import 'package:ef/ef.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:vbvs_app/common/util/CommonVariables.dart';
|
import 'package:vbvs_app/common/util/CommonVariables.dart';
|
||||||
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
|
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
|
||||||
|
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||||
import 'package:vbvs_app/model/WebSocketMessage.dart';
|
import 'package:vbvs_app/model/WebSocketMessage.dart';
|
||||||
import 'package:vbvs_app/pages/common/bezier_bottom_navigation_bar.dart';
|
import 'package:vbvs_app/pages/common/bezier_bottom_navigation_bar.dart';
|
||||||
@@ -107,9 +110,21 @@ class _HomePageState extends State<MainPageBBottomChange>
|
|||||||
return Center(child: Text('页面 ${titles[selectedIndex]}'));
|
return Center(child: Text('页面 ${titles[selectedIndex]}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DateTime? _lastBackPressedTime; // 记录上一次返回的时间
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return PopScope(
|
||||||
|
canPop: false,
|
||||||
|
onPopInvokedWithResult: (disposition, result) async {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
var flag = await _handleBackPressed(context); // 自定义返回逻辑
|
||||||
|
if (flag) {
|
||||||
|
SystemNavigator.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
backgroundColor: const Color(0xFF011C33),
|
backgroundColor: const Color(0xFF011C33),
|
||||||
body: IndexedStack(
|
body: IndexedStack(
|
||||||
index: selectedIndex,
|
index: selectedIndex,
|
||||||
@@ -122,7 +137,7 @@ class _HomePageState extends State<MainPageBBottomChange>
|
|||||||
path: path,
|
path: path,
|
||||||
titles: titles,
|
titles: titles,
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchTab(int index) {
|
void switchTab(int index) {
|
||||||
@@ -228,4 +243,19 @@ class _HomePageState extends State<MainPageBBottomChange>
|
|||||||
ef.log("[激活控制页面报错]:$e");
|
ef.log("[激活控制页面报错]:$e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> _handleBackPressed(BuildContext context) async {
|
||||||
|
final currentTime = DateTime.now();
|
||||||
|
|
||||||
|
// 如果上次点击返回键时间为空,或者间隔超过 1 秒
|
||||||
|
if (_lastBackPressedTime == null ||
|
||||||
|
currentTime.difference(_lastBackPressedTime!) > Duration(seconds: 2)) {
|
||||||
|
_lastBackPressedTime = currentTime;
|
||||||
|
// showToast("再按一次退出程序", color: color_warning, closeTime: 2);
|
||||||
|
TopSlideNotification.show(context, text: "再滑一次退出程序".tr);
|
||||||
|
return false; // 阻止退出程序
|
||||||
|
} else {
|
||||||
|
return true; // 允许退出程序
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -272,6 +272,15 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
|||||||
device: widget.bleDevice.scanResult.device);
|
device: widget.bleDevice.scanResult.device);
|
||||||
blueteethBindController.currentDevice = bledevice;
|
blueteethBindController.currentDevice = bledevice;
|
||||||
blueteethBindController.currentDeviceMac.value = "";
|
blueteethBindController.currentDeviceMac.value = "";
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (homeController
|
||||||
|
.homeSleepDays.value.isNotEmpty) {
|
||||||
|
homeController.selectedDayIndex.value =
|
||||||
|
homeController.homeSleepDays.value.length -
|
||||||
|
1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await homeController.getPersonList();
|
||||||
} else {
|
} else {
|
||||||
blueteethBindController.resumeScanning();
|
blueteethBindController.resumeScanning();
|
||||||
blueteethBindController.currentDeviceMac.value = "";
|
blueteethBindController.currentDeviceMac.value = "";
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
|||||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||||
|
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||||
import 'package:vbvs_app/model/api_response.dart';
|
import 'package:vbvs_app/model/api_response.dart';
|
||||||
import 'package:vbvs_app/pages/mh_page/device/model/BlueToothDataModel.dart';
|
import 'package:vbvs_app/pages/mh_page/device/model/BlueToothDataModel.dart';
|
||||||
@@ -71,8 +72,6 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
|||||||
RxMap connect_wifi = {}.obs;
|
RxMap connect_wifi = {}.obs;
|
||||||
RxString? cid = "".obs;
|
RxString? cid = "".obs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void startStatusPolling() {
|
void startStatusPolling() {
|
||||||
updateDeviceStatus().then((res) {
|
updateDeviceStatus().then((res) {
|
||||||
if (res.code == HttpStatusCodes.ok) {
|
if (res.code == HttpStatusCodes.ok) {
|
||||||
@@ -189,7 +188,7 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
|||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
model.deviceDataStatus = [];
|
model.deviceDataStatus = [];
|
||||||
return ApiResponse(code:1, msg: "".tr);
|
return ApiResponse(code: 1, msg: "".tr);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("获取设备状态异常: $e");
|
print("获取设备状态异常: $e");
|
||||||
@@ -257,6 +256,56 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
|||||||
}
|
}
|
||||||
return ApiResponse(code: -1, msg: "未知错误".tr);
|
return ApiResponse(code: -1, msg: "未知错误".tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveHabitData(sleepData) async {
|
||||||
|
String serviceAddress = ServiceConstant.service_address;
|
||||||
|
String serviceName = ServiceConstant.server_service;
|
||||||
|
String serviceApi = ServiceConstant.user_setting;
|
||||||
|
String type = "sleep_habit_${sleepData['mac']}";
|
||||||
|
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||||
|
var data = {
|
||||||
|
"type": type,
|
||||||
|
"mac": sleepData['mac'],
|
||||||
|
"time": DateTime.now().millisecondsSinceEpoch,
|
||||||
|
"data": sleepData,
|
||||||
|
};
|
||||||
|
await requestWithLog(
|
||||||
|
logTitle: "更新睡眠习惯",
|
||||||
|
method: MyHttpMethod.put,
|
||||||
|
queryUrl: queryUrl,
|
||||||
|
data: data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map> loadHabitDataApi(String mac, {int time = 3}) async {
|
||||||
|
String serviceAddress = ServiceConstant.service_address;
|
||||||
|
String serviceName = ServiceConstant.server_service;
|
||||||
|
String serviceApi = ServiceConstant.user_setting;
|
||||||
|
String type = "sleep_habit_${mac}";
|
||||||
|
String queryUrl =
|
||||||
|
"${serviceAddress}${serviceName}${serviceApi}?type=${type}";
|
||||||
|
|
||||||
|
// 使用 Future 来等待异步操作完成
|
||||||
|
Map<String, dynamic> result = {};
|
||||||
|
|
||||||
|
await requestWithLog(
|
||||||
|
logTitle: "更新睡眠习惯",
|
||||||
|
method: MyHttpMethod.get,
|
||||||
|
queryUrl: queryUrl,
|
||||||
|
onSuccess: (res) {
|
||||||
|
ef.log("加载睡眠习惯成功: ${res.data}");
|
||||||
|
result = res.data; // 将返回的数据存入 result
|
||||||
|
},
|
||||||
|
onFailure: (res) {
|
||||||
|
ef.log("加载睡眠习惯失败: ${res.msg}");
|
||||||
|
result = {}; // 如果失败,可以返回空的 Map
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return result; // 在 requestWithLog 完成之后返回 result
|
||||||
|
}
|
||||||
|
|
||||||
|
//todo 解绑的时候删除自己所拥有的所有设备的睡眠习惯
|
||||||
}
|
}
|
||||||
|
|
||||||
void safeShowNotification(String msg) {
|
void safeShowNotification(String msg) {
|
||||||
|
|||||||
@@ -873,7 +873,6 @@ class _MHTCalibrationPageState extends State<MHTCalibrationPage> {
|
|||||||
textColor: themeController.currentColor.sc9,
|
textColor: themeController.currentColor.sc9,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceCalibrationController.statusContext.value = "";
|
deviceCalibrationController.statusContext.value = "";
|
||||||
deviceCalibrationController.bed_calibration.value == 0;
|
deviceCalibrationController.bed_calibration.value == 0;
|
||||||
blueteethBindController.cid?.value = "";
|
blueteethBindController.cid?.value = "";
|
||||||
@@ -907,7 +906,7 @@ class _MHTCalibrationPageState extends State<MHTCalibrationPage> {
|
|||||||
data["side"] = currentCalibrationStep.value == 1 ? "A" : "B";
|
data["side"] = currentCalibrationStep.value == 1 ? "A" : "B";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data['cancel'] = true;
|
// data['cancel'] = true;
|
||||||
requestWithLog(
|
requestWithLog(
|
||||||
logTitle: "设备校准",
|
logTitle: "设备校准",
|
||||||
method: MyHttpMethod.post,
|
method: MyHttpMethod.post,
|
||||||
|
|||||||
@@ -404,6 +404,7 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
|
|||||||
queryUrl: queryUrl,
|
queryUrl: queryUrl,
|
||||||
onSuccess: (res) {
|
onSuccess: (res) {
|
||||||
personnelList.value = res.data ?? [];
|
personnelList.value = res.data ?? [];
|
||||||
|
updateAll();
|
||||||
},
|
},
|
||||||
onFailure: (res) {
|
onFailure: (res) {
|
||||||
EasyDartModule.logger.warning("请求人员信息列表失败: ${res.msg}");
|
EasyDartModule.logger.warning("请求人员信息列表失败: ${res.msg}");
|
||||||
|
|||||||
@@ -125,8 +125,19 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
|||||||
if (userInfoController.model.login! != null &&
|
if (userInfoController.model.login! != null &&
|
||||||
userInfoController.model.login! == 1) {
|
userInfoController.model.login! == 1) {
|
||||||
final list = deviceController.personnelList.value;
|
final list = deviceController.personnelList.value;
|
||||||
if (list.isNotEmpty &&
|
// if (list.isNotEmpty &&
|
||||||
formFieldController.value == null) {
|
// formFieldController.value == null) {
|
||||||
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
// formFieldController.value = list[0]["mac"];
|
||||||
|
// personInfo.value = list[0];
|
||||||
|
// homeController.selectPerson.value = list[0];
|
||||||
|
// homeController.selectDevcie.value = list[0]["mac"];
|
||||||
|
// deviceController
|
||||||
|
// .getSleeps(formFieldController.value);
|
||||||
|
// homeController.updateAll();
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
if (list.isNotEmpty) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
formFieldController.value = list[0]["mac"];
|
formFieldController.value = list[0]["mac"];
|
||||||
personInfo.value = list[0];
|
personInfo.value = list[0];
|
||||||
@@ -312,7 +323,8 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
|||||||
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
if (homeController.selectDevcie.value != null &&
|
if (homeController.selectDevcie.value != null &&
|
||||||
homeController.selectDevcie.value!.isNotEmpty)
|
homeController.selectDevcie.value!.isNotEmpty &&
|
||||||
|
deviceController.personnelList.value.isNotEmpty)
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: NewSleepReportPage(
|
child: NewSleepReportPage(
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import 'dart:ffi';
|
|
||||||
|
|
||||||
import 'package:ef/ef.dart';
|
import 'package:ef/ef.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
|
|||||||
await controller.savePeoples(data, context);
|
await controller.savePeoples(data, context);
|
||||||
MHTHomeController mhtHomeController =
|
MHTHomeController mhtHomeController =
|
||||||
Get.find();
|
Get.find();
|
||||||
mhtHomeController.getPersonList();
|
await Future.delayed(Duration(seconds: 1));
|
||||||
|
await mhtHomeController.getPersonList();
|
||||||
WebviewTestController
|
WebviewTestController
|
||||||
webviewTestController = Get.find();
|
webviewTestController = Get.find();
|
||||||
webviewTestController
|
webviewTestController
|
||||||
|
|||||||
@@ -177,7 +177,8 @@ class Smys extends GetView<SleepingHabitController> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(
|
bottom: BorderSide(
|
||||||
color: const Color(0xFF929699),
|
color: Color(0xFF929699),
|
||||||
|
// color: Colors.red,
|
||||||
width: 0.rpx),
|
width: 0.rpx),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import 'package:vbvs_app/common/util/MyUtils.dart';
|
|||||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||||
import 'package:vbvs_app/model/WebSocketMessage.dart';
|
import 'package:vbvs_app/model/WebSocketMessage.dart';
|
||||||
|
import 'package:vbvs_app/pages/mh_page/device/controller/mht_bluetooth_controller.dart';
|
||||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||||
|
|
||||||
class WebviewTestModel {
|
class WebviewTestModel {
|
||||||
@@ -138,6 +139,27 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
|||||||
Get.toNamed("/mHTDeviceTypePage");
|
Get.toNamed("/mHTDeviceTypePage");
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
bridge.sdk.saveSleepHabit((args) async {
|
||||||
|
ef.log('更新睡眠习惯: $args[0]');
|
||||||
|
try {
|
||||||
|
MHTBlueToothController blueToothController = Get.find();
|
||||||
|
blueToothController.saveHabitData(args[0]);
|
||||||
|
} catch (e) {
|
||||||
|
ef.log("[更新睡眠习惯失败]:$e");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
bridge.sdk.loadSleepHabit((args) async {
|
||||||
|
ef.log('查询睡眠习惯: $args[0]');
|
||||||
|
try {
|
||||||
|
MHTBlueToothController blueToothController = Get.find();
|
||||||
|
var sleepData = await blueToothController.loadHabitDataApi(args[0]);
|
||||||
|
return sleepData['data'];
|
||||||
|
} catch (e) {
|
||||||
|
ef.log("[查询睡眠习惯失败]:$e");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
ef.log('$e,$s');
|
ef.log('$e,$s');
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class UpdatePasswordController extends GetControllerEx<UpdatePasswordModel> {
|
|||||||
};
|
};
|
||||||
await requestWithLog(
|
await requestWithLog(
|
||||||
logTitle: "修改密码",
|
logTitle: "修改密码",
|
||||||
method: MyHttpMethod.post,
|
method: MyHttpMethod.put,
|
||||||
queryUrl: queryUrl,
|
queryUrl: queryUrl,
|
||||||
data: data,
|
data: data,
|
||||||
onSuccess: (res) {
|
onSuccess: (res) {
|
||||||
|
|||||||
Reference in New Issue
Block a user