From c21896a4080d140b0eb6f5fdd6a205852cbc2d1e Mon Sep 17 00:00:00 2001 From: wyf <494641114@qq.com> Date: Sun, 22 Jun 2025 19:10:47 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/mht_home_controller.dart | 67 ++++++++++++++++++- lib/pages/mh_page/test/WebviewTestModel.dart | 27 +++++--- 2 files changed, 85 insertions(+), 9 deletions(-) diff --git a/lib/pages/mh_page/homepage/controller/mht_home_controller.dart b/lib/pages/mh_page/homepage/controller/mht_home_controller.dart index 334c6c3..64ad167 100644 --- a/lib/pages/mh_page/homepage/controller/mht_home_controller.dart +++ b/lib/pages/mh_page/homepage/controller/mht_home_controller.dart @@ -39,6 +39,7 @@ class MHTHomeController extends GetControllerEx { RxInt bindDeviceNum = 0.obs; //设备数量 RxMap deviceList = {}.obs; //设备列表 + RxList deviceListForWeb = [].obs; //h5设备列表 RxMap> sleepReportData = >{}.obs; //睡眠报告 RxList personnelList = [].obs; //人员信息列表 @@ -49,12 +50,13 @@ class MHTHomeController extends GetControllerEx { var sleepDays = [].obs; var homeSleepDays = [].obs; - var selectedDayIndex = (6).obs; var selectDevcie = ''.obs; var selectPerson = {}.obs; + bool initDeviceFlag = false; + Future getDeviceNum() async { try { ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr); @@ -159,6 +161,68 @@ class MHTHomeController extends GetControllerEx { return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement } + Future getDeviceListForWeb( + {String? key, String? group, int? bindType}) async { + try { + ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr); + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.device_list; + + // 初始URL + String queryUrl = "$serviceAddress$serviceName$serviceApi"; + + // 用Map统一管理query参数 + Map queryParams = {}; + + if (key != null && key.isNotEmpty) { + queryParams['key'] = key; + } + + if (group != null && group.isNotEmpty) { + queryParams['group'] = group; + } + + if (bindType != null) { + queryParams['bindType'] = bindType.toString(); + } + + String? language = ""; + if (languageController.selectLanguage != null) { + language = languageController.selectLanguage.value!.language_code; + } + if (language != null && language.isNotEmpty) { + queryParams['lang'] = language; + } + + // 拼接完整URL + if (queryParams.isNotEmpty) { + queryUrl += '?' + Uri(queryParameters: queryParams).query; + } + + var response = await EasyDartModule.dio.get(queryUrl); + if (response != null) { + var responseData = + response.data is String ? jsonDecode(response.data) : response.data; + ApiResponse res = + ApiResponse.fromJson(responseData, (object) => object); + MyUtils.formatResponse(res, "设备.设备列表请求成功".tr, "设备.设备列表请求失败".tr); + if (res.code == HttpStatusCodes.ok) { + deviceListForWeb.value = res.data!; + updateAll(); + return res; + } + } else { + return ApiResponse(code: -1, msg: "服务器.失败".tr); + } + return apiResponse; + } catch (e) { + EasyDartModule.logger.info("设备请求列表: $e"); + DailyLogUtils.writeLog("设备请求列表: $e"); + } + return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement + } + Future deleteDevice(Map device) async { try { ApiResponse apiResponse = ApiResponse(code: -1, msg: "请求失败".tr); @@ -428,6 +492,7 @@ class MHTHomeController extends GetControllerEx { }, ); } + Future getHomeSleeps(String? mac) async { String serviceAddress = ServiceConstant.service_address; String serviceName = ServiceConstant.server_service; diff --git a/lib/pages/mh_page/test/WebviewTestModel.dart b/lib/pages/mh_page/test/WebviewTestModel.dart index f78c609..1010092 100644 --- a/lib/pages/mh_page/test/WebviewTestModel.dart +++ b/lib/pages/mh_page/test/WebviewTestModel.dart @@ -6,6 +6,7 @@ import 'package:easydevice/easydevice.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart'; +import 'package:vbvs_app/pages/mh_page/room_picker.dart'; class WebviewTestModel { WebviewTestModel(); @@ -16,14 +17,14 @@ class WebviewTestModel { } class WebviewTestController extends GetControllerEx { - var selectDevice; - var bluetooth = false; + var selectDevice = {}; + var bluetooth = 0; WebviewTestController() : super(WebviewTestModel()) { web = WebviewHelper( jsbridge: buildsdk( father: this, - // clientId: '494641114', - //dbgserverUrl: 'ws://192.168.1.2:9001', + clientId: '494641114', + // dbgserverUrl: 'ws://192.168.1.2:9001', ), settings: buildsettings(), params: PlatformHeadlessInAppWebViewCreationParams( @@ -46,19 +47,29 @@ class WebviewTestController extends GetControllerEx { bridge.sdk.updateDeviceRoute((args) async { ef.log('updateDeviceRoute: $args'); selectDevice['blueToothStatus'] = bluetooth; - Get.toNamed("$args[0]", arguments: selectDevice); + Get.toNamed("${args[0]}", arguments: selectDevice); return true; }); - bridge.sdk.selectDevice((args) { + bridge.sdk.selectDevice((args) async { ef.log('selectDevice: $args'); selectDevice = args[0]; return true; }); - bridge.sdk.updateBlueToothStatus((args) { + bridge.sdk.updateBlueToothStatus((args) async { ef.log('updateBlueToothStatus: $args'); bluetooth = args[0]; return true; }); + //sdk定义接口 + bridge.sdk.querySelectDevice((args) async { + ef.log('updateBlueToothStatus: $args'); + // bluetooth = args[0]; + MHTHomeController deviceController = Get.find(); + final allDevices = deviceController.deviceList.values + .expand((list) => list) + .toList(); + return allDevices; + }); }); web //.file( @@ -90,7 +101,7 @@ class WebviewTestView extends GetComponent { Widget build(BuildContext context) { UserInfoController userInfoController = Get.find(); MHTHomeController deviceController = Get.find(); - deviceController.getDeviceList(group: 'room').then((x) { + deviceController.getDeviceList().then((x) { if (controller.web.jsbridge!.inited) { //发送测试消息给webview controller.web.jsbridge!.dart From 1522f2e4c95be405f24cd0a2dcff90b57d1388e1 Mon Sep 17 00:00:00 2001 From: czz <862977248@qq.com> Date: Tue, 24 Jun 2025 15:38:18 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E8=A7=A3=E7=BB=91=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/img/icon/xiaoyi.svg | 1 + assets/mhlangs/zh_CN.json | 5 +- .../mh_controller/device_list_controller.dart | 33 +- .../mhdevice_share_controller.dart | 172 +++++----- .../mhdevice_share_controller.g.dart | 4 +- .../device_bind/componnet/bind_dialog.dart | 232 ++++++++++++++ lib/pages/mh_page/LanguagePage.dart | 24 +- lib/pages/mh_page/bluetooth.dart | 69 +++- .../mh_page/component/mht_bind_dialog.dart | 2 + lib/pages/mh_page/device/device.dart | 12 +- lib/pages/mh_page/device_people_info.dart | 19 +- lib/pages/mh_page/device_share_page.dart | 243 ++------------- lib/pages/mh_page/help/article.dart | 294 +++++++++++------- lib/pages/mh_page/issue_preview_widget.dart | 12 +- lib/pages/mh_page/new_mine_page.dart | 2 +- lib/pages/mh_page/searchWidget.dart | 51 +-- lib/routers/mh_routers.dart | 3 +- 17 files changed, 706 insertions(+), 472 deletions(-) create mode 100644 assets/img/icon/xiaoyi.svg diff --git a/assets/img/icon/xiaoyi.svg b/assets/img/icon/xiaoyi.svg new file mode 100644 index 0000000..1f4d468 --- /dev/null +++ b/assets/img/icon/xiaoyi.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/mhlangs/zh_CN.json b/assets/mhlangs/zh_CN.json index a2bee32..23bd1d3 100644 --- a/assets/mhlangs/zh_CN.json +++ b/assets/mhlangs/zh_CN.json @@ -171,5 +171,8 @@ "用户协议": "用户协议", "隐私协议": "隐私协议", "退出登录": "退出登录", - "注销账号": "注销账号" + "注销账号": "注销账号", + "我的智能设备":"我的智能设备", + "解绑成功": "解绑成功", + "解绑失败": "解绑失败" } \ No newline at end of file diff --git a/lib/controller/mh_controller/device_list_controller.dart b/lib/controller/mh_controller/device_list_controller.dart index 17e523a..3d7e91e 100644 --- a/lib/controller/mh_controller/device_list_controller.dart +++ b/lib/controller/mh_controller/device_list_controller.dart @@ -8,6 +8,7 @@ import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; import 'package:vbvs_app/common/util/DailyLogUtils.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/controller/mh_controller/device.dart'; import 'package:vbvs_app/model/api_response.dart'; @@ -19,7 +20,6 @@ class DeviceListModel { //设备列表 List deviceList = []; - @JsonKey(ignore: true) String? keyword; @JsonKey(ignore: true) @@ -70,4 +70,35 @@ class DeviceListController extends GetControllerEx { } return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement } + +//解绑设备 + Future unbindDevice(Map device) async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.device_bind; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}"; + String msg = ''; + int type = device['bind_type']; + await requestWithLog( + logTitle: '解绑设备', + method: MyHttpMethod.delete, + queryUrl: queryUrl, + data: {"mac": device['mac'], "uid": device['uid']}, + onSuccess: (res) { + if (type == 1) { + msg = '解绑成功'.tr; + } else { + msg = '删除成功'.tr; + } + }, + onFailure: (res) { + if (type == 1) { + msg = '解绑失败'.tr; + } else { + msg = '删除失败'.tr; + } + }, + ); + return msg; + } } diff --git a/lib/controller/mh_controller/mhdevice_share_controller.dart b/lib/controller/mh_controller/mhdevice_share_controller.dart index 0dd2c41..40f1e9d 100644 --- a/lib/controller/mh_controller/mhdevice_share_controller.dart +++ b/lib/controller/mh_controller/mhdevice_share_controller.dart @@ -1,19 +1,28 @@ +import 'dart:convert'; + +import 'package:EasyDartModule/EasyDartModule.dart'; import 'package:dio/dio.dart'; import 'package:dio/src/form_data.dart' as formdata; 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/color/app_uri_status.dart'; +import 'package:vbvs_app/common/util/DailyLogUtils.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; +import 'package:vbvs_app/model/api_response.dart'; part 'mhdevice_share_controller.g.dart'; @JsonSerializable() class MHDeviceShareModel { - String? phone; + String? account; int? type = 1; String? msg; int? show = 0; - + int? code = 0; int limit = AppConstants.limit; int offset = 0; bool isLoading = false; @@ -37,86 +46,91 @@ class MHDeviceShareController extends GetControllerEx { attr = GetModel(MHDeviceShareModel()).obs; } + // RxString account = "".obs; + // RxString msg = "".obs; + // RxInt code = 0.obs; @override - void onInit() { + Future onInit() async { super.onInit(); - model.shareUser = [ - { - 'userName': '张三', - 'opType': 1, // 允许控制 - }, - { - 'userName': '李四', - 'opType': 2, // 仅查看 - }, - { - 'userName': '王五', - 'opType': 1, - }, - ]; - update(); // 刷新UI + await shareDeviceList(Get.arguments["mac"]); } - // Future sendInvite(String? phone, String mac) async { - // if (phone == null || phone.isEmpty) { - // return "手机号不能为空"; - // } - // if (!MyUtils.isValidPhoneNumber(phone)) { - // return "手机号格式不正确"; - // } - // var type = model.type; - // try { - // var aa = await ApiService.requestNoInfo.post("/api/device/info/share", - // data: formdata.FormData.fromMap( - // {"mac": mac, "tel": phone, "type": type})); - // return ""; - // } catch (e) { - // if (e is DioError) { - // // 返回 DioError 的 message 属性 - // return e.message!; - // } else { - // // 处理其他类型的错误 - // return e.toString(); - // } - // } - // } + Future shareDevice(String mac) async { + ApiResponse apiResponse = ApiResponse(code: -1, msg: "请求失败".tr); + EasyDartModule.logger.info("分享设备"); + DailyLogUtils.writeLog("分享设备"); + try { + model.account = model.account!.trim(); + if (model.account == null || model.account!.isEmpty) { + apiResponse.msg = "请输入手机号".tr; + return apiResponse; + } + if (!MyUtils.isValidPhoneNumber(model.account!) && + !MyUtils.isValidEmail(model.account!)) { + apiResponse.msg = '请输入正确的手机号'.tr; + return apiResponse; + } + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.device_share; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}"; + String? language = ""; + if (languageController.selectLanguage != null) { + language = languageController.selectLanguage.value!.language_code; + } + if (language != null && language.isNotEmpty) { + if (queryUrl.contains("?")) { + queryUrl += "&lang=$language"; + } else { + queryUrl += "?lang=$language"; + } + } + var data = {"type": model.type, "userName": model.account, "mac": mac}; + var response = + await EasyDartModule.dio.post(queryUrl, data: jsonEncode(data)); + if (response != null) { + var responseData = + response.data is String ? jsonDecode(response.data) : response.data; + ApiResponse res = + ApiResponse.fromJson(responseData, (object) => object); + if (res.code != HttpStatusCodes.ok) { + if (res.msg == null || res.msg!.isEmpty) { + res.msg = apiResponse.msg; + } + } else { + if (res.msg == null || res.msg!.isEmpty) { + res.msg = "操作成功".tr; + } + } + if (res.code != HttpStatusCodes.ok) { + model.msg = res.msg!; + } + model.code = res.code!; + updateAll(); + return res; + } else { + return ApiResponse(code: -1, msg: "服务器.失败".tr); + } + } catch (e) { + EasyDartModule.logger.info("分享设备失败:${e.toString()}"); + DailyLogUtils.writeLog("分享设备失败:${e.toString()}"); + return ApiResponse(code: -1, msg: "服务器.失败".tr); + } + } - // Future initData() async { - // //todo 请求分享列表 - // var deviceController = Get.find(); - // var query = { - // "mac": deviceController.model.deviceMain['mac'], - // }; - // var data = await ApiService.request - // .get("/api/device/info/share", data: formdata.FormData.fromMap(query)); - - // if (data.data["data"] != null) { - // try { - // List tmp = data.data["data"] as List; - // model.shareUser = tmp; - // } catch (e) { - // print(e); - // } - // } else { - // model.shareUser = []; - // } - // updateAll(); - // } - - // //保存 - // saveShareDevice(Map shareInfo, RxInt type) async { - // return await ApiService.request.put("/api/device/info/share", - // data: formdata.FormData.fromMap({ - // "mac": shareInfo['mac'], - // "tel": shareInfo['tel'], - // "type": type.value - // })); - // } - - // //删除 - // deleteShare(Map shareInfo) async { - // return await ApiService.request.delete("/api/device/info/share", - // data: formdata.FormData.fromMap( - // {"mac": shareInfo['mac'], "tel": shareInfo['tel']})); - // } + shareDeviceList(String mac) async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.device_share; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?mac=$mac"; + await requestWithLog( + logTitle: '分享用户列表', + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) => { + model.shareUser = res.data, + updateAll(), + }, + ); + } } diff --git a/lib/controller/mh_controller/mhdevice_share_controller.g.dart b/lib/controller/mh_controller/mhdevice_share_controller.g.dart index 454795c..9da852a 100644 --- a/lib/controller/mh_controller/mhdevice_share_controller.g.dart +++ b/lib/controller/mh_controller/mhdevice_share_controller.g.dart @@ -8,7 +8,7 @@ part of 'mhdevice_share_controller.dart'; MHDeviceShareModel _$MHDeviceShareModelFromJson(Map json) => MHDeviceShareModel() - ..phone = json['phone'] as String? + ..account = json['account'] as String? ..type = (json['type'] as num?)?.toInt() ..msg = json['msg'] as String? ..show = (json['show'] as num?)?.toInt() @@ -21,7 +21,7 @@ MHDeviceShareModel _$MHDeviceShareModelFromJson(Map json) => Map _$MHDeviceShareModelToJson(MHDeviceShareModel instance) => { - 'phone': instance.phone, + 'phone': instance.account, 'type': instance.type, 'msg': instance.msg, 'show': instance.show, diff --git a/lib/pages/device_bind/componnet/bind_dialog.dart b/lib/pages/device_bind/componnet/bind_dialog.dart index eb7856e..090182c 100644 --- a/lib/pages/device_bind/componnet/bind_dialog.dart +++ b/lib/pages/device_bind/componnet/bind_dialog.dart @@ -1128,3 +1128,235 @@ Future showUnBindTipDialog( }, ); } + +Future showUnbindConfirmDialog({ + required BuildContext context, + required VoidCallback onConfirm, + required VoidCallback onCancel, + required String title, +}) async { + await showDialog( + context: context, + barrierDismissible: true, + builder: (BuildContext context) { + return FrostedDialog( + blurSigma: 3.0, + child: Container( + width: 520.rpx, + height: 460.rpx, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20.0), + ), + child: Padding( + padding: EdgeInsets.only( + left: 45.rpx, right: 45.rpx, top: 90.rpx, bottom: 60.rpx), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + title, + style: TextStyle( + fontSize: 30.rpx, + color: Colors.black, + ), + ), + const SizedBox(height: 12), + RichText( + textAlign: TextAlign.center, + text: TextSpan( + style: TextStyle(fontSize: 26.rpx, color: Colors.black87), + children: [ + TextSpan( + text: '该设备只可被一个用户绑定,', + style: TextStyle(fontSize: 26.rpx)), + TextSpan( + text: '解绑后', + style: TextStyle(color: Colors.red, fontSize: 26.rpx), + ), + TextSpan( + text: '其他用户才可以绑定', + style: TextStyle(fontSize: 26.rpx)), + ], + ), + ), + const SizedBox(height: 24), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + CustomCard( + gradientDirection: GradientDirection.vertical, + borderRadius: 16.rpx, + onTap: () { + Get.back(); + onCancel(); + }, + colors: [ + Color(0xFF1592AA), + Color(0XFF0C83A7), + Color(0XFF006FA3) + ], + child: Container( + width: 200.rpx, + height: 90.rpx, + alignment: Alignment.center, + child: Text( + '取消', + style: TextStyle( + fontSize: 26.rpx, color: Colors.white), + ), + )), + CustomCard( + borderRadius: 16.rpx, + onTap: () { + Get.back(); + onConfirm(); + }, + colors: [ + Color(0xFF1592AA), + Color(0XFF0C83A7), + Color(0XFF006FA3) + ], + child: Container( + width: 200.rpx, + height: 90.rpx, + alignment: Alignment.center, + child: Text( + '解绑', + style: TextStyle( + fontSize: 26.rpx, color: Colors.white), + ), + )) + // _buildButton( + // text: '解绑', + // onPressed: () { + // Navigator.pop(context); + // onConfirm(); + // }, + // isGradient: true, + // ), + ], + ) + ], + ), + ), + )); + }, + ); +} + +Future showDeleteDeviceConfirmDialog({ + required BuildContext context, + required VoidCallback onConfirm, + required VoidCallback onCancel, + required String title, +}) async { + await showDialog( + context: context, + barrierDismissible: true, + builder: (BuildContext context) { + return FrostedDialog( + blurSigma: 3.0, + child: Container( + width: 520.rpx, + height: 460.rpx, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20.0), + ), + child: Padding( + padding: EdgeInsets.only( + left: 45.rpx, right: 45.rpx, top: 90.rpx, bottom: 60.rpx), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + title, + style: TextStyle( + fontSize: 30.rpx, + color: Colors.black, + ), + ), + const SizedBox(height: 12), + RichText( + textAlign: TextAlign.center, + text: TextSpan( + style: TextStyle(fontSize: 26.rpx, color: Colors.black87), + children: [ + TextSpan( + text: '删除后,', + style: + TextStyle(color: Colors.red, fontSize: 26.rpx)), + TextSpan( + text: '该设备的历史数据将被清除', + style: TextStyle(fontSize: 26.rpx), + ), + ], + ), + ), + const SizedBox(height: 24), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + CustomCard( + gradientDirection: GradientDirection.vertical, + borderRadius: 16.rpx, + onTap: () { + Get.back(); + onCancel(); + }, + colors: [ + Color(0xFF1592AA), + Color(0XFF0C83A7), + Color(0XFF006FA3) + ], + child: Container( + width: 200.rpx, + height: 90.rpx, + alignment: Alignment.center, + child: Text( + '取消', + style: TextStyle( + fontSize: 26.rpx, color: Colors.white), + ), + )), + CustomCard( + borderRadius: 16.rpx, + onTap: () { + Get.back(); + onConfirm(); + }, + colors: [ + Color(0xFF1592AA), + Color(0XFF0C83A7), + Color(0XFF006FA3) + ], + child: Container( + width: 200.rpx, + height: 90.rpx, + alignment: Alignment.center, + child: Text( + '删除', + style: TextStyle( + fontSize: 26.rpx, color: Colors.white), + ), + )) + // _buildButton( + // text: '解绑', + // onPressed: () { + // Navigator.pop(context); + // onConfirm(); + // }, + // isGradient: true, + // ), + ], + ) + ], + ), + ), + )); + }, + ); +} diff --git a/lib/pages/mh_page/LanguagePage.dart b/lib/pages/mh_page/LanguagePage.dart index e71616e..3040719 100644 --- a/lib/pages/mh_page/LanguagePage.dart +++ b/lib/pages/mh_page/LanguagePage.dart @@ -12,16 +12,16 @@ class LanguagePage extends GetView { // } MHLanguageController controller = Get.find(); BoxConstraints? bodysize; - List languageList = [ - '简体中文', - '繁體中文', - 'English', - ]; - final Map languageMap = { - '简体中文': 'zh_CN', - '繁體中文': 'zh_TW', - 'English': 'en_US', - }; + // List languageList = [ + // '简体中文', + // '繁體中文', + // 'English', + // ]; + // final Map languageMap = { + // '简体中文': 'zh_CN', + // '繁體中文': 'zh_TW', + // 'English': 'en_US', + // }; // class _LanguagePageState extends State { RxBool checkboxValue = false.obs; @@ -56,7 +56,7 @@ class LanguagePage extends GetView { children: [ // 中间居中的标题 Text( - '切换语言', + '切换语言'.tr, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, @@ -135,7 +135,7 @@ class LanguagePage extends GetView { value: controller.selectLanguage.value?.language_code == model.language_code, onChanged: (newValue) async { - controller.selectLanguage.value = model; + controller.selectLanguage.value = model; // if (newValue!) { // selectLanguage!.value = languageMap[ // text]!; // Set selectLanguage to the current text value diff --git a/lib/pages/mh_page/bluetooth.dart b/lib/pages/mh_page/bluetooth.dart index d6f3312..ee7ced2 100644 --- a/lib/pages/mh_page/bluetooth.dart +++ b/lib/pages/mh_page/bluetooth.dart @@ -6,12 +6,16 @@ import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; +import 'package:vbvs_app/controller/mh_controller/device_list_controller.dart'; +import 'package:vbvs_app/model/api_response.dart'; +import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart'; class BluetoothPage extends GetView { Map data; BluetoothPage({required this.data}); BoxConstraints? bodysize; + DeviceListController deviceListController = Get.find(); @override Widget build(BuildContext context) { @@ -156,8 +160,44 @@ class BluetoothPage extends GetView { _buildMenuButton( context, '睡眠习惯', "/sleepHabitPage"), _buildMenuButton( - context, '分享设备', "/deviceSharePage"), - _buildMenuButton(context, '解绑', ""), + context, '分享设备', "/deviceSharePage", + arguments: data), + _buildMenuButton( + context, + data['bind_type'] == 1 ? '解绑' : '删除', + "", + onTap: () { + if (data['bind_type'] == 1) { + // 解绑弹窗 + showUnbindConfirmDialog( + context: context, + title: "是否进行解绑?", + onConfirm: () { + deviceListController + .unbindDevice(data); + // 执行解绑逻辑 + }, + onCancel: () { + // 点击取消后的逻辑 + }, + ); + } else if (data['bind_type'] == 2) { + // 删除弹窗 + showDeleteDeviceConfirmDialog( + context: context, + title: "是否进行删除?", + onConfirm: () { + deviceListController.unbindDevice( + data, + ); + }, + onCancel: () { + // 点击取消后的逻辑 + }, + ); + } + }, + ), ], ), ), @@ -168,8 +208,13 @@ class BluetoothPage extends GetView { }); } - Widget _buildMenuButton(BuildContext context, String title, String? path, - {Map? arguments}) { + Widget _buildMenuButton( + BuildContext context, + String title, + String? path, { + Map? arguments, + VoidCallback? onTap, + }) { return Padding( padding: EdgeInsets.only(bottom: 19.rpx), child: ClickableContainer( @@ -177,7 +222,21 @@ class BluetoothPage extends GetView { highlightColor: Color(0XFF055466), padding: EdgeInsets.only(left: 0), onTap: () { - if (path?.isNotEmpty == true) { + // if (path?.isNotEmpty == true) { + // if (arguments != null) { + // Get.toNamed(path!, arguments: arguments); + // } else { + // Get.toNamed(path!); + // } + // } else { + // TopSlideNotification.show( + // context, + // text: "功能开发中...", + // ); + // } + if (onTap != null) { + onTap(); // 优先执行自定义逻辑 + } else if (path?.isNotEmpty == true) { if (arguments != null) { Get.toNamed(path!, arguments: arguments); } else { diff --git a/lib/pages/mh_page/component/mht_bind_dialog.dart b/lib/pages/mh_page/component/mht_bind_dialog.dart index c03f008..ab72290 100644 --- a/lib/pages/mh_page/component/mht_bind_dialog.dart +++ b/lib/pages/mh_page/component/mht_bind_dialog.dart @@ -157,6 +157,8 @@ void showBindDoubleDialog( ); } +Future showUnBindDeviceDialog(BuildContext context) async {} + Future showHaveBindDialog(BuildContext context) async { ThemeController themeController = Get.find(); diff --git a/lib/pages/mh_page/device/device.dart b/lib/pages/mh_page/device/device.dart index 2ba275a..6bc6800 100644 --- a/lib/pages/mh_page/device/device.dart +++ b/lib/pages/mh_page/device/device.dart @@ -163,13 +163,7 @@ class DeviceInfoWidget extends GetView { Align( alignment: AlignmentDirectional(-1, 0), child: Text( - '设备状态:' + - (deviceListController - .model - .deviceList[index]["status"] - ?["status"] - ?.toString() ?? - ''), + '设备状态:${(deviceListController.model.deviceList[index]["status"]?["status"]) == 1 ? '在线' : '离线'}', style: TextStyle( fontFamily: 'Readex Pro', color: Color(0xFFC8CBD2), @@ -239,7 +233,9 @@ class DeviceInfoWidget extends GetView { children: [ InkWell( onTap: () async { - await Get.toNamed("/deviceSharePage"); + await Get.toNamed("/deviceSharePage", + arguments: deviceListController + .model.deviceList[index]); // if (device['type'] == 1) { // globalController.model.deviceMain = device; // await Get.toNamed("/deviceSharePage"); diff --git a/lib/pages/mh_page/device_people_info.dart b/lib/pages/mh_page/device_people_info.dart index f3b971c..605b8e4 100644 --- a/lib/pages/mh_page/device_people_info.dart +++ b/lib/pages/mh_page/device_people_info.dart @@ -146,13 +146,13 @@ class DevicePeopleInfo extends GetView { ...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 ? '左侧' : '右侧'; - } + // String location_ = ''; + // if ("${data["bindMacB"]}".length > 6 && + // (person["direction"] == 1 || + // person["direction"] == 2)) { + // location_ = + // person["direction"] == 1 ? '左侧' : '右侧'; + // } return ClickableContainer( backgroundColor: Color(0xFF003058), @@ -176,9 +176,8 @@ class DevicePeopleInfo extends GetView { ), ), ), - if (location_.isNotEmpty) - 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/device_share_page.dart b/lib/pages/mh_page/device_share_page.dart index 9a4d110..cdb0bf4 100644 --- a/lib/pages/mh_page/device_share_page.dart +++ b/lib/pages/mh_page/device_share_page.dart @@ -3,40 +3,34 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.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/util/CommonVariables.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/component/NullDataComponentWidget.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; import 'package:vbvs_app/controller/mh_controller/mhdevice_share_controller.dart'; +import 'package:vbvs_app/model/api_response.dart'; import 'package:vbvs_app/pages/mh_page/EmptyMessageWidget.dart'; import 'package:vbvs_app/pages/mh_page/ShareUserWidget.dart'; class ShareDeviceWidget extends GetView { + var data; + ShareDeviceWidget({super.key, required this.data}); final scaffoldKey = GlobalKey(); - final ScrollController scrollController = ScrollController(); - // ShareDeviceWidget() { - // controller.initData(); - // scrollController.addListener(() { - // if (scrollController.position.pixels == - // scrollController.position.maxScrollExtent && - // controller.model.hasMore) { - // controller.initData(); - // controller.updateAll(); - // } - // }); - // } final _formKey = GlobalKey(); final _phoneController = TextEditingController(); @override Widget build(BuildContext context) { - var deviceController = Get.find(); controller.model.msg = ""; - controller.model.show = 0; + controller.model.code = 0; controller.model.type = 1; + controller.model.account = ''; return GestureDetector( onTap: () => FocusScope.of(context).unfocus(), child: Container( @@ -122,7 +116,7 @@ class ShareDeviceWidget extends GetView { ), ), Text( - '设备ID:${deviceController.model.deviceMain['mac']}', + '设备ID:${data['mac']}', style: TextStyle( fontFamily: 'Readex Pro', color: const Color(0xFF6BFDAC), @@ -192,82 +186,12 @@ class ShareDeviceWidget extends GetView { color: Colors.white, fontSize: 36.rpx, ), - validator: (value) { - if (value == null || - value.isEmpty) { - return '手机号不能为空'; - } - final phoneReg = - RegExp(r'^1[3-9]\d{9}$'); - if (!phoneReg.hasMatch(value)) { - return '请输入正确的手机号'; - } - return null; - }, onChanged: (value) { - controller.model.phone = value; + controller.model.account = + value; }, ), - ) - // TextFormField( - // // controller: _model.textController, - // // focusNode: _model.textFieldFocusNode, - // // autofocus: true, - // obscureText: false, - // decoration: InputDecoration( - // hintText: '请输入对方手机号', - // hintStyle: FlutterFlowTheme.of( - // context) - // .labelMedium - // .override( - // fontFamily: 'Readex Pro', - // color: - // const Color(0xFFD2D2D2), - // fontSize: 13, - // letterSpacing: 0.0, - // ), - // enabledBorder: - // const UnderlineInputBorder( - // borderSide: BorderSide( - // color: Color(0xFFCCCCCC), - // width: 1), - // ), - // focusedBorder: - // const UnderlineInputBorder( - // borderSide: BorderSide( - // color: Color(0xFF929699), - // width: 0), - // ), - // errorBorder: - // const UnderlineInputBorder( - // borderSide: BorderSide( - // color: Colors.red, width: 1), - // ), - // focusedErrorBorder: - // const UnderlineInputBorder( - // borderSide: BorderSide( - // color: Colors.redAccent, - // width: 1.5), - // ), - // contentPadding: - // const EdgeInsets.only( - // left: 10, bottom: 5), - // ), - // style: FlutterFlowTheme.of(context) - // .bodyMedium - // .override( - // fontFamily: 'Readex Pro', - // fontSize: 13, - // letterSpacing: 0.0, - // ), - // onChanged: (value) { - // controller.model.phone = value; - // }, - // // validator: _model.textControllerValidator - // // .asValidator(context), - // ), - - ), + )), ), ), ClickableContainer( @@ -292,117 +216,6 @@ class ShareDeviceWidget extends GetView { ), ), )), - // Container( - // width: MediaQuery.sizeOf(context).width, - // constraints: const BoxConstraints( - // minHeight: 46, - // ), - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(0), - // ), - // child: Align( - // alignment: - // const AlignmentDirectional(0, 0), - // child: Obx(() { - // if (controller.model.show == 0) { - // return Container(); - // } else { - // return GestureDetector( - // onTap: controller - // .model.msg!.isNotEmpty - // ? () { - // Clipboard.setData( - // ClipboardData( - // text: CommonVariables - // .shareText)); - // showToast( - // "复制成功,粘贴分享APP下载链接!", - // color: color_success); - // } - // : null, // 不可点击时设置为 null - // child: RichText( - // textAlign: TextAlign - // .center, // 设置整个 RichText 内容居中 - // text: TextSpan( - // children: - // controller.model.msg! - // .isNotEmpty - // ? [ - // TextSpan( - // text: controller - // .model - // .msg! + - // "!", // 第一部分文本 - // style: FlutterFlowTheme.of( - // context) - // .bodyMedium - // .override( - // fontFamily: - // 'Readex Pro', - // color: const Color( - // 0xFFE55E92), // 设置为粉红色 - // fontSize: - // 26.rpx, - // letterSpacing: - // 0.0, - // ), - // ), - // const TextSpan( - // text: - // '\n', // 添加换行 - // ), - // WidgetSpan( - // child: SizedBox( - // height: 20 - // .rpx), // 添加间距 - // ), - // TextSpan( - // text: - // '点击复制APP下载链接', // 第二部分文本 - // style: FlutterFlowTheme.of( - // context) - // .bodyMedium - // .override( - // fontFamily: - // 'Readex Pro', - // color: const Color( - // 0xFF1890FF), // 设置为蓝色 - // fontSize: - // 20.rpx, - // letterSpacing: - // 0.0, - // decoration: - // TextDecoration - // .underline, // 添加下划线 - // ), - // ), - // ] - // : [ - // TextSpan( - // text: - // '发送成功!', // 当 msg 为空时显示的文本 - // style: FlutterFlowTheme.of( - // context) - // .bodyMedium - // .override( - // fontFamily: - // 'Readex Pro', - // color: const Color( - // 0xFF07C160), // 设置为绿色 - // fontSize: - // 20.rpx, - // letterSpacing: - // 0.0, - // ), - // ), - // ], - // ), - // ), - // ); - // } - // })), - // ), - Obx( () => GestureDetector( onTap: () { @@ -534,16 +347,19 @@ class ShareDeviceWidget extends GetView { child: FFButtonWidget( onPressed: () async { //todo 1:验证用户是否存在 2:发送邀请 - // controller.model.show = 1; - // String msg = - // await controller.sendInvite( - // controller.model.phone, - // deviceController - // .model.deviceMain['mac']); - // if (msg != null && msg.isNotEmpty) { - // controller.model.msg = msg; - // } - // controller.updateAll(); + ApiResponse apiResponse = + await controller + .shareDevice(data['mac']); + if (apiResponse.code == + HttpStatusCodes.ok) { + TopSlideNotification.show(context, + text: apiResponse.msg!); + } else { + TopSlideNotification.show(context, + text: apiResponse.msg!, + textColor: themeController + .currentColor.sc9); + } }, text: '发送邀请', options: FFButtonOptions( @@ -617,10 +433,11 @@ class ShareDeviceWidget extends GetView { // .bodyMedium, // 可根据需要自定义样式 // ), // ); - return EmptyMessageWidget( - imagePath: - "assets/images/emptyUser.png", - ); + return NullDataWidget(); + // EmptyMessageWidget( + // imagePath: + // "assets/images/emptyUser.png", + // ); } // 否则显示正常的 ListView diff --git a/lib/pages/mh_page/help/article.dart b/lib/pages/mh_page/help/article.dart index 3aebe6c..2df7b39 100644 --- a/lib/pages/mh_page/help/article.dart +++ b/lib/pages/mh_page/help/article.dart @@ -14,123 +14,195 @@ class HelpArticle extends StatelessWidget { var isLike = 0.obs; - @override + // @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: ""), + // ), + // ), + // ), + // ], + // ), + // ), + // ), + // ), + // ), + // ); + // } + 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, + return Scaffold( + backgroundColor: const Color(0xFF042C46), + appBar: AppBar( + backgroundColor: const Color(0xFF042C46), + title: Text("问题与帮助", style: TextStyle(color: Colors.white)), + centerTitle: true, + leading: IconButton( + icon: Icon(Icons.arrow_back, color: Colors.white), + onPressed: () => Navigator.pop(context), + ), + elevation: 0, + ), + body: Column( + children: [ + Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + alignment: Alignment.centerLeft, + child: Text( + article['title'], + style: const TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold), + ), ), - 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: ""), - ), - ), - ), - ], + Expanded( + child: InAppWebView( + initialData: InAppWebViewInitialData( + data: wrapHtml(article['content']), ), ), ), - ), + ], ), ); } + + /// 包装成完整 HTML 页面,添加适配样式 + String wrapHtml(String htmlContent) { + return """ + + + + + + + + + $htmlContent + + + """; + } } diff --git a/lib/pages/mh_page/issue_preview_widget.dart b/lib/pages/mh_page/issue_preview_widget.dart index e0e9241..efa5dbd 100644 --- a/lib/pages/mh_page/issue_preview_widget.dart +++ b/lib/pages/mh_page/issue_preview_widget.dart @@ -27,12 +27,12 @@ class IssuePreviewWidget extends GetView { // await Future.delayed(Duration(milliseconds: 100)); // issueListController.model.selectedIndex = -1; // issueListController.updateAll(); - // var article = issueListController.model.issueList![index]; - // Get.toNamed("/helpArticle", arguments: article); - TopSlideNotification.show( - context, - text: "功能开发中...", - ); + var article = issueListController.model.issueList![index]; + Get.toNamed("/helpArticle", arguments: article); + // TopSlideNotification.show( + // context, + // text: "功能开发中...", + // ); }, child: Obx(() { return Container( diff --git a/lib/pages/mh_page/new_mine_page.dart b/lib/pages/mh_page/new_mine_page.dart index 91ccc68..0074209 100644 --- a/lib/pages/mh_page/new_mine_page.dart +++ b/lib/pages/mh_page/new_mine_page.dart @@ -250,7 +250,7 @@ class _MinePageState extends State { ), ), child: Text( - '我的智能床', + '我的智能设备'.tr, style: TextStyle( fontSize: 26.rpx, color: const Color(0xFF003058)), ), diff --git a/lib/pages/mh_page/searchWidget.dart b/lib/pages/mh_page/searchWidget.dart index 3e5b0b7..ad7e729 100644 --- a/lib/pages/mh_page/searchWidget.dart +++ b/lib/pages/mh_page/searchWidget.dart @@ -117,6 +117,9 @@ class SearchWidget extends GetView { // validator: _model // .textControllerValidator // .asValidator(context), + onChanged: (d) { + onChange?.call(d); + }, ), ), ), @@ -125,29 +128,33 @@ class SearchWidget extends GetView { ), ), Padding( - padding: EdgeInsetsDirectional.fromSTEB(26.rpx, 0, 0, 0), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - SizedBox( - height: 30.rpx, - child: VerticalDivider( - thickness: 2.rpx, - color: stringToColor("#333333"), //固定 - ), + padding: EdgeInsetsDirectional.fromSTEB(26.rpx, 0, 0, 0), + child: InkWell( + onTap: () { + findCallback?.call(); + }, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + SizedBox( + height: 30.rpx, + child: VerticalDivider( + thickness: 2.rpx, + color: stringToColor("#333333"), //固定 + ), + ), + Text( + '搜索'.tr, + style: TextStyle( + fontFamily: 'Inter', + fontSize: 30.rpx, + letterSpacing: 0.0, + color: stringToColor("#333333"), //固定 + ), + ), + ].divide(SizedBox(width: 26.rpx)), ), - Text( - '搜索'.tr, - style: TextStyle( - fontFamily: 'Inter', - fontSize: 30.rpx, - letterSpacing: 0.0, - color: stringToColor("#333333"), //固定 - ), - ), - ].divide(SizedBox(width: 26.rpx)), - ), - ), + )), ], ), ), diff --git a/lib/routers/mh_routers.dart b/lib/routers/mh_routers.dart index a29f31b..14310bb 100644 --- a/lib/routers/mh_routers.dart +++ b/lib/routers/mh_routers.dart @@ -81,7 +81,8 @@ var mhroutes = { "/findPasswordPage": (context) => FindPasswordPage(), "/loginPage": (context) => MHTLoginPage(), "/updatePasswordPage": (context) => UpdatePasswordPage(), - "/deviceSharePage": (context) => ShareDeviceWidget(), + "/deviceSharePage": (context, {arguments}) => + ShareDeviceWidget(data: arguments), "/deviceListPage": (context) => DeviceListPage(), "/mHTDeviceTypePage": (context, {arguments}) => MHTBindDeviceTypePage(), "/mHTBlueteethDevicePage": (context, {arguments}) => From 65f7b577df011c82887dfc00ab75c744d13a2392 Mon Sep 17 00:00:00 2001 From: czz <862977248@qq.com> Date: Tue, 24 Jun 2025 17:07:32 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=E8=A7=A3=E7=BB=91=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mh_controller/device_list_controller.dart | 4 ++-- lib/pages/mh_page/bluetooth.dart | 15 +++++++++++---- lib/routers/mh_routers.dart | 2 ++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/controller/mh_controller/device_list_controller.dart b/lib/controller/mh_controller/device_list_controller.dart index 3d7e91e..09579f4 100644 --- a/lib/controller/mh_controller/device_list_controller.dart +++ b/lib/controller/mh_controller/device_list_controller.dart @@ -39,8 +39,8 @@ class DeviceListController extends GetControllerEx { getDeviceList() async { try { String search = (model.keyword != null && model.keyword!.isNotEmpty) - ? "?key=${model.keyword}" - : ""; + ? "?key=${model.keyword}&ncs=1" + : "?ncs=1"; ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr); String serviceAddress = ServiceConstant.service_address; String serviceName = ServiceConstant.server_service; diff --git a/lib/pages/mh_page/bluetooth.dart b/lib/pages/mh_page/bluetooth.dart index ee7ced2..e5032b4 100644 --- a/lib/pages/mh_page/bluetooth.dart +++ b/lib/pages/mh_page/bluetooth.dart @@ -172,9 +172,12 @@ class BluetoothPage extends GetView { showUnbindConfirmDialog( context: context, title: "是否进行解绑?", - onConfirm: () { - deviceListController + onConfirm: () async { + await deviceListController .unbindDevice(data); + await deviceListController + .getDeviceList(); + Get.toNamed("/homePage"); // 执行解绑逻辑 }, onCancel: () { @@ -186,10 +189,14 @@ class BluetoothPage extends GetView { showDeleteDeviceConfirmDialog( context: context, title: "是否进行删除?", - onConfirm: () { - deviceListController.unbindDevice( + onConfirm: () async { + await deviceListController + .unbindDevice( data, ); + await deviceListController + .getDeviceList(); + Get.toNamed("/homePage"); }, onCancel: () { // 点击取消后的逻辑 diff --git a/lib/routers/mh_routers.dart b/lib/routers/mh_routers.dart index 14310bb..2c9c22f 100644 --- a/lib/routers/mh_routers.dart +++ b/lib/routers/mh_routers.dart @@ -24,6 +24,7 @@ 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/homepage/new_Home_page.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'; @@ -49,6 +50,7 @@ ThemeController themeController = Get.find(); var mhroutes = { "/mianPageBottomChange": (contxt) => MainPageBBottomChange(), + "/homePage": (context) => NewHomePage(), "/homeDeviceType": (contxt) => HomeDeviceType(), "/editUserInfoPage": (contxt) => EditUserPage(), "/peopleInfoPage": (contxt, {arguments}) => PeopleInfoPage( From df1a4949178144f0f606eef06c777dc10f25cfcf Mon Sep 17 00:00:00 2001 From: wyf <494641114@qq.com> Date: Tue, 24 Jun 2025 17:14:46 +0800 Subject: [PATCH 04/17] =?UTF-8?q?=E6=9B=B4=E6=96=B0web=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 4 +- lib/component/base/SleepdateWidget.dart | 5 +- .../component/main_page_b_bottom_change.dart | 34 +++- lib/pages/mh_page/MattressControl.dart | 6 +- .../component/HomeDeviceStausWidget.dart | 23 ++- lib/pages/mh_page/test/WebviewTestModel.dart | 174 +++++++++++++++++- pubspec.yaml | 2 +- 7 files changed, 229 insertions(+), 19 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 523e747..93944bf 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -38,8 +38,8 @@ globalKey = GlobalKey<_HomePageState>(); + + MainPageBBottomChange({Key? key}) : super(key: globalKey); + + // 静态方法:外部调用,跳转 tab + static void jumpTo(int index) { + final state = globalKey.currentState; + if (state != null) { + state.switchTab(index); + } + } + @override _HomePageState createState() => _HomePageState(); } + class _HomePageState extends State with SingleTickerProviderStateMixin { int selectedIndex = 0; @@ -95,4 +108,23 @@ class _HomePageState extends State ), ); } + + void switchTab(int index) { + final begin = currentPosition; + final end = index.toDouble(); + + _positionAnimation = Tween(begin: begin, end: end).animate( + CurvedAnimation(parent: _controller, curve: Curves.easeOut), + )..addListener(() { + setState(() {}); + }); + + _controller.forward(from: 0.0); + currentPosition = end; + + setState(() { + selectedIndex = index; + }); +} + } diff --git a/lib/pages/mh_page/MattressControl.dart b/lib/pages/mh_page/MattressControl.dart index 6d7331b..74682fa 100644 --- a/lib/pages/mh_page/MattressControl.dart +++ b/lib/pages/mh_page/MattressControl.dart @@ -138,9 +138,9 @@ class _MattressControlPageState extends State { body: SafeArea( child: WebviewTestView( - oncreate: (widget) { - return WebviewTestController(); - }, + // oncreate: (widget) { + // return WebviewTestController(); + // }, ), ), )))); diff --git a/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart b/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart index 602d80a..20e2a91 100644 --- a/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart +++ b/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart @@ -5,6 +5,8 @@ import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; +import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart'; +import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart'; class HomeDeviceStausWidget extends StatefulWidget { final deviceStatus; @@ -72,10 +74,25 @@ class _HomeDeviceStausWidgetState extends State { CustomCard( gradientDirection: GradientDirection.vertical, borderRadius: 10.rpx, - onTap: () { - // 点击回调逻辑放这里 - TopSlideNotification.show(context,text: "功能开发中...".tr); + onTap: () async { + try { + var device = widget.deviceStatus; + WebviewTestController webviewTestController = Get.find(); + var future = webviewTestController.web.jsbridge?.dart + .appToHtmlDevice(device); + + Future.delayed(Duration(seconds: 5), () { + TopSlideNotification.show(context, text: "控制界面初始化中,请稍后再试".tr); + return; + }); + + await future; // 等待最终完成(即使超过 5 秒) + MainPageBBottomChange.jumpTo(2); + } catch (e) { + print("发生异常: $e"); + } }, + colors: AppConstants().mhtButtongradientColors, // 你原本没有渐变,单色即可 enableGradient: true, // 关闭渐变 diff --git a/lib/pages/mh_page/test/WebviewTestModel.dart b/lib/pages/mh_page/test/WebviewTestModel.dart index 1010092..3f3ac66 100644 --- a/lib/pages/mh_page/test/WebviewTestModel.dart +++ b/lib/pages/mh_page/test/WebviewTestModel.dart @@ -1,12 +1,18 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:EasyDartModule/EasyDartModule.dart' as edm; +import 'package:easydevice/easydevice.dart'; +import 'package:easyweb/base/easyws.dart'; +import 'package:easyweb/base/minisdk.dart'; import 'package:easyweb/easyweb.dart'; import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; -import 'package:easyweb/base/minisdk.dart'; -import 'package:easydevice/easydevice.dart'; +import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart'; -import 'package:vbvs_app/pages/mh_page/room_picker.dart'; class WebviewTestModel { WebviewTestModel(); @@ -18,12 +24,16 @@ class WebviewTestModel { class WebviewTestController extends GetControllerEx { var selectDevice = {}; + var lastSelectDevice = {}; var bluetooth = 0; + List personList = []; + List instantData = []; + WebviewTestController() : super(WebviewTestModel()) { web = WebviewHelper( jsbridge: buildsdk( - father: this, - clientId: '494641114', + // father: this, + // clientId: '494641114', // dbgserverUrl: 'ws://192.168.1.2:9001', ), settings: buildsettings(), @@ -51,8 +61,23 @@ class WebviewTestController extends GetControllerEx { return true; }); bridge.sdk.selectDevice((args) async { - ef.log('selectDevice: $args'); - selectDevice = args[0]; + try { + ef.log('selectDevice: $args'); + selectDevice = args[0]; + await queryPersonInfoByMac(); + if (selectDevice != null && + selectDevice.isNotEmpty && + selectDevice['mac'] != null && + (selectDevice['mac'] != args[0]['mac'])) { + lastSelectDevice = selectDevice; + } + dealInstantData(selectDevice); + } catch (e) { + ef.log("[aaaa]$e"); + } + + //查询人员信息 + return true; }); bridge.sdk.updateBlueToothStatus((args) async { @@ -70,6 +95,30 @@ class WebviewTestController extends GetControllerEx { .toList(); return allDevices; }); + //请求token信息 + bridge.sdk.queryUserToken((args) async { + ef.log('queryUserToken: $args'); + // bluetooth = args[0]; + return edm.EasyDartModule.dio.token; + }); + //请求设备人员信息 + bridge.sdk.queryPersonInfo((args) async { + ef.log('queryPersonInfo: $args'); + // bluetooth = args[0]; + return personList; + }); + //请求实时体征数据 + bridge.sdk.queryInstantData((args) async { + ef.log('queryInstantData: $args'); + // bluetooth = args[0]; + return instantData; + }); + bridge.sdk.queryInstantData((args) async { + ef.log('queryInstantData: $args'); + // bluetooth = args[0]; + return instantData; + }); + }); web //.file( @@ -91,6 +140,117 @@ class WebviewTestController extends GetControllerEx { late WebviewHelper web; var ready = false.obs; var cnt = 0.obs; + + Future queryPersonInfoByMac() async { + UserInfoController userInfoController = Get.find(); + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.person_info; + String queryUrl = + "${serviceAddress}${serviceName}${serviceApi}?mac=${selectDevice['mac']}"; + try { + final res = await requestWithLog( + logTitle: "查询设备绑定人员列表", + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + personList = res.data; + }); + } catch (e) { + print("查询设备绑定列表失败: $e"); + } + } + + void dealInstantData(selectDevice) { + //处理实时数据 + // edm.EasyDartModule.websocket.sendData( + // jsonEncode(WebSocketMessage(path: "/vsbs/web/rt/marttress", type: 2))); + lastSelectDevice; + var ws; + ws = Easyws( + url: ServiceConstant.webSocketService, + onData: (data) { + ef.log("ws recv =>$data"); + try { + var tmp; + if (data is String) { + tmp = jsonDecode(data); // 只有是 String 才 decode + } else if (data is Map) { + tmp = data; // 直接用 + } else { + print("未知数据格式"); + } + print("aaa"); + if (tmp['data'] != null && tmp['data'] is Map) { + var newData = tmp['data']; + var mac = newData['mac']; + if (mac != null) { + // 删除已有的同 mac 项 + instantData.removeWhere((element) => element['mac'] == mac); + // 添加新的数据 + instantData.add(newData); + } + } + } catch (e) { + ef.log("ws error =>$e"); + } + }, + onStateChange: (x) { + ef.log("ws =>$x"); + if (x == EasywsState.connected) { + try { + if (lastSelectDevice != null && lastSelectDevice.isNotEmpty) { + List oldMacList = [ + lastSelectDevice['bind_mac_a'], + lastSelectDevice['bind_mac_b'], + ]; + for (String? mac in oldMacList) { + if (mac != null && mac.isNotEmpty) { + bool success = ws.send({ + "type": 2, + "path": "/vsbs/web/rt/marttress", + "data": {"mac": mac}, + }); + if (success) { + ef.log("✅ 已取消监听:$mac"); + } + } + } + } + } catch (e) { + ef.log("❌ 取消旧设备监听失败: $e"); + } + try { + // 2. 开始监听新设备(A/B 都监听) + if (selectDevice != null && selectDevice.isNotEmpty) { + List newMacList = [ + selectDevice['bind_mac_a'], + selectDevice['bind_mac_b'], + ]; + for (String? mac in newMacList) { + if (mac != null && mac.isNotEmpty) { + bool success = ws.send({ + "type": 1, + "path": "/vsbs/web/rt/marttress", + "data": {"mac": mac}, + }); + if (success) { + ef.log("✅ 开始监听新设备:$mac"); + } + } + } + + // 更新记录 + lastSelectDevice = selectDevice; + } + } catch (e) { + ef.log("❌ 监听新设备失败: $e"); + } + } + }, + ); + ws.connect(); + } //EasyFlutter End } diff --git a/pubspec.yaml b/pubspec.yaml index 52b019d..bea776f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -66,7 +66,7 @@ dependencies: easyweb: git: url: https://gitea.wslpc.real.he-info.cn:94/flutter/easyweb.git - ref: main + ref: e86d515f77 archive: ^4.0.0 From a08574979e7e0338a13ceaedacc35f8adbf921fc Mon Sep 17 00:00:00 2001 From: czz <862977248@qq.com> Date: Tue, 24 Jun 2025 17:24:17 +0800 Subject: [PATCH 05/17] =?UTF-8?q?=E8=A7=A3=E7=BB=91=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/mh_page/bluetooth.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/mh_page/bluetooth.dart b/lib/pages/mh_page/bluetooth.dart index e5032b4..54ff9f2 100644 --- a/lib/pages/mh_page/bluetooth.dart +++ b/lib/pages/mh_page/bluetooth.dart @@ -177,7 +177,7 @@ class BluetoothPage extends GetView { .unbindDevice(data); await deviceListController .getDeviceList(); - Get.toNamed("/homePage"); + Get.toNamed("/mianPageBottomChange"); // 执行解绑逻辑 }, onCancel: () { @@ -196,7 +196,7 @@ class BluetoothPage extends GetView { ); await deviceListController .getDeviceList(); - Get.toNamed("/homePage"); + Get.toNamed("/mianPageBottomChange"); }, onCancel: () { // 点击取消后的逻辑 From 12c6a260c9db39d7cf6627ba76cf208f80ef76b2 Mon Sep 17 00:00:00 2001 From: wyf <494641114@qq.com> Date: Tue, 24 Jun 2025 19:51:47 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/taihe/mianhuatang/MainActivity.kt | 2 +- android/local.properties | 2 +- .../mh_controller/address_controller.dart | 13 +++---- .../component/HomeDeviceStausWidget.dart | 5 ++- lib/pages/mh_page/homepage/new_Home_page.dart | 34 ++++++++++++++++++- 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/android/app/src/main/kotlin/com/taihe/mianhuatang/MainActivity.kt b/android/app/src/main/kotlin/com/taihe/mianhuatang/MainActivity.kt index 38032ef..8537ae0 100644 --- a/android/app/src/main/kotlin/com/taihe/mianhuatang/MainActivity.kt +++ b/android/app/src/main/kotlin/com/taihe/mianhuatang/MainActivity.kt @@ -1,4 +1,4 @@ -package com.taihe.mh_app +package com.taihe.vbvs_app import io.flutter.embedding.android.FlutterActivity diff --git a/android/local.properties b/android/local.properties index ebc3f6f..ebcdb0b 100644 --- a/android/local.properties +++ b/android/local.properties @@ -1,6 +1,6 @@ sdk.dir=C:\\Users\\wyf\\AppData\\Local\\Android\\sdk flutter.sdk=D:\\flutter_res\\flutter -flutter.buildMode=release +flutter.buildMode=debug flutter.versionName=1.0.0 flutter.versionCode=1 flutter.minSdkVersion=21 diff --git a/lib/controller/mh_controller/address_controller.dart b/lib/controller/mh_controller/address_controller.dart index f675ffe..8805d68 100644 --- a/lib/controller/mh_controller/address_controller.dart +++ b/lib/controller/mh_controller/address_controller.dart @@ -9,7 +9,7 @@ import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/user_data.dart'; -import 'package:lpinyin/lpinyin.dart'; +// import 'package:lpinyin/lpinyin.dart'; part 'address_controller.g.dart'; @JsonSerializable() @@ -209,10 +209,11 @@ class AddressController extends GetControllerEx { // 工具:中文首字母转大写英文(你也可以用更专业的拼音库) String _getLetter(String name) { - if (name.isEmpty) return "#"; - String pinyin = PinyinHelper.getPinyinE(name, - separator: '', defPinyin: '', format: PinyinFormat.WITHOUT_TONE); - if (pinyin.isEmpty) return "#"; - return pinyin[0].toUpperCase(); + return name; + // if (name.isEmpty) return "#"; + // String pinyin = PinyinHelper.getPinyinE(name, + // separator: '', defPinyin: '', format: PinyinFormat.WITHOUT_TONE); + // if (pinyin.isEmpty) return "#"; + // return pinyin[0].toUpperCase(); } } diff --git a/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart b/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart index 20e2a91..79c52cd 100644 --- a/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart +++ b/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart @@ -81,12 +81,11 @@ class _HomeDeviceStausWidgetState extends State { var future = webviewTestController.web.jsbridge?.dart .appToHtmlDevice(device); - Future.delayed(Duration(seconds: 5), () { - TopSlideNotification.show(context, text: "控制界面初始化中,请稍后再试".tr); + Future.delayed(Duration(seconds: 5), () { return; }); - await future; // 等待最终完成(即使超过 5 秒) + await future; MainPageBBottomChange.jumpTo(2); } catch (e) { print("发生异常: $e"); diff --git a/lib/pages/mh_page/homepage/new_Home_page.dart b/lib/pages/mh_page/homepage/new_Home_page.dart index f88b6dc..b35bdfc 100644 --- a/lib/pages/mh_page/homepage/new_Home_page.dart +++ b/lib/pages/mh_page/homepage/new_Home_page.dart @@ -115,6 +115,39 @@ class _NewHomePageState extends State { // deviceController.getSleepReport(); } }); + if (userInfoController.model.login == 1) { + //查询人员信息列表 + deviceController.getPersonList(); + //请求绑定设备列表 + // homeController.getSleepReport(); + deviceController.getDeviceNum().then((apiResponse) { + if (apiResponse.code != HttpStatusCodes.ok) { + TopSlideNotification.show( + Get.context!, + text: apiResponse.msg!, + textColor: themeController.currentColor.sc9, + ); + } + }); + deviceController.getDeviceList(group: 'room').then((apiResponse) { + if (apiResponse.code != HttpStatusCodes.ok) { + TopSlideNotification.show( + Get.context!, + text: apiResponse.msg!, + textColor: themeController.currentColor.sc9, + ); + } else { + //请求睡眠报告 + // deviceController.getSleepReport(); + } + }); + } + WidgetsBinding.instance.addPostFrameCallback((_) { + if (homeController.homeSleepDays.value.isNotEmpty) { + homeController.selectedDayIndex.value = + homeController.homeSleepDays.value.length - 1; + } + }); int login = userInfoController.model.login!; return GestureDetector( onTap: () => FocusScope.of(context).unfocus(), @@ -482,7 +515,6 @@ class _NewHomePageState extends State { isMultiSelect: false, ), ), - ), InkWell( onTap: () { From 943f5a778afaa983b99a426cafeec43ca90cd01b Mon Sep 17 00:00:00 2001 From: czz <862977248@qq.com> Date: Fri, 27 Jun 2025 09:15:45 +0800 Subject: [PATCH 07/17] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/mhlangs/zh_CN.json | 335 ++++++------ lib/common/color/appConstants.dart | 2 +- .../mhdevice_share_controller.g.dart | 4 +- .../mh_controller/repair_list_controller.dart | 2 +- .../repair_list_controller.g.dart | 4 +- lib/main.dart | 3 +- lib/pages/common/selectDialog.dart | 16 +- lib/pages/mh_page/MattressControl.dart | 37 +- lib/pages/mh_page/ShareUserWidget.dart | 4 +- lib/pages/mh_page/about_us.dart | 128 +++++ lib/pages/mh_page/address_list_page.dart | 99 ++-- lib/pages/mh_page/apply_repair_page.dart | 192 ++++--- lib/pages/mh_page/device_share_page.dart | 380 +++++++++---- lib/pages/mh_page/edit_address_page.dart | 348 +++++++----- lib/pages/mh_page/edit_bed.dart | 5 +- lib/pages/mh_page/experience_store_page.dart | 5 +- lib/pages/mh_page/help/article.dart | 264 ++++------ lib/pages/mh_page/homepage/new_Home_page.dart | 1 + lib/pages/mh_page/new_mine_page.dart | 4 +- lib/pages/mh_page/new_settingPage.dart | 16 +- lib/pages/mh_page/people_info.dart | 101 ++-- lib/pages/mh_page/privacy_policy.dart | 121 +++++ lib/pages/mh_page/repair_list.dart | 3 +- lib/pages/mh_page/room_picker.dart | 13 +- lib/pages/mh_page/score_page.dart | 4 +- lib/pages/mh_page/sleep_habit.dart | 6 +- lib/pages/mh_page/smys.dart | 200 ++++--- lib/pages/mh_page/user/page/rxhx_mht.dart | 497 +++++++++--------- lib/pages/mh_page/user_agreement_page.dart | 126 +++++ .../mht_new_sleep_report_page.dart | 4 +- .../new_sleep_report_page copy.dart | 4 +- .../sleep_report/new_sleep_report_page.dart | 4 +- lib/pages/sleep_report/sleep_report_page.dart | 2 +- lib/pages/user/about_us_page.dart | 16 +- lib/routers/mh_routers.dart | 7 + pubspec.lock | 248 ++------- 36 files changed, 1850 insertions(+), 1355 deletions(-) create mode 100644 lib/pages/mh_page/about_us.dart create mode 100644 lib/pages/mh_page/privacy_policy.dart create mode 100644 lib/pages/mh_page/user_agreement_page.dart diff --git a/assets/mhlangs/zh_CN.json b/assets/mhlangs/zh_CN.json index 23bd1d3..844a75a 100644 --- a/assets/mhlangs/zh_CN.json +++ b/assets/mhlangs/zh_CN.json @@ -12,159 +12,159 @@ "详情": "详情", "人员资料": "人员资料" }, - "请输入手机号":"输入手机号码", - "请输入正确的手机号":"请输入正确的手机号", - "请输入密码":"请输入密码", - "密码格式提示":"1.密码长度必须至少8位\n2.密码需要字母加数字\n3.特殊字符和大写字母至少包含一个", - "请输入确认密码":"请输入确认密码", - "两次密码不一致":"两次密码不一致", - "请输入验证码":"请输入验证码", - "需要同意协议":"需要同意协议", - "请选择登录方式":"请选择登录方式", - "账户不能为空":"账户不能为空", - "密码不能为空":"密码不能为空", - "验证码不能为空":"验证码不能为空", - "密码登录":"密码登录", - "短信登录":"短信登录", - "获取验证码":"获取验证码", - "登录":"登录", - "找回密码":"找回密码", - "注册":"注册", - "我已阅读并同意":"我已阅读并同意", - "与":"与", - "《用户协议》":"《用户协议》", - "《隐私协议》":"《隐私协议》", - "注:首次登录会自动创建账号":"注:首次登录会自动创建账号", - "请输入新密码":"请输入新密码", - "确认新密码":"确认新密码", - "秒":"秒", - "添加一台新设备":"添加一台新设备", - "添加新设备":"添加新设备", - "网络未连接,请开启设备网络后重试":"网络未连接,请开启设备网络后重试", - "提交":"提交", - "发送验证码成功":"发送验证码成功", - "注册成功":"注册成功", - "再按一次退出程序":"再按一次退出程序成功", - "用户拒绝授权":"用户拒绝授权", - "用户取消授权":"用户取消授权", - "未命名":"未命名", - "编辑资料":"编辑资料", - "保存":"保存", - "点击更换头像":"点击更换头像", - "保存失败":"保存失败", - "昵称为空":"昵称为空", - "保存成功":"保存成功", - "请先登录":"请先登录", - "密码修改成功":"密码修改成功", - "未知数据":"-", - "必须登录提示":"请先登录!", - "输入验证码":"输入验证码", - "输入新密码":"输入新密码", - "确认验证码":"确认验证码", - "输入手机号码":"输入手机号码", - "操作成功":"操作成功", - "添加设备":"添加设备", - "扫描中":"扫描中...", - "检索设备":"检索设备", - "搜索":"搜索", - "匹配出的外围设备":"匹配出的外围设备", - "知道了":"知道了", - "蓝牙未开启":"蓝牙未开启", - "请先打开蓝牙在进行设备扫描":"请先打开蓝牙在进行设备扫描", - "等待扫描":"等待扫描", - "默认设备名称":"默认设备名称", - "连接异常":"连接异常", - "蓝牙绑定提示":"用手机进行设备添加时,请打开手机蓝牙搜索,靠近目标位置3米以内进行。", - "蓝牙连接成功":"蓝牙连接成功", - "蓝牙连接失败":"蓝牙连接失败,请重试", - "绑定失败请重试":"绑定失败请重试", - "无法绑定":"无法绑定!", - "无法绑定1":"检测到该设备", - "无法绑定2":"已被绑定", - "无法绑定3":",绑定前请先进行解绑,有疑问请联系客服", - "蓝牙绑定":{ - "标题":"蓝牙绑定", - "扫描":"扫描蓝牙设备中…", - "信号":"最小信号强度", - "搜索提示":"检索设备", - "搜索":"搜索", - "匹配":"匹配出的外围设备", - "信号强度":"信号强度", - "SN":"SN", - "蓝牙地址":"蓝牙地址", - "mac":"mac", - "网络":"网络", - "在线":"在线", - "离线":"离线", - "版本":"版本", - "默认设备名称":"未知设备", - "传感器":"传感器", - "可绑定":"可绑定", - "已被绑定":"已被绑定", - "双人版绑定标题":"该设备为双人版,请选择", - "绑定全部":"绑定全部", - "主设备":"主设备:", - "从设备":"从设备:", - "确定":"确定", - "取消":"取消", - "无法绑定":"无法绑定!", - "无法绑定1":"检测到该设备", - "无法绑定2":"已被绑定", - "无法绑定3":",绑定前请先进行解绑,有疑问请联系客服", - "知道了":"知道了", - "是":"是", - "否":"否", - "确定绑定提示":"确定绑定该设备吗?", - "连接成功":"蓝牙连接成功", - "连接异常":"蓝牙连接异常", - "连接":"连接", - "输入wifi密码":"请输入wifi密码", - "显示密码":"显示", - "不显示密码":"不显示" + "请输入手机号": "输入手机号码", + "请输入正确的手机号": "请输入正确的手机号", + "请输入密码": "请输入密码", + "密码格式提示": "1.密码长度必须至少8位\n2.密码需要字母加数字\n3.特殊字符和大写字母至少包含一个", + "请输入确认密码": "请输入确认密码", + "两次密码不一致": "两次密码不一致", + "请输入验证码": "请输入验证码", + "需要同意协议": "需要同意协议", + "请选择登录方式": "请选择登录方式", + "账户不能为空": "账户不能为空", + "密码不能为空": "密码不能为空", + "验证码不能为空": "验证码不能为空", + "密码登录": "密码登录", + "短信登录": "短信登录", + "获取验证码": "获取验证码", + "登录": "登录", + "找回密码": "找回密码", + "注册": "注册", + "我已阅读并同意": "我已阅读并同意", + "与": "与", + "《用户协议》": "《用户协议》", + "《隐私协议》": "《隐私协议》", + "注:首次登录会自动创建账号": "注:首次登录会自动创建账号", + "请输入新密码": "请输入新密码", + "确认新密码": "确认新密码", + "秒": "秒", + "添加一台新设备": "添加一台新设备", + "添加新设备": "添加新设备", + "网络未连接,请开启设备网络后重试": "网络未连接,请开启设备网络后重试", + "提交": "提交", + "发送验证码成功": "发送验证码成功", + "注册成功": "注册成功", + "再按一次退出程序": "再按一次退出程序成功", + "用户拒绝授权": "用户拒绝授权", + "用户取消授权": "用户取消授权", + "未命名": "未命名", + "编辑资料": "编辑资料", + "保存": "保存", + "点击更换头像": "点击更换头像", + "保存失败": "保存失败", + "昵称为空": "昵称为空", + "保存成功": "保存成功", + "请先登录": "请先登录", + "密码修改成功": "密码修改成功", + "未知数据": "-", + "必须登录提示": "请先登录!", + "输入验证码": "输入验证码", + "输入新密码": "输入新密码", + "确认验证码": "确认验证码", + "输入手机号码": "输入手机号码", + "操作成功": "操作成功", + "添加设备": "添加设备", + "扫描中": "扫描中...", + "检索设备": "检索设备", + "搜索": "搜索", + "匹配出的外围设备": "匹配出的外围设备", + "知道了": "知道了", + "蓝牙未开启": "蓝牙未开启", + "请先打开蓝牙在进行设备扫描": "请先打开蓝牙在进行设备扫描", + "等待扫描": "等待扫描", + "默认设备名称": "默认设备名称", + "连接异常": "连接异常", + "蓝牙绑定提示": "用手机进行设备添加时,请打开手机蓝牙搜索,靠近目标位置3米以内进行。", + "蓝牙连接成功": "蓝牙连接成功", + "蓝牙连接失败": "蓝牙连接失败,请重试", + "绑定失败请重试": "绑定失败请重试", + "无法绑定": "无法绑定!", + "无法绑定1": "检测到该设备", + "无法绑定2": "已被绑定", + "无法绑定3": ",绑定前请先进行解绑,有疑问请联系客服", + "蓝牙绑定": { + "标题": "蓝牙绑定", + "扫描": "扫描蓝牙设备中…", + "信号": "最小信号强度", + "搜索提示": "检索设备", + "搜索": "搜索", + "匹配": "匹配出的外围设备", + "信号强度": "信号强度", + "SN": "SN", + "蓝牙地址": "蓝牙地址", + "mac": "mac", + "网络": "网络", + "在线": "在线", + "离线": "离线", + "版本": "版本", + "默认设备名称": "未知设备", + "传感器": "传感器", + "可绑定": "可绑定", + "已被绑定": "已被绑定", + "双人版绑定标题": "该设备为双人版,请选择", + "绑定全部": "绑定全部", + "主设备": "主设备:", + "从设备": "从设备:", + "确定": "确定", + "取消": "取消", + "无法绑定": "无法绑定!", + "无法绑定1": "检测到该设备", + "无法绑定2": "已被绑定", + "无法绑定3": ",绑定前请先进行解绑,有疑问请联系客服", + "知道了": "知道了", + "是": "是", + "否": "否", + "确定绑定提示": "确定绑定该设备吗?", + "连接成功": "蓝牙连接成功", + "连接异常": "蓝牙连接异常", + "连接": "连接", + "输入wifi密码": "请输入wifi密码", + "显示密码": "显示", + "不显示密码": "不显示" }, - "wifi页":{ - "标题":"WIFI配置", - "跳过":"下一步", - "WLAN":"网络", - "未连接":"未连接", - "已连接":"已连接", - "可用WLAN":"可用WLAN", - "刷新":"刷新", - "密码为空":"密码不能为空", - "配网成功":"配网成功", - "配网失败":"配网失败", - "配网中":"配网中", - "需配网":"请给设备配置网络!" + "wifi页": { + "标题": "WIFI配置", + "跳过": "下一步", + "WLAN": "网络", + "未连接": "未连接", + "已连接": "已连接", + "可用WLAN": "可用WLAN", + "刷新": "刷新", + "密码为空": "密码不能为空", + "配网成功": "配网成功", + "配网失败": "配网失败", + "配网中": "配网中", + "需配网": "请给设备配置网络!" }, - "设备校准":"设备校准", - "离床校准":"离床校准", - "未完成":"未完成", - "已完成":"已完成", - "位置校准":"位置校准", - "床头":"床头", - "离床校准提示":"请校准人员暂时离开床铺且在校准期间保持周围安静", - "位置校准提示":"请校准人员到箭头指定一侧 平躺后点击开始,保持10秒", - "开始校准":"开始校准", - "校准完成":"校准完成!", - "绑定成功":{ - "标题":"绑定完成", - "绑定成功":"配置成功! ", - "分享标题":"是否进行分享?", - "分享内容":"设备绑定成功后,如需对朋友或家人共享我的睡眠情况,可以进行立即分享,分享成功后,对方即可享受查看该设备权限,可以收到该设备的睡眠报告。", - "立即分享":"立即分享", - "返回":"返回" + "设备校准": "设备校准", + "离床校准": "离床校准", + "未完成": "未完成", + "已完成": "已完成", + "位置校准": "位置校准", + "床头": "床头", + "离床校准提示": "请校准人员暂时离开床铺且在校准期间保持周围安静", + "位置校准提示": "请校准人员到箭头指定一侧 平躺后点击开始,保持10秒", + "开始校准": "开始校准", + "校准完成": "校准完成!", + "绑定成功": { + "标题": "绑定完成", + "绑定成功": "配置成功! ", + "分享标题": "是否进行分享?", + "分享内容": "设备绑定成功后,如需对朋友或家人共享我的睡眠情况,可以进行立即分享,分享成功后,对方即可享受查看该设备权限,可以收到该设备的睡眠报告。", + "立即分享": "立即分享", + "返回": "返回" }, - "设置页":{ - "标题":"设置", - "主题模式":"主题模式", - "选择语言":"选择语言", - "关于我们":"关于我们", - "用户协议":"用户协议", - "隐私协议":"隐私协议", - "退出登录":"退出登录", - "注销账号":"注销账号", - "退出成功":"退出成功", - "退出失败":"退出失败" + "设置页": { + "标题": "设置", + "主题模式": "主题模式", + "选择语言": "选择语言", + "关于我们": "关于我们", + "用户协议": "用户协议", + "隐私协议": "隐私协议", + "退出登录": "退出登录", + "注销账号": "注销账号", + "退出成功": "退出成功", + "退出失败": "退出失败" }, "操作成功": "操作成功", "关于我们": "关于我们", @@ -172,7 +172,38 @@ "隐私协议": "隐私协议", "退出登录": "退出登录", "注销账号": "注销账号", - "我的智能设备":"我的智能设备", + "我的智能设备": "我的智能设备", "解绑成功": "解绑成功", - "解绑失败": "解绑失败" + "解绑失败": "解绑失败", + "睡眠隐私": "睡眠隐私", + "睡眠隐私功能": "睡眠隐私功能", + "开始时间": "开始时间", + "结束时间": "结束时间", + "取消": "取消", + "确认": "确认", + "时": "时", + "分": "分", + "选择性别": "选择性别", + "*注:开启睡眠隐私功能后,在设置的时间段内,将不会采集您的睡眠数据。": "*注:开启睡眠隐私功能后,在设置时间段内,将不会采集您的睡眠数据。", + "柔性唤醒": "柔性唤醒", + "睡眠银色": "睡眠隐私", + "睡眠习惯": "睡眠习惯", + "允许对方查看设备": "允许对方查看设备", + "允许对方控制设备": "允许对方控制设备", + "已分享用户": "已分享用户", + "发送邀请": "发送邀请", + "仅允许对方查看该设备": "仅允许对方查看该设备", + "允许对方控制该设备": "允许对方控制该设备", + "点击复制APP下载链接": "点击复制APP下载链接", + "评价": "评价", + "我要评价": "我要评价", + "更新成功": "更新成功", + "更新失败": "更新失败", + "完成": "完成", + "请输入正确的联系人电话": "请输入正确的联系人电话", + "请选择体重": "请输入体重", + "请选择身高": "请输入身高", + "人员资料": "人员资料", + "请输入姓名": "请输入姓名" + } \ No newline at end of file diff --git a/lib/common/color/appConstants.dart b/lib/common/color/appConstants.dart index 60b737e..996e46e 100644 --- a/lib/common/color/appConstants.dart +++ b/lib/common/color/appConstants.dart @@ -3,7 +3,7 @@ import 'dart:ui'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; -class AppConstants { +class AppConstants { // App-related constants static const int code_time = 60; //验证码倒计时 static const int limit = 10; //分页数量 diff --git a/lib/controller/mh_controller/mhdevice_share_controller.g.dart b/lib/controller/mh_controller/mhdevice_share_controller.g.dart index 9da852a..4cceecd 100644 --- a/lib/controller/mh_controller/mhdevice_share_controller.g.dart +++ b/lib/controller/mh_controller/mhdevice_share_controller.g.dart @@ -12,6 +12,7 @@ MHDeviceShareModel _$MHDeviceShareModelFromJson(Map json) => ..type = (json['type'] as num?)?.toInt() ..msg = json['msg'] as String? ..show = (json['show'] as num?)?.toInt() + ..code = (json['code'] as num?)?.toInt() ..limit = (json['limit'] as num).toInt() ..offset = (json['offset'] as num).toInt() ..isLoading = json['isLoading'] as bool @@ -21,10 +22,11 @@ MHDeviceShareModel _$MHDeviceShareModelFromJson(Map json) => Map _$MHDeviceShareModelToJson(MHDeviceShareModel instance) => { - 'phone': instance.account, + 'account': instance.account, 'type': instance.type, 'msg': instance.msg, 'show': instance.show, + 'code': instance.code, 'limit': instance.limit, 'offset': instance.offset, 'isLoading': instance.isLoading, diff --git a/lib/controller/mh_controller/repair_list_controller.dart b/lib/controller/mh_controller/repair_list_controller.dart index 4661862..1d5f589 100644 --- a/lib/controller/mh_controller/repair_list_controller.dart +++ b/lib/controller/mh_controller/repair_list_controller.dart @@ -39,7 +39,7 @@ class RepairListController extends GetControllerEx { String serviceName = ServiceConstant.server_service; String serviceApi = ServiceConstant.submit_repair; String queryUrl = "${serviceAddress}${serviceName}${serviceApi}"; - requestWithLog( + await requestWithLog( logTitle: "查询报修数据", method: MyHttpMethod.get, queryUrl: queryUrl, diff --git a/lib/controller/mh_controller/repair_list_controller.g.dart b/lib/controller/mh_controller/repair_list_controller.g.dart index 0e260c6..274e511 100644 --- a/lib/controller/mh_controller/repair_list_controller.g.dart +++ b/lib/controller/mh_controller/repair_list_controller.g.dart @@ -12,9 +12,7 @@ RepairListModel _$RepairListModelFromJson(Map json) => ..offset = (json['offset'] as num).toInt() ..isLoading = json['isLoading'] as bool ..hasMore = json['hasMore'] as bool - ..repairList = (json['repairList'] as List) - .map((e) => ApplyRepairModel.fromJson(e as Map)) - .toList(); + ..repairList = json['repairList'] as List; Map _$RepairListModelToJson(RepairListModel instance) => { diff --git a/lib/main.dart b/lib/main.dart index 60faf3d..912d67f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -194,8 +194,6 @@ void initEasyDartModule() { //初始化 } - - Future initLogin() async { // 初始化控制器 Get.put(UserInfoController()); @@ -358,6 +356,7 @@ class MyApp extends StatelessWidget { Get.lazyPut(() => MHTDeviceCalibrationController()), Get.lazyPut(() => SleepReportController()), Get.lazyPut(() => CalendarController()), + Get.lazyPut(() => UserPdfController()), Get.put(WebviewTestController()), ])); } diff --git a/lib/pages/common/selectDialog.dart b/lib/pages/common/selectDialog.dart index 52591c7..3284ddf 100644 --- a/lib/pages/common/selectDialog.dart +++ b/lib/pages/common/selectDialog.dart @@ -714,13 +714,13 @@ Future showDayTimeSelectionDialog( width: 100.rpx, height: 60.rpx, alignment: Alignment.center, - child: Text("取消", + child: Text("取消".tr, style: TextStyle( fontSize: 30.rpx, color: Colors.white)), ), ), Text( - title, + title.tr, style: TextStyle( fontFamily: 'Readex Pro', color: themeController.currentColor.sc3, @@ -742,7 +742,7 @@ Future showDayTimeSelectionDialog( width: 100.rpx, height: 60.rpx, alignment: Alignment.center, - child: Text("确认", + child: Text("确认".tr, style: TextStyle( fontSize: 30.rpx, color: Colors.white)), ), @@ -778,7 +778,7 @@ Future showDayTimeSelectionDialog( context, hours, hoursIndex, - unit: "时", + unit: "时".tr, ), ), Expanded( @@ -786,7 +786,7 @@ Future showDayTimeSelectionDialog( context, minutes, minutesIndex, - unit: "分", + unit: "分".tr, ), ), ], @@ -856,12 +856,12 @@ Future showOneSelectionDialog( alignment: Alignment.center, width: 100.rpx, height: 60.rpx, - child: Text("取消", + child: Text("取消".tr, style: TextStyle( fontSize: 30.rpx, color: Colors.white)), ), ), - Text(title, + Text(title.tr, style: TextStyle( fontFamily: 'Readex Pro', color: Colors.white, @@ -879,7 +879,7 @@ Future showOneSelectionDialog( alignment: Alignment.center, width: 100.rpx, height: 60.rpx, - child: Text("确认", + child: Text("确认".tr, style: TextStyle( fontSize: 30.rpx, color: Colors.white)), ), diff --git a/lib/pages/mh_page/MattressControl.dart b/lib/pages/mh_page/MattressControl.dart index 74682fa..826a1de 100644 --- a/lib/pages/mh_page/MattressControl.dart +++ b/lib/pages/mh_page/MattressControl.dart @@ -17,35 +17,6 @@ class MattressControlPage extends StatefulWidget { class _MattressControlPageState extends State { final controller = Get.put(ControlCardController()); - final data = { - "_id": "333330000000000000000000", - "uid": "684b90df767e00004e0072e2", - "bind_type": 1, - "device_type": 3, - "mac": "545024122666", - "bind_mac": null, - "bind_mac_a": "B43A45C3D411", - "bind_mac_b": "B43A45C3D388", - "position": 0, - "share_uid": null, - "person": null, - "op_type": null, - "show": true, - "create_time": 1750121686274, - "room_id": "684395bf9ef8601da20f6475", - "roomName": "主卧", - "shareNum": 0, - "status": { - "signal": -1, - "status": 0, - "inBed": 0, - "upgrade": 0, - "failure": 0, - "updateTime": -1 - }, - "code": "545024122666", - "blueToothStatus": 1 - }; int selectedIndex = 1; // 当前选中的tab索引 @override Widget build(BuildContext context) { @@ -138,10 +109,10 @@ class _MattressControlPageState extends State { body: SafeArea( child: WebviewTestView( - // oncreate: (widget) { - // return WebviewTestController(); - // }, - ), + // oncreate: (widget) { + // return WebviewTestController(); + // }, + ), ), )))); } diff --git a/lib/pages/mh_page/ShareUserWidget.dart b/lib/pages/mh_page/ShareUserWidget.dart index 08f9ed8..c47fde7 100644 --- a/lib/pages/mh_page/ShareUserWidget.dart +++ b/lib/pages/mh_page/ShareUserWidget.dart @@ -78,9 +78,9 @@ class ShareUserWidget extends GetView { alignment: const AlignmentDirectional(-1, 0), child: Text( info['opType'] == 1 - ? '允许对方控制该设备' + ? '允许对方控制该设备'.tr : info['opType'] == 2 - ? '仅允许对方查看该设备' + ? '仅允许对方查看该设备'.tr : '', style: TextStyle( fontFamily: 'Readex Pro', diff --git a/lib/pages/mh_page/about_us.dart b/lib/pages/mh_page/about_us.dart new file mode 100644 index 0000000..c4e2d96 --- /dev/null +++ b/lib/pages/mh_page/about_us.dart @@ -0,0 +1,128 @@ +import 'package:ef/ef.dart'; +import 'package:flutter/material.dart'; +import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/component/tool/WebViewWidget.dart'; + +class MhAboutUsPage extends StatefulWidget { + late MyWebView webView; + MhAboutUsPage({super.key}); + + @override + State createState() => _MhAboutUsPageState(); +} + +class _MhAboutUsPageState extends State { + @override + void initState() { + super.initState(); + // pdfController.loadPdf(); + + widget.webView = MyWebView( + url: AppConstants().ent_type == 1 + ? "https://mp.weixin.qq.com/s/IAr4RNBy0hGJXGKyMxe7eQ" + : "https://mp.weixin.qq.com/s/7BvvprVDqX1eOzM3Lms8dg", + onLoad: () { + print('网页载入完毕'); + }, + ); + } + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (context, bodySize) => GestureDetector( + onTap: () => FocusScope.of(context).unfocus(), + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/new_background.png'), // 本地图片 + fit: BoxFit.fill, // 填满整个 Container + ), + ), + child: Scaffold( + backgroundColor: Colors.transparent, // 加上这一行 + appBar: AppBar( + backgroundColor: Colors.transparent, + // backgroundColor: Colors.transparent, + automaticallyImplyLeading: false, + iconTheme: IconThemeData(color: themeController.currentColor.sc3), + titleSpacing: 0, + // leading: returnIconButtom, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + /// 居中标题 + Text('关于我们'.tr, + style: TextStyle( + fontFamily: 'Readex Pro', + color: themeController.currentColor.sc3, + letterSpacing: 0, + fontSize: 30.rpx, + )), + + /// 左边返回按钮 + Positioned( + left: 20, + child: returnIconButtomNew, + ), + ], + ), + ), + + actions: [], + centerTitle: false, + ), + + // body: SafeArea( + // top: true, + // child: Padding( + // padding: EdgeInsets.symmetric(horizontal: 30.rpx), + // child: Column( + // children: [ + // Expanded( + // child: Obx(() { + // if (pdfController.localPdfPath.value == null) { + // return Center(child: CircularProgressIndicator()); + // } else { + // return PDFView( + // filePath: pdfController.localPdfPath.value!, + // autoSpacing: false, + // enableSwipe: true, + // swipeHorizontal: false, + // pageSnap: true, + // fitEachPage: true, + // defaultPage: 0, + // onRender: (pages) => print('PDF 渲染完成,共 $pages 页'), + // onError: (error) => print('PDF 加载错误: $error'), + // ); + // } + // }), + // ), + // ], + // ), + // ), + // ), + body: SafeArea( + top: true, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 0.rpx), + child: Column(children: [ + Expanded( + child: Container( + child: widget.webView, + ), + ), + ]), + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/mh_page/address_list_page.dart b/lib/pages/mh_page/address_list_page.dart index 191c1c2..0c07ab9 100644 --- a/lib/pages/mh_page/address_list_page.dart +++ b/lib/pages/mh_page/address_list_page.dart @@ -71,37 +71,76 @@ class AddressListPage extends GetView { child: Column( mainAxisSize: MainAxisSize.max, children: [ + // Obx(() { + // if (controller.model.addressList!.isEmpty) { + // // 如果地址列表为空,显示 EmptyMessageWidget + // return Expanded(child: NullDataWidget()); + // } else { + // // 如果地址列表不为空,显示地址列表 + // return Expanded( + // child: Container( + // width: bodysize!.maxWidth, + // height: bodysize!.maxHeight * 1, + // decoration: BoxDecoration(), + // child: Obx(() => ListView( + // shrinkWrap: true, + // scrollDirection: Axis.vertical, + // children: (controller.model.addressList! + // .asMap() + // .entries + // .map((e) => AddressModuleWidget( + // index: e.key, + // addressListController: + // controller, + // )) + // .toList() as List) + // .divide(const SizedBox(height: 10)) + // .addToEnd(const SizedBox( + // height: + // AppConstants.list_end_height)), + // )), + // ), + // ); + // } + // }), Obx(() { - if (controller.model.addressList!.isEmpty) { - // 如果地址列表为空,显示 EmptyMessageWidget - return Expanded(child: NullDataWidget()); - } else { - // 如果地址列表不为空,显示地址列表 - return Expanded( - child: Container( - width: bodysize!.maxWidth, - height: bodysize!.maxHeight * 1, - decoration: BoxDecoration(), - child: Obx(() => ListView( - shrinkWrap: true, - scrollDirection: Axis.vertical, - children: (controller.model.addressList! - .asMap() - .entries - .map((e) => AddressModuleWidget( - index: e.key, - addressListController: - controller, - )) - .toList() as List) - .divide(const SizedBox(height: 10)) - .addToEnd(const SizedBox( - height: - AppConstants.list_end_height)), - )), - ), - ); - } + final originList = controller.model.addressList ?? []; + + // 拆出默认地址 + final defaultItem = originList.firstWhere( + (e) => e["default"] == 1, + orElse: () => null, + ); + + // 其他非默认地址 + final others = + originList.where((e) => e["default"] != 1).toList(); + + // 新的展示顺序列表(默认地址排前面) + final reorderedList = [ + if (defaultItem != null) defaultItem, + ...others, + ]; + + return Expanded( + child: ListView( + shrinkWrap: true, + padding: EdgeInsets.zero, + children: reorderedList + .map((item) { + final realIndex = + originList.indexOf(item); // 保留原始 index + return AddressModuleWidget( + index: realIndex, + addressListController: controller, + ); + }) + .toList() + .divide(const SizedBox(height: 10)) + .addToEnd(const SizedBox( + height: AppConstants.list_end_height)), + ), + ); }), Align( alignment: AlignmentDirectional(0, 1), diff --git a/lib/pages/mh_page/apply_repair_page.dart b/lib/pages/mh_page/apply_repair_page.dart index 8250901..7cbe9cf 100644 --- a/lib/pages/mh_page/apply_repair_page.dart +++ b/lib/pages/mh_page/apply_repair_page.dart @@ -1168,90 +1168,100 @@ class ApplyRepairPage extends GetView { child: TextFormField( // autofocus: true, + obscureText: + false, onChanged: - (value) { + (val) { controller .model .apply_name = - value; + val; }, - obscureText: - false, + decoration: InputDecoration( - isDense: true, + contentPadding: + EdgeInsets + .symmetric( + vertical: + 25.rpx, + horizontal: + 26.rpx, + ), labelStyle: - const TextStyle( + TextStyle( fontFamily: 'Readex Pro', letterSpacing: 0, ), hintStyle: - const TextStyle( + TextStyle( fontFamily: 'Readex Pro', letterSpacing: 0, ), enabledBorder: - OutlineInputBorder( + UnderlineInputBorder( borderSide: - BorderSide( - color: const Color( + const BorderSide( + color: Color( 0x00000000), - width: - 1.rpx, + width: 2, ), borderRadius: - BorderRadius.circular( - AppConstants().normal_container_radius), + BorderRadius + .circular(8), ), focusedBorder: - OutlineInputBorder( + UnderlineInputBorder( borderSide: - BorderSide( - color: Colors - .transparent, - width: - 1.rpx, + const BorderSide( + color: Color( + 0x00000000), + width: 2, ), borderRadius: - BorderRadius.circular( - 8.rpx), + BorderRadius + .circular(8), ), errorBorder: - OutlineInputBorder( + UnderlineInputBorder( borderSide: - BorderSide( - // - width: - 1.rpx, + const BorderSide( + color: Color( + 0x00000000), + width: 2, ), borderRadius: - BorderRadius.circular( - 8.rpx), + BorderRadius + .circular(8), ), focusedErrorBorder: - OutlineInputBorder( + UnderlineInputBorder( borderSide: - BorderSide( - // - width: - 1.rpx, + const BorderSide( + color: Color( + 0x00000000), + width: 2, ), borderRadius: - BorderRadius.circular( - 8.rpx), + BorderRadius + .circular(8), ), ), - style: TextStyle( - letterSpacing: - 0, - color: Colors - .black, - fontSize: - 26.rpx), + style: + TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx, + ), ), ), ), @@ -1324,90 +1334,100 @@ class ApplyRepairPage extends GetView { child: TextFormField( // autofocus: true, + obscureText: + false, onChanged: - (value) { + (val) { controller .model .tel = - value; + val; }, - obscureText: - false, + decoration: InputDecoration( - isDense: true, + contentPadding: + EdgeInsets + .symmetric( + vertical: + 25.rpx, + horizontal: + 26.rpx, + ), labelStyle: - const TextStyle( + TextStyle( fontFamily: 'Readex Pro', letterSpacing: 0, ), hintStyle: - const TextStyle( + TextStyle( fontFamily: 'Readex Pro', letterSpacing: 0, ), enabledBorder: - OutlineInputBorder( + UnderlineInputBorder( borderSide: - BorderSide( - color: const Color( + const BorderSide( + color: Color( 0x00000000), - width: - 1.rpx, + width: 2, ), borderRadius: - BorderRadius.circular( - AppConstants().normal_container_radius), + BorderRadius + .circular(8), ), focusedBorder: - OutlineInputBorder( + UnderlineInputBorder( borderSide: - BorderSide( - color: Colors - .transparent, - width: - 1.rpx, + const BorderSide( + color: Color( + 0x00000000), + width: 2, ), borderRadius: - BorderRadius.circular( - 8.rpx), + BorderRadius + .circular(8), ), errorBorder: - OutlineInputBorder( + UnderlineInputBorder( borderSide: - BorderSide( - // - width: - 1.rpx, + const BorderSide( + color: Color( + 0x00000000), + width: 2, ), borderRadius: - BorderRadius.circular( - 8.rpx), + BorderRadius + .circular(8), ), focusedErrorBorder: - OutlineInputBorder( + UnderlineInputBorder( borderSide: - BorderSide( - // - width: - 1.rpx, + const BorderSide( + color: Color( + 0x00000000), + width: 2, ), borderRadius: - BorderRadius.circular( - 8.rpx), + BorderRadius + .circular(8), ), ), - style: TextStyle( - letterSpacing: - 0, - color: Colors - .black, - fontSize: - 26.rpx), + style: + TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx, + ), ), ), ), diff --git a/lib/pages/mh_page/device_share_page.dart b/lib/pages/mh_page/device_share_page.dart index cdb0bf4..e720dea 100644 --- a/lib/pages/mh_page/device_share_page.dart +++ b/lib/pages/mh_page/device_share_page.dart @@ -4,16 +4,13 @@ import 'package:flutter/services.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/util/CommonVariables.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/NullDataComponentWidget.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; -import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; import 'package:vbvs_app/controller/mh_controller/mhdevice_share_controller.dart'; import 'package:vbvs_app/model/api_response.dart'; -import 'package:vbvs_app/pages/mh_page/EmptyMessageWidget.dart'; import 'package:vbvs_app/pages/mh_page/ShareUserWidget.dart'; class ShareDeviceWidget extends GetView { @@ -216,125 +213,280 @@ class ShareDeviceWidget extends GetView { ), ), )), - Obx( - () => GestureDetector( - onTap: () { - // 当点击时,将 type 设置为 0(允许控制) - controller.model.type = 1; - controller.updateAll(); - }, - child: Container( - margin: EdgeInsets.only(top: 76.rpx), - width: MediaQuery.sizeOf(context).width, - constraints: const BoxConstraints( - minHeight: 46, - ), - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(0), - ), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '允许对方控制该设备', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Colors.white, - fontSize: 26.rpx, - letterSpacing: 0.0, - ), + GestureDetector( + onTap: () { + // 当点击时,将 type 设置为 0(允许控制) + controller.model.type = 1; + controller.updateAll(); + }, + child: Container( + margin: EdgeInsets.only(top: 76.rpx), + width: MediaQuery.sizeOf(context).width, + constraints: const BoxConstraints( + minHeight: 46, + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(0), + ), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '允许对方控制该设备'.tr, + style: TextStyle( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0.0, ), - Theme( - data: - Theme.of(context).copyWith( - unselectedWidgetColor: Color( - 0xFFC8CBD2), // 改变未选中状态边框颜色 + ), + Obx(() { + double h = 33.rpx; + bool check = + controller.model.type == 1; + + return Container( + height: 33.rpx, + child: AspectRatio( + aspectRatio: 1, + child: Center( + child: Container( + height: h, + width: h, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + h / 2), + border: Border.all( + width: check ? 1 : 0.5, + color: + Color(0xFFC8CBD2), + ), + ), + child: check + ? Center( + child: ClipOval( + child: Container( + width: h * 0.6, + height: h * 0.6, + color: const Color( + 0xFF6BFDAC), + ), + ), + ) + : null, + ), ), - child: Radio( - value: 1, - groupValue: - controller.model.type, - onChanged: (value) { - controller.model.type = - value!; - controller.updateAll(); - }, - activeColor: - const Color(0xFF6BFDAC), - materialTapTargetSize: - MaterialTapTargetSize - .shrinkWrap, // 减少内边距 - visualDensity: VisualDensity( - horizontal: -4, - vertical: -4), // 缩小视觉密度 - )) - ], - ), + ), + ); + }), + ], ), ), ), - Obx( - () => GestureDetector( - onTap: () { - // 当点击时,将 type 设置为 1(仅允许查看) - controller.model.type = 2; - controller.updateAll(); - }, - child: Container( - width: MediaQuery.sizeOf(context).width, - constraints: const BoxConstraints( - minHeight: 46, - ), - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(0), - ), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '仅允许对方查看该设备', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Colors.white, - fontSize: 26.rpx, - letterSpacing: 0.0, - ), + + // Obx( + // () => GestureDetector( + // onTap: () { + // controller.model.type = 2; + // controller.updateAll(); + // }, + // child: Container( + // width: MediaQuery.sizeOf(context).width, + // constraints: const BoxConstraints( + // minHeight: 46, + // ), + // decoration: BoxDecoration( + // borderRadius: + // BorderRadius.circular(0), + // ), + // child: Row( + // mainAxisSize: MainAxisSize.max, + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // '仅允许对方查看该设备'.tr, + // style: TextStyle( + // fontFamily: 'Readex Pro', + // color: Colors.white, + // fontSize: 26.rpx, + // letterSpacing: 0.0, + // ), + // ), + // // Theme( + // // data: + // // Theme.of(context).copyWith( + // // unselectedWidgetColor: Color( + // // 0xFFC8CBD2), // 改变未选中状态边框颜色 + // // ), + // // child: Radio( + // // value: 2, + // // groupValue: + // // controller.model.type, + // // onChanged: (value) { + // // controller.model.type = + // // value!; + // // controller.updateAll(); + // // }, + // // activeColor: + // // const Color(0xFF6BFDAC), + // // materialTapTargetSize: + // // MaterialTapTargetSize + // // .shrinkWrap, // 减少内边距 + // // visualDensity: VisualDensity( + // // horizontal: -4, + // // vertical: -4), // 缩小视觉密度 + // // )) + // ClipOval( + // child: Container( + // height: + // MediaQuery.sizeOf(context) + // .height * + // 0.0449, + // child: AspectRatio( + // aspectRatio: 1, + // child: Center( + // child: LayoutBuilder( + // builder: (context, + // constraints) { + // double h = + // MediaQuery.sizeOf( + // context) + // .height * + // 0.0326; + // bool check = controller + // .model.type == + // 2; + // if (check) { + // return Container( + // height: h, + // width: h, + // decoration: + // BoxDecoration( + // borderRadius: + // BorderRadius + // .circular( + // h / 2), + // border: Border.all( + // width: 1, + // color: Color( + // 0xFF6BFDAC)), + // ), + // child: Center( + // child: ClipOval( + // child: Container( + // width: + // h * 0.6, + // height: + // h * 0.6, + // color: Color( + // 0xFF6BFDAC)), + // ), + // ), + // ); + // } else { + // return Container( + // height: h, + // width: h, + // decoration: + // BoxDecoration( + // borderRadius: + // BorderRadius + // .circular( + // h / 2), + // border: Border.all( + // width: 0.5, + // color: Colors + // .white), + // ), + // ); + // } + // }, + // ), + // ), + // ), + // ), + // ), + // ], + // ), + // ), + // ), + // ), + GestureDetector( + onTap: () { + controller.model.type = 2; + controller.updateAll(); + }, + child: Container( + width: MediaQuery.sizeOf(context).width, + constraints: + const BoxConstraints(minHeight: 46), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(0), + ), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '仅允许对方查看该设备'.tr, + style: TextStyle( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 26.rpx, + letterSpacing: 0.0, ), - Theme( - data: - Theme.of(context).copyWith( - unselectedWidgetColor: Color( - 0xFFC8CBD2), // 改变未选中状态边框颜色 + ), + // ✅ 只包住响应式控件部分 + Obx(() { + double h = 33.rpx; + bool check = + controller.model.type == 2; + + return Container( + height: 33.rpx, + child: AspectRatio( + aspectRatio: 1, + child: Center( + child: Container( + height: h, + width: h, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + h / 2), + border: Border.all( + width: check ? 1 : 0.5, + color: + Color(0xFFC8CBD2), + ), + ), + child: check + ? Center( + child: ClipOval( + child: Container( + width: h * 0.6, + height: h * 0.6, + color: const Color( + 0xFF6BFDAC), + ), + ), + ) + : null, + ), ), - child: Radio( - value: 2, - groupValue: - controller.model.type, - onChanged: (value) { - controller.model.type = - value!; - controller.updateAll(); - }, - activeColor: - const Color(0xFF6BFDAC), - materialTapTargetSize: - MaterialTapTargetSize - .shrinkWrap, // 减少内边距 - visualDensity: VisualDensity( - horizontal: -4, - vertical: -4), // 缩小视觉密度 - )) - ], - ), + ), + ); + }), + ], ), ), ), + Align( alignment: const AlignmentDirectional(0, 0), child: Padding( @@ -361,7 +513,7 @@ class ShareDeviceWidget extends GetView { .currentColor.sc9); } }, - text: '发送邀请', + text: '发送邀请'.tr, options: FFButtonOptions( height: 60.rpx, padding: @@ -404,7 +556,7 @@ class ShareDeviceWidget extends GetView { padding: const EdgeInsetsDirectional .fromSTEB(14, 0, 0, 16), child: Text( - '已分享用户', + '已分享用户'.tr, style: TextStyle( fontFamily: 'Readex Pro', color: Colors.white, diff --git a/lib/pages/mh_page/edit_address_page.dart b/lib/pages/mh_page/edit_address_page.dart index 2100c6e..09a6e24 100644 --- a/lib/pages/mh_page/edit_address_page.dart +++ b/lib/pages/mh_page/edit_address_page.dart @@ -2,6 +2,7 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutter_city_picker/listener/picker_listener.dart'; import 'package:flutter_city_picker/model/address.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; @@ -739,6 +740,158 @@ class EditAddressPage extends GetView ], ), ), + // Expanded( + // child: InkWell( + // onTap: () { + // CityPicker.show( + // context: + // context, + // cityPickerListener: + // this, + // // 在大屏/Web 上最大宽度为 600px + // // 移除内边距 + // ); + // }, + // child: Container( + // width: 100, + // height: 100, + // decoration: + // BoxDecoration( + // color: const Color( + // 0xFFF3F5F6), + // borderRadius: + // BorderRadius + // .circular( + // 8), + // ), + // alignment: + // Alignment + // .center, + // child: Obx(() { + // return TextFormField( + // enabled: + // false, + // controller: controller.onReDraw( + // TextEditingController( + // text: + // controller.model.all_address), + // (val) { + // val.text = + // controller.model.all_address ?? + // ""; + // }), + // // autofocus: true, + // obscureText: + // false, + // maxLines: 1, + // textAlignVertical: + // TextAlignVertical + // .center, // 垂直居中 + // decoration: InputDecoration( + // contentPadding: EdgeInsets.symmetric( + // vertical: + // 25.rpx, + // horizontal: + // 26.rpx, + // ), + // labelStyle: TextStyle( + // fontFamily: + // 'Readex Pro', + // letterSpacing: + // 0, + // ), + // hintStyle: TextStyle( + // fontFamily: + // 'Readex Pro', + // letterSpacing: + // 0, + // ), + // enabledBorder: UnderlineInputBorder( + // borderSide: + // const BorderSide( + // color: + // Color(0x00000000), + // width: + // 2, + // ), + // borderRadius: + // BorderRadius.circular(8), + // ), + // disabledBorder: UnderlineInputBorder( + // borderSide: + // const BorderSide( + // color: + // Color(0x00000000), + // width: + // 0, + // ), + // borderRadius: + // BorderRadius.circular(8), + // ), + // focusedBorder: UnderlineInputBorder( + // borderSide: + // const BorderSide( + // color: + // Color(0x00000000), + // width: + // 2, + // ), + // borderRadius: + // BorderRadius.circular(8), + // ), + // errorBorder: UnderlineInputBorder( + // borderSide: + // const BorderSide( + // color: + // Color(0x00000000), + // width: + // 2, + // ), + // borderRadius: + // BorderRadius.circular(8), + // ), + // focusedErrorBorder: UnderlineInputBorder( + // borderSide: + // const BorderSide( + // color: + // Color(0x00000000), + // width: + // 2, + // ), + // borderRadius: + // BorderRadius.circular(8), + // ), + // suffixIcon: Transform.rotate( + // angle: + // 1.5708, // 90 度相当于 pi / 2 弧度 + // child: + // Icon( + // Icons.arrow_forward_ios, + // color: + // Colors.black, + // size: + // 26.rpx, + // ), + // )), + // style: + // TextStyle( + // fontFamily: + // 'Readex Pro', + // letterSpacing: + // 0, + // color: Color( + // 0xFF333333), + // fontSize: + // 26.rpx, + // overflow: + // TextOverflow + // .ellipsis, + // ), + // ); + // })), + + // ), + // ), Expanded( child: InkWell( onTap: () { @@ -747,148 +900,71 @@ class EditAddressPage extends GetView context, cityPickerListener: this, - // 在大屏/Web 上最大宽度为 600px - // 移除内边距 ); }, child: Container( - width: 100, - height: 100, - decoration: - BoxDecoration( - color: const Color( - 0xFFF3F5F6), - borderRadius: - BorderRadius - .circular( - 8), - ), - alignment: - Alignment - .center, - child: Obx(() { - return TextFormField( - enabled: - false, - controller: controller.onReDraw( - TextEditingController( - text: - controller.model.all_address), - (val) { - val.text = - controller.model.all_address ?? - ""; - }), - // autofocus: true, - obscureText: - false, - textAlignVertical: - TextAlignVertical - .center, // 垂直居中 - decoration: InputDecoration( - contentPadding: EdgeInsets.symmetric( - vertical: - 25.rpx, - horizontal: + width: 100, + height: 100, + decoration: + BoxDecoration( + color: const Color( + 0xFFF3F5F6), + borderRadius: + BorderRadius + .circular( + 8), + ), + alignment: + Alignment + .center, + child: Obx(() { + return Row( + children: [ + Expanded( + child: + Padding( + padding: EdgeInsets.only( + left: 27 + .rpx, + right: + 10.rpx), + child: + Text( + controller.model.all_address ?? + '', + maxLines: + 1, + overflow: + TextOverflow.ellipsis, + style: + TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + color: + Color(0xFF333333), + fontSize: 26.rpx, ), - labelStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), - hintStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), - enabledBorder: UnderlineInputBorder( - borderSide: - const BorderSide( - color: - Color(0x00000000), - width: - 2, - ), - borderRadius: - BorderRadius.circular(8), - ), - disabledBorder: UnderlineInputBorder( - borderSide: - const BorderSide( - color: - Color(0x00000000), - width: - 0, - ), - borderRadius: - BorderRadius.circular(8), - ), - focusedBorder: UnderlineInputBorder( - borderSide: - const BorderSide( - color: - Color(0x00000000), - width: - 2, - ), - borderRadius: - BorderRadius.circular(8), - ), - errorBorder: UnderlineInputBorder( - borderSide: - const BorderSide( - color: - Color(0x00000000), - width: - 2, - ), - borderRadius: - BorderRadius.circular(8), - ), - focusedErrorBorder: UnderlineInputBorder( - borderSide: - const BorderSide( - color: - Color(0x00000000), - width: - 2, - ), - borderRadius: - BorderRadius.circular(8), - ), - suffixIcon: Transform.rotate( - angle: - 1.5708, // 90 度相当于 pi / 2 弧度 - child: - Icon( - Icons.arrow_forward_ios, - color: - Colors.black, - size: - 26.rpx, - ), - )), - style: - TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - color: Color( - 0xFF333333), - fontSize: - 26.rpx, - overflow: - TextOverflow - .ellipsis, - ), - ); - })), + ), + )), + Padding( + padding: + EdgeInsets.only(right: 27.rpx), + child: Container( + height: 30.rpx, + width: 30.rpx, + child: SvgPicture.asset( + 'assets/img/icon/expand_more.svg', + color: Colors.black, + ))) + ], + ); + }), + ), ), - ), + ) ].divide(const SizedBox( width: 15)), ), diff --git a/lib/pages/mh_page/edit_bed.dart b/lib/pages/mh_page/edit_bed.dart index 466f414..205e9cf 100644 --- a/lib/pages/mh_page/edit_bed.dart +++ b/lib/pages/mh_page/edit_bed.dart @@ -6,6 +6,7 @@ import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; +import 'package:vbvs_app/controller/mh_controller/device_list_controller.dart'; class EditBedPage extends StatefulWidget { final Map data; @@ -19,6 +20,7 @@ BoxConstraints? bodysize; class _EditBedPageState extends State { late Map editedData; late TextEditingController _nameController; //名称文本输入框 + DeviceListController deviceListController = Get.find(); @override void initState() { super.initState(); @@ -205,6 +207,7 @@ class _EditBedPageState extends State { onSuccess: (res) { TopSlideNotification.show(context, text: "修改名称成功".tr); + deviceListController.getDeviceList(); }, ); }, @@ -222,7 +225,7 @@ class _EditBedPageState extends State { decoration: BoxDecoration( borderRadius: BorderRadius.circular(6), ), - child: Text("完成", + child: Text("完成".tr, style: TextStyle( color: const Color(0xFF003058), fontSize: 26.rpx)), diff --git a/lib/pages/mh_page/experience_store_page.dart b/lib/pages/mh_page/experience_store_page.dart index f99f3bc..a3bb28c 100644 --- a/lib/pages/mh_page/experience_store_page.dart +++ b/lib/pages/mh_page/experience_store_page.dart @@ -11,6 +11,7 @@ import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/NullDataComponentWidget.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/mh_controller/experience_store_list_page.dart'; import 'package:vbvs_app/controller/weather/weather_controller.dart'; import 'package:vbvs_app/pages/mh_page/Empty.dart'; @@ -104,7 +105,9 @@ class _ExperienceStorePageState extends State { highlightColor: Color(0xFF055466), padding: EdgeInsets.only(left: 0), onTap: () { - Get.toNamed("/myExperiencePage"); + TopSlideNotification.show(context, + text: "待开发功能".tr); + // Get.toNamed("/myExperiencePage"); }, child: SvgPicture.asset( 'assets/img/icon/history_store.svg', diff --git a/lib/pages/mh_page/help/article.dart b/lib/pages/mh_page/help/article.dart index 2df7b39..66e6bd6 100644 --- a/lib/pages/mh_page/help/article.dart +++ b/lib/pages/mh_page/help/article.dart @@ -2,177 +2,116 @@ 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/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; -class HelpArticle extends StatelessWidget { - Map article; +class HelpArticle extends StatefulWidget { + final Map article; HelpArticle({super.key, required this.article}); - // get articleController => Get.find(); - get userInfoController => Get.find(); + @override + State createState() => _HelpArticleState(); +} - 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: ""), - // ), - // ), - // ), - // ], - // ), - // ), - // ), - // ), - // ), - // ); - // } +class _HelpArticleState extends State { + bool isLoading = true; + @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xFF042C46), - appBar: AppBar( - backgroundColor: const Color(0xFF042C46), - title: Text("问题与帮助", style: TextStyle(color: Colors.white)), - centerTitle: true, - leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.white), - onPressed: () => Navigator.pop(context), + return Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/new_background.png'), // 本地图片 + fit: BoxFit.fill, // 填满整个 Container + ), ), - elevation: 0, - ), - body: Column( - children: [ - Container( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), - alignment: Alignment.centerLeft, - child: Text( - article['title'], - style: const TextStyle( - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.bold), - ), - ), - Expanded( - child: InAppWebView( - initialData: InAppWebViewInitialData( - data: wrapHtml(article['content']), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: AppBar( + backgroundColor: Colors.transparent, + automaticallyImplyLeading: false, + iconTheme: IconThemeData(color: Colors.white), + 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, + ), + ), + // 左侧图标 + Positioned( + left: 20.rpx, + child: returnIconButtomNew, + ), + ], + ), ), + actions: [], + centerTitle: false, ), - ), - ], - ), - ); + body: Padding( + padding: EdgeInsets.only(left: 30.rpx, right: 30.rpx), + child: Column( + children: [ + Container( + padding: EdgeInsets.only( + left: 26.rpx, top: 53.rpx, bottom: 15.rpx), + alignment: Alignment.centerLeft, + child: Text( + widget.article['title'], + style: TextStyle( + color: Colors.white, + fontSize: 30.rpx, + ), + ), + ), + Divider( + color: Color(0XFF929699), + thickness: 0.5.rpx, + ), + Expanded( + child: Stack( + children: [ + InAppWebView( + initialData: InAppWebViewInitialData( + data: wrapHtml(widget.article['content']), + ), + initialSettings: InAppWebViewSettings( + transparentBackground: true, + ), + onLoadStop: (controller, url) { + setState(() { + isLoading = false; + }); + }, + ), + if (isLoading) + Container( + color: const Color(0xFF042C46), + alignment: Alignment.center, + child: const CircularProgressIndicator( + valueColor: + AlwaysStoppedAnimation(Colors.white), + ), + ), + ], + ), + ), + ], + ), + ))); } - /// 包装成完整 HTML 页面,添加适配样式 String wrapHtml(String htmlContent) { return """ @@ -182,11 +121,12 @@ class HelpArticle extends StatelessWidget {