更新
This commit is contained in:
@@ -39,6 +39,7 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
|
|||||||
|
|
||||||
RxInt bindDeviceNum = 0.obs; //设备数量
|
RxInt bindDeviceNum = 0.obs; //设备数量
|
||||||
RxMap deviceList = {}.obs; //设备列表
|
RxMap deviceList = {}.obs; //设备列表
|
||||||
|
RxList deviceListForWeb = [].obs; //h5设备列表
|
||||||
RxMap<String, List<dynamic>> sleepReportData =
|
RxMap<String, List<dynamic>> sleepReportData =
|
||||||
<String, List<dynamic>>{}.obs; //睡眠报告
|
<String, List<dynamic>>{}.obs; //睡眠报告
|
||||||
RxList personnelList = [].obs; //人员信息列表
|
RxList personnelList = [].obs; //人员信息列表
|
||||||
@@ -49,12 +50,13 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
|
|||||||
var sleepDays = [].obs;
|
var sleepDays = [].obs;
|
||||||
var homeSleepDays = [].obs;
|
var homeSleepDays = [].obs;
|
||||||
|
|
||||||
|
|
||||||
var selectedDayIndex = (6).obs;
|
var selectedDayIndex = (6).obs;
|
||||||
|
|
||||||
var selectDevcie = ''.obs;
|
var selectDevcie = ''.obs;
|
||||||
var selectPerson = {}.obs;
|
var selectPerson = {}.obs;
|
||||||
|
|
||||||
|
bool initDeviceFlag = false;
|
||||||
|
|
||||||
Future<ApiResponse> getDeviceNum() async {
|
Future<ApiResponse> getDeviceNum() async {
|
||||||
try {
|
try {
|
||||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr);
|
ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr);
|
||||||
@@ -159,6 +161,68 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
|
|||||||
return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement
|
return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<ApiResponse> getDeviceListForWeb(
|
||||||
|
{String? key, String? group, int? bindType}) async {
|
||||||
|
try {
|
||||||
|
ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr);
|
||||||
|
String serviceAddress = ServiceConstant.service_address;
|
||||||
|
String serviceName = ServiceConstant.server_service;
|
||||||
|
String serviceApi = ServiceConstant.device_list;
|
||||||
|
|
||||||
|
// 初始URL
|
||||||
|
String queryUrl = "$serviceAddress$serviceName$serviceApi";
|
||||||
|
|
||||||
|
// 用Map统一管理query参数
|
||||||
|
Map<String, String> queryParams = {};
|
||||||
|
|
||||||
|
if (key != null && key.isNotEmpty) {
|
||||||
|
queryParams['key'] = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (group != null && group.isNotEmpty) {
|
||||||
|
queryParams['group'] = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bindType != null) {
|
||||||
|
queryParams['bindType'] = bindType.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
String? language = "";
|
||||||
|
if (languageController.selectLanguage != null) {
|
||||||
|
language = languageController.selectLanguage.value!.language_code;
|
||||||
|
}
|
||||||
|
if (language != null && language.isNotEmpty) {
|
||||||
|
queryParams['lang'] = language;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拼接完整URL
|
||||||
|
if (queryParams.isNotEmpty) {
|
||||||
|
queryUrl += '?' + Uri(queryParameters: queryParams).query;
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = await EasyDartModule.dio.get(queryUrl);
|
||||||
|
if (response != null) {
|
||||||
|
var responseData =
|
||||||
|
response.data is String ? jsonDecode(response.data) : response.data;
|
||||||
|
ApiResponse res =
|
||||||
|
ApiResponse.fromJson(responseData, (object) => object);
|
||||||
|
MyUtils.formatResponse(res, "设备.设备列表请求成功".tr, "设备.设备列表请求失败".tr);
|
||||||
|
if (res.code == HttpStatusCodes.ok) {
|
||||||
|
deviceListForWeb.value = res.data!;
|
||||||
|
updateAll();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ApiResponse(code: -1, msg: "服务器.失败".tr);
|
||||||
|
}
|
||||||
|
return apiResponse;
|
||||||
|
} catch (e) {
|
||||||
|
EasyDartModule.logger.info("设备请求列表: $e");
|
||||||
|
DailyLogUtils.writeLog("设备请求列表: $e");
|
||||||
|
}
|
||||||
|
return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement
|
||||||
|
}
|
||||||
|
|
||||||
Future<ApiResponse> deleteDevice(Map<String, dynamic> device) async {
|
Future<ApiResponse> deleteDevice(Map<String, dynamic> device) async {
|
||||||
try {
|
try {
|
||||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "请求失败".tr);
|
ApiResponse apiResponse = ApiResponse(code: -1, msg: "请求失败".tr);
|
||||||
@@ -428,6 +492,7 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getHomeSleeps(String? mac) async {
|
Future<void> getHomeSleeps(String? mac) async {
|
||||||
String serviceAddress = ServiceConstant.service_address;
|
String serviceAddress = ServiceConstant.service_address;
|
||||||
String serviceName = ServiceConstant.server_service;
|
String serviceName = ServiceConstant.server_service;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:easydevice/easydevice.dart';
|
|||||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
import 'package:vbvs_app/controller/user_info_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';
|
||||||
|
import 'package:vbvs_app/pages/mh_page/room_picker.dart';
|
||||||
|
|
||||||
class WebviewTestModel {
|
class WebviewTestModel {
|
||||||
WebviewTestModel();
|
WebviewTestModel();
|
||||||
@@ -16,14 +17,14 @@ class WebviewTestModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||||
var selectDevice;
|
var selectDevice = {};
|
||||||
var bluetooth = false;
|
var bluetooth = 0;
|
||||||
WebviewTestController() : super(WebviewTestModel()) {
|
WebviewTestController() : super(WebviewTestModel()) {
|
||||||
web = WebviewHelper(
|
web = WebviewHelper(
|
||||||
jsbridge: buildsdk(
|
jsbridge: buildsdk(
|
||||||
father: this,
|
father: this,
|
||||||
// clientId: '494641114',
|
clientId: '494641114',
|
||||||
//dbgserverUrl: 'ws://192.168.1.2:9001',
|
// dbgserverUrl: 'ws://192.168.1.2:9001',
|
||||||
),
|
),
|
||||||
settings: buildsettings(),
|
settings: buildsettings(),
|
||||||
params: PlatformHeadlessInAppWebViewCreationParams(
|
params: PlatformHeadlessInAppWebViewCreationParams(
|
||||||
@@ -46,19 +47,29 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
|||||||
bridge.sdk.updateDeviceRoute((args) async {
|
bridge.sdk.updateDeviceRoute((args) async {
|
||||||
ef.log('updateDeviceRoute: $args');
|
ef.log('updateDeviceRoute: $args');
|
||||||
selectDevice['blueToothStatus'] = bluetooth;
|
selectDevice['blueToothStatus'] = bluetooth;
|
||||||
Get.toNamed("$args[0]", arguments: selectDevice);
|
Get.toNamed("${args[0]}", arguments: selectDevice);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
bridge.sdk.selectDevice((args) {
|
bridge.sdk.selectDevice((args) async {
|
||||||
ef.log('selectDevice: $args');
|
ef.log('selectDevice: $args');
|
||||||
selectDevice = args[0];
|
selectDevice = args[0];
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
bridge.sdk.updateBlueToothStatus((args) {
|
bridge.sdk.updateBlueToothStatus((args) async {
|
||||||
ef.log('updateBlueToothStatus: $args');
|
ef.log('updateBlueToothStatus: $args');
|
||||||
bluetooth = args[0];
|
bluetooth = args[0];
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
//sdk定义接口
|
||||||
|
bridge.sdk.querySelectDevice((args) async {
|
||||||
|
ef.log('updateBlueToothStatus: $args');
|
||||||
|
// bluetooth = args[0];
|
||||||
|
MHTHomeController deviceController = Get.find();
|
||||||
|
final allDevices = deviceController.deviceList.values
|
||||||
|
.expand((list) => list)
|
||||||
|
.toList();
|
||||||
|
return allDevices;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
web
|
web
|
||||||
//.file(
|
//.file(
|
||||||
@@ -90,7 +101,7 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
UserInfoController userInfoController = Get.find();
|
UserInfoController userInfoController = Get.find();
|
||||||
MHTHomeController deviceController = Get.find();
|
MHTHomeController deviceController = Get.find();
|
||||||
deviceController.getDeviceList(group: 'room').then((x) {
|
deviceController.getDeviceList().then((x) {
|
||||||
if (controller.web.jsbridge!.inited) {
|
if (controller.web.jsbridge!.inited) {
|
||||||
//发送测试消息给webview
|
//发送测试消息给webview
|
||||||
controller.web.jsbridge!.dart
|
controller.web.jsbridge!.dart
|
||||||
|
|||||||
Reference in New Issue
Block a user