更新
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 318 KiB After Width: | Height: | Size: 265 KiB |
@@ -596,5 +596,6 @@
|
|||||||
"有一条新的设备分享消息": "You have a new device sharing message",
|
"有一条新的设备分享消息": "You have a new device sharing message",
|
||||||
"去查看": "View now",
|
"去查看": "View now",
|
||||||
"正常值": "range:",
|
"正常值": "range:",
|
||||||
|
"绑定设备": "Bind Device",
|
||||||
"设备分享提醒": "Device Sharing Alert"
|
"设备分享提醒": "Device Sharing Alert"
|
||||||
}
|
}
|
||||||
@@ -591,5 +591,7 @@
|
|||||||
"皮肤指数通过用户睡眠过程中的体征数据,计算皮肤电反应,生成综合评估指标,用于睡眠中的生理应激状态或自主神经活动。": "皮肤指数通过用户睡眠过程中的体征数据,计算皮肤电反应,生成综合评估指标,用于睡眠中的生理应激状态或自主神经活动。",
|
"皮肤指数通过用户睡眠过程中的体征数据,计算皮肤电反应,生成综合评估指标,用于睡眠中的生理应激状态或自主神经活动。": "皮肤指数通过用户睡眠过程中的体征数据,计算皮肤电反应,生成综合评估指标,用于睡眠中的生理应激状态或自主神经活动。",
|
||||||
"删除后": "删除后",
|
"删除后": "删除后",
|
||||||
"该设备的历史数据将被清除": "该设备的历史数据将被清除","有一条新的设备分享消息":"有一条新的设备分享消息","去查看":"去查看",
|
"该设备的历史数据将被清除": "该设备的历史数据将被清除","有一条新的设备分享消息":"有一条新的设备分享消息","去查看":"去查看",
|
||||||
"正常值":"正常值:","设备分享提醒":"设备分享提醒"
|
"正常值":"正常值:",
|
||||||
|
"绑定设备":"绑定设备",
|
||||||
|
"设备分享提醒":"设备分享提醒"
|
||||||
}
|
}
|
||||||
@@ -593,5 +593,7 @@
|
|||||||
"该设备的历史数据将被清除": "該設備的歷史數據將被清除",
|
"该设备的历史数据将被清除": "該設備的歷史數據將被清除",
|
||||||
"有一条新的设备分享消息": "有一條新的設備分享消息",
|
"有一条新的设备分享消息": "有一條新的設備分享消息",
|
||||||
"去查看": "去查看",
|
"去查看": "去查看",
|
||||||
"正常值": "正常值:","设备分享提醒":"設備分享提醒"
|
"正常值": "正常值:",
|
||||||
|
"绑定设备":"绑定设备",
|
||||||
|
"设备分享提醒":"設備分享提醒"
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
class ServiceConstant {
|
class ServiceConstant {
|
||||||
static const String baseHost = "vsbs-test.he-info.cn"; //服务地址
|
static const String baseHost = "zhmht.swes.com.cn:27020"; //服务地址
|
||||||
|
// static const String baseHost = "vsbs-test.he-info.cn"; //服务地址
|
||||||
// static const String baseHost = "vsbst-api.he-info.cn";//服务地址
|
// static const String baseHost = "vsbst-api.he-info.cn";//服务地址
|
||||||
static const String service_address = "http://$baseHost";
|
// static const String service_address = "http://$baseHost";
|
||||||
|
static const String service_address = "https://$baseHost";
|
||||||
|
|
||||||
static String server_service = "/vsbs_app_server"; //服务名称
|
static String server_service = "/vsbs_app_server"; //服务名称
|
||||||
|
|
||||||
@@ -33,7 +35,6 @@ class ServiceConstant {
|
|||||||
static String address_list = "/api/addresss/list"; //查询地址列表
|
static String address_list = "/api/addresss/list"; //查询地址列表
|
||||||
static String add_address = "/api/addresss/info"; //添加地址
|
static String add_address = "/api/addresss/info"; //添加地址
|
||||||
|
|
||||||
|
|
||||||
static String logService = "$service_address/vsbs_log";
|
static String logService = "$service_address/vsbs_log";
|
||||||
static const String webSocketService = "wss://$baseHost/vsbs_ws_gateway/ws";
|
static const String webSocketService = "wss://$baseHost/vsbs_ws_gateway/ws";
|
||||||
static const String sleep_token = "HdAMjzqiYQKsmHRyEFKhfRGQ";
|
static const String sleep_token = "HdAMjzqiYQKsmHRyEFKhfRGQ";
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'package:ef/ef.dart';
|
||||||
|
|
||||||
class CommonVariables {
|
class CommonVariables {
|
||||||
static bool isNetWorkOn = false;
|
static bool isNetWorkOn = false;
|
||||||
static String supabaseUrl = "https://zhmht.swes.com.cn:3443";
|
static String supabaseUrl = "https://zhmht.swes.com.cn:3443";
|
||||||
@@ -12,7 +14,7 @@ class CommonVariables {
|
|||||||
//公司名称
|
//公司名称
|
||||||
static String enterpriseName = "合肥眠花糖家具有限责任公司";
|
static String enterpriseName = "合肥眠花糖家具有限责任公司";
|
||||||
//备案时间
|
//备案时间
|
||||||
static String ICPTime = "2022-2025";
|
static String ICPTime = "2019-2029";
|
||||||
static String shoph5Url = "https://zhmht.swes.com.cn:1443";
|
static String shoph5Url = "https://zhmht.swes.com.cn:1443";
|
||||||
|
|
||||||
static Map<String, Function(dynamic)> callMap = {};
|
static Map<String, Function(dynamic)> callMap = {};
|
||||||
@@ -22,4 +24,10 @@ class CommonVariables {
|
|||||||
static String shareText = "您的朋友邀请您使用《智慧眠花糖》APP,请复制后面链接在浏览器中打开! " +
|
static String shareText = "您的朋友邀请您使用《智慧眠花糖》APP,请复制后面链接在浏览器中打开! " +
|
||||||
shoph5Url +
|
shoph5Url +
|
||||||
"/#/pages/download/download";
|
"/#/pages/download/download";
|
||||||
|
|
||||||
|
List permissionInfo = [
|
||||||
|
["位置权限说明".tr, "获得位置信息,连接附近的蓝牙设备与推荐附近门店".tr],
|
||||||
|
["蓝牙权限说明".tr, "搜索链接附近的蓝牙设备".tr],
|
||||||
|
["附近设备权限说明".tr, "搜索链接附近的蓝牙设备".tr]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||||
import 'package:ef/ef.dart';
|
import 'package:ef/ef.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:geocoding/geocoding.dart';
|
import 'package:geocoding/geocoding.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
import 'package:vbvs_app/common/util/CommonVariables.dart';
|
import 'package:vbvs_app/common/util/CommonVariables.dart';
|
||||||
import 'package:vbvs_app/controller/setting/language/language_controller.dart';
|
import 'package:vbvs_app/controller/setting/language/language_controller.dart';
|
||||||
|
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||||
import 'package:weather/weather.dart';
|
import 'package:weather/weather.dart';
|
||||||
|
|
||||||
part 'weather_controller.g.dart';
|
part 'weather_controller.g.dart';
|
||||||
@@ -100,8 +103,6 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
|
|||||||
// 调用获取天气方法
|
// 调用获取天气方法
|
||||||
_getCurrentWeather();
|
_getCurrentWeather();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
|
|
||||||
print(e);
|
print(e);
|
||||||
EasyDartModule.logger.error("获取位置失败: $e");
|
EasyDartModule.logger.error("获取位置失败: $e");
|
||||||
}
|
}
|
||||||
@@ -117,7 +118,20 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
|
|||||||
return Future.error('位置服务未启用');
|
return Future.error('位置服务未启用');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showPermissionInfoDialog(Get.context!, CommonVariables().permissionInfo);
|
||||||
|
// permission = await Geolocator.checkPermission();
|
||||||
|
try {
|
||||||
|
// 2️⃣ 检查权限(系统弹窗)—— 此时你的提示框仍然显示
|
||||||
permission = await Geolocator.checkPermission();
|
permission = await Geolocator.checkPermission();
|
||||||
|
|
||||||
|
if (permission == LocationPermission.denied) {
|
||||||
|
permission = await Geolocator.requestPermission();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// 3️⃣ 无论如何都关闭你的提示弹窗
|
||||||
|
Navigator.of(Get.context!, rootNavigator: true).pop();
|
||||||
|
}
|
||||||
|
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
permission = await Geolocator.requestPermission();
|
permission = await Geolocator.requestPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
@@ -199,166 +213,3 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// import 'dart:async';
|
|
||||||
// import 'package:EasyDartModule/EasyDartModule.dart';
|
|
||||||
// import 'package:ef/ef.dart';
|
|
||||||
// import 'package:amap_flutter_location/amap_flutter_location.dart'; // 导入 amap_flutter_location 插件
|
|
||||||
// import 'package:geocoding/geocoding.dart';
|
|
||||||
// import 'package:json_annotation/json_annotation.dart';
|
|
||||||
// import 'package:vbvs_app/common/util/CommonVariables.dart';
|
|
||||||
// import 'package:vbvs_app/controller/setting/language/language_controller.dart';
|
|
||||||
// import 'package:weather/weather.dart';
|
|
||||||
|
|
||||||
// part 'weather_controller.g.dart';
|
|
||||||
|
|
||||||
// @JsonSerializable()
|
|
||||||
// class WeatherModel {
|
|
||||||
// double? longitude; // 经度
|
|
||||||
// double? latitude; // 纬度
|
|
||||||
// String? weather_info = ''; // 天气
|
|
||||||
// int? current_temperature; // 温度
|
|
||||||
// int? min_temperature; // 最低温度
|
|
||||||
// int? max_temperature; // 最高温度
|
|
||||||
// String? wind_direction; // 风向
|
|
||||||
// int? wind_speed; // 风速等级
|
|
||||||
// String? cityName; // 城市名
|
|
||||||
// String? weatherIcon; // 天气图标
|
|
||||||
// String? weatherIconurl; // 天气图标url
|
|
||||||
|
|
||||||
// WeatherModel();
|
|
||||||
|
|
||||||
// static WeatherModel fromJson(Map<String, dynamic> json) =>
|
|
||||||
// _$WeatherModelFromJson(json);
|
|
||||||
|
|
||||||
// Map<String, dynamic> toJson() => _$WeatherModelToJson(this);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// class WeatherModelController extends GetControllerEx<WeatherModel> {
|
|
||||||
// LanguageController languageController = Get.find();
|
|
||||||
// WeatherModelController() {
|
|
||||||
// attr = GetModel(WeatherModel()).obs;
|
|
||||||
// weatherFactory = WeatherFactory(CommonVariables.weather_apiKey,
|
|
||||||
// language: Language.CHINESE_SIMPLIFIED);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Timer? _weatherTimer;
|
|
||||||
// Timer? _locationTimer;
|
|
||||||
|
|
||||||
// late WeatherFactory weatherFactory;
|
|
||||||
// late AMapFlutterLocation location; // 声明 AMapFlutterLocation 实例
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// Future<void> onInit() async {
|
|
||||||
// super.onInit();
|
|
||||||
|
|
||||||
// location = AMapFlutterLocation(); // 初始化 AMapFlutterLocation
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// await _getCurrentLocation();
|
|
||||||
// _weatherTimer = Timer.periodic(Duration(seconds: 5), (timer) {
|
|
||||||
// _getCurrentWeather(); // 每 5 秒更新一次天气
|
|
||||||
// });
|
|
||||||
|
|
||||||
// _locationTimer = Timer.periodic(Duration(minutes: 10), (timer) {
|
|
||||||
// _getCurrentLocation(); // 每 10 分钟更新一次位置
|
|
||||||
// });
|
|
||||||
// } catch (e) {
|
|
||||||
// ef.log("[天气和定位请求失败]");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// void onClose() {
|
|
||||||
// _weatherTimer?.cancel(); // 取消天气更新定时器
|
|
||||||
// _locationTimer?.cancel(); // 取消位置更新定时器
|
|
||||||
// location.stopLocation(); // 停止高德定位
|
|
||||||
// super.onClose();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 获取当前位置并存储到 model
|
|
||||||
// Future<void> _getCurrentLocation() async {
|
|
||||||
// try {
|
|
||||||
// // 开始定位
|
|
||||||
// location.startLocation();
|
|
||||||
|
|
||||||
// // 监听定位回调
|
|
||||||
|
|
||||||
// location.onLocationChanged().listen((Map<String, Object> result) {
|
|
||||||
// ///result即为定位结果
|
|
||||||
// ef.log("[位置]:${result}");
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // location.onLocationChanged.listen((locationData) {
|
|
||||||
// // if (locationData.latitude != null && locationData.longitude != null) {
|
|
||||||
// // model.latitude = locationData.latitude;
|
|
||||||
// // model.longitude = locationData.longitude;
|
|
||||||
|
|
||||||
// // // 获取位置对应的城市名
|
|
||||||
// // _getCityName(locationData.latitude!, locationData.longitude!);
|
|
||||||
// // }
|
|
||||||
// // });
|
|
||||||
// } catch (e) {
|
|
||||||
// print(e);
|
|
||||||
// EasyDartModule.logger.error("获取位置失败: $e");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 获取城市名
|
|
||||||
// Future<void> _getCityName(double latitude, double longitude) async {
|
|
||||||
// try {
|
|
||||||
// List<Placemark> placemarks =
|
|
||||||
// await placemarkFromCoordinates(latitude, longitude);
|
|
||||||
|
|
||||||
// if (placemarks.isNotEmpty) {
|
|
||||||
// model.cityName = placemarks[0].locality ?? "未知数据".tr;
|
|
||||||
// }
|
|
||||||
// // 获取天气
|
|
||||||
// _getCurrentWeather();
|
|
||||||
// } catch (e) {
|
|
||||||
// print(e);
|
|
||||||
// EasyDartModule.logger.error("获取城市名失败: $e");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 获取天气信息
|
|
||||||
// Future<void> _getCurrentWeather() async {
|
|
||||||
// if (model.latitude == null || model.longitude == null) {
|
|
||||||
// EasyDartModule.logger.error("获取天气失败:位置数据获取失败");
|
|
||||||
// return; // 如果位置数据没有获取到,则不更新天气
|
|
||||||
// }
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// weatherFactory.language = Language.CHINESE_SIMPLIFIED;
|
|
||||||
// Weather weather = await weatherFactory.currentWeatherByLocation(
|
|
||||||
// model.latitude!, model.longitude!);
|
|
||||||
|
|
||||||
// model.weather_info = weather.weatherDescription;
|
|
||||||
// model.min_temperature = weather.tempMin?.celsius?.toInt();
|
|
||||||
// model.max_temperature = weather.tempMax?.celsius?.toInt();
|
|
||||||
// model.current_temperature = weather.temperature?.celsius?.toInt();
|
|
||||||
// model.wind_speed = weather.windSpeed?.toInt();
|
|
||||||
// model.weatherIcon = weather.weatherIcon;
|
|
||||||
// if (model.weatherIcon != null) {
|
|
||||||
// model.weatherIconurl =
|
|
||||||
// "https://openweathermap.org/img/w/${model.weatherIcon}.png";
|
|
||||||
// }
|
|
||||||
// updateAll(); // 更新 UI
|
|
||||||
// } catch (e) {
|
|
||||||
// EasyDartModule.logger.error("获取天气失败: $e");
|
|
||||||
// print('获取天气失败: $e');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 获取 5 天天气预报
|
|
||||||
// Future<List<Weather>> getWeatherForecast(
|
|
||||||
// double latitude, double longitude) async {
|
|
||||||
// try {
|
|
||||||
// return await weatherFactory.fiveDayForecastByLocation(
|
|
||||||
// latitude, longitude);
|
|
||||||
// } catch (e) {
|
|
||||||
// print('获取天气预报失败: $e');
|
|
||||||
// rethrow;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -137,9 +137,13 @@ class _LanguagePageState extends State<LanguagePage> {
|
|||||||
.value = language;
|
.value = language;
|
||||||
final list = deviceController
|
final list = deviceController
|
||||||
.personnelList.value;
|
.personnelList.value;
|
||||||
deviceController.getHomeSleeps(
|
if (list != null &&
|
||||||
list[0]["mac"], context);
|
list.isNotEmpty) {
|
||||||
|
deviceController
|
||||||
|
.getHomeSleeps(
|
||||||
|
list[0]["mac"],
|
||||||
|
context);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// ef.kv.set("language",
|
// ef.kv.set("language",
|
||||||
// language.language_code);
|
// language.language_code);
|
||||||
@@ -203,10 +207,13 @@ class _LanguagePageState extends State<LanguagePage> {
|
|||||||
deviceController
|
deviceController
|
||||||
.personnelList
|
.personnelList
|
||||||
.value;
|
.value;
|
||||||
|
if (list != null &&
|
||||||
|
list.isNotEmpty) {
|
||||||
deviceController
|
deviceController
|
||||||
.getHomeSleeps(
|
.getHomeSleeps(
|
||||||
list[0]["mac"],
|
list[0]["mac"],
|
||||||
context);
|
context);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// ef.kv.set("language",
|
// ef.kv.set("language",
|
||||||
|
|||||||
@@ -494,16 +494,74 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取智能床/床垫mac
|
//获取智能床/床垫mac
|
||||||
|
// Future<String> getBindTHMAC(
|
||||||
|
// BuildContext context, BlueToothDataModel device, Map deviceType) async {
|
||||||
|
// const int maxRetries = 2;
|
||||||
|
// const Duration timeout = Duration(seconds: 5);
|
||||||
|
// String? macAddress;
|
||||||
|
// try {
|
||||||
|
// // 连接设备
|
||||||
|
// THapp bledevice = THapp(device: device.scanResult.device);
|
||||||
|
// await bledevice.connect();
|
||||||
|
// var res2 = bledevice.isConnected;
|
||||||
|
// if (!res2) {
|
||||||
|
// edm.EasyDartModule.logger.error("蓝牙连接失败".tr);
|
||||||
|
// DailyLogUtils.printLog("蓝牙连接失败".tr);
|
||||||
|
// TopSlideNotification.show(
|
||||||
|
// context,
|
||||||
|
// text: "蓝牙连接失败".tr,
|
||||||
|
// textColor: themeController.currentColor.sc9,
|
||||||
|
// );
|
||||||
|
// throw Exception("蓝牙连接失败".tr);
|
||||||
|
// }
|
||||||
|
// blueteethBindController.blueConnectFlag.value = 2;
|
||||||
|
// blueteethBindController.currentDevice = bledevice;
|
||||||
|
// await Future.delayed(Duration(seconds: 2));
|
||||||
|
|
||||||
|
// if (deviceType['type'] == 3) {
|
||||||
|
// //智能床垫
|
||||||
|
// macAddress = await getMacFromType3(bledevice, timeout);
|
||||||
|
// } else if (deviceType['type'] == 2) {
|
||||||
|
// //智能床
|
||||||
|
// macAddress = await getMacFromType2(bledevice, timeout);
|
||||||
|
// } else {
|
||||||
|
// throw Exception("不支持的设备类型".tr);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (macAddress == null) {
|
||||||
|
// throw Exception("未能获取到MAC地址".tr);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // device.macA = macAddress;
|
||||||
|
// print('MAC地址: $macAddress');
|
||||||
|
// return macAddress;
|
||||||
|
// } catch (e) {
|
||||||
|
// blueteethBindController.currentDeviceMac.value = "";
|
||||||
|
// edm.EasyDartModule.logger.error("蓝牙获取MAC失败:$e");
|
||||||
|
// DailyLogUtils.printLog("蓝牙获取MAC失败:$e");
|
||||||
|
// TopSlideNotification.show(
|
||||||
|
// context,
|
||||||
|
// // text: e.message ?? "设备连接失败,请重试".tr,
|
||||||
|
// text: "获取不到传感器mac,请重试".tr,
|
||||||
|
// textColor: themeController.currentColor.sc9,
|
||||||
|
// );
|
||||||
|
// rethrow;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
Future<String> getBindTHMAC(
|
Future<String> getBindTHMAC(
|
||||||
BuildContext context, BlueToothDataModel device, Map deviceType) async {
|
BuildContext context, BlueToothDataModel device, Map deviceType) async {
|
||||||
const int maxRetries = 2;
|
const int maxRetries = 2; // 重试2次
|
||||||
const Duration timeout = Duration(seconds: 5);
|
const Duration timeout = Duration(seconds: 5);
|
||||||
String? macAddress;
|
String? macAddress;
|
||||||
|
|
||||||
|
for (int attempt = 1; attempt <= maxRetries; attempt++) {
|
||||||
try {
|
try {
|
||||||
// 连接设备
|
// 连接设备
|
||||||
THapp bledevice = THapp(device: device.scanResult.device);
|
THapp bledevice = THapp(device: device.scanResult.device);
|
||||||
await bledevice.connect();
|
await bledevice.connect();
|
||||||
var res2 = bledevice.isConnected;
|
var res2 = bledevice.isConnected;
|
||||||
|
|
||||||
if (!res2) {
|
if (!res2) {
|
||||||
edm.EasyDartModule.logger.error("蓝牙连接失败".tr);
|
edm.EasyDartModule.logger.error("蓝牙连接失败".tr);
|
||||||
DailyLogUtils.printLog("蓝牙连接失败".tr);
|
DailyLogUtils.printLog("蓝牙连接失败".tr);
|
||||||
@@ -514,39 +572,52 @@ class _DeviceComponentWidgetState extends State<DeviceComponentWidget> {
|
|||||||
);
|
);
|
||||||
throw Exception("蓝牙连接失败".tr);
|
throw Exception("蓝牙连接失败".tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
blueteethBindController.blueConnectFlag.value = 2;
|
blueteethBindController.blueConnectFlag.value = 2;
|
||||||
blueteethBindController.currentDevice = bledevice;
|
blueteethBindController.currentDevice = bledevice;
|
||||||
await Future.delayed(Duration(seconds: 2));
|
await Future.delayed(Duration(seconds: 2));
|
||||||
|
|
||||||
|
// 根据设备类型获取 MAC
|
||||||
if (deviceType['type'] == 3) {
|
if (deviceType['type'] == 3) {
|
||||||
//智能床垫
|
|
||||||
macAddress = await getMacFromType3(bledevice, timeout);
|
macAddress = await getMacFromType3(bledevice, timeout);
|
||||||
} else if (deviceType['type'] == 2) {
|
} else if (deviceType['type'] == 2) {
|
||||||
//智能床
|
|
||||||
macAddress = await getMacFromType2(bledevice, timeout);
|
macAddress = await getMacFromType2(bledevice, timeout);
|
||||||
} else {
|
} else {
|
||||||
throw Exception("不支持的设备类型".tr);
|
throw Exception("不支持的设备类型".tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (macAddress == null) {
|
if (macAddress != null) {
|
||||||
throw Exception("未能获取到MAC地址".tr);
|
print('MAC地址: $macAddress');
|
||||||
|
return macAddress; // 成功获取直接返回
|
||||||
}
|
}
|
||||||
|
|
||||||
// device.macA = macAddress;
|
// 当前尝试失败,准备重试
|
||||||
print('MAC地址: $macAddress');
|
DailyLogUtils.printLog("第$attempt次尝试未获取到MAC地址");
|
||||||
return macAddress;
|
|
||||||
|
if (attempt < maxRetries) {
|
||||||
|
await Future.delayed(Duration(seconds: 1)); // 等待后重试
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
DailyLogUtils.printLog("第$attempt次蓝牙获取MAC失败: $e");
|
||||||
|
edm.EasyDartModule.logger.error("第$attempt次蓝牙获取MAC失败: $e");
|
||||||
|
|
||||||
|
// 最后一次尝试失败后才提示
|
||||||
|
if (attempt == maxRetries) {
|
||||||
blueteethBindController.currentDeviceMac.value = "";
|
blueteethBindController.currentDeviceMac.value = "";
|
||||||
edm.EasyDartModule.logger.error("蓝牙获取MAC失败:$e");
|
|
||||||
DailyLogUtils.printLog("蓝牙获取MAC失败:$e");
|
|
||||||
TopSlideNotification.show(
|
TopSlideNotification.show(
|
||||||
context,
|
context,
|
||||||
// text: e.message ?? "设备连接失败,请重试".tr,
|
|
||||||
text: "获取不到传感器mac,请重试".tr,
|
text: "获取不到传感器mac,请重试".tr,
|
||||||
textColor: themeController.currentColor.sc9,
|
textColor: themeController.currentColor.sc9,
|
||||||
);
|
);
|
||||||
rethrow;
|
rethrow; // 抛出最后的异常
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 否则继续尝试
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 正常不会到这里
|
||||||
|
throw Exception("未知错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
fillTHMac(
|
fillTHMac(
|
||||||
|
|||||||
@@ -558,7 +558,7 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'ICP备案号:浙ICP备2023000785号-1'.tr,
|
'ICP备案号:皖ICP备2024068219号-1A'.tr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: themeController.currentColor.sc4,
|
color: themeController.currentColor.sc4,
|
||||||
fontFamily: 'Inter',
|
fontFamily: 'Inter',
|
||||||
@@ -571,7 +571,7 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
AppConstants().ent_type == 1
|
AppConstants().ent_type == 1
|
||||||
? 'Copyright © 202-2025 嘉兴太和信息技术有限责任公司 版权所有'
|
? 'Copyright © 202-2025 嘉兴太和信息技术有限责任公司 版权所有'
|
||||||
.tr
|
.tr
|
||||||
: "Copyright © 202-2025 杭州欢睡科技有限公司 版权所有".tr,
|
: "Copyright © 202-2025 合肥眠花糖家具有限责任公司 版权所有".tr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: themeController.currentColor.sc4,
|
color: themeController.currentColor.sc4,
|
||||||
fontFamily: 'Inter',
|
fontFamily: 'Inter',
|
||||||
|
|||||||
@@ -538,7 +538,7 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
|
|||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
child: Obx(() {
|
child: Obx(() {
|
||||||
return (controller.ready.value)
|
return (controller.ready.value)
|
||||||
?controller.web.build()
|
? controller.web.build()
|
||||||
: Center(child: CircularProgressIndicator());
|
: Center(child: CircularProgressIndicator());
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
|||||||
}
|
}
|
||||||
sleepReportController = Get.find(tag: widget.data["tag"]);
|
sleepReportController = Get.find(tag: widget.data["tag"]);
|
||||||
sleepReportController.sleepReport.value = {};
|
sleepReportController.sleepReport.value = {};
|
||||||
|
|
||||||
if (widget.data['date'] == null) {
|
if (widget.data['date'] == null) {
|
||||||
widget.data['date'] = DateTime.now();
|
widget.data['date'] = DateTime.now();
|
||||||
}
|
}
|
||||||
@@ -129,6 +130,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
|||||||
}
|
}
|
||||||
String date = MyUtils.formatToDate(widget.data['date']);
|
String date = MyUtils.formatToDate(widget.data['date']);
|
||||||
// String date = '2025-5-27';
|
// String date = '2025-5-27';
|
||||||
|
sleepReportController.isLoading.value = true;
|
||||||
requestWithLog(
|
requestWithLog(
|
||||||
logTitle: "查询睡眠报告",
|
logTitle: "查询睡眠报告",
|
||||||
method: MyHttpMethod.get,
|
method: MyHttpMethod.get,
|
||||||
@@ -136,6 +138,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
|||||||
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${date}&type=${sleepReportController.model.type}",
|
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${date}&type=${sleepReportController.model.type}",
|
||||||
onSuccess: (res) {
|
onSuccess: (res) {
|
||||||
print(res);
|
print(res);
|
||||||
|
sleepReportController.isLoading.value = false;
|
||||||
sleepReportController.sleepReport.value = res.data;
|
sleepReportController.sleepReport.value = res.data;
|
||||||
sleepReportController.updateAll();
|
sleepReportController.updateAll();
|
||||||
_scrollToTargetComponent(sleepReportController.sleepReport);
|
_scrollToTargetComponent(sleepReportController.sleepReport);
|
||||||
@@ -148,6 +151,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
|||||||
}
|
}
|
||||||
} else {}
|
} else {}
|
||||||
sleepReportController.sleepReport.value = {};
|
sleepReportController.sleepReport.value = {};
|
||||||
|
sleepReportController.isLoading.value = false;
|
||||||
sleepReportController.updateAll();
|
sleepReportController.updateAll();
|
||||||
print(res);
|
print(res);
|
||||||
});
|
});
|
||||||
@@ -624,23 +628,34 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
(sleepReport == null || sleepReport.isEmpty)
|
Obx(() {
|
||||||
? Container(
|
if (sleepReportController.isLoading.value) {
|
||||||
child: Expanded(child: NullDataWidget()),
|
return Center(child: CircularProgressIndicator());
|
||||||
)
|
}
|
||||||
: (sleepReportController.model.type == 1
|
if (sleepReport == null || sleepReport.isEmpty) {
|
||||||
? DailyDataWidget(
|
// 空数据
|
||||||
|
return Expanded(child: NullDataWidget());
|
||||||
|
} else {
|
||||||
|
// 有数据,根据类型返回不同 widget
|
||||||
|
switch (sleepReportController.model.type) {
|
||||||
|
case 1:
|
||||||
|
return DailyDataWidget(
|
||||||
sleepReport,
|
sleepReport,
|
||||||
sleepCardKey,
|
sleepCardKey,
|
||||||
heartRateCardKey,
|
heartRateCardKey,
|
||||||
breatheCardKey,
|
breatheCardKey,
|
||||||
widget.data)
|
widget.data,
|
||||||
: sleepReportController.model.type == 2
|
);
|
||||||
? WeekDataWidget(sleepReport, widget.data)
|
case 2:
|
||||||
: sleepReportController.model.type == 3
|
return WeekDataWidget(sleepReport, widget.data);
|
||||||
? MonthDataWidget(
|
case 3:
|
||||||
sleepReport, widget.data)
|
return MonthDataWidget(
|
||||||
: NullDataWidget()),
|
sleepReport, widget.data);
|
||||||
|
default:
|
||||||
|
return Expanded(child: NullDataWidget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
].divide(SizedBox(
|
].divide(SizedBox(
|
||||||
height: 25.rpx,
|
height: 25.rpx,
|
||||||
)),
|
)),
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'ICP备案号:浙ICP备2023000785号-1'.tr,
|
'ICP备案号:皖ICP备2024068219号-1A'.tr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: themeController.currentColor.sc4,
|
color: themeController.currentColor.sc4,
|
||||||
fontFamily: 'Inter',
|
fontFamily: 'Inter',
|
||||||
@@ -578,9 +578,9 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
AppConstants().ent_type == 1
|
AppConstants().ent_type == 1
|
||||||
? 'Copyright © 202-2025 嘉兴太和信息技术有限责任公司 版权所有'
|
? 'Copyright © 2022-2025 嘉兴太和信息技术有限责任公司 版权所有'
|
||||||
.tr
|
.tr
|
||||||
: "Copyright © 202-2025 杭州欢睡科技有限公司 版权所有",
|
: "Copyright © 2019-2029 合肥眠花糖家具有限责任公司 版权所有",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: themeController.currentColor.sc4,
|
color: themeController.currentColor.sc4,
|
||||||
fontFamily: 'Inter',
|
fontFamily: 'Inter',
|
||||||
|
|||||||
Reference in New Issue
Block a user