diff --git a/assets/mhlangs/en_US.json b/assets/mhlangs/en_US.json index cc415b4..8b2b780 100644 --- a/assets/mhlangs/en_US.json +++ b/assets/mhlangs/en_US.json @@ -634,5 +634,9 @@ "正常心率窦性图": "Normal Sinus Rhythm Chart", "窦性心律不齐图": "Sinus Arrhythmia Chart", "持续性房颤图": " Continuous Ventricular Flutter Chart", - "阵法性房颤图": " Arrhythmia Chart" + "阵法性房颤图": " Arrhythmia Chart", + "选择城市": "Select City", + "请选择城市": "city", + "输入关键词": "Enter keywords", + "输入国家、省份或城市": "Enter country, province, or city" } \ No newline at end of file diff --git a/assets/mhlangs/zh_CN.json b/assets/mhlangs/zh_CN.json index 57e584d..b84e334 100644 --- a/assets/mhlangs/zh_CN.json +++ b/assets/mhlangs/zh_CN.json @@ -641,5 +641,9 @@ "正常心率窦性图": "正常心率窦性图", "窦性心律不齐图": "窦性心律不齐图", "持续性房颤图": "持续性房颤图", - "阵法性房颤图": "阵法性房颤图" + "阵法性房颤图": "阵法性房颤图", + "选择城市": "选择城市", + "请选择城市": "请选择城市", + "输入关键词": "输入关键词", + "输入国家、省份或城市": "输入国家、省份或城市" } \ No newline at end of file diff --git a/assets/mhlangs/zh_TW.json b/assets/mhlangs/zh_TW.json index ba5ad90..ba6847c 100644 --- a/assets/mhlangs/zh_TW.json +++ b/assets/mhlangs/zh_TW.json @@ -634,5 +634,9 @@ "正常心率窦性图": "正常心率竇性圖", "窦性心律不齐图": "竇性心律不齊圖", "持续性房颤图": "持續性房顫圖", - "阵法性房颤图": "陣法性房顫圖" + "阵法性房颤图": "陣法性房顫圖", + "选择城市": "選擇城市", + "请选择城市": "請選擇城市", + "输入关键词": "輸入關鍵詞", + "输入国家、省份或城市": "輸入國家、省份或城市" } \ No newline at end of file diff --git a/lib/controller/mh_controller/bedController.dart b/lib/controller/mh_controller/bedController.dart index 74e36af..a323985 100644 --- a/lib/controller/mh_controller/bedController.dart +++ b/lib/controller/mh_controller/bedController.dart @@ -1,8 +1,3 @@ -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'; @@ -65,154 +60,4 @@ class BedController extends GetControllerEx { 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/people_info_controller.dart b/lib/controller/mh_controller/people_info_controller.dart index 52d5b73..cabea99 100644 --- a/lib/controller/mh_controller/people_info_controller.dart +++ b/lib/controller/mh_controller/people_info_controller.dart @@ -1,6 +1,7 @@ +import 'dart:async'; import 'dart:ui'; - import 'package:EasyDartModule/EasyDartModule.dart'; +import 'package:EasyDartModule/EasyDartModule.dart'; import 'package:ef/ef.dart'; import 'package:flutter/src/widgets/framework.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; @@ -10,7 +11,9 @@ import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; import 'package:vbvs_app/common/pojo/city.dart'; import 'package:vbvs_app/common/util/DailyLogUtils.dart'; +import 'package:vbvs_app/common/util/EventBus.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/eventType.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/enum/APPPackageType.dart'; @@ -53,17 +56,26 @@ class PeopleInfoController extends GetControllerEx { final CityModelController cityController = Get.find(); RxList diseaseList = [].obs; - @override Future onInit() async { super.onInit(); cityDataFuture = cityController.loadAndSetCityData().then((success) { return cityController.cityList; }); + // 监听切换语言 + subscription = EventBus().on().listen((event) async { + final CityModelController cityController = + Get.find(); + ef.log("切换语言事件通知:${event.language}"); + cityController.cityList = []; + await initializeCityData(); + }); } late Future> cityDataFuture; + late StreamSubscription subscription; + getPeoples(String mac) async { String serviceAddress = ServiceConstant.service_address; String serviceName = ServiceConstant.server_service; diff --git a/lib/pages/mh_page/LanguagePage.dart b/lib/pages/mh_page/LanguagePage.dart index a623c2f..edeb6d9 100644 --- a/lib/pages/mh_page/LanguagePage.dart +++ b/lib/pages/mh_page/LanguagePage.dart @@ -2,8 +2,10 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/EventBus.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/eventType.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/controller/mh_controller/mh_language_controller.dart'; import 'package:vbvs_app/controller/weather/weather_controller.dart'; @@ -122,7 +124,9 @@ class _LanguagePageState extends State { lang.selected = (lang == language); // 根据选择更新状态 } - + EventBus().emit( + SwitchLanguageEvent(language + .language_code)); await AppLanguage() .loadLanguage( language.language_code, diff --git a/lib/pages/mh_page/new_settingPage.dart b/lib/pages/mh_page/new_settingPage.dart index 0433090..3a38d4f 100644 --- a/lib/pages/mh_page/new_settingPage.dart +++ b/lib/pages/mh_page/new_settingPage.dart @@ -253,7 +253,7 @@ class _SettingPageState extends State { ), ].divide(SizedBox(width: 22.rpx)), ), - Text('SWES2025.10.31', + Text('SWES2025.12.17', style: TextStyle( color: Colors.white, fontSize: 26.rpx, diff --git a/lib/pages/mh_page/people_info.dart b/lib/pages/mh_page/people_info.dart index f6da9d0..f32652c 100644 --- a/lib/pages/mh_page/people_info.dart +++ b/lib/pages/mh_page/people_info.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/color/app_uri_status.dart'; import 'package:vbvs_app/common/pojo/city.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; @@ -15,6 +16,7 @@ import 'package:vbvs_app/pages/common/selectDialog.dart'; import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart'; import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart'; import 'package:vbvs_app/pages/person/select_city.dart'; +import 'package:vbvs_app/pages/person/select_disease.dart'; //更新人员信息 class PeopleInfoPage extends GetView { @@ -31,9 +33,26 @@ class PeopleInfoPage extends GetView { PeopleInfoController controller = Get.put(PeopleInfoController()); + final CityModelController cityController = Get.find(); + @override Widget build(BuildContext context) { - getPersonData(); + controller.getDiseaseData().then((apiResponse) { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (apiResponse.code != HttpStatusCodes.ok) { + TopSlideNotification.show( + context, + text: apiResponse.msg ?? '', + textColor: themeController.currentColor.sc9, + ); + } + }); + }); + getPersonData(); + + controller.cityDataFuture = cityController.loadAndSetCityData().then((success) { + return cityController.cityList; + }); return LayoutBuilder( builder: (context, boxConstraints) => GestureDetector( onTap: () { @@ -931,6 +950,242 @@ class PeopleInfoPage extends GetView { ), ), getLine(), + // Container( + // height: 90.rpx, + // margin: EdgeInsets.only( + // left: 40.rpx, right: 35.rpx), + // child: InkWell( + // onTap: () { + // // if (widget.status == + // // BindType.share.code) { + // // TopSlideNotification.show( + // // context, + // // text: "被分享用户只能修改用户名称", + // // textColor: + // // themeController + // // .currentColor + // // .sc9); + // // return; + // // } + // FocusScope.of(context) + // .requestFocus( + // FocusNode()); + // Future.delayed( + // Duration( + // milliseconds: 250), + // () { + // // 使用当前选中的城市数据,如果没有则创建默认 + // CityModel? currentCity; + // if (controller + // .model + // .cityModels + // .isNotEmpty && + // index < + // controller + // .model + // .cityModels + // .length) { + // currentCity = controller + // .model + // .cityModels[index]; + // } else { + // currentCity = CityModel(); + // } + + // showCitySelectionDialog( + // context, + // selectedCity: currentCity, + // onCityChanged: + // (CityModel newCity) { + // final list = controller + // .model.cityModels; + // if (index < + // list.length) { + // // 替换 + // list[index] = newCity; + // } else { + // // 补齐并追加 + // list.add(newCity); + // } + // controller.model + // .peopleList[ + // index]['UTC'] = + // list[index].UTC; + // controller.model + // .peopleList[ + // index] + // ['city_id'] = list[ + // index] + // .id; + // controller.updateAll(); + // }, + + // title: "选择城市".tr, + // cityDataFuture: controller + // .cityDataFuture, // 传入预加载的数据 + // colors: + // CitySelectionColors( + // pickerBackgroundColor: + // stringToColor( + // "#003058"), + // confirmTextColor: + // stringToColor( + // "#84F5FF"), + // selectedCityColor: + // stringToColor( + // "#84F5FF"), + // ), + // ); + // }); + // }, + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment + // .spaceBetween, + // children: [ + // Text( + // '慢病管理'.tr, + // style: TextStyle( + // fontFamily: + // 'Readex Pro', + // color: + // Color(0xFF9EA4B7), + // fontSize: 30.rpx, + // letterSpacing: 0, + // ), + // ), + // Text( + // getCityModel(index) != + // null + // ? MyUtils + // .getDetailedCityDisplayText( + // getCityModel( + // index)) + // : "请选择城市".tr, + // style: TextStyle( + // color: getCityModel( + // index) != + // null + // ? themeController + // .currentColor + // .sc3 + // : themeController + // .currentColor + // .sc4, + // fontSize: AppConstants() + // .title_text_fontSize, + // ), + // ), + // ], + // ), + // ), + // ), + + Container( + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, right: 35.rpx), + child: InkWell( + onTap: () { + FocusScope.of(context) + .requestFocus( + FocusNode()); + Future.delayed( + Duration( + milliseconds: 250), + () { + // 获取当前已选择的慢病ID列表 + final currentDiseaseIds = List< + String>.from(controller + .model + .peopleList[ + index] + ['disease_ids'] ?? + []); + + showDiseaseSelectionDialog( + context, + selectedIds: + currentDiseaseIds, + onDiseasesChanged: + (List + newDiseaseIds) { + // 更新模型数据 + controller.model.peopleList[ + index][ + 'disease_ids'] = + newDiseaseIds; + controller.updateAll(); + }, + title: "选择慢病".tr, + colors: + DiseaseSelectionColors( + pickerBackgroundColor: + stringToColor( + "#003058"), + confirmTextColor: + stringToColor( + "#84F5FF"), + selectedDiseaseColor: + stringToColor( + "#84F5FF"), + ), + diseaseList: controller + .diseaseList, + ); + }); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '慢病管理'.tr, + style: TextStyle( + fontFamily: + 'Readex Pro', + color: + Color(0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + Obx(() { + final selectedIds = controller + .model + .peopleList[ + index] + ['disease_ids'] ?? + []; + final diseases = + controller + .diseaseList; + + return Text( + getSelectedDiseaseNames( + diseases, + List.from( + selectedIds)), + style: TextStyle( + color: selectedIds + .isNotEmpty + ? themeController + .currentColor + .sc3 + : themeController + .currentColor + .sc4, + fontSize: AppConstants() + .title_text_fontSize, + ), + ); + }), + ], + ), + ), + ), + getLine(), ], ), ) diff --git a/lib/pages/person/select_city.dart b/lib/pages/person/select_city.dart index f967cee..a41f96b 100644 --- a/lib/pages/person/select_city.dart +++ b/lib/pages/person/select_city.dart @@ -40,9 +40,9 @@ Future> loadCityData() async { // 定义城市选择器颜色配置 class CitySelectionColors { final Color? pickerBackgroundColor; // 选择器整体背景色 - final Color? confirmTextColor; // 确定按钮文字颜色 - final Color? selectedCityColor; // 选中的城市背景色 - + final Color? confirmTextColor; // 确定按钮文字颜色 + final Color? selectedCityColor; // 选中的城市背景色 + const CitySelectionColors({ this.pickerBackgroundColor, this.confirmTextColor, @@ -59,12 +59,15 @@ Future showCitySelectionDialog( CitySelectionColors? colors, // 新增:颜色配置参数 }) { ThemeController themeController = Get.find(); - final bool isChinese = Get.locale?.languageCode == 'zh' ?? true; + final bool isChinese = Get.locale?.languageCode == 'zh_CN' ?? true; // 使用传入的颜色,如果没传则使用主题颜色 - final Color pickerBackgroundColor = colors?.pickerBackgroundColor ?? themeController.currentColor.sc17; - final Color confirmTextColor = colors?.confirmTextColor ?? themeController.currentColor.sc2; - final Color selectedCityColor = colors?.selectedCityColor ?? themeController.currentColor.sc2; + final Color pickerBackgroundColor = + colors?.pickerBackgroundColor ?? themeController.currentColor.sc17; + final Color confirmTextColor = + colors?.confirmTextColor ?? themeController.currentColor.sc2; + final Color selectedCityColor = + colors?.selectedCityColor ?? themeController.currentColor.sc2; final RxList countries = [].obs; final RxList provinces = [].obs; @@ -263,7 +266,7 @@ Future showCitySelectionDialog( // 数据加载中 if (snapshot.connectionState == ConnectionState.waiting) { return _buildLoadingBottomSheet( - themeController, + themeController, pickerBackgroundColor, confirmTextColor, ); @@ -272,8 +275,8 @@ Future showCitySelectionDialog( // 数据加载错误 if (snapshot.hasError || !snapshot.hasData) { return _buildErrorBottomSheet( - themeController, - context, + themeController, + context, pickerBackgroundColor, confirmTextColor, ); @@ -282,9 +285,10 @@ Future showCitySelectionDialog( final cityData = snapshot.data!; // 只在第一次初始化数据 - if (countries.isEmpty) { - initializePickerData(cityData); - } + // if (countries.isEmpty) { + + // } + initializePickerData(cityData); return _buildCityPickerContent( context, @@ -796,4 +800,4 @@ Widget _buildErrorBottomSheet( ], ), ); -} \ No newline at end of file +}