diff --git a/assets/img/icon/expand_more.svg b/assets/img/icon/expand_more.svg new file mode 100644 index 0000000..35d6d8f --- /dev/null +++ b/assets/img/icon/expand_more.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/lib/common/color/ServiceConstant.dart b/lib/common/color/ServiceConstant.dart index dd2002f..5504953 100644 --- a/lib/common/color/ServiceConstant.dart +++ b/lib/common/color/ServiceConstant.dart @@ -25,10 +25,8 @@ class ServiceConstant { static String calibration_process = "/api/caibration";//校准进度 static String submit_repair = "/api/device/repair";//提交报修 static String user_setting = "/api/user/config";//查询和更新用户自定义配置 - - - - + static String room_list = "/api/room/info"; //查询房间列表 + static String issue_list = "/api/help/list"; //问题与帮助列表 static String logService = "$service_address/vsbs_log"; static const String webSocketService = "wss://$baseHost/vsbs_ws_gateway/ws"; diff --git a/lib/common/util/CommonVariables.dart b/lib/common/util/CommonVariables.dart index cc0bc68..5cf6168 100644 --- a/lib/common/util/CommonVariables.dart +++ b/lib/common/util/CommonVariables.dart @@ -1,6 +1,6 @@ class CommonVariables { static bool isNetWorkOn = false; - + static String supabaseUrl = "https://zhmht.swes.com.cn:3443"; // 企业微信客服拉起的url地址 static String wxKfUrl = "https://work.weixin.qq.com/kfid/kfcab6a07e8aac68945"; // 企业微信ID diff --git a/lib/common/util/MyUtils.dart b/lib/common/util/MyUtils.dart index f5abeed..2dbd632 100644 --- a/lib/common/util/MyUtils.dart +++ b/lib/common/util/MyUtils.dart @@ -6,6 +6,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:intl/intl.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; +import 'package:vbvs_app/common/util/CommonVariables.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/controller/mh_controller/mh_language_controller.dart'; @@ -436,6 +437,16 @@ String time_08_Formatter_pattern(dynamic date, String pattern) { } } +String storagePubSrc = + "${CommonVariables.supabaseUrl}/storage/v1/object/public/"; + +getStorageResourceUrl(String v) { + if (v.contains('http')) { + return v; + } + return storagePubSrc + v; +} + enum LoadingDialogIcon { ble, wifi, none } class LoadingDialog { diff --git a/lib/controller/mh_controller/bedController.dart b/lib/controller/mh_controller/bedController.dart new file mode 100644 index 0000000..74e36af --- /dev/null +++ b/lib/controller/mh_controller/bedController.dart @@ -0,0 +1,218 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:ef/ef.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'bedController.g.dart'; // 由json_serializable自动生成的部分 + +@JsonSerializable() +class BedModel { + int patternType = 2; //1.助眠 2.手动 + + int noAutoPattern = -1; //1 TV 2 零重力 3 阅读 4 放平 + int zhuMianPattern = -1; //1 一键放松 2 休闲模式 3腰部放松 4 腿部放松 + // int anMoleftRight = 1; //1.左侧律动 2右侧律动 + bool anMoStart = false; //启动按摩 + bool isAnMoBei = false; //背部律动 + bool isAnMoTui = false; //腿部律动 + int anMoPattern = -1; //1234分别为模式1、2、3、4 + double slideValue_bei = 1.0; //背部力度调节 + double slideValue_tui = 1.0; //腿部力度调节 + // bool isStart = false; //开启 关闭 + int timerPattern = 2; //定时设置 10、20、30分钟 + + bool isZhuMian = false; //一键助眠开启 + int zhuMainInitTime = 0; + int zhuMainRunTime = 1800; //默认床垫30分钟,床为15分钟 + int zhuMainRunAllTime = 1800; //默认床垫30分钟,床为15分钟 + int useLastTime = DateTime.now().millisecondsSinceEpoch; //最新的使用时间 + + String? deviceMac; // 当前选中设备mac地址 + + List bodyData = [ + {"lastData": {}, "bodyData": []}, + {"lastData": {}, "bodyData": []} + ]; + + BedModel(); + + factory BedModel.fromJson(Map json) { + try { + return _$BedModelFromJson(json); + } catch (e) { + return BedModel(); + } + } + + Map toJson() => _$BedModelToJson(this); +} + +class BedController extends GetControllerEx { + // WebsocketProp? websocketProp; + + // ble.ConnectedDeviceProp? deviceProp; + + // GlobalController get glcontroller => Get.find(); + + Function? calibrationListenCall; + + List pinlvTimerList = [null, null]; + + BedController() { + attr = GetModel(BedModel()).obs; + } + + // @override + // void onInit() { + // super.onInit(); + // GlobalController globalController = Get.find(); + // Timer.periodic(Duration(milliseconds: 1000), (e) { + // if (model.isZhuMian) { + // var deviceInfo = globalController.model.deviceMain; //获取当前选中设备信息 + // if (deviceInfo != null && + // deviceInfo.isNotEmpty && + // model.deviceMac != deviceInfo["mac"]) { + // model.deviceMac = deviceInfo["mac"]; + // String deviceType = deviceInfo["deviceType"]["id"]; + // if (deviceType == "1") { + // //床 + // model.zhuMainRunTime = 900; + // model.zhuMainRunAllTime = 900; + // } else if (deviceType == "3") { + // //床垫 + // model.zhuMainRunTime = 1800; + // model.zhuMainRunAllTime = 1800; + // } + // } + + // int time = + // DateTime.now().millisecondsSinceEpoch - model.zhuMainInitTime; + // time = time ~/ 1000; + // if (time <= model.zhuMainRunAllTime) { + // model.zhuMainRunTime = model.zhuMainRunAllTime - time; + // } else { + // model.isZhuMian = false; + // model.zhuMainRunTime = 0; + // } + // } + // updateAll(); + // }); + // } + + // Future bleSendCode(d) async { + // Completer completer = Completer(); + // bleSendCodeNext(completer, d); + // return completer.future; + // } + + // Future bleSendCodeNext(Completer completer, d) async { + // if (deviceProp == null) { + // showToast("蓝牙设备尚未连接"); + // completer.completeError(Exception("蓝牙设备尚未连接")); + // return; + // } + // if (deviceProp!.isClose) { + // showToast("蓝牙已断开,请稍后再试"); + // completer.completeError(Exception("蓝牙已断开")); + // return; + // } + // model.useLastTime = DateTime.now().millisecondsSinceEpoch; + // deviceProp!.write(Uint8List.fromList(d), ([d]) { + // completer.complete("success"); + // }, (d) { + // completer.completeError(Exception("蓝牙发送失败")); + // }); + // } + + // websocketInit() { + // websocketProp = WebsocketProp(); + // websocketProp!.initState(CommonVariables.wsUrl, {"message": onMessage}); + // } + + // websocketSend(v) { + // var deviceMain = glcontroller.model.deviceMain; + // if (deviceMain == null || deviceMain["mac"] == null) { + // return; + // } + // print("websocketSend 发送 $v"); + // websocketProp?.sendMessage( + // {"type": "10002", "did": deviceMain["bindMacA"], "state": v}); + // if (deviceMain["bindMacB"] != null && deviceMain["bindMacB"] != "") { + // websocketProp?.sendMessage( + // {"type": "10002", "did": deviceMain["bindMacB"], "state": v}); + // } + // } + + // bodyDataHandle(index, data) { + // var bodyData = model.bodyData[index]["bodyData"]; + // if (bodyData.length > 0 && + // data["data"]["deviceSendTime"] != null && + // data["data"]["deviceSendTime"] == + // bodyData[bodyData.length - 1]["deviceSendTime"]) { + // return; + // } + // model.bodyData[index]["lastData"] = data["data"]; + // model.bodyData[index]["bodyData"].add(data["data"]); + // if (model.bodyData[index]["bodyData"].length > 120) { + // model.bodyData[index]["bodyData"].removeAt(0); + // } + // } + + // onMessage(d) { + // var data = jsonDecode(d); + // if (calibrationListenCall != null) { + // calibrationListenCall?.call(data); + // return; + // } + // // print("receive ${data["data"]["deviceNo"]}"); + // String mac = "${data?["data"]?["deviceNo"]}".toUpperCase() ?? ""; + // if (CommonVariables.test) { + // if (data["data"]["breathRate"] == 0) { + // data["data"]["breathRate"] = Random().nextInt(10) + 10; + // } + // if (data["data"]["heartRate"] == 0) { + // data["data"]["heartRate"] = Random().nextInt(10) + 60; + // } + // } + // if ("${glcontroller.model.deviceMain["bindMacA"]}".length > 6 && + // mac == "${glcontroller.model.deviceMain["bindMacA"]}".toUpperCase()) { + // bodyDataHandle(0, data); + // } else if ("${glcontroller.model.deviceMain["bindMacB"]}".length > 6 && + // mac == "${glcontroller.model.deviceMain["bindMacB"]}".toUpperCase()) { + // bodyDataHandle(1, data); + // } + // } + + // anmoReset() { + // pinlvTimerList = [null, null]; + // model.anMoStart = false; //启动按摩 + // model.isAnMoBei = false; + // model.isAnMoTui = false; + // model.anMoPattern = -1; //1234分别为模式1、2、3、4 + // model.slideValue_bei = 1.0; //背部力度调节 + // model.slideValue_tui = 1.0; //腿部力度调节 + // model.timerPattern = -1; //定时设置 10、20、30分钟 + // updateAll(); + // } + + // resetParm() { + // model.noAutoPattern = -1; //1 TV 2 零重力 3 阅读 4放平 + // model.zhuMianPattern = -1; //1 一键放松 2 休闲模式 3腰部放松 4 腿部放松 + // model.isZhuMian = false; + // model.useLastTime = DateTime.now().millisecondsSinceEpoch; + // model.bodyData = [ + // {"lastData": {}, "bodyData": []}, + // {"lastData": {}, "bodyData": []} + // ]; + // anmoReset(); + // } + + // anMoChange() { + // model.zhuMianPattern = -1; //1 一键放松 2 休闲模式 3腰部放松 4 腿部放松 + // model.isZhuMian = false; + // updateAll(); + // } +} diff --git a/lib/controller/mh_controller/bedController.g.dart b/lib/controller/mh_controller/bedController.g.dart new file mode 100644 index 0000000..a5e1578 --- /dev/null +++ b/lib/controller/mh_controller/bedController.g.dart @@ -0,0 +1,46 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'bedController.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +BedModel _$BedModelFromJson(Map json) => BedModel() + ..patternType = (json['patternType'] as num).toInt() + ..noAutoPattern = (json['noAutoPattern'] as num).toInt() + ..zhuMianPattern = (json['zhuMianPattern'] as num).toInt() + ..anMoStart = json['anMoStart'] as bool + ..isAnMoBei = json['isAnMoBei'] as bool + ..isAnMoTui = json['isAnMoTui'] as bool + ..anMoPattern = (json['anMoPattern'] as num).toInt() + ..slideValue_bei = (json['slideValue_bei'] as num).toDouble() + ..slideValue_tui = (json['slideValue_tui'] as num).toDouble() + ..timerPattern = (json['timerPattern'] as num).toInt() + ..isZhuMian = json['isZhuMian'] as bool + ..zhuMainInitTime = (json['zhuMainInitTime'] as num).toInt() + ..zhuMainRunTime = (json['zhuMainRunTime'] as num).toInt() + ..zhuMainRunAllTime = (json['zhuMainRunAllTime'] as num).toInt() + ..useLastTime = (json['useLastTime'] as num).toInt() + ..deviceMac = json['deviceMac'] as String? + ..bodyData = json['bodyData'] as List; + +Map _$BedModelToJson(BedModel instance) => { + 'patternType': instance.patternType, + 'noAutoPattern': instance.noAutoPattern, + 'zhuMianPattern': instance.zhuMianPattern, + 'anMoStart': instance.anMoStart, + 'isAnMoBei': instance.isAnMoBei, + 'isAnMoTui': instance.isAnMoTui, + 'anMoPattern': instance.anMoPattern, + 'slideValue_bei': instance.slideValue_bei, + 'slideValue_tui': instance.slideValue_tui, + 'timerPattern': instance.timerPattern, + 'isZhuMian': instance.isZhuMian, + 'zhuMainInitTime': instance.zhuMainInitTime, + 'zhuMainRunTime': instance.zhuMainRunTime, + 'zhuMainRunAllTime': instance.zhuMainRunAllTime, + 'useLastTime': instance.useLastTime, + 'deviceMac': instance.deviceMac, + 'bodyData': instance.bodyData, + }; diff --git a/lib/controller/mh_controller/device_list_controller.g.dart b/lib/controller/mh_controller/device_list_controller.g.dart index 1d4a7b4..0c92bc2 100644 --- a/lib/controller/mh_controller/device_list_controller.g.dart +++ b/lib/controller/mh_controller/device_list_controller.g.dart @@ -8,9 +8,7 @@ part of 'device_list_controller.dart'; DeviceListModel _$DeviceListModelFromJson(Map json) => DeviceListModel() - ..deviceList = (json['deviceList'] as List) - .map((e) => DeviceModel.fromJson(e as Map)) - .toList() + ..deviceList = json['deviceList'] as List ..deviceListWyf = json['deviceListWyf'] as List; Map _$DeviceListModelToJson(DeviceListModel instance) => diff --git a/lib/controller/mh_controller/issue_controller.dart b/lib/controller/mh_controller/issue_controller.dart index 222a666..f0fc485 100644 --- a/lib/controller/mh_controller/issue_controller.dart +++ b/lib/controller/mh_controller/issue_controller.dart @@ -1,6 +1,8 @@ import 'package:ef/ef.dart'; import 'package:json_annotation/json_annotation.dart'; +import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; part 'issue_controller.g.dart'; @@ -22,34 +24,35 @@ class IssueListModel { } class IssueListController extends GetControllerEx { - // HelpRepository helpRepository = HelpRepository(); IssueListController() { attr = GetModel(IssueListModel()).obs; } + void onInit() async { + super.onInit(); + await getIssueList(); + } + getIssueList() async { + model.isLoading = true; + updateAll(); - // //初始化列表数据 - // Future initData() async { - // if (model.isLoading) { - // return; - // } - // model.isLoading = true; - // final List fetchedRepairs = await helpRepository.findHelpInfos( - // limit: model.limit, offset: model.offset); - // if (fetchedRepairs != null) { - // List infos = []; - // List tmp = fetchedRepairs as List; - // try { - // // infos = tmp.map((repair) => IssueModel.fromJson(repair)).toList(); - // // model.issueList!.addAll(infos); - // model.issueList.addAll(tmp); - // } catch (e) { - // print('Error parsing JSON: $e'); - // } - // } - // model.offset += model.limit; // 更新 offset,下一次查询跳过当前已经加载的记录 - // model.hasMore = fetchedRepairs.length == model.limit; // 判断是否还有更多数据 - // model.isLoading = false; - // updateAll(); - // } + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.issue_list; + String queryUrl = "$serviceAddress$serviceName$serviceApi"; + requestWithLog( + logTitle: '获取所有的问题与帮助列表', + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + model.issueList = res.data; + model.isLoading = false; + updateAll(); + }, + onFailure: (e) { + model.isLoading = false; + updateAll(); + }, + ); + } } diff --git a/lib/controller/mh_controller/people_info_controller.dart b/lib/controller/mh_controller/people_info_controller.dart index 9a8f5f3..27d1622 100644 --- a/lib/controller/mh_controller/people_info_controller.dart +++ b/lib/controller/mh_controller/people_info_controller.dart @@ -1,13 +1,15 @@ import 'package:ef/ef.dart'; +import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:vbvs_app/common/color/ServiceConstant.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; part 'people_info_controller.g.dart'; // 由json_serializable自动生成的部分 @JsonSerializable() -class PeopleInfoPojo { +class PeopleInfoModel { String? name; String sex = "男"; String? height; @@ -15,95 +17,71 @@ class PeopleInfoPojo { DateTime? birthday; String? phone; String? contact; + List peopleList = []; + PeopleInfoModel(); - PeopleInfoPojo(); - - // // 从JSON反序列化时的异常处理 - - factory PeopleInfoPojo.fromJson(Map json) { + factory PeopleInfoModel.fromJson(Map json) { try { - return _$PeopleInfoPojoFromJson(json); + return _$PeopleInfoModelFromJson(json); } catch (e) { // 在实际应用中,应该有更细致的异常处理策略和错误日志 - return PeopleInfoPojo(); // 或者返回一个带有错误信息的特定PeopleInfoModel实例 + return PeopleInfoModel(); // 或者返回一个带有错误信息的特定PeopleInfoModel实例 } } // 序列化为JSON时的异常处理 - Map toJson() => _$PeopleInfoPojoToJson(this); + Map toJson() => _$PeopleInfoModelToJson(this); } -class PeopleInfoController extends GetControllerEx { +class PeopleInfoController extends GetControllerEx { PeopleInfoController() { - attr = GetModel(PeopleInfoPojo()).obs; + attr = GetModel(PeopleInfoModel()).obs; } - GlobalController get glcontroller => Get.find(); + @override + Future initData(String mac) async { + await getPeoples(mac); // 控制器创建时立即执行 + } - // getPeoples() async { - // var arr = []; - // String bindMacA = - // glcontroller.getUpperCaseMac(glcontroller.model.deviceMain["bindMacA"]); - // String bindMacB = - // glcontroller.getUpperCaseMac(glcontroller.model.deviceMain["bindMacB"]); - // arr.add(bindMacA); - // if (bindMacB.length > 6) { - // arr.add(bindMacB); - // } else { - // model.peopleList[1] = PeopleInfoPojo(); - // } - // model.peopleList[0] = PeopleInfoPojo(); - // print("getuser $arr"); - // var data = await ef.from("app_personnel").select().inFilter("mac", arr); - // print("getuser $data"); - // data?.forEach((d) { - // PeopleInfoPojo peopleInfoPojo = PeopleInfoPojo(); - // peopleInfoPojo.name = d["name"]; - // peopleInfoPojo.sex = d["gender"] == 1 ? "男" : "女"; - // peopleInfoPojo.height = d["height"] == null ? null : "${d["height"]}"; - // peopleInfoPojo.weight = d["weight"] == null ? null : "${d["weight"]}"; - // if (d["birthday"] != null) { - // peopleInfoPojo.birthday = DateTime.parse(d["birthday"]).toLocal(); - // } - // peopleInfoPojo.tel = d["tel"]; - // peopleInfoPojo.emergencyContact = d["contact"]; - // if (glcontroller.getUpperCaseMac(d['mac']) == bindMacA) { - // model.peopleList[0] = peopleInfoPojo; - // } - // if (glcontroller.getUpperCaseMac(d['mac']) == bindMacB) { - // model.peopleList[1] = peopleInfoPojo; - // } - // }); - // updateAll(); - // attr.value.updateAll(); - // } + getPeoples(String mac) async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.person_info; + String queryUrl = "$serviceAddress$serviceName$serviceApi?mac=$mac"; - // savePeoples() async { - // String bindMacA = - // glcontroller.getUpperCaseMac(glcontroller.model.deviceMain["bindMacA"]); - // String bindMacB = - // glcontroller.getUpperCaseMac(glcontroller.model.deviceMain["bindMacB"]); - // List arr = []; - // for (var i = 0; i < 2; i++) { - // if (i == 1 && bindMacB.length < 6) { - // break; - // } - // arr.add(ef.from("app_personnel").update({ - // "name": model.peopleList[i].name, - // "gender": model.peopleList[i].sex == "男" ? 1 : 0, - // "height": int.tryParse("${model.peopleList[i].height}"), - // "weight": int.tryParse("${model.peopleList[i].weight}"), - // "birthday": model.peopleList[i].birthday == null - // ? null - // : model.peopleList[i].birthday.toString(), - // "tel": model.peopleList[i].tel, - // "contact": model.peopleList[i].emergencyContact - // }).eq("mac", i == 0 ? bindMacA : bindMacB)); - // } - // return Future.wait(arr); - // } + requestWithLog( + logTitle: "获取设备的人员信息列表", + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + if (res.data != null && res.data is List) { + model.peopleList = res.data; + updateAll(); + print("peopleList: ${model.peopleList}"); + } + }, + onFailure: (err) { + print("获取人员信息失败: $err"); + }, + ); + } - // Future saveOnePeople(mac, data) async { - // return ef.from("app_personnel").update(data).eq("mac", mac); - // } + savePeoples(Map data) async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.person_info; + String queryUrl = "$serviceAddress$serviceName$serviceApi"; + requestWithLog( + logTitle: "更新人员信息", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: data, + onSuccess: (res) { + print("更新人员信息成功: $res"); + }, + onFailure: (err) { + print("更新人员信息失败: $err"); + }, + ); + } } diff --git a/lib/controller/mh_controller/people_info_controller.g.dart b/lib/controller/mh_controller/people_info_controller.g.dart index 9a2db2f..e36ba24 100644 --- a/lib/controller/mh_controller/people_info_controller.g.dart +++ b/lib/controller/mh_controller/people_info_controller.g.dart @@ -6,8 +6,8 @@ part of 'people_info_controller.dart'; // JsonSerializableGenerator // ************************************************************************** -PeopleInfoPojo _$PeopleInfoPojoFromJson(Map json) => - PeopleInfoPojo() +PeopleInfoModel _$PeopleInfoModelFromJson(Map json) => + PeopleInfoModel() ..name = json['name'] as String? ..sex = json['sex'] as String ..height = json['height'] as String? @@ -15,16 +15,18 @@ PeopleInfoPojo _$PeopleInfoPojoFromJson(Map json) => ..birthday = json['birthday'] == null ? null : DateTime.parse(json['birthday'] as String) - ..phone = json['tel'] as String? - ..contact = json['emergencyContact'] as String?; + ..phone = json['phone'] as String? + ..contact = json['contact'] as String? + ..peopleList = json['peopleList'] as List; -Map _$PeopleInfoPojoToJson(PeopleInfoPojo instance) => +Map _$PeopleInfoModelToJson(PeopleInfoModel instance) => { 'name': instance.name, 'sex': instance.sex, 'height': instance.height, 'weight': instance.weight, 'birthday': instance.birthday?.toIso8601String(), - 'tel': instance.phone, - 'emergencyContact': instance.contact, + 'phone': instance.phone, + 'contact': instance.contact, + 'peopleList': instance.peopleList, }; diff --git a/lib/main.dart b/lib/main.dart index 3946ff4..7872109 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -36,6 +36,7 @@ import 'package:vbvs_app/controller/message/message_review_controller.dart'; import 'package:vbvs_app/controller/message/message_setting_controller.dart'; import 'package:vbvs_app/controller/mh_controller/address_controller.dart'; import 'package:vbvs_app/controller/mh_controller/address_list_controller.dart'; +import 'package:vbvs_app/controller/mh_controller/bedController.dart'; import 'package:vbvs_app/controller/mh_controller/book_info_controller.dart'; import 'package:vbvs_app/controller/mh_controller/device_list_controller.dart'; import 'package:vbvs_app/controller/mh_controller/experience_store_list_page.dart'; @@ -292,6 +293,13 @@ class MyApp extends StatelessWidget { debugShowCheckedModeBanner: false, title: '', theme: themeController.currentTheme, + localizationsDelegates: const [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + locale: Locale('zh', 'CN'), // 设置默认语言为中文 + // home: MainPageBBottomChange(), // initialRoute: "/loginPage", initialRoute: "/mianPageBottomChange", @@ -336,7 +344,10 @@ class MyApp extends StatelessWidget { Get.lazyPut(() => MHTRegisterController()), Get.lazyPut(() => WeatherModelController()), Get.lazyPut(() => RegisterController()), + Get.lazyPut(() => SleepingHabitController()), + Get.lazyPut(() => BedController()), Get.lazyPut(() => UpdatePasswordController()), + Get.lazyPut(() => IssueListController()), Get.lazyPut(() => DeviceListController()), Get.lazyPut(() => MHTBlueToothController()), Get.lazyPut(() => MHTHomeController()), diff --git a/lib/pages/device_bind/device_calibration_person.dart b/lib/pages/device_bind/device_calibration_person.dart index 3398f9c..3520e6b 100644 --- a/lib/pages/device_bind/device_calibration_person.dart +++ b/lib/pages/device_bind/device_calibration_person.dart @@ -1058,6 +1058,7 @@ class _CalibrationPersonPageState extends State { ); }, onFailure: (res) {}, + ); } } diff --git a/lib/pages/mh_page/MattressControl.dart b/lib/pages/mh_page/MattressControl.dart index 193a94f..e86e6cd 100644 --- a/lib/pages/mh_page/MattressControl.dart +++ b/lib/pages/mh_page/MattressControl.dart @@ -16,36 +16,32 @@ class MattressControlPage extends StatefulWidget { class _MattressControlPageState extends State { final controller = Get.put(ControlCardController()); - final data ={ - "_id": "6840ee86693db58798000000", - "uid": "68465947a0cff49592000000", - "bind_type": 1, - "device_type": 1, - "mac": "B43A45C3E9A8", - "bind_mac": null, - "position": 0, - "share_uid": null, - "person": { - "name": "bb", - "gender": 0, - "birthday": "2025/05/27", - "weight": "10", - "height": "100", - "disease": [] - }, - "show": true, - "create_time": 1749085830536, - "shareNum": 0, - "status": { - "signal": -1, - "status": 0, - "inBed": 0, - "upgrade": 0, - "failure": 0, - "updateTime": 1749110182000 - }, - "code": "B43A45C3E9A8" - }; + final data = { + "_id": "684bf0845a81f423c0000000", + "uid": "68465947a0cff49592000000", + "bind_type": 1, + "device_type": 3, + "mac": "545024122617", + "bind_mac": null, + "bind_mac_a": "48CA43B2E8C8", + "bind_mac_b": "48CA43B2E8B0", + "position": 0, + "share_uid": null, + "person": null, + "op_type": null, + "show": true, + "create_time": 1749807236514, + "shareNum": 0, + "status": { + "signal": -1, + "status": 0, + "inBed": 0, + "upgrade": 0, + "failure": 0, + "updateTime": -1 + }, + "code": "545024122617" + }; int selectedIndex = 1; // 当前选中的tab索引 @override Widget build(BuildContext context) { diff --git a/lib/pages/mh_page/apply_repair_page.dart b/lib/pages/mh_page/apply_repair_page.dart index a3a628c..a70b9be 100644 --- a/lib/pages/mh_page/apply_repair_page.dart +++ b/lib/pages/mh_page/apply_repair_page.dart @@ -150,9 +150,6 @@ class ApplyRepairPage extends GetView { fontSize: AppFontsize .title_size, - fontWeight: - FontWeight - .bold, color: Colors .white // 加粗文字 ), @@ -200,9 +197,8 @@ class ApplyRepairPage extends GetView { style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'Readex Pro', - fontSize: - AppFontsize - .normal_text_size, + fontSize: 26 + .rpx, letterSpacing: 0, color: Colors @@ -353,9 +349,8 @@ class ApplyRepairPage extends GetView { style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'Readex Pro', - fontSize: - AppFontsize - .normal_text_size, + fontSize: 26 + .rpx, letterSpacing: 0, color: Colors @@ -524,9 +519,8 @@ class ApplyRepairPage extends GetView { style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'Readex Pro', - fontSize: - AppFontsize - .normal_text_size, + fontSize: 26 + .rpx, letterSpacing: 0, color: Colors @@ -695,9 +689,8 @@ class ApplyRepairPage extends GetView { style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'Readex Pro', - fontSize: - AppFontsize - .normal_text_size, + fontSize: 26 + .rpx, letterSpacing: 0, color: Colors @@ -1314,6 +1307,8 @@ class ApplyRepairPage extends GetView { 10, 5, 10, 5), ), maxLines: 4, + maxLength: + 100, // ✅ 限制最多输入 100 字符 style: FlutterFlowTheme.of( context) .bodyMedium @@ -1443,9 +1438,8 @@ class ApplyRepairPage extends GetView { style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'Readex Pro', - fontSize: - AppFontsize - .small_text_size, + fontSize: 26 + .rpx, letterSpacing: 0, color: Colors @@ -1486,6 +1480,9 @@ class ApplyRepairPage extends GetView { .apply_name, obscureText: false, + textAlignVertical: + TextAlignVertical + .center, decoration: InputDecoration( contentPadding: @@ -1624,9 +1621,8 @@ class ApplyRepairPage extends GetView { style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: 'Readex Pro', - fontSize: - AppFontsize - .small_text_size, + fontSize: 26 + .rpx, letterSpacing: 0, color: Colors @@ -1664,6 +1660,9 @@ class ApplyRepairPage extends GetView { .tel, obscureText: false, + textAlignVertical: + TextAlignVertical + .center, decoration: InputDecoration( contentPadding: diff --git a/lib/pages/mh_page/bluetooth.dart b/lib/pages/mh_page/bluetooth.dart index eb00614..f213056 100644 --- a/lib/pages/mh_page/bluetooth.dart +++ b/lib/pages/mh_page/bluetooth.dart @@ -96,7 +96,7 @@ class BluetoothPage extends GetView { ), const SizedBox(height: 4), - Text('MAC:4645146546', + Text(data['mac']?.toString() ?? '未命名', style: TextStyle( color: Colors.white70, fontSize: 26.rpx)), diff --git a/lib/pages/mh_page/book_info_page.dart b/lib/pages/mh_page/book_info_page.dart index 8ae1242..c0b2772 100644 --- a/lib/pages/mh_page/book_info_page.dart +++ b/lib/pages/mh_page/book_info_page.dart @@ -37,7 +37,7 @@ class BookInfoPage extends GetView { ), ), child: Scaffold( - resizeToAvoidBottomInset: false, // 自 + // resizeToAvoidBottomInset: false, // 自 // key: scaffoldKey, backgroundColor: Colors.transparent, appBar: AppBar( @@ -323,6 +323,8 @@ class BookInfoPage extends GetView { onChanged: (d) { controller.model.userName = d; }, + enableInteractiveSelection: + false, obscureText: false, decoration: InputDecoration( labelStyle: @@ -393,9 +395,8 @@ class BookInfoPage extends GetView { 8), ), contentPadding: - const EdgeInsetsDirectional - .fromSTEB( - 0, 0, 0, 12), + EdgeInsets.symmetric( + vertical: 0), ), style: FlutterFlowTheme.of(context) @@ -417,6 +418,7 @@ class BookInfoPage extends GetView { ), ), ), + getLine(), Padding( padding: EdgeInsetsDirectional.fromSTEB( @@ -545,9 +547,8 @@ class BookInfoPage extends GetView { 8), ), contentPadding: - const EdgeInsetsDirectional - .fromSTEB( - 0, 0, 0, 12), + EdgeInsets.symmetric( + vertical: 0), ), style: FlutterFlowTheme.of(context) diff --git a/lib/pages/mh_page/device_list.dart b/lib/pages/mh_page/device_list.dart index 402266a..85b91fc 100644 --- a/lib/pages/mh_page/device_list.dart +++ b/lib/pages/mh_page/device_list.dart @@ -33,57 +33,56 @@ class _DeviceListPageState extends State { return LayoutBuilder(builder: (context, cc) { bodysize = cc; return GestureDetector( - onTap: () => FocusScope.of(context).unfocus(), - child: Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/images/new_background.png'), // 本地图片 - fit: BoxFit.fill, // 填满整个 Container + onTap: () => FocusScope.of(context).unfocus(), + child: Scaffold( + resizeToAvoidBottomInset: false, + appBar: AppBar( + backgroundColor: Colors.transparent, + automaticallyImplyLeading: false, + iconTheme: IconThemeData(color: Colors.white), + titleSpacing: 0, + // leading: returnIconButtomAddCallback(() { + // controller.saveDataApi(); + // updateParm(isShowToast: false); + // }), + // leading: returnIconButtomNew, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + // 中间居中的标题 + Text( + '设备列表', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 30.rpx, + ), + ), + // 左侧图标 + Positioned( + left: 20.rpx, + child: returnIconButtomNew, + ), + ], + ), ), + + actions: [], + centerTitle: false, ), - child: Scaffold( - appBar: AppBar( - backgroundColor: Colors.transparent, - automaticallyImplyLeading: false, - iconTheme: IconThemeData(color: Colors.white), - titleSpacing: 0, - // leading: returnIconButtomAddCallback(() { - // controller.saveDataApi(); - // updateParm(isShowToast: false); - // }), - // leading: returnIconButtomNew, - title: Container( - width: double.infinity, - height: 180.rpx, - child: Stack( - alignment: Alignment.center, - children: [ - // 中间居中的标题 - Text( - '设备列表', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 30.rpx, - ), - ), - // 左侧图标 - Positioned( - left: 20.rpx, - child: returnIconButtomNew, - ), - ], + backgroundColor: Colors.transparent, + body: Stack( + children: [ + Positioned.fill( + child: Image.asset( + 'assets/images/new_background.png', + fit: BoxFit.fill, ), ), - - actions: [], - centerTitle: false, - ), - backgroundColor: Colors.transparent, - body: Container( - width: bodysize!.maxWidth, - height: bodysize!.maxHeight, - child: Column( + Column( mainAxisSize: MainAxisSize.max, children: [ Padding( @@ -126,9 +125,16 @@ class _DeviceListPageState extends State { }), ], ), - ), + ], + ) + + // Container( + // width: bodysize!.maxWidth, + // height: bodysize!.maxHeight, + + // ), ), - )); + ); }); } } diff --git a/lib/pages/mh_page/device_people_info.dart b/lib/pages/mh_page/device_people_info.dart index ea504cb..b8c3c5c 100644 --- a/lib/pages/mh_page/device_people_info.dart +++ b/lib/pages/mh_page/device_people_info.dart @@ -8,34 +8,13 @@ import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; +import 'package:vbvs_app/controller/mh_controller/people_info_controller.dart'; -class DevicePeopleInfo extends GetView { +class DevicePeopleInfo extends GetView { Map data; DevicePeopleInfo({required this.data}); - // get glController => Get.find(); - // get bodyData => glController.model.mainDevicePeople; - RxList peopleList = [].obs; - Future devicePeopleInfo() async { - String serviceAddress = ServiceConstant.service_address; - String serviceName = ServiceConstant.server_service; - String serviceApi = ServiceConstant.person_info; - String queryUrl = - "$serviceAddress$serviceName$serviceApi?mac=${data["mac"]}"; - - requestWithLog( - logTitle: "获取设备的人员信息列表", - method: MyHttpMethod.get, - queryUrl: queryUrl, - onSuccess: (res) { - if (res.data != null && res.data is List) { - peopleList.assignAll(res.data); - print("peopleList: $peopleList"); - } - }, - ); - } - + PeopleInfoController controller = Get.put(PeopleInfoController()); getInfoRow(context, String str) { return Container( width: double.infinity, @@ -56,11 +35,6 @@ class DevicePeopleInfo extends GetView { @override Widget build(BuildContext context) { - WidgetsBinding.instance.addPostFrameCallback((_) { - if (data["device_type"] == 1 && peopleList.isEmpty) { - devicePeopleInfo(); - } - }); return LayoutBuilder( builder: (context, boxConstraints) => GestureDetector( onTap: () => FocusScope.of(context).unfocus(), @@ -170,9 +144,10 @@ class DevicePeopleInfo extends GetView { ], ), )), - if (data["device_type"] == 1 && peopleList.isNotEmpty) - ...List.generate(peopleList.length, (index) { - final person = peopleList[index]; + if (controller.model.peopleList.isNotEmpty) + ...List.generate(controller.model.peopleList.length, + (index) { + final person = controller.model.peopleList[index]; String location_ = ''; if ("${data["bindMacB"]}".length > 6 && (person["direction"] == 1 || @@ -206,9 +181,8 @@ class DevicePeopleInfo extends GetView { ), ), if (location_.isNotEmpty) - getInfoRow(context, "校准位置:$location_"), - getInfoRow( - context, "姓名:${person["name"] ?? "-"}"), + getInfoRow(context, + "姓名:${person["name"] ?? "-"}"), getInfoRow(context, "性别:${person["gender"] == null ? "-" : (person["gender"] == 1 ? "男" : "女")}"), getInfoRow(context, diff --git a/lib/pages/mh_page/experience_store_page.dart b/lib/pages/mh_page/experience_store_page.dart index 26f1fdc..f99f3bc 100644 --- a/lib/pages/mh_page/experience_store_page.dart +++ b/lib/pages/mh_page/experience_store_page.dart @@ -147,7 +147,11 @@ class _ExperienceStorePageState extends State { if (controller .model.experienceStoreModelList.length == 0) { - return Empty(); + return CircularProgressIndicator( + strokeWidth: 1, + valueColor: + AlwaysStoppedAnimation(Colors.white), + ); } else { return Container(); } diff --git a/lib/pages/mh_page/help/article.dart b/lib/pages/mh_page/help/article.dart new file mode 100644 index 0000000..3aebe6c --- /dev/null +++ b/lib/pages/mh_page/help/article.dart @@ -0,0 +1,136 @@ +import 'package:ef/ef.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import 'package:vbvs_app/common/color/appColors.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/controller/user_info_controller.dart'; + +class HelpArticle extends StatelessWidget { + Map article; + HelpArticle({super.key, required this.article}); + + // get articleController => Get.find(); + get userInfoController => Get.find(); + + var isLike = 0.obs; + + @override + Widget build(BuildContext context) { + String top_imgOrVideo = ""; + if (article['imgOrVideo'] == 0) { + top_imgOrVideo = + ''''''; + } else { + top_imgOrVideo = + ''''''; + } + String newText = article['text']; + + RegExp(" d.group(1)) + .toList() + .forEach((d) { + newText = newText.replaceAll("$d", getStorageResourceUrl("$d")); + }); + + String html = ''' + + + + + Test Page + + + + + + ${top_imgOrVideo} + + ${article['title']} + + ${article['author']} + ${time_08_Formatter(article['created_at'])} + + ${newText} + + + + + '''; + + print("$html"); + // articleController.readAdd(article['id']); + String? uid = userInfoController.model.user?.uid; + print("${userInfoController.model.user}"); + // uid = "sss"; + // if (uid != null) { + // articleController.findIsLike(uid, article['id']).then((d) { + // isLike.value = d; + // }); + // } + + return LayoutBuilder( + builder: (context, boxConstraints) => GestureDetector( + onTap: () => FocusScope.of(context).unfocus(), + child: Scaffold( + appBar: AppBar( + backgroundColor: AppColors.bg_color, + automaticallyImplyLeading: false, + iconTheme: IconThemeData(color: Colors.white), + titleSpacing: 0, + leading: returnIconButtom, + ), + body: SafeArea( + top: true, + child: Container( + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height, + decoration: BoxDecoration( + color: Colors.white, + // color: AppColors.bg_color, + // image: DecorationImage( + // image: AssetImage("assets/images/background.png$test"), + // fit: BoxFit.cover, + // ), + ), + child: Column( + children: [ + Expanded( + child: Container( + // child: WebViewWidget( + // controller: WebViewController() + // ..setJavaScriptMode(JavaScriptMode.unrestricted) + // ..loadHtmlString(html), + // ), + child: InAppWebView( + initialData: + InAppWebViewInitialData(data: html, encoding: ""), + ), + ), + ), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/mh_page/issue_list_page.dart b/lib/pages/mh_page/issue_list_page.dart index 1cfe95d..fe9c891 100644 --- a/lib/pages/mh_page/issue_list_page.dart +++ b/lib/pages/mh_page/issue_list_page.dart @@ -11,13 +11,9 @@ class IssueListPage extends GetView { final scaffoldKey = GlobalKey(); BoxConstraints? bodysize; - final ScrollController scrollController = ScrollController(); - + IssueListController controller = Get.put(IssueListController()); + // ScrollController scrollController = ScrollController(); // IssueListPage() { - // controller.model.limit = AppConstants.limit; - // controller.model.offset = 0; - // controller.model.isLoading = false; - // controller.model.hasMore = true; // controller.model.issueList!.clear(); // controller.initData(); @@ -31,20 +27,10 @@ class IssueListPage extends GetView { // }); // } - // void initData() async {} - @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, cc) { bodysize = cc; - controller.model.issueList = [ - {'title': 'APP如何连接我的智能床?'}, - {'title': '智能床如何连接网络?'}, - {'title': '跟换WIFI名称或密码,或者刚换了路由器后,我的智能床无法使用怎么办?'}, - {'title': '在APP中,如何查看我的睡眠报告?'}, - {'title': '在APP中,如何查看我的睡眠报告?'}, - {'title': '在APP中,如何查看我的睡眠报告?'} - ]; return GestureDetector( onTap: () => FocusScope.of(context).unfocus(), child: Container( @@ -96,89 +82,120 @@ class IssueListPage extends GetView { // color: Color(0xFFF6F6F6), ), child: Obx(() { - return Visibility( - visible: controller.model.issueList != null && - controller.model.issueList!.isNotEmpty, - replacement: Container( + if (controller.model.isLoading) { + return Center(child: CircularProgressIndicator()); // ✅ 加载中 + } + + if (controller.model.issueList.isEmpty) { + return Container( width: MediaQuery.sizeOf(context).width, height: 100, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).secondaryBackground, - ), child: Padding( padding: EdgeInsetsDirectional.fromSTEB(31, 27, 0, 0), - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - Align( - alignment: AlignmentDirectional(-1, 0), - child: Text( - '暂无内容!', - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: AppFontsize.title_size, - letterSpacing: 0, - fontWeight: FontWeight.w600, - ), - ), - ), - ], - ), - ), - ), - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - // TitleComponentWidget( - // titleName: '问题与帮助', - // ), - Flexible( - child: Padding( - padding: - EdgeInsetsDirectional.fromSTEB(15, 13, 15, 15), - child: Container( - width: bodysize!.maxWidth, - decoration: BoxDecoration( - // color: Colors.white, - // borderRadius: BorderRadius.circular(16), - ), - child: Obx(() => ListView( - controller: scrollController, - padding: const EdgeInsets.fromLTRB( - 0, - 5, - 0, - 0, - ), - shrinkWrap: true, - scrollDirection: Axis.vertical, - children: (controller.model.issueList! - .asMap() - .entries - .map((e) => IssuePreviewWidget( - index: e.key, - issueListController: controller)) - .toList() as List) - // .divide(const SizedBox( - // height: 30, - // )) - // .addToEnd(const SizedBox( - // height: 26, - // )) - // .addToStart(SizedBox( - // height: 16, - // )) - )), - ), + child: Align( + alignment: AlignmentDirectional(-1, 0), + child: Text( + '暂无内容!', + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Color(0xFF9EA4B7), + fontSize: AppFontsize.title_size, + fontWeight: FontWeight.w600, + ), ), ), - ], - ), + ), + ); + } + + // 有数据时渲染列表 + return ListView( + children: controller.model.issueList! + .asMap() + .entries + .map((e) => IssuePreviewWidget( + index: e.key, + issueListController: controller, + )) + .toList(), ); }), + + // Obx(() { + // return Visibility( + // visible: controller.model.issueList != null && + // controller.model.issueList.isNotEmpty, + // replacement: Container( + // width: MediaQuery.sizeOf(context).width, + // height: 100, + // decoration: BoxDecoration( + // color: FlutterFlowTheme.of(context).secondaryBackground, + // ), + // child: Padding( + // padding: EdgeInsetsDirectional.fromSTEB(31, 27, 0, 0), + // child: Column( + // mainAxisSize: MainAxisSize.max, + // children: [ + // Align( + // alignment: AlignmentDirectional(-1, 0), + // child: Text( + // '暂无内容!', + // style: FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Readex Pro', + // color: Color(0xFF9EA4B7), + // fontSize: AppFontsize.title_size, + // letterSpacing: 0, + // fontWeight: FontWeight.w600, + // ), + // ), + // ), + // ], + // ), + // ), + // ), + // child: Column( + // mainAxisSize: MainAxisSize.max, + // children: [ + // // TitleComponentWidget( + // // titleName: '问题与帮助', + // // ), + // Flexible( + // child: Padding( + // padding: + // EdgeInsetsDirectional.fromSTEB(15, 13, 15, 15), + // child: Container( + // width: bodysize!.maxWidth, + // decoration: BoxDecoration( + // // color: Colors.white, + // // borderRadius: BorderRadius.circular(16), + // ), + // child: Obx(() => ListView( + // padding: const EdgeInsets.fromLTRB( + // 0, + // 5, + // 0, + // 0, + // ), + // shrinkWrap: true, + // scrollDirection: Axis.vertical, + // children: (controller.model.issueList! + // .asMap() + // .entries + // .map((e) => IssuePreviewWidget( + // index: e.key, + // issueListController: controller)) + // .toList() as List))), + // ), + // ), + // ), + // ], + // ), + // ); + // }), ), ), )); diff --git a/lib/pages/mh_page/issue_preview_widget.dart b/lib/pages/mh_page/issue_preview_widget.dart index e8cda1e..b7b1a81 100644 --- a/lib/pages/mh_page/issue_preview_widget.dart +++ b/lib/pages/mh_page/issue_preview_widget.dart @@ -21,16 +21,17 @@ class IssuePreviewWidget extends GetView { Widget build(BuildContext context) { return InkWell( onTap: () async { - // issueListController.model.selectedIndex = index; - // issueListController.updateAll(); - // await Future.delayed(Duration(milliseconds: 100)); - // issueListController.model.selectedIndex = -1; - // issueListController.updateAll(); - // var article = issueListController.model.issueList![index]; - // Get.toNamed("/helpArticle", arguments: article); + issueListController.model.selectedIndex = index; + issueListController.updateAll(); + await Future.delayed(Duration(milliseconds: 100)); + issueListController.model.selectedIndex = -1; + issueListController.updateAll(); + var article = issueListController.model.issueList![index]; + Get.toNamed("/helpArticle", arguments: article); }, child: Obx(() { return Container( + margin: EdgeInsets.only(left: 30.rpx, right: 30.rpx), alignment: Alignment.center, width: double.infinity, constraints: BoxConstraints( diff --git a/lib/pages/mh_page/new_mine_page.dart b/lib/pages/mh_page/new_mine_page.dart index 7a9c5d9..dcb2399 100644 --- a/lib/pages/mh_page/new_mine_page.dart +++ b/lib/pages/mh_page/new_mine_page.dart @@ -82,6 +82,8 @@ class _MinePageState extends State { child: Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( + elevation: 0, + surfaceTintColor: Colors.transparent, backgroundColor: Colors.transparent, iconTheme: const IconThemeData(color: Colors.white), automaticallyImplyLeading: false, @@ -116,20 +118,6 @@ class _MinePageState extends State { color: Colors.white, // color: Colors.white, ))), - // ClickableContainer( - // backgroundColor: Colors.transparent, - // highlightColor: Colors.transparent, - // padding: EdgeInsets.only(right: 11.rpx), - // onTap: () { - - // }, - // child: Container( - // height: 42.rpx, - // width: 42.rpx, - // child: SvgPicture.asset( - // 'assets/img/icon/people_info.svg', - // color: Colors.white, - // ))), ], ), body: SafeArea( @@ -239,7 +227,7 @@ class _MinePageState extends State { margin: EdgeInsets.only( left: 30.rpx, right: 30.rpx, top: 94.rpx), child: Text( - '对已绑定的智能设备进行个性化配置,以获得更好的体验,', + '对已绑定的智能设备进行个性化配置,以获得更好的体验', style: TextStyle( fontSize: 26.rpx, color: const Color(0XFF929699), diff --git a/lib/pages/mh_page/people_info.dart b/lib/pages/mh_page/people_info.dart index 2c6f544..fd1f061 100644 --- a/lib/pages/mh_page/people_info.dart +++ b/lib/pages/mh_page/people_info.dart @@ -14,35 +14,27 @@ import 'package:vbvs_app/controller/mh_controller/people_info_controller.dart'; import 'package:vbvs_app/pages/common/selectDialog.dart'; -class PeopleInfoPage extends StatefulWidget { - const PeopleInfoPage({super.key}); - - @override - State createState() => _PeopleInfoState(); -} - -class _PeopleInfoState extends State { - get controller => Get.find(); - - get glcontroller => Get.find(); - - // @override - // void initState() { - // super.initState(); - // Timer(const Duration(milliseconds: 100), () { - // controller.getPeoples(); - // }); - // } +class PeopleInfoPage extends GetView { + Map data; + PeopleInfoPage({required this.data}); getLine() { - return Container(height: 0.5.rpx, color: Color(0xFF929699)); + return Divider( + color: Color(0XFF929699), + thickness: 0.5.rpx, + height: 0, + ); } + PeopleInfoController controller = Get.put(PeopleInfoController()); @override Widget build(BuildContext context) { + // 初始化只做一次 + WidgetsBinding.instance.addPostFrameCallback((_) { + controller.initData(data['mac']); + }); return LayoutBuilder( builder: (context, boxConstraints) => GestureDetector( - // onTap: () => FocusScope.of(context).unfocus(), onTap: () { // 触摸收起键盘 FocusScope.of(context).requestFocus(FocusNode()); @@ -57,121 +49,129 @@ class _PeopleInfoState extends State { child: Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( + elevation: 0, + surfaceTintColor: Colors.transparent, backgroundColor: Colors.transparent, automaticallyImplyLeading: false, iconTheme: IconThemeData(color: Colors.white), titleSpacing: 0, - title: AppBar( - backgroundColor: Colors.transparent, - iconTheme: const IconThemeData(color: Colors.white), - automaticallyImplyLeading: false, - titleSpacing: 0, - title: SizedBox( - width: double.infinity, - height: 180.rpx, - child: Stack( - alignment: Alignment.center, - children: [ - // 中间居中的标题 - Text( - '人员资料', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 30.rpx, - ), + title: SizedBox( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + // 中间居中的标题 + Text( + '人员资料', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 30.rpx, ), - // 左侧图标 - Positioned( - left: 20.rpx, - child: returnIconButtomNew, - ), - Positioned( - right: 30.rpx, - child: CustomCard( - borderRadius: 16.rpx, - gradientDirection: GradientDirection.vertical, - onTap: () { - // bool isOk = true; - // for (var i = 0; i < 2; i++) { - // var d = controller.model.peopleList[i]; - // print("${d.toJson()}"); - // String before = "人员信息${i == 0 ? "A" : "B"}:"; - // if (isOk && - // d.height != null && - // d.height != "" && - // int.tryParse("${d.height}") == null) { - // showToast("$before身高请输入数字"); - // isOk = false; - // } - // if (isOk && - // d.weight != null && - // d.weight != "" && - // int.tryParse("${d.weight}") == null) { - // showToast("$before体重请输入数字"); - // isOk = false; - // } - // if (isOk && - // d.tel != null && - // d.tel != "" && - // MyUtils.isValidPhoneNumber("${d.tel}") == - // false) { - // showToast("$before请输入正确的电话"); - // isOk = false; - // } - // if (isOk && - // d.emergencyContact != null && - // d.emergencyContact != "" && - // MyUtils.isValidPhoneNumber( - // "${d.emergencyContact}") == - // false) { - // showToast("$before请输入正确的紧急联系人电话"); - // isOk = false; - // } - // if (isOk) { - // controller.savePeoples().then((d) { - // showToast("保存成功", color: color_success); - // }).catchError((d) { - // print("$d"); - // showToast("保存失败"); - // }); - // } - // } - // controller.model.peopleList.forEach((d) {}); - }, - colors: const [ - Color(0xFFFCFCFC), - Color(0xFFF8FAF9), - Color(0XFFECF6F3), - Color(0XFFD9F0E9), - Color(0xFFCEECE3) - ], - child: Container( - width: 120.rpx, - height: 60.rpx, - alignment: Alignment.center, - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(5), - // color: stringToColor("#182B7C"), - // ), - child: Text( - "保存", - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Readex Pro', - color: Color(0XFF011D33), - letterSpacing: 0, - fontSize: 30.rpx, - ), - ), + ), + // 左侧图标 + Positioned( + left: 20.rpx, + child: returnIconButtomNew, + ), + Positioned( + right: 30.rpx, + child: CustomCard( + borderRadius: 16.rpx, + gradientDirection: GradientDirection.vertical, + onTap: () async { + bool isValid = true; + + // 数据验证 + for (int i = 0; + i < controller.model.peopleList.length; + i++) { + var d = controller.model.peopleList[i]; + String prefix = "人员信息${i == 0 ? "A" : "B"}:"; + + if (d['height'] != null && + d['height'].toString().isNotEmpty && + int.tryParse(d['height'].toString()) == + null) { + showToast("$prefix身高请输入数字"); + isValid = false; + break; + } + + if (d['weight'] != null && + d['weight'].toString().isNotEmpty && + int.tryParse(d['weight'].toString()) == + null) { + showToast("$prefix体重请输入数字"); + isValid = false; + break; + } + + if (d['tel'] != null && + d['tel'].toString().isNotEmpty && + !MyUtils.isValidPhoneNumber( + d['tel'].toString())) { + showToast("$prefix请输入正确的电话"); + isValid = false; + break; + } + + if (d['contact'] != null && + d['contact'].toString().isNotEmpty && + !MyUtils.isValidPhoneNumber( + d['contact'].toString())) { + showToast("$prefix请输入正确的紧急联系人电话"); + isValid = false; + break; + } + } + + // 所有数据合法,开始保存 + if (isValid) { + for (var data in controller.model.peopleList) { + try { + await controller.savePeoples( + data); // 注意:你这个方法名是 savePeoples,建议改成 savePerson + showToast("保存成功(${data['mac']})", + color: color_success); + } catch (e) { + print("保存失败:$e"); + showToast("保存失败(${data['mac']})"); + } + } + } + }, + colors: const [ + Color(0xFFFCFCFC), + Color(0xFFF8FAF9), + Color(0XFFECF6F3), + Color(0XFFD9F0E9), + Color(0xFFCEECE3) + ], + child: Container( + width: 120.rpx, + height: 60.rpx, + alignment: Alignment.center, + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(5), + // color: stringToColor("#182B7C"), + // ), + child: Text( + "保存", + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Color(0XFF011D33), + letterSpacing: 0, + fontSize: 30.rpx, + ), ), - )) - ], - ), + ), + )) + ], ), - actions: [], - centerTitle: false, ), centerTitle: false, ), @@ -191,50 +191,205 @@ class _PeopleInfoState extends State { child: SingleChildScrollView( child: Column( children: [ - ...List.generate( - "${glcontroller.model.deviceMain["bindMacB"]}" - .length > - 6 - ? 2 - : 1, (index) { - String location_ = ""; - if ("${glcontroller.model.deviceMain["bindMacB"]}" - .length > - 6 && - (glcontroller.model.mainDevicePeople[0] - ?["direction"] == - 1 || - glcontroller.model.mainDevicePeople[1] - ?["direction"] == - 1)) { - location_ = - "${glcontroller.model.mainDevicePeople[index]?["direction"] == 1 ? '左侧' : '右侧'}"; - } - return Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only( - top: index == 0 ? 30.rpx : 90.rpx, - bottom: 20.rpx), - child: Text( - "人员信息${index == 0 ? "A" : "B"}", - style: TextStyle( - color: Colors.white, fontSize: 30.rpx), + if (controller.model.peopleList.isNotEmpty) + ...List.generate(controller.model.peopleList.length, + (index) { + final person = controller.model.peopleList[index]; + String location_ = ''; + // if ("${data["bindMacB"]}".length > 6 && + // (person["direction"] == 1 || + // person["direction"] == 2)) { + // location_ = person["direction"] == 1 ? '左侧' : '右侧'; + // } + return Column( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only( + left: 18.rpx, + top: index == 0 ? 30.rpx : 90.rpx, + bottom: 20.rpx), + child: Text( + "人员资料${index == 0 ? "A" : "B"}", + style: TextStyle( + color: Colors.white, fontSize: 30.rpx), + ), ), - ), - Container( - padding: - EdgeInsets.only(left: 30.rpx, right: 30.rpx), - child: Column( - children: [ - if (location_.isNotEmpty) + Container( + child: Column( + children: [ + getLine(), + Obx( + () => Container( + width: double.infinity, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, right: 35.rpx), + decoration: BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '姓名', + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Color(0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + Container( + width: 300.rpx, + child: TextField( + obscureText: false, + textAlign: TextAlign.right, + style: TextStyle( + fontSize: 30.rpx, + color: Colors.white), + decoration: + const InputDecoration( + fillColor: + Colors.transparent, + filled: true, + hintText: "请输入姓名", + hintStyle: TextStyle( + color: + Colors.white), + border: + InputBorder.none, + contentPadding: + EdgeInsets.all(0)), + onChanged: (value) { + controller.model + .peopleList[index] + ["name"] = value; + }, + controller: controller.onReDraw( + TextEditingController( + text: controller.model + .peopleList[ + index] + ["name"] ?? + ""), + (textEditingController) { + textEditingController + .text = controller.model + .peopleList[index] + ["name"] ?? + ""; + }, "people_name_$index"), + ), + ), + ], + ), + ), + ), + getLine(), + Obx( + () => Container( + margin: EdgeInsets.only( + left: 40.rpx, right: 35.rpx), + width: double.infinity, + height: 90.rpx, + decoration: BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '性别', + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Color(0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + InkWell( + onTap: () { + // 触摸收起键盘 + FocusScope.of(context) + .requestFocus(FocusNode()); + Future.delayed( + const Duration( + milliseconds: 250), () { + // 延迟执行的代码 + showOneSelectionDialog( + context, + arr: ["女", "男"], + checkIndex: controller + .model + .peopleList[ + index] + ['gender'] == + "女" + ? 0 + : 1, + checkChange: (sindex) { + controller.model.peopleList[ + index]['gender'] = + sindex; // 👈 保存为 0 / 1 + controller.updateAll(); + print("gender $sindex"); + }).then((d) { + // Timer(Duration.zero, () { + // FocusScope.of(context).unfocus(); + // }); + }); + }); + }, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 200.rpx, + child: Text( + '${controller.model.peopleList[index]['gender'] == 1 ? '男' : '女'}', + textAlign: + TextAlign.right, + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: Colors.white, + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + ), + SizedBox( + width: 16.rpx, + ), + Icon( + Icons.expand_more, + color: Colors.white, + size: 48.rpx, + ), + ], + ), + ), + ], + ), + ), + ), + getLine(), Container( width: double.infinity, - height: - MediaQuery.sizeOf(context).height * - 0.064, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, right: 35.rpx), decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, @@ -242,109 +397,7 @@ class _PeopleInfoState extends State { MainAxisAlignment.spaceBetween, children: [ Text( - '校准位置', - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - Text( - '$location_', - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - ], - ), - ), - getLine(), - Container( - width: double.infinity, - height: MediaQuery.sizeOf(context).height * - 0.064, - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '姓名', - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - Container( - width: 300.rpx, - child: TextField( - obscureText: false, - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 30.rpx, - color: Colors.white), - decoration: const InputDecoration( - fillColor: Colors.transparent, - filled: true, - hintText: "请输入姓名", - hintStyle: TextStyle( - color: Colors.white), - border: InputBorder.none, - contentPadding: - EdgeInsets.all(0)), - onChanged: (value) { - controller.model.peopleList[index] - .name = value; - controller.updateAll(); - }, - controller: controller.onReDraw( - TextEditingController( - text: controller - .model - .peopleList[index] - .name ?? - ""), - (textEditingController) { - textEditingController.text = - controller - .model - .peopleList[index] - .name ?? - ""; - }, "people_name_$index"), - ), - ), - ], - ), - ), - getLine(), - Obx( - () => Container( - width: double.infinity, - height: - MediaQuery.sizeOf(context).height * - 0.064, - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '性别', + '身高(cm)', style: FlutterFlowTheme.of(context) .bodyMedium .override( @@ -356,239 +409,65 @@ class _PeopleInfoState extends State { ), InkWell( onTap: () { - // 触摸收起键盘 - FocusScope.of(context) - .requestFocus(FocusNode()); + FocusScope.of(context).unfocus(); Future.delayed( const Duration( milliseconds: 250), () { - // 延迟执行的代码 - showOneSelectionDialog(context, - arr: ["女", "男"], - checkIndex: controller - .model - .peopleList[ - index] - .sex == - "女" - ? 0 - : 1, - checkChange: (sindex) { - controller - .model - .peopleList[index] - .sex = - (sindex == 0 ? '女' : '男'); - controller.updateAll(); - print("sex $sindex"); - }).then((d) { - // Timer(Duration.zero, () { - // FocusScope.of(context).unfocus(); - // }); - }); + showHeightPickerDialog( + context, + initialHeight: controller + .model + .peopleList[index] + ['height'] ?? + 170, + onConfirm: + (int selectedHeight) { + controller.model.peopleList[ + index]['height'] = + selectedHeight + .toString(); + controller.updateAll(); + print( + "身高: $selectedHeight cm"); + }, + ); }); }, child: Row( - mainAxisSize: MainAxisSize.max, children: [ - Container( - width: 200.rpx, - child: Text( - '${controller.model.peopleList[index].sex}', - textAlign: TextAlign.right, - style: FlutterFlowTheme.of( - context) - .bodyMedium - .override( - fontFamily: - 'Readex Pro', - color: Colors.white, - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - ), - SizedBox( - width: 16.rpx, - ), - Icon( - Icons.expand_more, - color: Colors.white, - size: 48.rpx, + Text( + controller.model.peopleList[ + index] + ['height'] != + null + ? "${controller.model.peopleList[index]['height']} cm" + : '', + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: Colors.white, + fontSize: 30.rpx, + ), ), + SizedBox(width: 16.rpx), + Icon(Icons.expand_more, + color: Colors.white, + size: 48.rpx), ], ), ), ], ), ), - ), - getLine(), - Container( - width: double.infinity, - height: MediaQuery.sizeOf(context).height * - 0.064, - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '身高(cm)', - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - InkWell( - onTap: () { - FocusScope.of(context).unfocus(); - Future.delayed( - const Duration( - milliseconds: 250), () { - showHeightPickerDialog( - context, - initialHeight: controller - .model - .peopleList[index] - .height ?? - 170, - onConfirm: - (int selectedHeight) { - controller - .model - .peopleList[index] - .height = - selectedHeight.toString(); - controller.updateAll(); - print( - "身高: $selectedHeight cm"); - }, - ); - }); - }, - child: Row( - children: [ - Text( - controller - .model - .peopleList[index] - .height != - null - ? "${controller.model.peopleList[index].height} cm" - : '', - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - 'Readex Pro', - color: Colors.white, - fontSize: 30.rpx, - ), - ), - SizedBox(width: 16.rpx), - Icon(Icons.expand_more, - color: Colors.white, - size: 48.rpx), - ], - ), - ), - ], - ), - ), - getLine(), - Container( - width: double.infinity, - height: MediaQuery.sizeOf(context).height * - 0.064, - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '体重(kg)', - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - InkWell( - onTap: () { - FocusScope.of(context).unfocus(); - Future.delayed( - const Duration( - milliseconds: 250), () { - showWeightPickerDialog( - context, - initialWeight: controller - .model - .peopleList[index] - .weight ?? - "", - onConfirm: - (int selectedWeight) { - controller - .model - .peopleList[index] - .weight = - selectedWeight - .toString(); // ✅ 转成字符串 - controller.updateAll(); - print( - "体重: $selectedWeight kg"); - }, - ); - }); - }, - child: Row( - children: [ - Text( - controller - .model - .peopleList[index] - .weight != - null - ? "${controller.model.peopleList[index].weight} kg" - : '', - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - 'Readex Pro', - color: Colors.white, - fontSize: 30.rpx, - ), - ), - SizedBox(width: 16.rpx), - Icon(Icons.expand_more, - color: Colors.white, - size: 48.rpx), - ], - ), - ), - ], - ), - ), - getLine(), - Obx( - () => Container( + getLine(), + Container( width: double.infinity, - height: - MediaQuery.sizeOf(context).height * - 0.064, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, right: 35.rpx), decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, @@ -596,7 +475,7 @@ class _PeopleInfoState extends State { MainAxisAlignment.spaceBetween, children: [ Text( - '生日', + '体重(kg)', style: FlutterFlowTheme.of(context) .bodyMedium .override( @@ -608,156 +487,243 @@ class _PeopleInfoState extends State { ), InkWell( onTap: () { - // 触摸收起键盘 - FocusScope.of(context) - .requestFocus(FocusNode()); + FocusScope.of(context).unfocus(); Future.delayed( const Duration( milliseconds: 250), () { - // 延迟执行的代码 - showDateSelectionDialog(context, - checkDate: controller - .model - .peopleList[index] - .birthday ?? - DateTime.now(), - checkChange: (DateTime d) { - controller - .model - .peopleList[index] - .birthday = d; - controller.updateAll(); - print("$d"); - }).then((d) { - // Timer(Duration.zero, () { - // FocusScope.of(context).unfocus(); - // }); - }); + showWeightPickerDialog( + context, + initialWeight: controller + .model + .peopleList[index] + ['weight'] ?? + "", + onConfirm: + (int selectedWeight) { + controller.model.peopleList[ + index]['weight'] = + selectedWeight + .toString(); // ✅ 转成字符串 + controller.updateAll(); + print( + "体重: $selectedWeight kg"); + }, + ); }); }, child: Row( - mainAxisSize: MainAxisSize.max, children: [ - Container( - constraints: BoxConstraints( - minWidth: 200.rpx), - child: Text( - controller - .model - .peopleList[ - index] - .birthday != - null - ? DateFormat( - "yyyy年MM月dd日") - .format(controller - .model - .peopleList[ - index] - .birthday!) - : '', - textAlign: TextAlign.right, - style: FlutterFlowTheme.of( - context) - .bodyMedium - .override( - fontFamily: - 'Readex Pro', - color: Colors.white, - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - ), - SizedBox( - width: 16.rpx, - ), - Icon( - Icons.expand_more, - color: Colors.white, - size: 48.rpx, + Text( + controller.model.peopleList[ + index] + ['weight'] != + null + ? "${controller.model.peopleList[index]['weight']} kg" + : '', + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: Colors.white, + fontSize: 30.rpx, + ), ), + SizedBox(width: 16.rpx), + Icon(Icons.expand_more, + color: Colors.white, + size: 48.rpx), ], ), ), ], ), ), - ), - getLine(), - Container( - width: double.infinity, - height: MediaQuery.sizeOf(context).height * - 0.064, - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '联系人', - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - Container( - width: 300.rpx, - child: TextField( - obscureText: false, - keyboardType: TextInputType.number, - textInputAction: - TextInputAction.done, - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 30.rpx, - color: Colors.white), - decoration: InputDecoration( - fillColor: Colors.transparent, - filled: true, - hintText: "请输入联系人", - hintStyle: TextStyle( - color: Colors.white), - border: InputBorder.none, - contentPadding: - EdgeInsets.all(0)), - onChanged: (value) { - controller.model.peopleList[index] - .emergencyContact = value; - controller.updateAll(); - }, - controller: controller.onReDraw( - TextEditingController( - text: controller - .model + getLine(), + Obx( + () => Container( + width: double.infinity, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, right: 35.rpx), + decoration: BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '生日', + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Color(0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + InkWell( + onTap: () { + // 触摸收起键盘 + FocusScope.of(context) + .requestFocus(FocusNode()); + Future.delayed( + const Duration( + milliseconds: 250), () { + // 延迟执行的代码 + showDateSelectionDialog( + context, + checkDate: controller + .model + .peopleList[index] + ['birthday'] + is DateTime + ? controller.model + .peopleList[index] + ['birthday'] + : DateTime.tryParse( + controller.model.peopleList[index]['birthday'] ?? + '') ?? + DateTime.now(), + checkChange: (DateTime d) { + controller.model .peopleList[index] - .emergencyContact ?? - ""), - (textEditingController) { - textEditingController.text = - controller - .model - .peopleList[index] - .emergencyContact ?? - ""; - }, "people_emergencyContact_$index"), - ), + ['birthday'] = d; + controller.updateAll(); + print("$d"); + }).then((d) { + // Timer(Duration.zero, () { + // FocusScope.of(context).unfocus(); + // }); + }); + }); + }, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + constraints: BoxConstraints( + minWidth: 200.rpx), + child: Text( + controller.model.peopleList[ + index][ + 'birthday'] != + null + ? time_08_Formatter_pattern( + controller.model + .peopleList[ + index] + ['birthday'], + "yyyy年MM月dd日") + : '', + textAlign: + TextAlign.right, + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: Colors.white, + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + ), + SizedBox( + width: 16.rpx, + ), + Icon( + Icons.expand_more, + color: Colors.white, + size: 48.rpx, + ), + ], + ), + ), + ], ), - ], + ), ), - ), - getLine(), - ], - ), - ) - ], - ); - }), + getLine(), + Container( + width: double.infinity, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, right: 35.rpx), + decoration: BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '联系人', + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Color(0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + Container( + width: 300.rpx, + child: TextField( + obscureText: false, + keyboardType: + TextInputType.number, + textInputAction: + TextInputAction.done, + textAlign: TextAlign.right, + style: TextStyle( + fontSize: 30.rpx, + color: Colors.white), + decoration: InputDecoration( + fillColor: Colors.transparent, + filled: true, + hintText: "请输入联系人", + hintStyle: TextStyle( + color: Colors.white), + border: InputBorder.none, + contentPadding: + EdgeInsets.all(0)), + onChanged: (value) { + controller + .model.peopleList[index] + ['contact'] = value; + controller.updateAll(); + }, + controller: controller.onReDraw( + TextEditingController( + text: controller.model + .peopleList[ + index] + ['contact'] ?? + ""), + (textEditingController) { + textEditingController + .text = controller.model + .peopleList[index] + ['contact'] ?? + ""; + }, "contact_$index"), + ), + ), + ], + ), + ), + getLine(), + ], + ), + ) + ], + ); + }), SizedBox( height: 100.rpx, ), @@ -769,4 +735,15 @@ class _PeopleInfoState extends State { )), ); } + + String time_08_Formatter_pattern(dynamic date, String pattern) { + if (date == null || date.toString().isEmpty) return "-"; + try { + String normalized = date.toString().replaceAll("/", "-"); + DateTime dt = DateTime.parse(normalized); + return DateFormat(pattern).format(dt); + } catch (e) { + return "-"; + } + } } diff --git a/lib/pages/mh_page/room_picker.dart b/lib/pages/mh_page/room_picker.dart index 381d8f6..19a8da3 100644 --- a/lib/pages/mh_page/room_picker.dart +++ b/lib/pages/mh_page/room_picker.dart @@ -1,8 +1,10 @@ import 'package:ef/base/widget/flutterflow/FlutterFlowTheme.dart'; import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; +import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; class RoomPickerPage extends StatefulWidget { @@ -11,7 +13,28 @@ class RoomPickerPage extends StatefulWidget { } class _RoomPickerPageState extends State { - final List rooms = ['主卧', '次卧', '儿童房', '客厅', '厨房', '书房', '阳台', '洗手间']; + RxList rooms = [].obs; + + @override + void initState() { + super.initState(); + getRoomList(); + } + + getRoomList() async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.room_list; + String queryUrl = "$serviceAddress$serviceName$serviceApi"; + requestWithLog( + logTitle: '查询房间列表', + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + rooms.assignAll(res.data); + }, + ); + } int selectedIndex = 1; BoxConstraints? bodysize; @@ -63,21 +86,6 @@ class _RoomPickerPageState extends State { body: SafeArea( child: Column( children: [ - // 顶部标题栏 - // const Padding( - // padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 12), - // child: Row( - // children: [ - // Icon(Icons.arrow_back_ios, color: Colors.white), - // Spacer(), - // Text( - // '房间选择', - // style: TextStyle(color: Colors.white, fontSize: 18), - // ), - // Spacer(flex: 2), - // ], - // ), - // ), const Spacer(), // 滚轮选择器 SizedBox( @@ -86,30 +94,33 @@ class _RoomPickerPageState extends State { alignment: Alignment.center, children: [ // 滚轮列表 - ListWheelScrollView.useDelegate( - itemExtent: 120.rpx, - perspective: 0.003, - physics: const FixedExtentScrollPhysics(), - onSelectedItemChanged: (index) { - setState(() => selectedIndex = index); - }, - childDelegate: ListWheelChildBuilderDelegate( - builder: (context, index) { - if (index >= rooms.length) return null; - final isSelected = index == selectedIndex; - return Center( - child: Text( - rooms[index], - style: TextStyle( - fontSize: isSelected ? 36.rpx : 30.rpx, - color: isSelected - ? Colors.white - : const Color(0xFF929699), - ), - ), - ); + Obx( + () => ListWheelScrollView.useDelegate( + itemExtent: 120.rpx, + perspective: 0.003, + physics: const FixedExtentScrollPhysics(), + onSelectedItemChanged: (index) { + setState(() => selectedIndex = index); }, - childCount: rooms.length, + childDelegate: ListWheelChildBuilderDelegate( + builder: (context, index) { + if (index >= rooms.length) return null; + final isSelected = index == selectedIndex; + return Center( + child: Text( + rooms[index]['name'], + style: TextStyle( + fontSize: + isSelected ? 36.rpx : 30.rpx, + color: isSelected + ? Colors.white + : const Color(0xFF929699), + ), + ), + ); + }, + childCount: rooms.length, + ), ), ), diff --git a/lib/pages/mh_page/sleep_habit.dart b/lib/pages/mh_page/sleep_habit.dart index 87e548a..fb321b4 100644 --- a/lib/pages/mh_page/sleep_habit.dart +++ b/lib/pages/mh_page/sleep_habit.dart @@ -69,7 +69,9 @@ class _SleepHabitPageState extends State { highlightColor: Color(0XFF055466), borderRadius: 16.rpx, padding: EdgeInsets.only(top: 0), - onTap: () {}, + onTap: () { + Get.toNamed('/rxhxMht'); + }, child: Container( alignment: Alignment.center, width: bodysize!.maxWidth * 1, diff --git a/lib/pages/mh_page/smys.dart b/lib/pages/mh_page/smys.dart index 3316737..2930c2b 100644 --- a/lib/pages/mh_page/smys.dart +++ b/lib/pages/mh_page/smys.dart @@ -1,5 +1,6 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:flutter_switch/flutter_switch.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; @@ -130,7 +131,7 @@ class Smys extends GetView { .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), - fontSize: 30.rpx, + fontSize: 26.rpx, letterSpacing: 0, ), ), @@ -152,35 +153,7 @@ class Smys extends GetView { getmodel.model.smysIsStart = val; }); }, - ) - // Switch.adaptive( - // value: controller.model.smysIsStart, - // onChanged: (newValue) async { - // controller.attr.update((getmodel) { - // getmodel.model.smysIsStart = - // newValue; - // }); - // // updateParm(errorccCallback: () { - // // controller.attr.update((getmodel) { - // // getmodel.model.smysIsStart = !newValue; - // // }); - // // }); - // }, - // activeTrackColor: Color(0xFF6BFDAC), - // inactiveTrackColor: Color(0xFF003058), - // inactiveThumbColor: Color(0xFF011D33), - // trackOutlineWidth: MaterialStateProperty - // .resolveWith( - // (Set states) { - // if (states.contains( - // MaterialState.disabled)) { - // return null; - // } - // return null; // Use the default width. - // }), - // ), - - ), + )), ], ), )), @@ -213,7 +186,7 @@ class Smys extends GetView { .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), - fontSize: 30.rpx, + fontSize: 26.rpx, letterSpacing: 0, ), ), @@ -242,18 +215,20 @@ class Smys extends GetView { .override( fontFamily: 'Readex Pro', color: Colors.white, - fontSize: 36.rpx, + fontSize: 26.rpx, letterSpacing: 0, ), ), SizedBox( width: 16.rpx, ), - Icon( - Icons.expand_more, - color: Colors.white, - size: 40.rpx, - ), + Container( + height: 30.rpx, + width: 30.rpx, + child: SvgPicture.asset( + 'assets/img/icon/expand_more.svg', + color: Colors.white, + )) ], ), ), @@ -289,7 +264,7 @@ class Smys extends GetView { .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), - fontSize: 30.rpx, + fontSize: 26.rpx, letterSpacing: 0, ), ), @@ -318,18 +293,20 @@ class Smys extends GetView { .override( fontFamily: 'Readex Pro', color: Colors.white, - fontSize: 36.rpx, + fontSize: 26.rpx, letterSpacing: 0, ), ), SizedBox( width: 16.rpx, ), - Icon( - Icons.expand_more, - color: Colors.white, - size: 40.rpx, - ), + Container( + height: 30.rpx, + width: 30.rpx, + child: SvgPicture.asset( + 'assets/img/icon/expand_more.svg', + color: Colors.white, + )) ], ), ), diff --git a/lib/pages/mh_page/user/page/rxhx_mht.dart b/lib/pages/mh_page/user/page/rxhx_mht.dart new file mode 100644 index 0000000..0c76e34 --- /dev/null +++ b/lib/pages/mh_page/user/page/rxhx_mht.dart @@ -0,0 +1,682 @@ +import 'dart:async'; +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:ef/ef.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:flutter_switch/flutter_switch.dart'; +import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/component/tool/CustomCard.dart'; +import 'package:vbvs_app/controller/mh_controller/bedController.dart'; +import 'package:vbvs_app/controller/mh_controller/sleeping_habit_controller.dart'; +import 'package:vbvs_app/pages/common/selectDialog.dart'; + +class RxhxMht extends StatefulWidget { + const RxhxMht({super.key}); + + @override + State createState() => _RxhxMhtState(); +} + +class _RxhxMhtState extends State { + get controller => Get.find(); + get bedController => Get.find(); + List location = ["床垫全局", "床垫左侧", "床垫右侧"]; + + @override + void initState() { + super.initState(); + Timer(Duration.zero, () { + resetRxhx(); + currentTimeSend(); + }); + } + + resetRxhx() { + controller.model.rxhxIsStart = false; + controller.model.rxhxWakeTime = [7, 0]; + controller.model.rxhxIsAnMo = true; + controller.model.rxhxWeeks = [0, 0, 0, 0, 0, 0, 0]; + controller.model.rxhxLocation = 0; + controller.updateAll(); + } + + @override + dispose() { + super.dispose(); + } + + alarmChange() async { + // List arr = [0x30, 0x01]; + // arr.add(controller.model.rxhxIsStart ? 0x01 : 0x00); + // arr.add(int.parse("${controller.model.rxhxWakeTime[0]}", radix: 16)); + // arr.add(int.parse("${controller.model.rxhxWakeTime[1]}", radix: 16)); + // arr.add(0); + // int value = int.parse("${controller.model.rxhxWeeks[0]}") * 2 + + // int.parse("${controller.model.rxhxWeeks[1]}") * 4 + + // int.parse("${controller.model.rxhxWeeks[2]}") * 8 + + // int.parse("${controller.model.rxhxWeeks[3]}") * 16 + + // int.parse("${controller.model.rxhxWeeks[4]}") * 32 + + // int.parse("${controller.model.rxhxWeeks[5]}") * 64 + + // int.parse("${controller.model.rxhxWeeks[6]}") * 128; + // arr.add(value); + // arr.add(value > 1 ? 1 : 0); + // arr.add((controller.model.rxhxIsAnMo ? 1 : 0) + + // int.parse("${controller.model.rxhxLocation * 16}")); + // var sendArr = getCode(arr); + // List receive = []; + // Function fun = (d) { + // receive.add(d); + // }; + // bedController.deviceProp?.receiveLogArr.add(fun); + // for (var i = 0; i < 3; i++) { + // bedController.bleSendCode(sendArr); + // await Future.delayed(const Duration(milliseconds: 500)); + // print("$receive"); + // if (receive.length > 0) { + // for (var i = 0; i < receive.length; i++) { + // List r = receive[i]; + // if (handleTimeResult(r, 0x30)) { + // bedController.deviceProp?.receiveLogArr.remove(fun); + // showToast("保存成功", color: color_success); + // return; + // } + // } + // } + // } + // showToast("保存失败"); + // bedController.deviceProp?.receiveLogArr.remove(fun); + } + + handleTimeResult(List r, int type) { + if (r.length == 18 && + r[0] == 255 && + r[1] == 255 && + r[2] == 255 && + r[3] == 255 && + r[4] == 0 && + r[5] == 9 && + r[6] == type && + r[7] == 0x01) { + if (r[8] == 0x01) { + controller.model.rxhxIsStart = true; + } else if (r[8] == 0x02 || r[8] == 0x00) { + controller.model.rxhxIsStart = false; + } else { + return false; + } + controller.model.rxhxWakeTime[0] = int.parse(r[9].toRadixString(16)); + controller.model.rxhxWakeTime[1] = int.parse(r[10].toRadixString(16)); + for (var i = 0; i < 7; i++) { + int v = pow(2, i + 1).toInt(); + controller.model.rxhxWeeks[i] = (v & r[12]) == v ? 1 : 0; + } + controller.model.rxhxIsAnMo = (r[14] & 0x0f) == 1 ? true : false; + controller.model.rxhxLocation = (r[14] & 0xf0) >> 4; + controller.updateAll(); + return true; + } + if (r[0] == 255 && + r[1] == 255 && + r[2] == 255 && + r[3] == 255 && + r[4] == 0 && + r[5] == 3 && + r[6] == type && + r[7] == 0x01 && + r[8] == 0x00 && + r.length == 12) { + resetRxhx(); + return true; + } + return false; + } + + currentTimeSend() async { + // DateTime date = DateTime.now(); + // List arr = [0x20, 0x01]; + // arr.add(int.parse("${date.hour}", radix: 16)); + // arr.add(int.parse("${date.minute}", radix: 16)); + // arr.add(int.parse("${date.second}", radix: 16)); + // arr.add(int.parse("${date.weekday}", radix: 16)); + // arr.add(int.parse("${date.year}".substring(2), radix: 16)); + // arr.add(int.parse("${date.month}", radix: 16)); + // arr.add(int.parse("${date.day}", radix: 16)); + // var sendArr = getCode(arr); + // List receive = []; + // Function fun = (d) { + // receive.add(d); + // }; + // bedController.deviceProp?.receiveLogArr.add(fun); + // bedController.bleSendCode(sendArr); + // for (var i = 0; i < 3; i++) { + // await Future.delayed(const Duration(milliseconds: 500)); + // print("$receive"); + // if (receive.length > 0) { + // for (var i = 0; i < receive.length; i++) { + // List r = receive[i]; + // if (handleTimeResult(r, 0x20)) { + // bedController.deviceProp?.receiveLogArr.remove(fun); + // return; + // } + // } + // } + // } + // bedController.deviceProp?.receiveLogArr.remove(fun); + } + + getLine() { + return Divider( + color: const Color(0XFF929699), + thickness: 0.5.rpx, + height: 0, + ); + } + + List weeks = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]; + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (context, boxConstraints) => GestureDetector( + onTap: () => FocusScope.of(context).unfocus(), + child: Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/new_background.png'), // 本地图片 + fit: BoxFit.fill, // 填满整个 Container + ), + ), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: AppBar( + backgroundColor: Colors.transparent, + automaticallyImplyLeading: false, + iconTheme: const IconThemeData(color: Colors.white), + titleSpacing: 0, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + // 中间居中的标题 + Text( + '柔性唤醒', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 30.rpx, + ), + ), + // 左侧图标 + Positioned( + left: 20.rpx, + child: returnIconButtomNew, + ), + ], + ), + ), + // leading: returnIconButtomAddCallback(() { + // controller.saveDataApi(); + // }), + + // Container( + // width: double.infinity, + // height: 70.rpx, + // child: Row( + // mainAxisSize: MainAxisSize.max, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // '柔性唤醒', + // style: FlutterFlowTheme.of(context).bodyMedium.override( + // fontFamily: 'Readex Pro', + // color: Colors.white, + // letterSpacing: 0, + // fontSize: 30.rpx), + // ), + // InkWell( + // onTap: () { + // alarmChange(); + // }, + // child: Container( + // margin: EdgeInsets.only(right: 30.rpx), + // width: 140.rpx, + // height: 66.rpx, + // alignment: Alignment.center, + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(5), + // color: stringToColor("#182B7C")), + // child: Text( + // "保存", + // style: FlutterFlowTheme.of(context) + // .bodyMedium + // .override( + // fontFamily: 'Readex Pro', + // color: stringToColor("#9EA4B7"), + // letterSpacing: 0, + // fontSize: 30.rpx), + // ), + // ), + // ) + // ], + // ), + // ), + actions: [], + centerTitle: false, + ), + body: SafeArea( + top: true, + child: Obx( + () => Container( + padding: EdgeInsets.only(left: 30.rpx, right: 30.rpx), + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height * 1.123, + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + margin: EdgeInsets.only(left: 40.rpx, right: 16.rpx), + width: double.infinity, + height: 90.rpx, + decoration: const BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '柔性唤醒功能', + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0, + ), + ), + Container( + + // height: + // MediaQuery.sizeOf(context).height * + // 0.04, + child: FlutterSwitch( + width: 70.rpx, + height: 36.rpx, + toggleSize: 30.rpx, + activeColor: Color(0XFF6BFDAC), + inactiveColor: Color(0XFF003058), + toggleColor: Color(0xFF011D33), + value: controller.model.smysIsStart, + onToggle: (val) { + controller.attr.update((getmodel) { + getmodel.model.smysIsStart = val; + }); + }, + )), + // Container( + // height: + // MediaQuery.sizeOf(context).height * 0.04, + // child: Switch.adaptive( + // value: controller.model.rxhxIsStart, + // onChanged: (newValue) async { + // controller.attr.update((getmodel) { + // getmodel.model.rxhxIsStart = newValue; + // }); + // }, + // activeTrackColor: const Color(0xFFD3B684), + // inactiveTrackColor: const Color(0xFF0A1562), + // inactiveThumbColor: const Color(0xFF182B7C), + // trackOutlineWidth: MaterialStateProperty + // .resolveWith( + // (Set states) { + // if (states + // .contains(MaterialState.disabled)) { + // return null; + // } + // return null; // Use the default width. + // }), + // ), + // ), + ], + ), + ), + getLine(), + Container( + margin: EdgeInsets.only(left: 40.rpx, right: 30.rpx), + width: double.infinity, + height: 90.rpx, + decoration: const BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '唤醒时间', + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0, + ), + ), + InkWell( + onTap: () async { + showDayTimeSelectionDialog(context, + dayTimeArr: controller.model.rxhxWakeTime, + title: "唤醒时间", checkChange: (d) { + controller.attr.update((getmodel) { + getmodel.model.rxhxWakeTime = [ + int.parse("${d[0]}"), + int.parse("${d[1]}") + ]; + }); + print("$d"); + }); + }, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Text( + "${controller.model.rxhxWakeTimeToString}", + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0, + ), + ), + SizedBox( + width: 16.rpx, + ), + Container( + height: 30.rpx, + width: 30.rpx, + child: SvgPicture.asset( + 'assets/img/icon/expand_more.svg', + color: Colors.white, + )) + ], + ), + ), + ], + ), + ), + getLine(), + Container( + margin: EdgeInsets.only(left: 40.rpx, right: 30.rpx), + width: double.infinity, + height: 90.rpx, + decoration: const BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '按摩', + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0, + ), + ), + InkWell( + onTap: () { + showOneSelectionDialog( + context, + arr: ['开', "关"], + checkIndex: + controller.model.rxhxIsAnMo ? 0 : 1, + title: "按摩", + checkChange: (index) { + controller.attr.update((getmodel) { + getmodel.model.rxhxIsAnMo = + index == 0 ? true : false; + }); + }, + ); + }, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Text( + controller.model.rxhxIsAnMo ? '开' : '关', + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0, + ), + ), + SizedBox( + width: 16.rpx, + ), + Container( + height: 30.rpx, + width: 30.rpx, + child: SvgPicture.asset( + 'assets/img/icon/expand_more.svg', + color: Colors.white, + )) + ], + ), + ), + ], + ), + ), + getLine(), + Container( + margin: EdgeInsets.only(left: 40.rpx, right: 30.rpx), + width: double.infinity, + height: 90.rpx, + decoration: const BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '唤醒部位', + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0, + ), + ), + InkWell( + onTap: () { + showOneSelectionDialog( + context, + arr: location, + checkIndex: controller.model.rxhxLocation, + title: "唤醒部位", + checkChange: (index) { + controller.attr.update((getmodel) { + getmodel.model.rxhxLocation = index; + }); + }, + ); + }, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Text( + location[controller.model.rxhxLocation], + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0, + ), + ), + SizedBox( + width: 16.rpx, + ), + Container( + height: 30.rpx, + width: 30.rpx, + child: SvgPicture.asset( + 'assets/img/icon/expand_more.svg', + color: Colors.white, + )) + ], + ), + ), + ], + ), + ), + getLine(), + Container( + margin: EdgeInsets.only( + top: 30.rpx, + bottom: 30.rpx, + left: 40.rpx, + right: 30.rpx), + width: double.infinity, + decoration: const BoxDecoration(), + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '自定义', + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0, + ), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 0, 20.rpx, 0, 0), + child: Container( + width: double.infinity, + height: + MediaQuery.sizeOf(context).height * 0.046, + decoration: const BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + ...List.generate(7, (index) { + return InkWell( + onTap: () { + controller.attr.update((getmodel) { + getmodel.model + .rxhxWeeks[index] = getmodel + .model + .rxhxWeeks[index] == + 0 + ? 1 + : 0; + }); + }, + child: AspectRatio( + aspectRatio: 1, + child: ClipOval( + child: Container( + height: double.infinity, + decoration: BoxDecoration( + color: controller.model + .rxhxWeeks[ + index] == + 1 + ? Color(0xFF84F5FF) + : Color(0XFF003058)), + child: Center( + child: Text( + weeks[index], + style: const TextStyle( + color: Colors.white), + ), + ), + ), + ), + ), + ); + }), + ], + ), + ), + ), + ], + ), + ), + getLine(), + SizedBox( + height: 30.rpx, + ), + Container( + margin: EdgeInsets.only(left: 26.rpx, right: 26.rpx), + width: double.infinity, + decoration: const BoxDecoration(), + child: Text( + '*注:开启该功能后,在设置的时间点,设备将启动一段固定时长的柔性唤醒功能。', + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 20.rpx, + letterSpacing: 0, + ), + ), + ), + Spacer(), + Padding( + padding: EdgeInsets.only(bottom: 85.rpx), + child: CustomCard( + borderRadius: 16.rpx, + gradientDirection: GradientDirection.vertical, + onTap: () {}, + colors: const [ + Color(0xFFFCFCFC), + Color(0xFFF8FAF9), + Color(0XFFECF6F3), + Color(0XFFD9F0E9), + Color(0xFFCEECE3) + ], + child: Container( + width: double.infinity, + height: 90.rpx, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6), + ), + child: Text("完成", + style: TextStyle( + color: const Color(0xFF003058), + fontSize: 26.rpx)), + ), + )) + ], + ), + ), + ), + ), + ), + )), + ); + } +} diff --git a/lib/routers/mh_routers.dart b/lib/routers/mh_routers.dart index d4e997f..15d2e78 100644 --- a/lib/routers/mh_routers.dart +++ b/lib/routers/mh_routers.dart @@ -1,8 +1,10 @@ import 'package:ef/ef.dart'; import 'package:flutter/cupertino.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; +import 'package:vbvs_app/main.dart'; import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart'; import 'package:vbvs_app/pages/mh_page/HomeDeviceType.dart'; import 'package:vbvs_app/pages/mh_page/LanguagePage.dart'; @@ -16,8 +18,10 @@ import 'package:vbvs_app/pages/mh_page/device/mht_blueteeth_device_page.dart'; import 'package:vbvs_app/pages/mh_page/device/mht_device_calibration.dart'; import 'package:vbvs_app/pages/mh_page/device/mht_wifi_page.dart'; import 'package:vbvs_app/pages/mh_page/device_list.dart'; +import 'package:vbvs_app/pages/mh_page/device_people_info.dart'; import 'package:vbvs_app/pages/mh_page/device_share_page.dart'; import 'package:vbvs_app/pages/mh_page/edit_bed.dart'; +import 'package:vbvs_app/pages/mh_page/help/article.dart'; import 'package:vbvs_app/pages/mh_page/user/page/edit_userinfo_page.dart'; import 'package:vbvs_app/pages/mh_page/experience_store_page.dart'; import 'package:vbvs_app/pages/mh_page/issue_list_page.dart'; @@ -31,8 +35,10 @@ import 'package:vbvs_app/pages/mh_page/sleep_habit.dart'; import 'package:vbvs_app/pages/mh_page/smys.dart'; import 'package:vbvs_app/pages/mh_page/user/page/find_password_page.dart'; import 'package:vbvs_app/pages/mh_page/user/page/mht_login_page.dart'; +import 'package:vbvs_app/pages/mh_page/user/page/rxhx_mht.dart'; import 'package:vbvs_app/pages/mh_page/user/page/update_password_page.dart'; import 'package:vbvs_app/pages/sleep_report/new_sleep_report_page.dart'; +import '../pages/mh_page/bluetooth.dart'; import '../pages/mh_page/edit_address_page.dart'; import '../pages/mh_page/message_page.dart'; import '../pages/mh_page/new_settingPage.dart'; @@ -43,7 +49,9 @@ var mhroutes = { "/mianPageBottomChange": (contxt) => MainPageBBottomChange(), "/homeDeviceType": (contxt) => HomeDeviceType(), "/editUserInfoPage": (contxt) => EditUserPage(), - "/peopleInfoPage": (contxt) => PeopleInfoPage(), + "/peopleInfoPage": (contxt, {arguments}) => PeopleInfoPage( + data: arguments, + ), "/repairHistoryListPage": (contxt) => RepairHistoryListPage(), "/deviceRepairPage": (contxt) => DeviceRepairPage(), "/settingPage": (contxt) => SettingPage(), @@ -52,8 +60,9 @@ var mhroutes = { "/addressListPage": (contxt) => AddressListPage(), "/editAddressPage": (contxt) => EditAddressPage(), "/languagePage": (context) => LanguagePage(), - // '/bluetoothPage': (context) => BluetoothPage(), - // "/devicePeopleInfo": (context) => DevicePeopleInfo(), + '/bluetoothPage': (context, {arguments}) => BluetoothPage(data: arguments), + "/devicePeopleInfo": (context, {arguments}) => + DevicePeopleInfo(data: arguments), "/sleepHabitPage": (context) => SleepHabitPage(), '/syms': (context) => Smys(), "/applyRepairPage": (context) => ApplyRepairPage(), @@ -79,6 +88,8 @@ var mhroutes = { "/bindDeviceSuccess": (contxt) => MHTBindDeviceSuccess(), "/newSleepReportPage": (contxt, {arguments}) => NewSleepReportPage(data: arguments), + "/rxhxMht": (context) => RxhxMht(), + "/helpArticle": (contxt, {arguments}) => HelpArticle(article: arguments), }; var mhonGenerateRoute = (RouteSettings settings) { final String? name = settings.name; // 获取路由名称,如 /news 或 /search