更新睡眠报告正式地址

This commit is contained in:
wyf
2025-08-30 09:15:18 +08:00
parent ae6933bd96
commit f7b11fbb7e
14 changed files with 278 additions and 168 deletions

View File

@@ -42,6 +42,7 @@ class _MHTWifiAfterPageState extends State<MHTWifiAfterPage> {
Timer? _timeoutTimer;
StreamSubscription<List<ScanResult>>? _scanSubscription;
bool _isDisposed = false;
ScanResult? targetDevice;
@override
void initState() {
@@ -916,7 +917,7 @@ class _MHTWifiAfterPageState extends State<MHTWifiAfterPage> {
_scanSubscription = FlutterBluePlus.scanResults.listen((results) async {
if (_isDisposed) return;
ScanResult? targetDevice;
for (var r in results) {
if (r.advertisementData.manufacturerData.containsKey(0xFFED)) {
@@ -937,7 +938,7 @@ class _MHTWifiAfterPageState extends State<MHTWifiAfterPage> {
_scanSubscription?.cancel();
try {
THapp bledevice = THapp(device: targetDevice.device);
THapp bledevice = THapp(device: targetDevice!.device);
await bledevice.device.connect();
var res2 = bledevice.isConnected;
@@ -1085,7 +1086,8 @@ class _MHTWifiAfterPageState extends State<MHTWifiAfterPage> {
Future<void> _disconnectDevice() async {
try {
THapp bledevice = THapp(device: widget.deviceInfo.scanResult.device);
// THapp bledevice = THapp(device: widget.deviceInfo.scanResult.device);
THapp bledevice = THapp(device: targetDevice!.device);
await bledevice.disconnect();
DailyLogUtils.writeLog("关闭蓝牙连接成功".tr);
} catch (e) {

View File

@@ -434,6 +434,7 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
queryParams.add("mac=$mac");
}
queryParams.add("time=$timestamp");
queryParams.add("sleepType=1");
if (queryParams.isNotEmpty) {
queryUrl += "?${queryParams.join("&")}";
@@ -502,6 +503,7 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
queryParams.add("mac=$mac");
}
queryParams.add("time=$timestamp");
queryParams.add("sleepType=1");
if (queryParams.isNotEmpty) {
queryUrl += "?${queryParams.join("&")}";

View File

@@ -4,6 +4,7 @@ import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/color/ServiceConstant.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/color/app_uri_status.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
@@ -501,12 +502,14 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
padding: EdgeInsets.fromLTRB(
0, 30.rpx, 0, 0),
child: Center(
child:CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
themeController.currentColor.sc1,
),
),),
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor:
AlwaysStoppedAnimation<Color>(
themeController.currentColor.sc1,
),
),
),
)
: hasValidData
? Column(
@@ -682,11 +685,17 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
void loadSleepReport(String data) {
isLoading.value = true;
String serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.sleep_report;
String queryUrl =
"$serviceAddress$serviceName$serviceApi?mac=${homeController.selectDevcie.value}&time=${data}&type=1&sleepType=2";
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${homeController.selectDevcie.value}&time=${data}&type=1",
// queryUrl:
// "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${homeController.selectDevcie.value}&time=${data}&type=1",
queryUrl: queryUrl,
onSuccess: (res) {
isLoading.value = false;
print(res);

View File

@@ -285,10 +285,11 @@ class _NewHomePageState extends State<NewHomePage> {
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
shape: BoxShape.circle),
child: Image.network(
weatherModelController
.model.weatherIconurl!,
fit: BoxFit.cover,
child: SvgPicture.asset(
"assets/images/weather/${weatherModelController.model.weatherIconurl}-fill.svg",
// fit: BoxFit.cover,
color: themeController
.currentColor.sc4,
),
),
].divide(SizedBox(

View File

@@ -44,10 +44,11 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
web = WebviewHelper(
isheadless: false,
jsbridge: buildsdk(
// father: this,
// clientId: '494641114',
// dbgserverUrl: 'ws://192.168.1.2:9001',
),
// father: this,
// clientId: '123',
// clientId: '494641114',
// dbgserverUrl: 'ws://192.168.1.2:9001',
),
settings: buildsettings(),
params: PlatformHeadlessInAppWebViewCreationParams(
onLoadStop: (controller, url) {
@@ -56,9 +57,9 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
});
},
onLoadResource: (controller, resource) {
sourceTime = web.requestTimestamp;
ef.log("[请求资源时间]${web.requestTimestamp}");
_startMonitoringIfNeeded();
// sourceTime = web.requestTimestamp;
// ef.log("[请求资源时间]${web.requestTimestamp}");`
// _startMonitoringIfNeeded();
},
),
);
@@ -113,7 +114,6 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
});
}
final normalizedMac = mac.replaceAll(":", "").toUpperCase();
if (deviceId != null &&
@@ -291,7 +291,7 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
return true;
});
bridge.sdk.updatePermisson((args) async {
ef.log('获取权限: $args[0]');
// ef.log('获取权限: $args[0]');
try {
if (MainPageBBottomChange.getCurrentIndex() != 2) {
return false;
@@ -331,6 +331,17 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
// }
// return true;
// });
bridge.sdk.loadFinish((args) async {
ef.log('[资源加载完成]: $args[0]');
try {
loadRecource.value = true;
updateAll();
return true;
} catch (e) {
ef.log("[资源加载完成]:$e");
}
return true;
});
});
} catch (e, s) {
ef.log('$e,$s');
@@ -371,7 +382,7 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
ws = Easyws(
url: ServiceConstant.webSocketService,
onData: (data) {
ef.log("ws recv =>$data");
// ef.log("ws recv =>$data");
try {
var tmp;
if (data is String) {
@@ -412,7 +423,7 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
"data": {"mac".tr: mac},
});
if (success) {
ef.log("✅ 已取消监听:$mac");
// ef.log("✅ 已取消监听:$mac");
}
}
}
@@ -435,7 +446,7 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
"data": {"mac".tr: mac},
});
if (success) {
ef.log("✅ 开始监听新设备:$mac");
// ef.log("✅ 开始监听新设备:$mac");
}
}
}
@@ -470,25 +481,6 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
ef.log('$e,$s');
}
}
void _startMonitoringIfNeeded() {
// 如果定时器已启动,则无需重新启动
if (_resourceLoadTimer != null) return;
_resourceLoadTimer = Timer.periodic(Duration(seconds: 1), (timer) {
int now = DateTime.now().millisecondsSinceEpoch;
if (sourceTime == 0) return; // 还未加载任何资源
if (now - sourceTime > 3000) {
ef.log("[资源加载完成] 当前时间: $now, 上次请求时间: $sourceTime");
_resourceLoadTimer?.cancel();
_resourceLoadTimer = null;
loadRecource.value = true;
updateAll();
}
});
}
}
class WebviewTestView extends GetComponent<WebviewTestController> {
@@ -634,19 +626,67 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
child: Align(
alignment: Alignment.topLeft,
child: Obx(() {
int? aa = MainPageBBottomChange.getCurrentIndex();
print(aa);
// return (controller.ready.value && (MainPageBBottomChange.getCurrentIndex() == 2))
return (controller.ready.value)
? controller.web.build()
: Center(
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
themeController.currentColor.sc1,
// return (controller.ready.value && (MainPageBBottomChange.getCurrentIndex() == 2)&& controller.loadRecource.value == true)
// return Stack(children: [
// controller.ready.value
// ? controller.web.build()
// : Container(),
// Text("1222121212"),
// ]);
// return Stack(
// children: [
// controller.ready.value
// ? controller.web.build()
// : Container(),
// // 只有 loadRecource == false 时才显示覆盖文字
// if (!controller.loadRecource.value)
// Positioned.fill(
// child: Container(
// color: Colors.black54, // 半透明遮罩,可选
// alignment: Alignment.center,
// child: Text(
// "资源加载中...",
// style: TextStyle(
// color: Colors.red,
// fontSize: 30.rpx,
// fontWeight: FontWeight.bold,
// ),
// ),
// ),
// ),
// ],
// );
return Stack(
children: [
controller.ready.value
? controller.web.build()
: Container(),
if (!controller.loadRecource.value)
Positioned.fill(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/new_background.png'),
fit: BoxFit.fill,
),
),
alignment: Alignment.center,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
Colors.white),
),
],
),
),
);
),
],
);
}),
),
),