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] =?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}) =>