This commit is contained in:
wyf
2025-06-22 12:04:57 +08:00
parent 6f076f6d74
commit 8c27f0b26c
2 changed files with 36 additions and 9 deletions

View File

@@ -69,6 +69,7 @@ import 'package:vbvs_app/pages/mh_page/MattressControl.dart';
import 'package:vbvs_app/pages/mh_page/device/component/mht_device_calibration_controller.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/test/WebviewTestModel.dart';
import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart';
import 'package:vbvs_app/pages/mh_page/user/controller/mht_register_controller.dart';
import 'package:vbvs_app/pages/mh_page/user/controller/update_password_controller.dart';
@@ -96,7 +97,6 @@ Future<void> main() async {
await initLocalStorage();
initEasyDartModule();
await initLogin();
await initLog();
await messageStatus();
startMessagePolling();
@@ -194,7 +194,7 @@ void initEasyDartModule() {
//初始化
}
initLog() {}
Future<void> initLogin() async {
// 初始化控制器

View File

@@ -16,6 +16,8 @@ class WebviewTestModel {
}
class WebviewTestController extends GetControllerEx<WebviewTestModel> {
var selectDevice;
var bluetooth = false;
WebviewTestController() : super(WebviewTestModel()) {
web = WebviewHelper(
jsbridge: buildsdk(
@@ -29,13 +31,34 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
url: WebUri(
'https://wyf.it.real.he-info.cn:94/goods-front/index.html'),
),
onLoadStop: (controller, url) => {setState(() => ready.value = true)},
onLoadStop: (controller, url) {
setState(() => ready.value = true);
MHTHomeController deviceController = Get.find();
web.jsbridge!.dart
.updateDeviceList(deviceController.deviceList.values);
},
),
);
try {
web.jsbridge!.bind((bridge) {
var minible = Minibleapp(bridge: bridge);
// minible.bridge.sdk.ble.scanenable(5);
// ef.kvroot.devicelist.listen((x) {});
bridge.sdk.updateDeviceRoute((args) async {
ef.log('updateDeviceRoute: $args');
selectDevice['blueToothStatus'] = bluetooth;
Get.toNamed("$args[0]", arguments: selectDevice);
return true;
});
bridge.sdk.selectDevice((args) {
ef.log('selectDevice: $args');
selectDevice = args[0];
return true;
});
bridge.sdk.updateBlueToothStatus((args) {
ef.log('updateBlueToothStatus: $args');
bluetooth = args[0];
return true;
});
});
web
//.file(
@@ -45,7 +68,6 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
.network()
.then((value) {
if (value) {
//资源准备完成..
setState(() {
ready.value = true;
});
@@ -68,7 +90,14 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
Widget build(BuildContext context) {
UserInfoController userInfoController = Get.find();
MHTHomeController deviceController = Get.find();
deviceController.getDeviceList(group: 'room');
deviceController.getDeviceList(group: 'room').then((x) {
if (controller.web.jsbridge!.inited) {
//发送测试消息给webview
controller.web.jsbridge!.dart
.updateDeviceList(deviceController.deviceList.values);
}
});
return Scaffold(
backgroundColor: Colors.black12,
body: Column(
@@ -90,9 +119,7 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
),
);
}
WebviewTestController webviewTestController = Get.find();
var dataList = deviceController.deviceList.value;
webviewTestController.web.jsbridge!.dart.updateDeviceList(dataList);
return Expanded(
child: Align(
alignment: Alignment.topLeft,