diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launchermh.png b/android/app/src/main/res/mipmap-hdpi/ic_launchermh.png new file mode 100644 index 0000000..17f8265 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launchermh.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launchermh.png b/android/app/src/main/res/mipmap-mdpi/ic_launchermh.png new file mode 100644 index 0000000..98c4f5e Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launchermh.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launchermh.png b/android/app/src/main/res/mipmap-xhdpi/ic_launchermh.png new file mode 100644 index 0000000..63ce850 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launchermh.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launchermh.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launchermh.png new file mode 100644 index 0000000..92662bd Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launchermh.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launchermh.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launchermh.png new file mode 100644 index 0000000..d31b2cb Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launchermh.png differ diff --git a/lib/common/color/ServiceConstant.dart b/lib/common/color/ServiceConstant.dart index cecc407..b97a506 100644 --- a/lib/common/color/ServiceConstant.dart +++ b/lib/common/color/ServiceConstant.dart @@ -1,45 +1,45 @@ class ServiceConstant { - static const String baseHost = "vsbs-test.he-info.cn";//服务地址 + static const String baseHost = "vsbs-test.he-info.cn"; //服务地址 // static const String baseHost = "vsbst-api.he-info.cn";//服务地址 static const String service_address = "http://$baseHost"; - static String server_service = "/vsbs_app_server";//服务名称 + static String server_service = "/vsbs_app_server"; //服务名称 - static String send_code = "/api/verifycode/send";//发送验证码 - static String login = "/api/user/login";//登录 - static String get_bluetooth_device_status = "/api/device/status/info";//设备绑定状态 - static String device_bind = "/api/device/bind";//设备绑定 - static String device_type = "/api/device/type/list";//设备类型 - static String upload_file = "/api/file/info";//上传文件 - static String user_info = "/api/user/info";//更新用户资料,查询用户信息 - static String device_list = "/api/device/list";//绑定设备列表 - static String person_info = "/api/personnel/info";//用户资料 - static String sleep_report = "/api/device/sleep/data";//睡眠报告 - static String device_share = "/api/device/share";//分享设备 - static String message_list = "/api/mesasge/list";//消息列表 - static String message_read = "/api/mesasge/read";//消息未读数量 - static String device_show = "/api/device/bind";//更新设备绑定 - static String disease_list = "/api/personnel/disease/list";//获取疾病类型 - static String share_deleted = "";//删除分享 - static String start_calibration = "/api/caibration";//开始校准 - static String calibration_process = "/api/caibration";//校准进度 - static String submit_repair = "/api/device/repair";//提交报修 - static String user_setting = "/api/user/config";//查询和更新用户自定义配置 + static String send_code = "/api/verifycode/send"; //发送验证码 + static String login = "/api/user/login"; //登录 + static String get_bluetooth_device_status = + "/api/device/status/info"; //设备绑定状态 + static String device_bind = "/api/device/bind"; //设备绑定 + static String device_type = "/api/device/type/list"; //设备类型 + static String upload_file = "/api/file/info"; //上传文件 + static String user_info = "/api/user/info"; //更新用户资料,查询用户信息 + static String device_list = "/api/device/list"; //绑定设备列表 + static String person_info = "/api/personnel/info"; //用户资料 + static String sleep_report = "/api/device/sleep/data"; //睡眠报告 + static String device_share = "/api/device/share"; //分享设备 + static String message_list = "/api/mesasge/list"; //消息列表 + static String message_read = "/api/mesasge/read"; //消息未读数量 + static String device_show = "/api/device/bind"; //更新设备绑定 + static String disease_list = "/api/personnel/disease/list"; //获取疾病类型 + static String share_deleted = ""; //删除分享 + static String start_calibration = "/api/caibration"; //开始校准 + static String calibration_process = "/api/caibration"; //校准进度 + static String submit_repair = "/api/device/repair"; //提交报修 + static String user_setting = "/api/user/config"; //查询和更新用户自定义配置 static String room_list = "/api/room/info"; //查询房间列表 static String issue_list = "/api/help/list"; //问题与帮助列表 - + static String city_data = "/api/city/data/info"; //城市数据 + static String address_list = "/api/addresss/list"; //查询地址列表 + static String add_address = "/api/addresss/info"; //添加地址 static String logService = "$service_address/vsbs_log"; static const String webSocketService = "wss://$baseHost/vsbs_ws_gateway/ws"; static const String sleep_token = "HdAMjzqiYQKsmHRyEFKhfRGQ"; - static const String sleep_report_url = "https://alltoone.he-info.cn/h5/#/mattress/sleep/sleep"; - - - static const String user_register = "/api/user/register";//用户注册 - static const String user_forgot = "/api/user/forgot";//找回密码 - static const String user_changePassword = "/api/user/changePassword";//修改密码 - static const String personnel_info = "/api/personnel/info";//人员信息列表 - - + static const String sleep_report_url = + "https://alltoone.he-info.cn/h5/#/mattress/sleep/sleep"; + static const String user_register = "/api/user/register"; //用户注册 + static const String user_forgot = "/api/user/forgot"; //找回密码 + static const String user_changePassword = "/api/user/changePassword"; //修改密码 + static const String personnel_info = "/api/personnel/info"; //人员信息列表 } diff --git a/lib/controller/mh_controller/address_controller.dart b/lib/controller/mh_controller/address_controller.dart index 48d41dc..f675ffe 100644 --- a/lib/controller/mh_controller/address_controller.dart +++ b/lib/controller/mh_controller/address_controller.dart @@ -1,10 +1,15 @@ import 'package:ef/ef.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_city_picker/model/address.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:json_annotation/json_annotation.dart'; +import 'package:vbvs_app/common/color/ServiceConstant.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/common/util/requestWithLog.dart'; +import 'package:vbvs_app/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'; part 'address_controller.g.dart'; @JsonSerializable() @@ -14,10 +19,11 @@ class AddressModel { String? city; //市 String? county; //区 String? street; //街道 - String? detail; //详细信息 + String? address; //详细信息 String? name; //名字 - String? phone; //手机号 - bool? ischecked = false; //是否默认 + String? tel; //手机号 + @JsonKey(name: 'default') + int? default_ = 0; //是否默认 int currentType = 0; String? all_address; @@ -52,105 +58,161 @@ class AddressController extends GetControllerEx { address["street"] = model.addressList![3].name; // 第四个元素为街道 } } - address['detail'] = model.detail; + address['address'] = model.address; address['name'] = model.name; - address['phone'] = model.phone; - address['isChecked'] = model.ischecked; + address['tel'] = model.tel; + address['default'] = model.default_; - // try { - // final data = await ef.client.rpc("get_now_datetime"); - // final response = await ef.client.from("app_user_address").update({ - // 'province': address["province"], - // 'city': address["city"], - // 'county': address["county"], - // 'street': address["street"], - // 'detail': address["detail"], - // 'name': address["name"], - // 'phone': address["phone"], - // 'ischecked': address['isChecked'] ? 1 : 0, - // 'update_time': - // DateFormat("yyyy-MM-dd HH:mm:ss").parse("$data").toString(), - // }).eq("id", address['id']); - // } catch (e) { - // print('Error fetching repairs: $e'); - // return e.toString(); - // } + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.add_address; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}"; + await requestWithLog( + logTitle: "更新地址", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: { + "id": address['_id'], + "default": address['default'], + "name": address['name'], + "tel": address['tel'], + // "area": address['all_address'], + "address": address['address'], + "province": address['province'], + "city": address['city'], + "county": address['county'], + "street": address['street'], + }, + onSuccess: (res) { + if (res.code == 1) { + print("更新地址成功"); + } + }, + ); return ''; } - addAddress(AddressModel model) async { - // try { - // final UserInfoController userInfoController = - // Get.find(); - // UserModel user = userInfoController.model.user!; + Future addAddress(AddressModel model, BuildContext context) async { + try { + final UserInfoController userInfoController = + Get.find(); + UserModel user = userInfoController.model.user!; - // // 设置省市区街道名称 - // if (model.addressList != null && model.addressList!.isNotEmpty) { - // if (model.addressList!.length > 0) - // model.province = model.addressList![0].name; // 第一个元素为省 - // if (model.addressList!.length > 1) - // model.city = model.addressList![1].name; // 第二个元素为市 - // if (model.addressList!.length > 2) - // model.county = model.addressList![2].name; // 第三个元素为区 - // if (model.addressList!.length > 3) - // model.street = model.addressList![3].name; // 第四个元素为街道 - // } + // 设置省市区街道名称 + if (model.addressList != null && model.addressList!.isNotEmpty) { + if (model.addressList!.length > 0) + model.province = model.addressList![0].name; + if (model.addressList!.length > 1) + model.city = model.addressList![1].name; + if (model.addressList!.length > 2) + model.county = model.addressList![2].name; + if (model.addressList!.length > 3) + model.street = model.addressList![3].name; + } - // // 查询数据库是否已有该用户的地址 - // final existingAddresses = await ef.client - // .from('app_user_address') - // .select() - // .eq('user_id', user.uid!); + // 查询现有地址判断是否设置为默认 + String listUrl = + "${ServiceConstant.service_address}${ServiceConstant.server_service}${ServiceConstant.address_list}"; + final listRes = await requestWithLog( + logTitle: "查询地址列表", + method: MyHttpMethod.get, + queryUrl: listUrl, + ); + if (listRes.data.length <= 0) { + model.default_ = 1; + } + // 添加地址 + String addUrl = + "${ServiceConstant.service_address}${ServiceConstant.server_service}${ServiceConstant.add_address}"; + final addRes = await requestWithLog( + logTitle: '添加地址', + method: MyHttpMethod.post, + queryUrl: addUrl, + data: model.toJson(), + ); - // // 如果没有地址,将新增地址默认选中 - // if (existingAddresses.isEmpty) { - // model.ischecked = true; - // } else if (model.ischecked == true) { - // // 如果新地址被选中,将其他地址的 `ischecked` 字段设为 `0` - // await ef.client - // .from('app_user_address') - // .update({'ischecked': 0}).eq('user_id', user.uid!); - // } - - // // 添加新地址 - // final response = await ef.client.from('app_user_address').insert({ - // 'province': model.province, - // 'city': model.city, - // 'county': model.county, - // 'street': model.street, - // 'detail': model.detail, - // 'name': model.name, - // 'phone': model.phone, - // 'ischecked': model.ischecked! ? 1 : 0, - // 'user_id': user.uid, - // }); - // } catch (e) { - // print(e); - // } + if (addRes.code == 1) { + TopSlideNotification.show(context, text: "添加成功".tr); + } + } catch (e) { + print(e); + } } - Future> getData({int? level, int? pid}) async { - // 构建查询 - return []; - // var query = ef.from("app_area_city").select(); + List? _cityCache; - // // 如果 pid 不为 null,添加 pid 的条件 - // if (pid != null) { - // query = query.eq("pid", pid); - // } - // if (level != null) { - // query = query.eq("deep", level); - // } - // List arr = await query; + Future _loadCityDataOnce() async { + if (_cityCache != null) return; - // List addressNodes = arr.map((item) { - // return AddressNode.fromJson({ - // "name": item["ext_name"], // ext_name 对应 name - // "code": item["id"], // id 对应 code - // "letter": item["pinyin_prefix_upper"], // pinyin_prefix_upper 对应 letter - // }); - // }).toList(); + String country = "CN"; + String queryUrl = + "${ServiceConstant.service_address}${ServiceConstant.server_service}${ServiceConstant.city_data}?country=$country"; - // return addressNodes; + await requestWithLog( + logTitle: "查询城市数据", + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + if (res.data != null && res.data is List) { + // 提取所有 data 并展开成一个统一列表 + _cityCache = res.data + .where((e) => e["data"] != null && e["data"] is List) + .expand((e) => e["data"] as List) + .toList(); + } + }, + ); + } + + // 构建查询 + Future> getData({int? level, String? parentCode}) async { + await _loadCityDataOnce(); // 确保只加载一次 + if (_cityCache == null) return []; + + // 获取省级数据 + if (parentCode == null || parentCode.isEmpty) { + return _cityCache!.map((item) { + return AddressNode.fromJson({ + "name": item["name"], + "code": item["code"], + "letter": _getLetter(item["name"]), + }); + }).toList(); + } + + // 递归查找下级 + final parent = _findNodeByCode(_cityCache!, parentCode); + if (parent == null || parent["children"] == null) return []; + + List children = parent["children"]; + return children.map((item) { + return AddressNode.fromJson({ + "name": item["name"], + "code": item["code"], + "letter": _getLetter(item["name"]), + }); + }).toList(); + } + + Map? _findNodeByCode(List list, String code) { + for (var item in list) { + if (item is Map) { + if (item["code"] == code) return item; + if (item["children"] != null && item["children"] is List) { + var result = _findNodeByCode(item["children"], code); + if (result != null) return result; + } + } + } + return null; + } + +// 工具:中文首字母转大写英文(你也可以用更专业的拼音库) + 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(); } } diff --git a/lib/controller/mh_controller/address_controller.g.dart b/lib/controller/mh_controller/address_controller.g.dart index 2e0927c..9df01c5 100644 --- a/lib/controller/mh_controller/address_controller.g.dart +++ b/lib/controller/mh_controller/address_controller.g.dart @@ -11,10 +11,10 @@ AddressModel _$AddressModelFromJson(Map json) => AddressModel() ..city = json['city'] as String? ..county = json['county'] as String? ..street = json['street'] as String? - ..detail = json['detail'] as String? + ..address = json['address'] as String? ..name = json['name'] as String? - ..phone = json['phone'] as String? - ..ischecked = json['ischecked'] as bool? + ..tel = json['tel'] as String? + ..default_ = (json['default'] as num?)?.toInt() ..currentType = (json['currentType'] as num).toInt() ..all_address = json['all_address'] as String?; @@ -24,10 +24,10 @@ Map _$AddressModelToJson(AddressModel instance) => 'city': instance.city, 'county': instance.county, 'street': instance.street, - 'detail': instance.detail, + 'address': instance.address, 'name': instance.name, - 'phone': instance.phone, - 'ischecked': instance.ischecked, + 'tel': instance.tel, + 'default': instance.default_, 'currentType': instance.currentType, 'all_address': instance.all_address, }; diff --git a/lib/controller/mh_controller/address_list_controller.dart b/lib/controller/mh_controller/address_list_controller.dart index 25b0456..7849683 100644 --- a/lib/controller/mh_controller/address_list_controller.dart +++ b/lib/controller/mh_controller/address_list_controller.dart @@ -1,6 +1,7 @@ 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/util/requestWithLog.dart'; part 'address_list_controller.g.dart'; @@ -23,42 +24,48 @@ class AddressListController extends GetControllerEx { attr = GetModel(AddressListModel()).obs; } - // getAddressList() async { - // await ApiService.request.get("/api/address/info/list").then((d) { - // model.addressList = d.data["data"] ?? []; - // updateAll(); - // }).catchError((e) { - // print("$e"); - // }); - // } + getAddressList() async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.address_list; + String queryUrl = "$serviceAddress$serviceName$serviceApi"; - // //更新默认 - // Future updateDefault(address) async { - // var id = address['id']; - // var uid = address['userId']; - // try { - // await ef.client - // .from("app_user_address") - // .update({ - // 'ischecked': 0, - // }) - // .eq("user_id", address['userId']) - // .eq("ischecked", 1); - // await ef.client.from("app_user_address").update({ - // 'ischecked': 1, - // }).eq("id", address['id']); - // } catch (e) { - // print('Error fetching repairs: $e'); - // } - // } + requestWithLog( + logTitle: '查询地址列表', + method: MyHttpMethod.get, + queryUrl: queryUrl, + onSuccess: (res) { + // 安全检查 res.data 是否为 List + if (res.data != null && res.data is List && res.data.isNotEmpty) { + model.addressList = res.data; + } else { + model.addressList = []; // 设为空数组,防止空指针问题 + } + updateAll(); + }, + onFailure: (err) { + model.addressList = []; // 请求失败时也清空列表以防旧数据残留 + updateAll(); + }, + ); + } // // 删除地址 - // Future deleteAddress(String id) async { - // try { - // await ef.client.from("app_user_address").delete().eq("id", id); - // print("Address with ID $id has been successfully deleted."); - // } catch (e) { - // print("Error deleting address with ID $id: $e"); - // } - // } + Future deleteAddress(String id) async { + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.add_address; + String queryUrl = "$serviceAddress$serviceName$serviceApi?id=$id"; + requestWithLog( + logTitle: '删除地址', + method: MyHttpMethod.delete, + queryUrl: queryUrl, + onSuccess: (res) { + getAddressList(); + }, + onFailure: (err) { + getAddressList(); + }, + ); + } } diff --git a/lib/controller/mh_controller/apply_repair_controller.dart b/lib/controller/mh_controller/apply_repair_controller.dart index 7343622..f900fb6 100644 --- a/lib/controller/mh_controller/apply_repair_controller.dart +++ b/lib/controller/mh_controller/apply_repair_controller.dart @@ -6,6 +6,7 @@ import 'package:vbvs_app/common/color/repair_status.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/myDialog/my_dialog_controller.dart'; import 'package:vbvs_app/common/util/requestWithLog.dart'; +import 'package:vbvs_app/controller/mh_controller/device_list_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/user_data.dart'; @@ -216,16 +217,14 @@ class ApplyRepairController extends GetControllerEx { return message; } - // Future getDeviceList() async { - // final UserInfoController userInfoController = - // Get.find(); - // // UserModel loginUser = userInfoController.model.user!; - // DeviceListController deviceListController = Get.find(); - // await deviceListController.getDeviceList(); - // var aa = deviceListController.model.deviceListWyf; - // ApplyRepairController applyRepairController = Get.find(); - // applyRepairController.model.device_list = aa; - // } + Future getDeviceList() async { + // UserModel loginUser = userInfoController.model.user!; + DeviceListController deviceListController = Get.find(); + await deviceListController.getDeviceList(); + var aa = deviceListController.model.deviceList; + ApplyRepairController applyRepairController = Get.find(); + applyRepairController.model.device_list = aa; + } // String getPublicUrl(String path) { // try { diff --git a/lib/controller/mh_controller/device_list_controller.dart b/lib/controller/mh_controller/device_list_controller.dart index ff5b058..17e523a 100644 --- a/lib/controller/mh_controller/device_list_controller.dart +++ b/lib/controller/mh_controller/device_list_controller.dart @@ -18,7 +18,7 @@ part 'device_list_controller.g.dart'; class DeviceListModel { //设备列表 List deviceList = []; - List deviceListWyf = []; + @JsonKey(ignore: true) String? keyword; diff --git a/lib/controller/mh_controller/device_list_controller.g.dart b/lib/controller/mh_controller/device_list_controller.g.dart index 0c92bc2..9cb69ac 100644 --- a/lib/controller/mh_controller/device_list_controller.g.dart +++ b/lib/controller/mh_controller/device_list_controller.g.dart @@ -7,12 +7,9 @@ part of 'device_list_controller.dart'; // ************************************************************************** DeviceListModel _$DeviceListModelFromJson(Map json) => - DeviceListModel() - ..deviceList = json['deviceList'] as List - ..deviceListWyf = json['deviceListWyf'] as List; + DeviceListModel()..deviceList = json['deviceList'] as List; Map _$DeviceListModelToJson(DeviceListModel instance) => { 'deviceList': instance.deviceList, - 'deviceListWyf': instance.deviceListWyf, }; diff --git a/lib/controller/repair/repair_controller.dart b/lib/controller/repair/repair_controller.dart index a3689f3..b909bf2 100644 --- a/lib/controller/repair/repair_controller.dart +++ b/lib/controller/repair/repair_controller.dart @@ -19,8 +19,8 @@ class RepairModel { // String? issue; //问题描述 String? fileUrl; //文件地址 String? mac; //状态 - String? desc;//问题描述 - List? img;//上传图片 + String? desc; //问题描述 + List? img; //上传图片 RepairModel(); factory RepairModel.fromJson(Map json) { try { diff --git a/lib/controller/user_info_controller.g.dart b/lib/controller/user_info_controller.g.dart index 3c95bf2..a0bde94 100644 --- a/lib/controller/user_info_controller.g.dart +++ b/lib/controller/user_info_controller.g.dart @@ -18,7 +18,6 @@ UserInfoModel _$UserInfoModelFromJson(Map json) => ..deviceId = json['deviceId'] as String? ..deviceModel = json['deviceModel'] as String? ..appVersion = json['appVersion'] as String? - ..img_bucket = json['img_bucket'] as String? ..login = (json['login'] as num?)?.toInt() ..deviceBindNum = (json['deviceBindNum'] as num?)?.toInt() ..loginPhone = (json['loginPhone'] as num?)?.toInt(); @@ -33,7 +32,6 @@ Map _$UserInfoModelToJson(UserInfoModel instance) => 'deviceId': instance.deviceId, 'deviceModel': instance.deviceModel, 'appVersion': instance.appVersion, - 'img_bucket': instance.img_bucket, 'login': instance.login, 'deviceBindNum': instance.deviceBindNum, 'loginPhone': instance.loginPhone, diff --git a/lib/pages/common/bezier_bottom_navigation_bar.dart b/lib/pages/common/bezier_bottom_navigation_bar.dart index 1d411a6..0b15fcb 100644 --- a/lib/pages/common/bezier_bottom_navigation_bar.dart +++ b/lib/pages/common/bezier_bottom_navigation_bar.dart @@ -73,7 +73,7 @@ class BezierBottomNavigationBar extends StatelessWidget { fontSize: 22.rpx, color: selectedIndex == i ? Colors.white - : Colors.grey.shade400, + : const Color(0XFF929699), ), ), ], diff --git a/lib/pages/common/selectDialog.dart b/lib/pages/common/selectDialog.dart index cd0c840..52591c7 100644 --- a/lib/pages/common/selectDialog.dart +++ b/lib/pages/common/selectDialog.dart @@ -381,7 +381,7 @@ Future showWeightPickerDialog( context, weights, tempIndex, // ✅ 传入 RxInt - unit: "cm", + unit: "kg", ), ), ], @@ -408,7 +408,6 @@ Future showHeightPickerDialog( int selectedIndex = heights.indexOf(initialHeight); // int tempIndex = selectedIndex; final RxInt tempIndex = RxInt(selectedIndex); // ✅ 改为 RxInt - ThemeController themeController = Get.find(); await showDialog( diff --git a/lib/pages/mh_page/MattressControl.dart b/lib/pages/mh_page/MattressControl.dart index 5e54853..55856b5 100644 --- a/lib/pages/mh_page/MattressControl.dart +++ b/lib/pages/mh_page/MattressControl.dart @@ -17,20 +17,22 @@ class _MattressControlPageState extends State { final controller = Get.put(ControlCardController()); final data = { - "_id": "684bf0845a81f423c0000000", - "uid": "68465947a0cff49592000000", + "_id": "333330000000000000000000", + "uid": "684b90df767e00004e0072e2", "bind_type": 1, "device_type": 3, - "mac": "545024122617", + "mac": "545024122666", "bind_mac": null, - "bind_mac_a": "48CA43B2E8C8", - "bind_mac_b": "48CA43B2E8B0", + "bind_mac_a": "B43A45C3D411", + "bind_mac_b": "B43A45C3D388", "position": 0, "share_uid": null, "person": null, "op_type": null, "show": true, - "create_time": 1749807236514, + "create_time": 1750121686274, + "room_id": "684395bf9ef8601da20f6475", + "roomName": "主卧", "shareNum": 0, "status": { "signal": -1, @@ -40,7 +42,7 @@ class _MattressControlPageState extends State { "failure": 0, "updateTime": -1 }, - "code": "545024122617" + "code": "545024122666" }; int selectedIndex = 1; // 当前选中的tab索引 @override @@ -75,7 +77,7 @@ class _MattressControlPageState extends State { SizedBox(width: 26.rpx), Container( decoration: BoxDecoration( - color: Color(0xFF003058), + color: const Color(0xFF003058), borderRadius: BorderRadius.circular(30.rpx), ), constraints: BoxConstraints( @@ -90,6 +92,11 @@ class _MattressControlPageState extends State { underline: const SizedBox(), dropdownColor: Colors.blueGrey, iconEnabledColor: Colors.white, + icon: Icon( + Icons.keyboard_arrow_down, // 最常用的向下箭头 + color: Colors.white, + size: 30.rpx, + ), style: const TextStyle(color: Colors.white), isExpanded: true, items: const [ @@ -113,11 +120,16 @@ class _MattressControlPageState extends State { highlightColor: Colors.transparent, padding: EdgeInsets.only(right: 69.rpx), onTap: () {}, - child: Icon( - Icons.bluetooth, - color: Colors.white, - size: 42.rpx, + child: Image.asset( + 'assets/images/active_bluetooth.png', + width: 42.rpx, + height: 42.rpx, ), + // Icon( + // Icons.bluetooth, + // color: Colors.white, + // size: 42.rpx, + // ), ), ClickableContainer( backgroundColor: Colors.transparent, @@ -131,7 +143,7 @@ class _MattressControlPageState extends State { ], centerTitle: false, ), - body: SafeArea( + body: const SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/lib/pages/mh_page/ShareUserWidget.dart b/lib/pages/mh_page/ShareUserWidget.dart index 9b3130f..08f9ed8 100644 --- a/lib/pages/mh_page/ShareUserWidget.dart +++ b/lib/pages/mh_page/ShareUserWidget.dart @@ -51,14 +51,10 @@ class ShareUserWidget extends GetView { height: 42.rpx, child: SvgPicture.asset('assets/img/icon/default_head.svg'), ), - Expanded( child: Container( margin: EdgeInsetsDirectional.only(start: 30.rpx, end: 30.rpx), - // width: MediaQuery.sizeOf(context).width * 0.5, - // height: MediaQuery.sizeOf(context).height * 0.075, - child: Column( mainAxisSize: MainAxisSize.max, children: [ @@ -72,6 +68,7 @@ class ShareUserWidget extends GetView { color: Colors.white, fontSize: 30.rpx, letterSpacing: 0.0, + height: 1, ), ), ), @@ -90,6 +87,7 @@ class ShareUserWidget extends GetView { color: const Color(0xFFC8CBD2), fontSize: 20.rpx, letterSpacing: 0.0, + height: 1, ), ), ), @@ -98,44 +96,6 @@ class ShareUserWidget extends GetView { ), ), ), - // Container( - // width: MediaQuery.sizeOf(context).width * 0.2, - // height: MediaQuery.sizeOf(context).height * 0.075, - // constraints: const BoxConstraints( - // maxWidth: 130, - // ), - // decoration: BoxDecoration( - // - // ), - // child: Row( - // mainAxisSize: MainAxisSize.max, - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Align( - // alignment: const AlignmentDirectional(0, 0), - // child: Text( - // ' ', - // style: TextStyle( - // fontFamily: 'Readex Pro', - // color: const Color(0xFF333333), - // fontSize: 13, - // letterSpacing: 0.0, - // ), - // ), - // ), - // Flexible( - // child: Align( - // alignment: const AlignmentDirectional(0, 0.05), - // child: Icon( - // Icons.arrow_forward_ios, - // color: FlutterFlowTheme.of(context).secondaryText, - // size: 10, - // ), - // ), - // ), - // ].divide(const SizedBox(width: 27)), - // ), - // ), ClickableContainer( backgroundColor: Colors.transparent, highlightColor: Colors.transparent, @@ -147,25 +107,9 @@ class ShareUserWidget extends GetView { child: SvgPicture.asset( 'assets/img/icon/expand.svg', color: Colors.white, - ) - // Icon( - // Icons.arrow_forward_ios, - // color: Colors.white, - // // size: 14.rpx, - // ), - )), + ))), ], ), - // Container( - // width: MediaQuery.sizeOf(context).width, - // height: MediaQuery.sizeOf(context).height * 0.09, - // child: Container( - // width: MediaQuery.sizeOf(context).width, - // height: MediaQuery.sizeOf(context).height * 0.09, - // decoration: BoxDecoration(), - - // ), - // ), ), ), ); diff --git a/lib/pages/mh_page/address_list_page.dart b/lib/pages/mh_page/address_list_page.dart index 299303f..191c1c2 100644 --- a/lib/pages/mh_page/address_list_page.dart +++ b/lib/pages/mh_page/address_list_page.dart @@ -15,9 +15,9 @@ class AddressListPage extends GetView { final scaffoldKey = GlobalKey(); BoxConstraints? bodysize; - // AddressListPage() { - // controller.getAddressList(); - // } + AddressListPage() { + controller.getAddressList(); + } @override Widget build(BuildContext context) { @@ -65,6 +65,7 @@ class AddressListPage extends GetView { centerTitle: false, ), body: Container( + margin: EdgeInsets.only(top: 30.rpx), width: bodysize!.maxWidth, height: bodysize!.maxHeight * 1, child: Column( @@ -80,49 +81,24 @@ class AddressListPage extends GetView { child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 1, - decoration: BoxDecoration( - color: Color(0xFFF6F6F6), - ), - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - Align( - alignment: AlignmentDirectional(-1, 0), - child: Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 31, 27, 0, 26), - child: Text( - '我的地址', - style: TextStyle( - fontFamily: 'Readex Pro', - fontSize: AppFontsize.title_size, - letterSpacing: 0, - fontWeight: FontWeight.w600, - ), - ), - ), - ), - Expanded( - 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)), - )), - ), - ], - ), + 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)), + )), ), ); } @@ -143,7 +119,7 @@ class AddressListPage extends GetView { ), child: TextButton( onPressed: () { - controller.model.address = {'isChecked': false}; + controller.model.address = {'default': 0}; controller.model.type = 1; Get.toNamed("/editAddressPage"); }, @@ -167,20 +143,7 @@ class AddressListPage extends GetView { width: 42.rpx, height: 42.rpx, ), - // Text( - // '+', - // style: FlutterFlowTheme.of(context) - // .titleSmall - // .override( - // fontFamily: 'Readex Pro', - // color: Color(0xFF85F5FF), - // fontSize: - // AppFontsize.normal_text_size + - // 12, // 让加号比文字稍大 - // letterSpacing: 0, - // ), - // ), - //), + SizedBox(width: 10), // 加号和文字间距 Text( '添加新地址', diff --git a/lib/pages/mh_page/address_module_widget.dart b/lib/pages/mh_page/address_module_widget.dart index 07a6ffb..0314dd8 100644 --- a/lib/pages/mh_page/address_module_widget.dart +++ b/lib/pages/mh_page/address_module_widget.dart @@ -2,8 +2,8 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; +import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/controller/mh_controller/address_list_controller.dart'; - import '../../common/color/appFontsize.dart'; class AddressModuleWidget extends GetView { @@ -20,14 +20,14 @@ class AddressModuleWidget extends GetView { return SingleChildScrollView( child: SlidableAutoCloseBehavior( child: Padding( - padding: EdgeInsetsDirectional.fromSTEB(15, 0, 15, 0), + padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0, 30.rpx, 0), child: Container( width: MediaQuery.sizeOf(context).width, constraints: BoxConstraints( - minHeight: 100, + minHeight: 220.rpx, ), decoration: BoxDecoration( - color: Colors.white, + color: Color(0xFF003058), borderRadius: BorderRadius.circular(16), ), child: Slidable( @@ -38,12 +38,12 @@ class AddressModuleWidget extends GetView { Expanded( child: InkWell( onTap: () async { - // await addressListController.deleteAddress( - // addressListController.model.addressList[index] - // ['id']); - // addressListController.model.addressList.removeAt(index); + await addressListController.deleteAddress( + addressListController.model.addressList[index] + ['_id']); + addressListController.model.addressList.removeAt(index); - // addressListController.updateAll(); + addressListController.updateAll(); }, child: Container( margin: EdgeInsets.only(left: 30), @@ -62,184 +62,128 @@ class AddressModuleWidget extends GetView { ], ), child: Padding( - padding: EdgeInsetsDirectional.fromSTEB(15, 13, 15, 10), + padding: EdgeInsetsDirectional.fromSTEB( + 30.rpx, 20.rpx, 30.rpx, 20.rpx), child: Container( width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height * 0.123, child: Column( mainAxisSize: MainAxisSize.max, children: [ - Expanded( - child: Container( - width: MediaQuery.sizeOf(context).width, - height: MediaQuery.sizeOf(context).height * 0.08, - constraints: BoxConstraints( - minHeight: 112, - ), + Container( + height: 60.rpx, child: Row( - mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container( - width: MediaQuery.sizeOf(context).width * 0.7, - height: - MediaQuery.sizeOf(context).height * 0.08, - constraints: BoxConstraints( - minHeight: 112, - ), - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - Flexible( - child: Align( - alignment: AlignmentDirectional(-1, 0), - child: Text( - [ - addressListController.model - .addressList[index]['province'], - addressListController.model - .addressList[index]['city'], - addressListController.model - .addressList[index]['county'], - addressListController.model - .addressList[index]['street'] - ] - .where((element) => - element != null && - element.isNotEmpty) - .join(' '), - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF333333), - fontSize: - AppFontsize.normal_text_size, - letterSpacing: 0, - ), - ), - ), - ), - Flexible( - child: Align( - alignment: AlignmentDirectional(-1, 0), - child: Text( - addressListController - .model - .addressList[index] - ['detail'] - ?.isEmpty ?? - true - ? '无详细地址' - : addressListController.model - .addressList[index]['detail'], - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF333333), - fontSize: - AppFontsize.normal_text_size, - letterSpacing: 0, - ), - ), - ), - ), - Flexible( - child: Align( - alignment: AlignmentDirectional(-1, 0), - child: Text( - '${addressListController.model.addressList[index]['name']} ' + - '${addressListController.model.addressList[index]['phone']} ', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF333333), - fontSize: - AppFontsize.normal_text_size, - letterSpacing: 0, - ), - ), - ), - ), - ].divide(SizedBox(height: 5)), + Expanded( + child: Text( + [ + addressListController + .model.addressList[index]['province'], + addressListController + .model.addressList[index]['city'], + addressListController + .model.addressList[index]['county'], + addressListController + .model.addressList[index]['street'] + ] + .where((element) => + element != null && element.isNotEmpty) + .join(' '), + style: TextStyle( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: AppFontsize.normal_text_size, + letterSpacing: 0, + ), ), ), - Align( - alignment: AlignmentDirectional(1, -1), - child: Theme( - data: ThemeData( - checkboxTheme: CheckboxThemeData( - visualDensity: VisualDensity.compact, - materialTapTargetSize: - MaterialTapTargetSize.shrinkWrap, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(64), + Obx(() => Visibility( + visible: addressListController.model + .addressList[index]["default"] == + 1, + child: Container( + width: 71.rpx, + height: 36.rpx, + child: ElevatedButton( + onPressed: () {}, + child: Text( + '默认', + style: TextStyle( + color: Color(0XFF6BFDAC), + fontSize: 20.rpx, + ), + ), + style: ElevatedButton.styleFrom( + backgroundColor: + const Color(0x4D6BFDAC), + padding: EdgeInsets.zero, + ), ), ), - unselectedWidgetColor: Color(0xFFD3D3D3), - ), - child: Obx(() { - return Checkbox( - value: addressListController - .model.addressList[index] - ['isChecked'] ?? - false, - onChanged: (newValue) async { - // if (newValue == true) { - // for (var i = 0; - // i < - // addressListController - // .model.addressList.length; - // i++) { - // addressListController - // .model.addressList[i] - // ['isChecked'] = false; - // } - // addressListController - // .model.addressList[index] - // ['isChecked'] = newValue; - // addressListController.updateDefault( - // addressListController - // .model.addressList[index]); - // } - // addressListController.updateAll(); - }, - side: BorderSide( - width: 1.5, - color: Colors.white, - ), - activeColor: const Color(0xFFd3b684), - // checkColor: - // FlutterFlowTheme.of(context).info, - ); - }), - ), - ) + )) ], + )), + Container( + height: 60.rpx, + alignment: Alignment.centerLeft, + child: Text( + addressListController.model + .addressList[index]['address']?.isEmpty ?? + true + ? '无详细地址' + : addressListController.model.addressList[index] + ['address'], + style: TextStyle( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: AppFontsize.normal_text_size, + letterSpacing: 0, ), ), ), - Align( - alignment: AlignmentDirectional(1, 0), - child: InkWell( - onTap: () { - addressListController.model.address = - addressListController.model.addressList[index]; - addressListController.model.type = 2; - Get.toNamed("/editAddressPage"); - }, - child: Container( - width: 100, - height: MediaQuery.sizeOf(context).height * 0.03, - child: Align( - alignment: AlignmentDirectional(1, 0), - child: Text( - '编辑', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: AppFontsize.small_text_size, - letterSpacing: 0, + Container( + height: 60.rpx, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${addressListController.model.addressList[index]['name']} ' + + '${addressListController.model.addressList[index]['tel']} ', + style: TextStyle( + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: AppFontsize.normal_text_size, + letterSpacing: 0, + ), + ), + InkWell( + onTap: () { + addressListController.model.address = + addressListController + .model.addressList[index]; + addressListController.model.type = 2; + Get.toNamed("/editAddressPage"); + }, + child: Container( + width: 100, + height: + MediaQuery.sizeOf(context).height * 0.03, + child: Align( + alignment: AlignmentDirectional(1, 0), + child: Text( + '编辑', + style: TextStyle( + fontFamily: 'Readex Pro', + color: Color(0xFF84F5FF), + fontSize: AppFontsize.small_text_size, + letterSpacing: 0, + ), + ), ), ), ), - ), + ], ), ), ], diff --git a/lib/pages/mh_page/apply_repair_page.dart b/lib/pages/mh_page/apply_repair_page.dart index 15a1180..b77b3b6 100644 --- a/lib/pages/mh_page/apply_repair_page.dart +++ b/lib/pages/mh_page/apply_repair_page.dart @@ -20,15 +20,15 @@ class ApplyRepairPage extends GetView { final scaffoldKey = GlobalKey(); BoxConstraints? bodysize; RepairController repairController = Get.find(); - // ApplyRepairPage() { - // controller.attr.value.listenlists.clear(); - // controller.getDeviceList(); - // controller.model.device_type = ""; - // controller.model.select_device = ""; - // controller.model.device_category = ""; - // controller.model.device_name = ""; - // controller.model.device_id = ""; - // } + ApplyRepairPage() { + controller.attr.value.listenlists.clear(); + controller.getDeviceList(); + controller.model.device_type = ""; + controller.model.select_device = ""; + controller.model.device_category = ""; + controller.model.device_name = ""; + controller.model.device_id = ""; + } final List repairItemKeys = []; final GlobalKey contactKey = GlobalKey(); @@ -118,7 +118,7 @@ class ApplyRepairPage extends GetView { maxHeight: 500.rpx, ), decoration: BoxDecoration( - color: Color(0XFF003058), + color: const Color(0XFF003058), borderRadius: BorderRadius.circular(16.rpx), ), @@ -231,7 +231,7 @@ class ApplyRepairPage extends GetView { .model .device_list! .map((device) => { - 'id': device['id'].toString(), // 提取设备 ID + 'id': device['_id'].toString(), // 提取设备 ID 'name': device['name'].toString(), // 提取设备名称 }) .toList(); @@ -249,13 +249,15 @@ class ApplyRepairPage extends GetView { String>( controller: tmpcontroller, + fillColor: + Colors.white, // 控件区域背景色 options: deviceIds, // 下拉菜单选项为设备的 ID optionLabels: deviceNames, // 下拉菜单显示的内容为设备名称 onChanged: (val) { - var selectedDevice = controller.model.device_list!.firstWhere((device) => device['id'].toString() == val); + var selectedDevice = controller.model.device_list!.firstWhere((device) => device['_id'].toString() == val); controller.model.select_device = val; controller.model.device_type = selectedDevice['type'] == 1 ? '床' : '床垫'; controller.model.device_category = selectedDevice['deviceSeries']['name'] ?? '未知型号'; // 获取设备型号 @@ -268,18 +270,21 @@ class ApplyRepairPage extends GetView { height: 56, searchHintTextStyle: - TextStyle( + const TextStyle( fontFamily: 'Readex Pro', letterSpacing: 0, ), + searchTextStyle: - TextStyle( + const TextStyle( fontFamily: 'Readex Pro', letterSpacing: 0, ), textStyle: TextStyle( fontFamily: 'Readex Pro', + color: Colors.black, + fontSize: 26.rpx, letterSpacing: 0, ), hintText: @@ -287,9 +292,9 @@ class ApplyRepairPage extends GetView { searchHintText: '查找', icon: - Icon( + const Icon( Icons.keyboard_arrow_down_rounded, - color: Colors.white, + color: Colors.black, size: 24, ), // fillColor: @@ -368,124 +373,107 @@ class ApplyRepairPage extends GetView { ), Expanded( child: Container( - width: 100, - height: 100, - decoration: - BoxDecoration( - color: Colors - .white, - borderRadius: - BorderRadius - .circular(8), - ), - child: - Obx(() { - return TextFormField( - // autofocus: true, - controller: - controller - .onReDraw( - TextEditingController( - text: - controller.model.device_category ?? ""), - (value) => - { - value.text = - controller.model.device_category ?? "" - }, - ), - onChanged: - (value) { - controller + width: 100, + height: 100, + decoration: + BoxDecoration( + color: Colors + .white, + borderRadius: + BorderRadius + .circular( + 8), + ), + child: + TextFormField( + // autofocus: true, + onChanged: + (value) { + controller .model - .device_category = value; - }, - // initialValue: - // controller - // .model - // .device_category, - obscureText: - false, - decoration: - InputDecoration( - 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), - ), - 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), - ), - contentPadding: const EdgeInsetsDirectional - .fromSTEB( - 10, - 0, - 10, - 18), + .device_type = + value; + }, + obscureText: + false, + decoration: + InputDecoration( + isDense: + true, + labelStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + hintStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + enabledBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: const Color( + 0x00000000), + width: 1 + .rpx, ), - style: - TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, + borderRadius: + BorderRadius.circular( + AppConstants().normal_container_radius), + ), + focusedBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: Colors + .transparent, + width: 1 + .rpx, ), - ); - })), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + errorBorder: + OutlineInputBorder( + borderSide: + BorderSide( + // + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + focusedErrorBorder: + OutlineInputBorder( + borderSide: + BorderSide( + // + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + ), + style: TextStyle( + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx), + ), + ), ), ].divide(SizedBox( width: 26.rpx)), @@ -538,124 +526,107 @@ class ApplyRepairPage extends GetView { ), Expanded( child: Container( - width: 100, - height: 100, - decoration: - BoxDecoration( - color: Colors - .white, - borderRadius: - BorderRadius - .circular(8), - ), - child: - Obx(() { - return TextFormField( - // autofocus: true, - controller: - controller - .onReDraw( - TextEditingController( - text: - controller.model.device_category ?? ""), - (value) => - { - value.text = - controller.model.device_category ?? "" - }, - ), - onChanged: - (value) { - controller + width: 100, + height: 100, + decoration: + BoxDecoration( + color: Colors + .white, + borderRadius: + BorderRadius + .circular( + 8), + ), + child: + TextFormField( + // autofocus: true, + onChanged: + (value) { + controller .model - .device_category = value; - }, - // initialValue: - // controller - // .model - // .device_category, - obscureText: - false, - decoration: - InputDecoration( - 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), - ), - 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), - ), - contentPadding: const EdgeInsetsDirectional - .fromSTEB( - 10, - 0, - 10, - 18), + .device_category = + value; + }, + obscureText: + false, + decoration: + InputDecoration( + isDense: + true, + labelStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + hintStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + enabledBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: const Color( + 0x00000000), + width: 1 + .rpx, ), - style: - TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, + borderRadius: + BorderRadius.circular( + AppConstants().normal_container_radius), + ), + focusedBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: Colors + .transparent, + width: 1 + .rpx, ), - ); - })), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + errorBorder: + OutlineInputBorder( + borderSide: + BorderSide( + // + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + focusedErrorBorder: + OutlineInputBorder( + borderSide: + BorderSide( + // + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + ), + style: TextStyle( + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx), + ), + ), ), ].divide(SizedBox( width: 26.rpx)), @@ -708,124 +679,107 @@ class ApplyRepairPage extends GetView { ), Expanded( child: Container( - width: 100, - height: 100, - decoration: - BoxDecoration( - color: const Color( - 0xFFF3F5F6), - borderRadius: - BorderRadius - .circular(8), - ), - child: - Obx(() { - return TextFormField( - // autofocus: true, - controller: - controller - .onReDraw( - TextEditingController( - text: - controller.model.device_id ?? ""), - (value) => - { - value.text = - controller.model.device_id ?? "" - }, - ), - onChanged: - (value) { - controller + width: 100, + height: 100, + decoration: + BoxDecoration( + color: const Color( + 0xFFF3F5F6), + borderRadius: + BorderRadius + .circular( + 8), + ), + child: + TextFormField( + // autofocus: true, + onChanged: + (value) { + controller .model - .device_id = value; - }, - // initialValue: - // controller - // .model - // .device_id, - obscureText: - false, - decoration: - InputDecoration( - 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), - ), - 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), - ), - contentPadding: const EdgeInsetsDirectional - .fromSTEB( - 10, - 0, - 10, - 18), + .device_id = + value; + }, + obscureText: + false, + decoration: + InputDecoration( + isDense: + true, + labelStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + hintStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + enabledBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: const Color( + 0x00000000), + width: 1 + .rpx, ), - style: - TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, + borderRadius: + BorderRadius.circular( + AppConstants().normal_container_radius), + ), + focusedBorder: + OutlineInputBorder( + borderSide: + BorderSide( + color: Colors + .transparent, + width: 1 + .rpx, ), - ); - })), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + errorBorder: + OutlineInputBorder( + borderSide: + BorderSide( + // + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + focusedErrorBorder: + OutlineInputBorder( + borderSide: + BorderSide( + // + width: 1 + .rpx, + ), + borderRadius: + BorderRadius.circular( + 8.rpx), + ), + ), + style: TextStyle( + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx), + ), + ), ), ].divide(SizedBox( width: 26.rpx)), @@ -853,7 +807,7 @@ class ApplyRepairPage extends GetView { minHeight: 345.rpx, ), decoration: BoxDecoration( - color: Color(0XFF003058), + color: const Color(0XFF003058), borderRadius: BorderRadius.circular(16.rpx), ), @@ -862,7 +816,7 @@ class ApplyRepairPage extends GetView { width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.17, decoration: BoxDecoration( - color: Color(0XFF003058), + color: const Color(0XFF003058), borderRadius: BorderRadius.circular(16.rpx), ), @@ -881,41 +835,43 @@ class ApplyRepairPage extends GetView { ApiResponse apiResponse = await repairController .uploadImg(); - // print(apiResponse); - // if (apiResponse.code == - // HttpStatusCodes.ok) { - // print(widget.model); - // // setState(() { - // // widget.model['path'] = apiResponse.data['path']; - // // }); - // widget.model['path'] = - // apiResponse - // .data['path']; - // repairController.repairList - // .refresh(); // 通知 Obx 更新(如果用了 GetX) - // print(widget.model); - // } else { - // if (widget.model['path'] == - // null || - // widget.model['path'] - // .isEmpty - // ) { - // TopSlideNotification.show( - // context, - // text: apiResponse.msg!, - // textColor: apiResponse - // .code == - // HttpStatusCodes - // .ok - // ? themeController - // .currentColor - // .sc2 - // : themeController - // .currentColor - // .sc9, - // ); - // } - // } + print(apiResponse); + if (apiResponse.code == + HttpStatusCodes.ok) { + print(controller.model); + // setState(() { + // controller.model['path'] = apiResponse.data['path']; + // }); + controller.model.issue_img! + .add(apiResponse + .data['path']); + repairController.repairList + .refresh(); // 通知 Obx 更新(如果用了 GetX) + print(controller.model); + } else { + if (controller.model + .issue_img == + null || + controller + .model + .issue_img! + .isEmpty) { + TopSlideNotification.show( + context, + text: apiResponse.msg!, + textColor: apiResponse + .code == + HttpStatusCodes + .ok + ? themeController + .currentColor + .sc2 + : themeController + .currentColor + .sc9, + ); + } + } }, child: Container( width: @@ -1022,7 +978,8 @@ class ApplyRepairPage extends GetView { const BoxConstraints( minHeight: 250, ), - decoration: BoxDecoration( + decoration: + const BoxDecoration( color: Colors.white, ), child: Column( @@ -1046,8 +1003,9 @@ class ApplyRepairPage extends GetView { 0.2, height: 21, decoration: - BoxDecoration( - color: Colors.white, + const BoxDecoration( + color: + Colors.white, ), child: Container( width: MediaQuery @@ -1057,8 +1015,9 @@ class ApplyRepairPage extends GetView { 0.2, height: 21, decoration: - BoxDecoration( - color: Colors.white, + const BoxDecoration( + color: Colors + .white, ), child: Row( mainAxisSize: @@ -1139,15 +1098,17 @@ class ApplyRepairPage extends GetView { minHeight: 152, ), decoration: - BoxDecoration( - color: Colors.white, + const BoxDecoration( + color: + Colors.white, ), child: Container( width: 100, height: 100, decoration: - BoxDecoration( - color: Colors.white, + const BoxDecoration( + color: Colors + .white, ), child: Obx(() => ListView( shrinkWrap: true, @@ -1184,7 +1145,7 @@ class ApplyRepairPage extends GetView { minHeight: 345.rpx, ), decoration: BoxDecoration( - color: Color(0xFF003058), + color: const Color(0xFF003058), borderRadius: BorderRadius.circular(16.rpx), ), @@ -1253,21 +1214,21 @@ class ApplyRepairPage extends GetView { decoration: InputDecoration( hintText: '问题描述(100个字以内)', labelStyle: TextStyle( - fontFamily: - 'Readex Pro', - fontSize: AppFontsize - .normal_text_size, - letterSpacing: 0, - color: Color( - 0XFF929699)), + fontFamily: + 'Readex Pro', + fontSize: AppFontsize + .normal_text_size, + letterSpacing: 0, + color: const Color( + 0XFF929699)), hintStyle: TextStyle( - fontFamily: - 'Readex Pro', - fontSize: AppFontsize - .normal_text_size, - letterSpacing: 0, - color: Color( - 0XFF929699)), + fontFamily: + 'Readex Pro', + fontSize: AppFontsize + .normal_text_size, + letterSpacing: 0, + color: const Color( + 0XFF929699)), enabledBorder: UnderlineInputBorder( borderSide: @@ -1352,7 +1313,7 @@ class ApplyRepairPage extends GetView { minHeight: 345.rpx, ), decoration: BoxDecoration( - color: Color(0XFF003058), + color: const Color(0XFF003058), borderRadius: BorderRadius.circular(16), ), child: Column( @@ -1368,12 +1329,12 @@ class ApplyRepairPage extends GetView { child: Text( '联系方式', style: TextStyle( - fontFamily: 'Readex Pro', - color: Colors.white, - fontSize: 30.rpx, - letterSpacing: 0, - fontWeight: FontWeight.w600, - ), + fontFamily: 'Readex Pro', + color: Colors.white, + fontSize: 30.rpx, + letterSpacing: 0, + fontWeight: FontWeight.w600, + ), ), ), ), @@ -1471,91 +1432,83 @@ class ApplyRepairPage extends GetView { .apply_name = value; }, - initialValue: - controller - .model - .apply_name, obscureText: false, - textAlignVertical: - TextAlignVertical - .center, decoration: InputDecoration( - contentPadding: - const EdgeInsetsDirectional - .fromSTEB( - 10, - 10, - 10, - 14), - labelStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), - hintStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), + isDense: true, + labelStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + hintStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), enabledBorder: - UnderlineInputBorder( + OutlineInputBorder( borderSide: - const BorderSide( - color: Color( + BorderSide( + color: const Color( 0x00000000), - width: 2, + width: + 1.rpx, ), borderRadius: - BorderRadius - .circular(8), + BorderRadius.circular( + AppConstants().normal_container_radius), ), focusedBorder: - UnderlineInputBorder( + OutlineInputBorder( borderSide: - const BorderSide( - color: Color( - 0x00000000), - width: 2, + BorderSide( + color: Colors + .transparent, + width: + 1.rpx, ), borderRadius: - BorderRadius - .circular(8), + BorderRadius.circular( + 8.rpx), ), errorBorder: - UnderlineInputBorder( + OutlineInputBorder( borderSide: - const BorderSide( - color: Color( - 0x00000000), - width: 2, + BorderSide( + // + width: + 1.rpx, ), borderRadius: - BorderRadius - .circular(8), + BorderRadius.circular( + 8.rpx), ), focusedErrorBorder: - UnderlineInputBorder( + OutlineInputBorder( borderSide: - const BorderSide( - color: Color( - 0x00000000), - width: 2, + BorderSide( + // + width: + 1.rpx, ), borderRadius: - BorderRadius - .circular(8), + BorderRadius.circular( + 8.rpx), ), ), style: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx), ), ), ), @@ -1635,91 +1588,83 @@ class ApplyRepairPage extends GetView { .tel = value; }, - initialValue: - controller - .model - .tel, obscureText: false, - textAlignVertical: - TextAlignVertical - .center, decoration: InputDecoration( - contentPadding: - const EdgeInsetsDirectional - .fromSTEB( - 10, - 10, - 10, - 14), - labelStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), - hintStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), + isDense: true, + labelStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + hintStyle: + const TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), enabledBorder: - UnderlineInputBorder( + OutlineInputBorder( borderSide: - const BorderSide( - color: Color( + BorderSide( + color: const Color( 0x00000000), - width: 2, + width: + 1.rpx, ), borderRadius: - BorderRadius - .circular(8), + BorderRadius.circular( + AppConstants().normal_container_radius), ), focusedBorder: - UnderlineInputBorder( + OutlineInputBorder( borderSide: - const BorderSide( - color: Color( - 0x00000000), - width: 2, + BorderSide( + color: Colors + .transparent, + width: + 1.rpx, ), borderRadius: - BorderRadius - .circular(8), + BorderRadius.circular( + 8.rpx), ), errorBorder: - UnderlineInputBorder( + OutlineInputBorder( borderSide: - const BorderSide( - color: Color( - 0x00000000), - width: 2, + BorderSide( + // + width: + 1.rpx, ), borderRadius: - BorderRadius - .circular(8), + BorderRadius.circular( + 8.rpx), ), focusedErrorBorder: - UnderlineInputBorder( + OutlineInputBorder( borderSide: - const BorderSide( - color: Color( - 0x00000000), - width: 2, + BorderSide( + // + width: + 1.rpx, ), borderRadius: - BorderRadius - .circular(8), + BorderRadius.circular( + 8.rpx), ), ), style: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx), ), ), ), @@ -1757,12 +1702,11 @@ class ApplyRepairPage extends GetView { borderRadius: 16.rpx, gradientDirection: GradientDirection.vertical, onTap: () async { - Get.toNamed("/applyRepairSuccess"); - // TopSlideNotification.show( - // context, - // text: "功能开发中...", - // ); - + TopSlideNotification.show( + context, + text: "功能开发中...", + ); + // Get.toNamed("/applyRepairSuccess"); // String msg = checkRepairParam(); // if (msg.isNotEmpty) { // TopSlideNotification.show(context, @@ -1804,7 +1748,7 @@ class ApplyRepairPage extends GetView { // themeController.currentColor.sc9); // }, // ); - // } + //} }, colors: const [ Color(0xFFFCFCFC), @@ -1937,7 +1881,7 @@ class ApplyRepairPage extends GetView { WidgetsBinding.instance.addPostFrameCallback((_) { Scrollable.ensureVisible( key.currentContext!, - duration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), curve: Curves.easeInOut, ); }); diff --git a/lib/pages/mh_page/bluetooth.dart b/lib/pages/mh_page/bluetooth.dart index 01e5344..0075f95 100644 --- a/lib/pages/mh_page/bluetooth.dart +++ b/lib/pages/mh_page/bluetooth.dart @@ -84,7 +84,8 @@ class BluetoothPage extends GetView { highlightColor: const Color(0xFF055466), padding: EdgeInsets.only(left: 0), onTap: () { - Get.toNamed("/editBedPage"); + Get.toNamed("/editBedPage", + arguments: data); }, child: Container( width: 42.rpx, @@ -135,7 +136,7 @@ class BluetoothPage extends GetView { context, '人员资料', "/peopleInfoPage", arguments: data), _buildMenuButton( - context, '房间选择', "/roomPickerPage"), + context, '房间选择', "/roomPickerPage",arguments: data), _buildMenuButton(context, '设备校准', ""), _buildMenuButton(context, '体征传感器', ""), _buildMenuButton(context, 'WIFI配置', ""), diff --git a/lib/pages/mh_page/device/device.dart b/lib/pages/mh_page/device/device.dart index 2a798e0..2ba275a 100644 --- a/lib/pages/mh_page/device/device.dart +++ b/lib/pages/mh_page/device/device.dart @@ -6,6 +6,7 @@ import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/appFontsize.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.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/device_list_controller.dart'; @@ -115,25 +116,25 @@ class DeviceInfoWidget extends GetView { letterSpacing: 0, height: 1), ), - TextSpan( - text: - ' (${deviceListController.model.deviceList[index]['status'] ?? ''})', - style: TextStyle( - fontFamily: 'Readex Pro', - color: deviceListController - .model - .deviceList[ - index] - ['status'] == - '在线' - ? Color( - 0xFF07C160) // 在线的颜色 - : Color( - 0xFFEA7CA7), // 离线的颜色 - fontSize: 26.rpx, - letterSpacing: 0, - ), - ), + // TextSpan( + // text: + // ' (${deviceListController.model.deviceList[index]['status'] ?? ''})', + // style: TextStyle( + // fontFamily: 'Readex Pro', + // color: deviceListController + // .model + // .deviceList[ + // index] + // ['status'] == + // '在线' + // ? Color( + // 0xFF07C160) // 在线的颜色 + // : Color( + // 0xFFEA7CA7), // 离线的颜色 + // fontSize: 26.rpx, + // letterSpacing: 0, + // ), + // ), ], ), maxLines: 1, // 限制显示一行 @@ -196,7 +197,7 @@ class DeviceInfoWidget extends GetView { color: Color(0XFF85F5FF), textStyle: TextStyle( fontFamily: 'Readex Pro', - color: Colors.white, + color: Color(0xFF011D33), fontSize: 28.rpx, letterSpacing: 0, ), @@ -238,11 +239,12 @@ class DeviceInfoWidget extends GetView { children: [ InkWell( onTap: () async { - if (device['type'] == 1) { - globalController.model.deviceMain = device; - await Get.toNamed("/deviceShare"); - globalController.getDeviceList(); - } + await Get.toNamed("/deviceSharePage"); + // if (device['type'] == 1) { + // globalController.model.deviceMain = device; + // await Get.toNamed("/deviceSharePage"); + // globalController.getDeviceList(); + // } }, child: Container( height: MediaQuery.sizeOf(context).height * 0.1, @@ -351,11 +353,15 @@ class DeviceInfoWidget extends GetView { ), InkWell( onTap: () { - var a = [device["bindMacA"]]; - if ("${device["bindMacB"]}".length > 6) { - a.add(device["bindMacB"]); - } - Get.toNamed("/sleepWebview", arguments: a); + TopSlideNotification.show( + context, + text: "功能开发中...", + ); + // var a = [device["bindMacA"]]; + // if ("${device["bindMacB"]}".length > 6) { + // a.add(device["bindMacB"]); + // } + // Get.toNamed("/sleepWebview", arguments: a); }, child: Container( height: MediaQuery.sizeOf(context).height * 0.1, diff --git a/lib/pages/mh_page/device_list.dart b/lib/pages/mh_page/device_list.dart index 85b91fc..f200b5c 100644 --- a/lib/pages/mh_page/device_list.dart +++ b/lib/pages/mh_page/device_list.dart @@ -33,108 +33,107 @@ class _DeviceListPageState extends State { return LayoutBuilder(builder: (context, cc) { bodysize = cc; return GestureDetector( - onTap: () => FocusScope.of(context).unfocus(), - child: Scaffold( - resizeToAvoidBottomInset: false, - appBar: AppBar( - backgroundColor: Colors.transparent, - automaticallyImplyLeading: false, - iconTheme: IconThemeData(color: Colors.white), - titleSpacing: 0, - // leading: returnIconButtomAddCallback(() { - // controller.saveDataApi(); - // updateParm(isShowToast: false); - // }), - // leading: returnIconButtomNew, - title: Container( - width: double.infinity, - height: 180.rpx, - child: Stack( - alignment: Alignment.center, - children: [ - // 中间居中的标题 - Text( - '设备列表', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 30.rpx, - ), - ), - // 左侧图标 - Positioned( - left: 20.rpx, - child: returnIconButtomNew, - ), - ], - ), + onTap: () => FocusScope.of(context).unfocus(), + child: Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/new_background.png'), // 本地图片 + fit: BoxFit.fill, // 填满整个 Container ), - - actions: [], - centerTitle: false, ), - backgroundColor: Colors.transparent, - body: Stack( - children: [ - Positioned.fill( - child: Image.asset( - 'assets/images/new_background.png', - fit: BoxFit.fill, - ), - ), - Column( - mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: EdgeInsetsDirectional.fromSTEB(0, 10, 0, 23), - child: SearchWidget( - keyword: controller.model.keyword, - color: controller.model.color, - hint: "检索设备", - onChange: (d) { - controller.model.keyword = d; - }, - findCallback: () { - controller.getDeviceList(); - }, - ), - ), - Obx(() { - if (controller.model.deviceList == null || - controller.model.deviceList.isEmpty) { - return Expanded(child: NullDataWidget()); - } - - // 如果 deviceList 不为空,渲染列表 - return Expanded( - child: ListView( - shrinkWrap: true, - scrollDirection: Axis.vertical, - children: controller.model.deviceList - .asMap() - .entries - .map((e) => DeviceInfoWidget( - index: e.key, - deviceListController: controller, - )) - .toList() - .divide(const SizedBox(height: 10)) - .addToEnd(const SizedBox(height: 100)), + child: Scaffold( + resizeToAvoidBottomInset: false, + appBar: AppBar( + backgroundColor: Colors.transparent, + automaticallyImplyLeading: false, + iconTheme: IconThemeData(color: Colors.white), + titleSpacing: 0, + // leading: returnIconButtomAddCallback(() { + // controller.saveDataApi(); + // updateParm(isShowToast: false); + // }), + // leading: returnIconButtomNew, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + // 中间居中的标题 + Text( + '设备列表', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 30.rpx, + ), ), - ); - }), - ], + // 左侧图标 + Positioned( + left: 20.rpx, + child: returnIconButtomNew, + ), + ], + ), + ), + + actions: [], + centerTitle: false, ), - ], - ) + backgroundColor: Colors.transparent, + body: Container( + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: EdgeInsetsDirectional.fromSTEB(0, 10, 0, 23), + child: SearchWidget( + keyword: controller.model.keyword, + color: controller.model.color, + hint: "检索设备", + onChange: (d) { + controller.model.keyword = d; + }, + findCallback: () { + controller.getDeviceList(); + }, + ), + ), + Obx(() { + if (controller.model.deviceList == null || + controller.model.deviceList.isEmpty) { + return Expanded(child: NullDataWidget()); + } - // Container( - // width: bodysize!.maxWidth, - // height: bodysize!.maxHeight, + // 如果 deviceList 不为空,渲染列表 + return Expanded( + child: ListView( + shrinkWrap: true, + scrollDirection: Axis.vertical, + children: controller.model.deviceList + .asMap() + .entries + .map((e) => DeviceInfoWidget( + index: e.key, + deviceListController: controller, + )) + .toList() + .divide(const SizedBox(height: 10)) + .addToEnd(const SizedBox(height: 100)), + ), + ); + }), + ], + ), + ) - // ), - ), - ); + // Container( + // width: bodysize!.maxWidth, + // height: bodysize!.maxHeight, + + // ), + ), + )); }); } } diff --git a/lib/pages/mh_page/device_people_info.dart b/lib/pages/mh_page/device_people_info.dart index 6b1ce1e..f3b971c 100644 --- a/lib/pages/mh_page/device_people_info.dart +++ b/lib/pages/mh_page/device_people_info.dart @@ -35,9 +35,6 @@ class DevicePeopleInfo extends GetView { @override Widget build(BuildContext context) { - WidgetsBinding.instance.addPostFrameCallback((_) { - controller.initData(data['mac']); - }); return LayoutBuilder( builder: (context, boxConstraints) => GestureDetector( onTap: () => FocusScope.of(context).unfocus(), diff --git a/lib/pages/mh_page/device_share_page.dart b/lib/pages/mh_page/device_share_page.dart index 1315d8e..9a4d110 100644 --- a/lib/pages/mh_page/device_share_page.dart +++ b/lib/pages/mh_page/device_share_page.dart @@ -434,22 +434,30 @@ class ShareDeviceWidget extends GetView { letterSpacing: 0.0, ), ), - 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), // 缩小视觉密度 - ) + Theme( + data: + Theme.of(context).copyWith( + unselectedWidgetColor: Color( + 0xFFC8CBD2), // 改变未选中状态边框颜色 + ), + 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), // 缩小视觉密度 + )) ], ), ), @@ -485,22 +493,30 @@ class ShareDeviceWidget extends GetView { letterSpacing: 0.0, ), ), - 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), // 缩小视觉密度 - ) + 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), // 缩小视觉密度 + )) ], ), ), diff --git a/lib/pages/mh_page/edit_address_page.dart b/lib/pages/mh_page/edit_address_page.dart index c639c08..2100c6e 100644 --- a/lib/pages/mh_page/edit_address_page.dart +++ b/lib/pages/mh_page/edit_address_page.dart @@ -1,6 +1,6 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_city_picker/city_picker.dart'; +import 'package:flutter_city_picker/listener/picker_listener.dart'; import 'package:flutter_city_picker/model/address.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; @@ -11,6 +11,7 @@ import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; import 'package:vbvs_app/controller/mh_controller/address_controller.dart'; import 'package:vbvs_app/controller/mh_controller/address_list_controller.dart'; +import 'package:vbvs_app/pages/mh_page/homepage/component/citypicker.dart'; class EditAddressPage extends GetView implements CityPickerListener { @@ -36,12 +37,12 @@ class EditAddressPage extends GetView AddressListController addressListController = Get.find(); var address = Map.from(addressListController.model.address); - controller.model.ischecked = address['isChecked']; + controller.model.default_ = address['default']; controller.model.all_address = getAddressDesc(address); - controller.model.detail = address['detail']; + controller.model.address = address['address']; controller.model.name = address['name']; - controller.model.phone = address['phone']; - controller.model.ischecked = address['isChecked']; + controller.model.tel = address['tel']; + return LayoutBuilder(builder: (context, cc) { bodysize = cc; return GestureDetector( @@ -61,11 +62,6 @@ class EditAddressPage extends GetView automaticallyImplyLeading: false, iconTheme: IconThemeData(color: Colors.white), titleSpacing: 0, - // leading: returnIconButtomAddCallback(() { - // controller.saveDataApi(); - // updateParm(isShowToast: false); - // }), - // leading: returnIconButtomNew, title: Container( width: double.infinity, height: 180.rpx, @@ -89,7 +85,6 @@ class EditAddressPage extends GetView ], ), ), - actions: [], centerTitle: false, ), @@ -181,38 +176,34 @@ class EditAddressPage extends GetView -1, 0), child: Text( '地址信息', - style: TextStyle( - fontFamily: - 'Readex Pro', - color: Colors - .white, - fontSize: - AppFontsize - .title_size, - letterSpacing: - 0, - fontWeight: - FontWeight - .w600, - ), + style: + TextStyle( + fontFamily: + 'Readex Pro', + color: Colors + .white, + fontSize: + AppFontsize + .title_size, + letterSpacing: + 0, + fontWeight: + FontWeight + .w600, + ), ), ), ), ), Container( - width: - MediaQuery.sizeOf( - context) - .width * - 0.17, height: MediaQuery.sizeOf( context) .height * 0.038, constraints: - const BoxConstraints( - maxWidth: 55, + BoxConstraints( + minWidth: 104.rpx, ), decoration: BoxDecoration(), @@ -238,8 +229,10 @@ class EditAddressPage extends GetView 0), child: Container( - width: 18, - height: 18, + width: + 60.rpx, + height: + 60.rpx, decoration: const BoxDecoration(), child: @@ -248,51 +241,73 @@ class EditAddressPage extends GetView const AlignmentDirectional( 0, 0), - child: Theme( - data: ThemeData( - checkboxTheme: - CheckboxThemeData( - visualDensity: VisualDensity.compact, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(64), - ), + child: + Theme( + data: + ThemeData( + checkboxTheme: + CheckboxThemeData( + visualDensity: + VisualDensity.compact, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + shape: + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(64), ), - unselectedWidgetColor: - const Color(0xFFD3D3D3), ), - child: Obx(() { - return Checkbox( - value: controller.model.ischecked, - onChanged: (newValue) async { - controller.model.ischecked = newValue; - controller.updateAll(); - }, - side: BorderSide( - width: 1.5, - color:Colors.white, - ), - activeColor: const Color(0xFF84F5FF), - checkColor: Color(0xFF011D33), - ); - })), + unselectedWidgetColor: + const Color(0xFFD3D3D3), + ), + child: Obx( + () { + return Checkbox( + value: + controller.model.default_ == 1, + onChanged: + (newValue) { + controller.model.default_ = (newValue ?? false) ? 1 : 0; + controller.updateAll(); + }, + side: + const BorderSide( + width: 1.5, + color: Colors.white, + ), + activeColor: + const Color(0xFF84F5FF), + checkColor: + const Color(0xFF011D33), + // Add this to prevent double triggers + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + ); + }), + ), ), ), ), ), - Text( - '默认', - style: TextStyle( - fontFamily: - 'Readex Pro', - fontSize: - AppFontsize - .normal_text_size, - letterSpacing: - 0, - color: Color( - 0XFF84F5FF)), - ), + Obx( + () => Text( + '默认', + style: + TextStyle( + fontFamily: + 'Readex Pro', + fontSize: + 26.rpx, + letterSpacing: + 0, + color: controller.model.default_ == + 1 + ? const Color( + 0XFF84F5FF) + : Colors + .white, + ), + ), + ) ], ), ), @@ -344,15 +359,15 @@ class EditAddressPage extends GetView Text( '收件人', style: TextStyle( - fontFamily: - 'Readex Pro', - fontSize: - AppFontsize - .normal_text_size, - letterSpacing: - 0, - color: Colors - .white), + fontFamily: + 'Readex Pro', + fontSize: + AppFontsize + .normal_text_size, + letterSpacing: + 0, + color: Colors + .white), ), ], ), @@ -379,200 +394,34 @@ class EditAddressPage extends GetView controller.model .name = val; }, + initialValue: address[ 'name'], decoration: InputDecoration( contentPadding: - const EdgeInsetsDirectional - .fromSTEB( - 10, - 0, - 10, - 18), - 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), + EdgeInsets + .symmetric( + vertical: + 25.rpx, + horizontal: + 26.rpx, ), - focusedBorder: - UnderlineInputBorder( - borderSide: - const BorderSide( - color: Color( - 0x00000000), - width: 2, - ), - borderRadius: - BorderRadius - .circular( - 8), + labelStyle: + TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, ), - errorBorder: - UnderlineInputBorder( - borderSide: - const BorderSide( - color: Color( - 0x00000000), - width: 2, - ), - borderRadius: - BorderRadius - .circular( - 8), + hintStyle: + TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, ), - focusedErrorBorder: - UnderlineInputBorder( - borderSide: - const BorderSide( - color: Color( - 0x00000000), - width: 2, - ), - borderRadius: - BorderRadius - .circular( - 8), - ), - ), - style:TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), - ), - ), - ), - ].divide(const SizedBox( - width: 15)), - ), - ), - Container( - width: MediaQuery.sizeOf( - context) - .width, - height: MediaQuery.sizeOf( - context) - .height * - 0.038, - constraints: - const BoxConstraints( - minHeight: 31, - ), - child: Row( - mainAxisSize: - MainAxisSize.max, - children: [ - Container( - width: - MediaQuery.sizeOf( - context) - .width * - 0.17, - height: - MediaQuery.sizeOf( - context) - .height * - 0.038, - constraints: - BoxConstraints( - minWidth: - 105.rpx, - maxWidth: - 105.rpx), - decoration: - BoxDecoration(), - child: Row( - mainAxisSize: - MainAxisSize - .max, - children: [ - Text( - '手机号', - style: TextStyle( - fontFamily: - 'Readex Pro', - fontSize: - AppFontsize - .normal_text_size, - letterSpacing: - 0, - color: Colors - .white, - ), - ), - ], - ), - ), - Expanded( - child: Container( - width: 100, - height: 100, - decoration: - BoxDecoration( - borderRadius: - BorderRadius - .circular( - 8), - color: - Colors.white, - ), - child: - TextFormField( - // autofocus: true, - onChanged: (val) { - controller.model - .phone = - val; - }, - obscureText: - false, - initialValue: - address[ - 'phone'], - decoration: - InputDecoration( - contentPadding: - const EdgeInsetsDirectional - .fromSTEB( - 10, - 0, - 10, - 18), - labelStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), - hintStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), enabledBorder: UnderlineInputBorder( borderSide: @@ -627,11 +476,195 @@ class EditAddressPage extends GetView ), ), style: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx, + ), + ), + ), + ), + ].divide(const SizedBox( + width: 15)), + ), + ), + Container( + width: MediaQuery.sizeOf( + context) + .width, + height: MediaQuery.sizeOf( + context) + .height * + 0.038, + constraints: + const BoxConstraints( + minHeight: 31, + ), + child: Row( + mainAxisSize: + MainAxisSize.max, + children: [ + Container( + width: + MediaQuery.sizeOf( + context) + .width * + 0.17, + height: + MediaQuery.sizeOf( + context) + .height * + 0.038, + constraints: + BoxConstraints( + minWidth: + 105.rpx, + maxWidth: + 105.rpx), + decoration: + BoxDecoration(), + child: Row( + mainAxisSize: + MainAxisSize + .max, + children: [ + Text( + '手机号', + style: + TextStyle( + fontFamily: + 'Readex Pro', + fontSize: + AppFontsize + .normal_text_size, + letterSpacing: + 0, + color: Colors + .white, + ), + ), + ], + ), + ), + Expanded( + child: Container( + width: 100, + height: 100, + decoration: + BoxDecoration( + borderRadius: + BorderRadius + .circular( + 8), + color: + Colors.white, + ), + child: + TextFormField( + // autofocus: true, + onChanged: (val) { + controller.model + .tel = val; + }, + textAlignVertical: + TextAlignVertical + .center, // 垂直居中 + obscureText: + false, + initialValue: + address[ + 'tel'], + 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), + ), + 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), + ), + ), + style: TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx, + ), ), ), ), @@ -678,27 +711,29 @@ class EditAddressPage extends GetView .max, children: [ InkWell( - // onTap: () { - // CityPicker - // .show( - // context: - // context, - // cityPickerListener: - // this, - // ); - // }, + onTap: () { + // CityPicker + // .show( + // context: + // context, + // cityPickerListener: + // this, + // ); + }, child: Text( '所在地区', - style: TextStyle( - fontFamily: - 'Readex Pro', - fontSize: - AppFontsize.normal_text_size, - letterSpacing: - 0, - color: Colors - .white, - ), + style: + TextStyle( + fontFamily: + 'Readex Pro', + fontSize: + AppFontsize + .normal_text_size, + letterSpacing: + 0, + color: Colors + .white, + ), ), ), ], @@ -712,6 +747,8 @@ class EditAddressPage extends GetView context, cityPickerListener: this, + // 在大屏/Web 上最大宽度为 600px + // 移除内边距 ); }, child: Container( @@ -726,6 +763,9 @@ class EditAddressPage extends GetView .circular( 8), ), + alignment: + Alignment + .center, child: Obx(() { return TextFormField( enabled: @@ -735,23 +775,35 @@ class EditAddressPage extends GetView text: controller.model.all_address), (val) { - val.text = controller - .model - .all_address; + val.text = + controller.model.all_address ?? + ""; }), // autofocus: true, obscureText: false, + textAlignVertical: + TextAlignVertical + .center, // 垂直居中 decoration: InputDecoration( - contentPadding: const EdgeInsetsDirectional.fromSTEB(10, 0, 10, 18), + contentPadding: EdgeInsets.symmetric( + vertical: + 25.rpx, + horizontal: + 26.rpx, + ), labelStyle: TextStyle( - fontFamily: 'Readex Pro', - letterSpacing: 0, - ), + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), hintStyle: TextStyle( - fontFamily: 'Readex Pro', - letterSpacing: 0, - ), + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), enabledBorder: UnderlineInputBorder( borderSide: const BorderSide( @@ -814,17 +866,25 @@ class EditAddressPage extends GetView Icon( Icons.arrow_forward_ios, color: - Colors.white, + Colors.black, size: - 12, + 26.rpx, ), )), - style: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), + style: + TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + color: Color( + 0xFF333333), + fontSize: + 26.rpx, + overflow: + TextOverflow + .ellipsis, + ), ); })), ), @@ -882,7 +942,7 @@ class EditAddressPage extends GetView children: [ Text( '详细地址', - style:TextStyle( + style: TextStyle( fontFamily: 'Readex Pro', fontSize: @@ -934,36 +994,39 @@ class EditAddressPage extends GetView (val) { controller .model - .detail = + .address = val; }, initialValue: address[ - 'detail'], + 'address'], maxLines: 2, obscureText: false, decoration: InputDecoration( contentPadding: - const EdgeInsetsDirectional - .fromSTEB( - 10, - 10, - 10, - 10), - labelStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), - hintStyle: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), + EdgeInsets + .symmetric( + vertical: + 10.rpx, + horizontal: + 26.rpx, + ), + labelStyle: + TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + hintStyle: + TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), enabledBorder: UnderlineInputBorder( borderSide: @@ -1013,12 +1076,17 @@ class EditAddressPage extends GetView .circular(8), ), ), - style: TextStyle( - fontFamily: - 'Readex Pro', - letterSpacing: - 0, - ), + style: + TextStyle( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + color: Colors + .black, + fontSize: + 26.rpx, + ), ), ), ), @@ -1049,42 +1117,43 @@ class EditAddressPage extends GetView child: CustomCard( borderRadius: 16.rpx, gradientDirection: GradientDirection.vertical, - onTap: () { - // if (controller.model.all_address == null || - // controller.model.all_address!.isEmpty) { - // showToast("地址不能为空"); - // return; - // } - // if (controller.model.name == null || - // controller.model.name!.isEmpty) { - // showToast("名字不能为空"); - // return; - // } - // if (controller.model.detail == null || - // controller.model.detail!.isEmpty) { - // showToast("详细地址不能为空"); - // return; - // } - // if (controller.model.phone == null || - // controller.model.phone!.isEmpty) { - // showToast("手机号不能为空"); - // return; - // } - // if (!MyUtils.isValidPhoneNumber( - // controller.model.phone!)) { - // showToast("无效的手机号码"); - // return; - // } - // if (addressListController.model.type == 1) { - // await controller.addAddress(controller.model); - // } else { - // await controller.updateAddress( - // address, controller.model); - // } - // await addressListController.getAddressList(); - // Get.back(); - // controller.model = AddressModel(); - // controller.updateAll(); + onTap: () async { + if (controller.model.all_address == null || + controller.model.all_address!.isEmpty) { + showToast("地址不能为空"); + return; + } + if (controller.model.name == null || + controller.model.name!.isEmpty) { + showToast("名字不能为空"); + return; + } + if (controller.model.address == null || + controller.model.address!.isEmpty) { + showToast("详细地址不能为空"); + return; + } + if (controller.model.tel == null || + controller.model.tel!.isEmpty) { + showToast("手机号不能为空"); + return; + } + if (!MyUtils.isValidPhoneNumber( + controller.model.tel!)) { + showToast("无效的手机号码"); + return; + } + if (addressListController.model.type == 1) { + await controller.addAddress( + controller.model, context); + } else { + await controller.updateAddress( + address, controller.model); + } + await addressListController.getAddressList(); + Get.back(); + controller.model = AddressModel(); + controller.updateAll(); }, colors: const [ Color(0xFFFCFCFC), @@ -1103,98 +1172,14 @@ class EditAddressPage extends GetView child: Text( "保存", style: TextStyle( - fontFamily: 'Readex Pro', - color: stringToColor("#011D33"), - letterSpacing: 0, - fontSize: 30.rpx, - ), + fontFamily: 'Readex Pro', + color: stringToColor("#011D33"), + letterSpacing: 0, + fontSize: 30.rpx, + ), ), ), - ) - - // Container( - // width: bodysize!.maxWidth, - // height: bodysize!.maxHeight * 0.056, - // decoration: BoxDecoration( - // color: FlutterFlowTheme.of(context) - // .secondaryBackground, - // ), - // child: - - // Container( - // width: bodysize!.maxWidth, - // height: bodysize!.maxHeight * 0.056, - // decoration: BoxDecoration( - // color: FlutterFlowTheme.of(context) - // .secondaryBackground, - // borderRadius: BorderRadius.circular(12), - // ), - // child: FFButtonWidget( - // onPressed: () async { - // // if (controller.model.all_address == null || - // // controller.model.all_address!.isEmpty) { - // // showToast("地址不能为空"); - // // return; - // // } - // // if (controller.model.name == null || - // // controller.model.name!.isEmpty) { - // // showToast("名字不能为空"); - // // return; - // // } - // // if (controller.model.detail == null || - // // controller.model.detail!.isEmpty) { - // // showToast("详细地址不能为空"); - // // return; - // // } - // // if (controller.model.phone == null || - // // controller.model.phone!.isEmpty) { - // // showToast("手机号不能为空"); - // // return; - // // } - // // if (!MyUtils.isValidPhoneNumber( - // // controller.model.phone!)) { - // // showToast("无效的手机号码"); - // // return; - // // } - // // if (addressListController.model.type == 1) { - // // await controller.addAddress(controller.model); - // // } else { - // // await controller.updateAddress( - // // address, controller.model); - // // } - // // await addressListController.getAddressList(); - // // Get.back(); - // // controller.model = AddressModel(); - // // controller.updateAll(); - // }, - // text: '确定', - // options: FFButtonOptions( - // height: 40, - // padding: const EdgeInsetsDirectional.fromSTEB( - // 24, 0, 24, 0), - // iconPadding: - // const EdgeInsetsDirectional.fromSTEB( - // 0, 0, 0, 0), - // color: const Color(0xFFD3B684), - // textStyle: FlutterFlowTheme.of(context) - // .titleSmall - // .override( - // fontFamily: 'Readex Pro', - // color: Colors.white, - // fontSize: AppFontsize.normal_text_size, - // letterSpacing: 0, - // ), - // elevation: 0, - // borderSide: const BorderSide( - // color: Colors.transparent, - // width: 1, - // ), - // borderRadius: BorderRadius.circular(6), - // ), - // ), - // ), - // ), - ), + )), ], ), ), @@ -1205,28 +1190,9 @@ class EditAddressPage extends GetView @override Future> onDataLoad( int index, String code, String name) async { - debugPrint("onDataLoad ---> $index $name"); + debugPrint("onDataLoad ---> index=$index, code=$code, name=$name"); - if (index == 0) { - await Future.delayed(const Duration(milliseconds: 200)); - return HttpUtils.getCityData("", index); - } else { - if (controller.model.currentType == 0) { - return Future.value([]); - } else if (controller.model.currentType == 1) { - if (index == 2) { - return Future.value([]); - } - return HttpUtils.getCityData(code, index); - } else if (controller.model.currentType == 2) { - if (index == 3) { - return Future.value([]); - } - return HttpUtils.getCityData(code, index); - } else { - return HttpUtils.getCityData(code, index); - } - } + return HttpUtils.getCityData(code, index); } @override @@ -1268,20 +1234,28 @@ class EditAddressPage extends GetView } } +// class HttpUtils { +// static Future> getCityData(String code, int index) async { +// final AddressController addressController = Get.find(); +// addressController.model.currentType = 1; + +// if (code.isEmpty) { +// addressController.updateAll(); +// return addressController.getData(); +// } +// addressController.model.currentType = index + 1; +// //控制选择区域层级 1.省 2.市 3.区 4.街道 +// if (addressController.model.currentType > 3) { +// return []; +// } +// return addressController.getData(); +// } +// } class HttpUtils { static Future> getCityData(String code, int index) async { - final AddressController addressController = Get.find(); - addressController.model.currentType = 1; + final AddressController controller = Get.find(); + controller.model.currentType = index; - if (code.isEmpty) { - addressController.updateAll(); - return addressController.getData(level: 0); - } - addressController.model.currentType = index + 1; - //控制选择区域层级 1.省 2.市 3.区 4.街道 - if (addressController.model.currentType > 3) { - return []; - } - return addressController.getData(pid: int.parse(code)); + return controller.getData(parentCode: code, level: index); } } diff --git a/lib/pages/mh_page/edit_bed.dart b/lib/pages/mh_page/edit_bed.dart index b056d80..1d64fd8 100644 --- a/lib/pages/mh_page/edit_bed.dart +++ b/lib/pages/mh_page/edit_bed.dart @@ -188,7 +188,7 @@ class _EditBedPageState extends State { ServiceConstant.service_address; String serviceName = ServiceConstant.server_service; - String serviceApi = ServiceConstant.person_info; + String serviceApi = ServiceConstant.device_show; String queryUrl = "$serviceAddress$serviceName$serviceApi"; await requestWithLog( @@ -196,10 +196,12 @@ class _EditBedPageState extends State { method: MyHttpMethod.put, queryUrl: queryUrl, data: { - "id": editedData["id"], + "id": editedData["_id"], "name": editedData["name"], }, - onSuccess: (res) {}, + onSuccess: (res) { + '更新人员信息成功: $res'; + }, ); }, colors: const [ diff --git a/lib/pages/mh_page/homepage/component/citypicker.dart b/lib/pages/mh_page/homepage/component/citypicker.dart new file mode 100644 index 0000000..ab62fd8 --- /dev/null +++ b/lib/pages/mh_page/homepage/component/citypicker.dart @@ -0,0 +1,105 @@ +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_city_picker/view/city_picker.dart'; + +class CityPicker { + /// 展示 + static void show({ + required BuildContext context, + AnimationController? animController, + double opacity = 0.5, + bool dismissible = true, + double height = 500.0, + double titleHeight = 50.0, + double corner = 20.0, + Color? backgroundColor, + double paddingLeft = 15.0, + Widget? titleWidget, + String? selectText, + Widget? closeWidget, + double tabHeight = 40.0, + bool showTabIndicator = true, + double tabPadding = 10.0, + Color? tabIndicatorColor, + double tabIndicatorHeight = 3.0, + double labelTextSize = 15.0, + Color? selectedLabelColor, + Color? unselectedLabelColor, + double itemHeadHeight = 30.0, + Color? itemHeadBackgroundColor, + Color? itemHeadLineColor, + double itemHeadLineHeight = 0.1, + TextStyle? itemHeadTextStyle, + double itemHeight = 40.0, + double indexBarWidth = 28, + double indexBarItemHeight = 20, + Color indexBarBackgroundColor = Colors.black12, + TextStyle? indexBarTextStyle, + Widget? itemSelectedIconWidget, + TextStyle? itemSelectedTextStyle, + TextStyle? itemUnSelectedTextStyle, + List? initialAddress, + required CityPickerListener cityPickerListener, + }) { + showGeneralDialog( + context: context, + barrierColor: Colors.black.withOpacity(opacity), + barrierDismissible: dismissible, + barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, + transitionDuration: const Duration(milliseconds: 300), + pageBuilder: (context, animation, secondaryAnimation) { + return Align( + alignment: Alignment.bottomCenter, + child: Material( + color: Colors.transparent, + child: Container( + width: MediaQuery.of(context).size.width, + height: height, + decoration: BoxDecoration( + color: backgroundColor ?? Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(corner), + topRight: Radius.circular(corner), + ), + ), + child: CityPickerWidget( + height: height, + titleHeight: titleHeight, + corner: corner, + backgroundColor: backgroundColor, + paddingLeft: paddingLeft, + titleWidget: titleWidget, + selectText: selectText, + closeWidget: closeWidget, + tabHeight: tabHeight, + showTabIndicator: showTabIndicator, + tabPadding: tabPadding, + tabIndicatorColor: tabIndicatorColor, + tabIndicatorHeight: tabIndicatorHeight, + labelTextSize: labelTextSize, + selectedLabelColor: selectedLabelColor, + unselectedLabelColor: unselectedLabelColor, + itemHeadHeight: itemHeadHeight, + itemHeadBackgroundColor: itemHeadBackgroundColor, + itemHeadLineColor: itemHeadLineColor, + itemHeadLineHeight: itemHeadLineHeight, + itemHeadTextStyle: itemHeadTextStyle, + itemHeight: itemHeight, + indexBarWidth: indexBarWidth, + indexBarItemHeight: indexBarItemHeight, + indexBarBackgroundColor: indexBarBackgroundColor, + indexBarTextStyle: indexBarTextStyle, + itemSelectedIconWidget: itemSelectedIconWidget, + itemSelectedTextStyle: itemSelectedTextStyle, + itemUnSelectedTextStyle: itemUnSelectedTextStyle, + initialAddress: initialAddress, + cityPickerListener: cityPickerListener, + ), + ), + ), + ); + }, + ); + } +} \ No newline at end of file diff --git a/lib/pages/mh_page/homepage/new_Home_page.dart b/lib/pages/mh_page/homepage/new_Home_page.dart index 1ac7cf7..f88b6dc 100644 --- a/lib/pages/mh_page/homepage/new_Home_page.dart +++ b/lib/pages/mh_page/homepage/new_Home_page.dart @@ -142,7 +142,7 @@ class _NewHomePageState extends State { }), const Spacer(), // 左右分隔 FloatingSvgIcon( - assetPath: 'assets/img/icon/xiaoe.svg', + assetPath: 'assets/img/icon/xiaoyi.svg', width: 60.rpx, height: 60.rpx, onTap: () { @@ -463,7 +463,7 @@ class _NewHomePageState extends State { ), fillColor: stringToColor( - "#184468"), + "##011D33"), elevation: 2, borderColor: Colors.transparent, @@ -482,6 +482,7 @@ class _NewHomePageState extends State { isMultiSelect: false, ), ), + ), InkWell( onTap: () { @@ -559,7 +560,8 @@ class _NewHomePageState extends State { .value .length, (index) { var day = homeController - .homeSleepDays[index]; + .homeSleepDays[ + index]; bool isSelected = homeController .selectedDayIndex @@ -607,7 +609,7 @@ class _NewHomePageState extends State { BoxDecoration( color: isSelected ? stringToColor( - "#184468") + "#011D33") : Colors .transparent, borderRadius: diff --git a/lib/pages/mh_page/people_info.dart b/lib/pages/mh_page/people_info.dart index 72b0233..175bc7d 100644 --- a/lib/pages/mh_page/people_info.dart +++ b/lib/pages/mh_page/people_info.dart @@ -28,10 +28,6 @@ class PeopleInfoPage extends GetView { PeopleInfoController controller = Get.put(PeopleInfoController()); @override Widget build(BuildContext context) { - // 初始化只做一次 - WidgetsBinding.instance.addPostFrameCallback((_) { - controller.initData(data['mac']); - }); return LayoutBuilder( builder: (context, boxConstraints) => GestureDetector( onTap: () { @@ -175,529 +171,705 @@ class PeopleInfoPage extends GetView { body: SafeArea( top: true, child: Container( - padding: EdgeInsets.only(left: 30.rpx, right: 30.rpx), - width: MediaQuery.sizeOf(context).width, - height: MediaQuery.sizeOf(context).height * 1.123, - // decoration: BoxDecoration( - // color: Colors.transparent, - // image: DecorationImage( - // image: AssetImage("assets/images/background.png"), - // fit: BoxFit.cover, - // ), - // ), - child: SingleChildScrollView( - child: Column( - children: [ - if (controller.model.peopleList.isNotEmpty) - ...List.generate(controller.model.peopleList.length, - (index) { - final person = controller.model.peopleList[index]; - String location_ = ''; - // if ("${data["bindMacB"]}".length > 6 && - // (person["direction"] == 1 || - // person["direction"] == 2)) { - // location_ = person["direction"] == 1 ? '左侧' : '右侧'; - // } - return Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.start, + padding: EdgeInsets.only(left: 30.rpx, right: 30.rpx), + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height * 1.123, + // decoration: BoxDecoration( + // color: Colors.transparent, + // image: DecorationImage( + // image: AssetImage("assets/images/background.png"), + // fit: BoxFit.cover, + // ), + // ), + child: SingleChildScrollView( + child: Obx(() => Column( children: [ - Container( - margin: EdgeInsets.only( - left: 18.rpx, - top: index == 0 ? 30.rpx : 90.rpx, - bottom: 20.rpx), - child: Text( - "人员资料${index == 0 ? "A" : "B"}", - style: TextStyle( - color: Colors.white, fontSize: 30.rpx), - ), - ), - Container( - child: Column( - children: [ - getLine(), - Obx( - () => Container( - width: double.infinity, - height: 90.rpx, + if (controller.model.peopleList.isNotEmpty) + ...List.generate( + controller.model.peopleList.length, + (index) { + final person = + controller.model.peopleList[index]; + String location_ = ''; + // if ("${data["bindMacB"]}".length > 6 && + // (person["direction"] == 1 || + // person["direction"] == 2)) { + // location_ = person["direction"] == 1 ? '左侧' : '右侧'; + // } + return Column( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( margin: EdgeInsets.only( - left: 40.rpx, right: 35.rpx), - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '姓名', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - Container( - width: 300.rpx, - child: TextField( - obscureText: false, - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 30.rpx, - color: Colors.white), - decoration: - const InputDecoration( - fillColor: - Colors.transparent, - filled: true, - hintText: "请输入姓名", - hintStyle: TextStyle( - color: - Colors.white), - border: - InputBorder.none, - contentPadding: - EdgeInsets.all(0)), - onChanged: (value) { - controller.model - .peopleList[index] - ["name"] = value; - }, - controller: controller.onReDraw( - TextEditingController( - text: controller.model - .peopleList[ - index] - ["name"] ?? - ""), - (textEditingController) { - textEditingController - .text = controller.model - .peopleList[index] - ["name"] ?? - ""; - }, "people_name_$index"), - ), - ), - ], + left: 18.rpx, + top: index == 0 ? 30.rpx : 90.rpx, + bottom: 20.rpx), + child: Text( + "人员资料${index == 0 ? "A" : "B"}", + style: TextStyle( + color: Colors.white, + fontSize: 30.rpx), ), ), - ), - getLine(), - Obx( - () => Container( - margin: EdgeInsets.only( - left: 40.rpx, right: 35.rpx), - width: double.infinity, - height: 90.rpx, - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + Container( + child: Column( children: [ - Text( - '性别', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, + getLine(), + Obx( + () => Container( + width: double.infinity, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, + right: 35.rpx), + decoration: BoxDecoration(), + child: Row( + mainAxisSize: + MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '姓名', + style: TextStyle( + fontFamily: + 'Readex Pro', + color: + Color(0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + Container( + width: 300.rpx, + child: TextField( + obscureText: false, + textAlign: + TextAlign.right, + style: TextStyle( + fontSize: 30.rpx, + color: + Colors.white), + decoration: + const InputDecoration( + fillColor: Colors + .transparent, + filled: true, + hintText: + "请输入姓名", + hintStyle: TextStyle( + color: Colors + .white), + border: + InputBorder + .none, + contentPadding: + EdgeInsets + .all( + 0)), + onChanged: (value) { + controller.model + .peopleList[ + index] + ["name"] = value; + }, + controller: controller.onReDraw( + TextEditingController( + text: controller + .model + .peopleList[index] + [ + "name"] ?? + ""), + (textEditingController) { + textEditingController + .text = controller + .model + .peopleList[ + index]["name"] ?? + ""; + }, "people_name_$index"), + ), + ), + ], + ), ), ), - InkWell( - onTap: () { - // 触摸收起键盘 - FocusScope.of(context) - .requestFocus(FocusNode()); - Future.delayed( - const Duration( - milliseconds: 250), () { - // 延迟执行的代码 - showOneSelectionDialog( - context, - arr: ["女", "男"], - checkIndex: controller + getLine(), + Obx( + () => Container( + margin: EdgeInsets.only( + left: 40.rpx, + right: 35.rpx), + width: double.infinity, + height: 90.rpx, + decoration: BoxDecoration(), + child: InkWell( + onTap: () { + // 触摸收起键盘 + FocusScope.of(context) + .requestFocus( + FocusNode()); + Future.delayed( + const Duration( + milliseconds: + 250), () { + // 延迟执行的代码 + showOneSelectionDialog( + context, + arr: ["女", "男"], + checkIndex: controller + .model + .peopleList[index] + [ + 'gender'] == + "女" + ? 0 + : 1, + checkChange: + (sindex) { + controller.model.peopleList[ + index] + ['gender'] = + sindex; // 👈 保存为 0 / 1 + controller + .updateAll(); + print( + "gender $sindex"); + }).then((d) { + // Timer(Duration.zero, () { + // FocusScope.of(context).unfocus(); + // }); + }); + }); + }, + child: Row( + mainAxisSize: + MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '性别', + style: TextStyle( + fontFamily: + 'Readex Pro', + color: Color( + 0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + Row( + mainAxisSize: + MainAxisSize.max, + children: [ + Container( + width: 200.rpx, + child: Text( + '${controller.model.peopleList[index]['gender'] == 1 ? '男' : '女'}', + textAlign: + TextAlign + .right, + style: + TextStyle( + fontFamily: + 'Readex Pro', + color: Colors + .white, + fontSize: + 30.rpx, + letterSpacing: + 0, + ), + ), + ), + SizedBox( + width: 16.rpx, + ), + Icon( + Icons.expand_more, + color: + Colors.white, + size: 48.rpx, + ), + ], + ), + ], + ), + )), + ), + getLine(), + // Container( + // width: double.infinity, + // height: 90.rpx, + // margin: EdgeInsets.only( + // left: 40.rpx, right: 35.rpx), + // decoration: BoxDecoration(), + // child: Row( + // mainAxisSize: MainAxisSize.max, + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // '身高(cm)', + // style: TextStyle( + // fontFamily: 'Readex Pro', + // color: Color(0xFF9EA4B7), + // fontSize: 30.rpx, + // letterSpacing: 0, + // ), + // ), + // InkWell( + // onTap: () { + // FocusScope.of(context).unfocus(); + // Future.delayed( + // const Duration( + // milliseconds: 250), () { + // showHeightPickerDialog( + // context, + // initialHeight: controller + // .model + // .peopleList[index] + // ['height'] ?? + // 170, + // onConfirm: + // (int selectedHeight) { + // controller.model.peopleList[ + // index]['height'] = + // selectedHeight + // .toString(); + // controller.updateAll(); + // print( + // "身高: $selectedHeight cm"); + // }, + // ); + // }); + // }, + // child: Row( + // children: [ + // Text( + // controller.model.peopleList[ + // index] + // ['height'] != + // null + // ? "${controller.model.peopleList[index]['height']} cm" + // : '', + // style: TextStyle( + // fontFamily: 'Readex Pro', + // color: Colors.white, + // fontSize: 30.rpx, + // ), + // ), + // SizedBox(width: 16.rpx), + // Icon(Icons.expand_more, + // color: Colors.white, + // size: 48.rpx), + // ], + // ), + // ), + // ], + // ), + // ), + Container( + width: double.infinity, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, + right: 35.rpx), + decoration: BoxDecoration(), + child: InkWell( + onTap: () { + FocusScope.of(context) + .unfocus(); + Future.delayed( + const Duration( + milliseconds: 250), + () { + // Convert string height to int for initial value + final currentHeight = + controller.model + .peopleList[ + index]['height']; + final initialHeight = + currentHeight != null + ? int.tryParse( + currentHeight + .toString()) ?? + 170 + : 170; + + showHeightPickerDialog( + context, + initialHeight: + initialHeight, + onConfirm: (int + selectedHeight) { + controller.model.peopleList[ + index] + ['height'] = + selectedHeight + .toString(); + controller + .updateAll(); + print( + "身高: $selectedHeight cm"); + }, + ); + }); + }, + child: Row( + mainAxisSize: + MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '身高(cm)', + style: TextStyle( + fontFamily: + 'Readex Pro', + color: + Color(0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + Row( + children: [ + Text( + controller.model.peopleList[ + index] + [ + 'height'] != + null + ? "${controller.model.peopleList[index]['height']} cm" + : '', + style: TextStyle( + fontFamily: + 'Readex Pro', + color: + Colors.white, + fontSize: 30.rpx, + ), + ), + SizedBox( + width: 16.rpx), + Icon( + Icons.expand_more, + color: + Colors.white, + size: 48.rpx), + ], + ), + ], + ), + )), + getLine(), + Obx( + () => Container( + width: double.infinity, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, + right: 35.rpx), + decoration: BoxDecoration(), + child: InkWell( + onTap: () { + FocusScope.of(context) + .unfocus(); + Future.delayed( + const Duration( + milliseconds: + 250), () { + showWeightPickerDialog( + context, + initialWeight: controller .model .peopleList[ index] - ['gender'] == - "女" - ? 0 - : 1, - checkChange: (sindex) { - controller.model.peopleList[ - index]['gender'] = - sindex; // 👈 保存为 0 / 1 - controller.updateAll(); - print("gender $sindex"); - }).then((d) { - // Timer(Duration.zero, () { - // FocusScope.of(context).unfocus(); - // }); - }); - }); - }, - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Container( - width: 200.rpx, - child: Text( - '${controller.model.peopleList[index]['gender'] == 1 ? '男' : '女'}', - textAlign: - TextAlign.right, - style: TextStyle( - fontFamily: - 'Readex Pro', - color: Colors.white, - fontSize: 30.rpx, - letterSpacing: 0, - ), + ['weight'] ?? + "", + onConfirm: (int + selectedWeight) { + controller.model.peopleList[ + index] + ['weight'] = + selectedWeight + .toString(); // ✅ 转成字符串 + controller + .updateAll(); + print( + "体重: $selectedWeight kg"); + }, + ); + }); + }, + child: Row( + mainAxisSize: + MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '体重(kg)', + style: TextStyle( + fontFamily: + 'Readex Pro', + color: Color( + 0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + Row( + children: [ + Text( + controller.model.peopleList[ + index] + [ + 'weight'] != + null + ? "${controller.model.peopleList[index]['weight']} kg" + : '', + style: TextStyle( + fontFamily: + 'Readex Pro', + color: Colors + .white, + fontSize: + 30.rpx, + ), + ), + SizedBox( + width: 16.rpx), + Icon( + Icons + .expand_more, + color: Colors + .white, + size: 48.rpx), + ], + ), + ], ), - ), - SizedBox( - width: 16.rpx, - ), - Icon( - Icons.expand_more, - color: Colors.white, - size: 48.rpx, - ), - ], - ), + )), ), - ], - ), - ), - ), - getLine(), - Container( - width: double.infinity, - height: 90.rpx, - margin: EdgeInsets.only( - left: 40.rpx, right: 35.rpx), - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '身高(cm)', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - InkWell( - onTap: () { - FocusScope.of(context).unfocus(); - Future.delayed( - const Duration( - milliseconds: 250), () { - showHeightPickerDialog( - context, - initialHeight: controller - .model - .peopleList[index] - ['height'] ?? - 170, - onConfirm: - (int selectedHeight) { - controller.model.peopleList[ - index]['height'] = - selectedHeight - .toString(); - controller.updateAll(); - print( - "身高: $selectedHeight cm"); - }, - ); - }); - }, - child: Row( - children: [ - Text( - controller.model.peopleList[ - index] - ['height'] != - null - ? "${controller.model.peopleList[index]['height']} cm" - : '', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Colors.white, - fontSize: 30.rpx, - ), - ), - SizedBox(width: 16.rpx), - Icon(Icons.expand_more, - color: Colors.white, - size: 48.rpx), - ], - ), - ), - ], - ), - ), - getLine(), - Container( - width: double.infinity, - height: 90.rpx, - margin: EdgeInsets.only( - left: 40.rpx, right: 35.rpx), - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '体重(kg)', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - InkWell( - onTap: () { - FocusScope.of(context).unfocus(); - Future.delayed( - const Duration( - milliseconds: 250), () { - showWeightPickerDialog( - context, - initialWeight: controller - .model - .peopleList[index] - ['weight'] ?? - "", - onConfirm: - (int selectedWeight) { - controller.model.peopleList[ - index]['weight'] = - selectedWeight - .toString(); // ✅ 转成字符串 - controller.updateAll(); - print( - "体重: $selectedWeight kg"); - }, - ); - }); - }, - child: Row( - children: [ - Text( - controller.model.peopleList[ - index] - ['weight'] != - null - ? "${controller.model.peopleList[index]['weight']} kg" - : '', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Colors.white, - fontSize: 30.rpx, - ), - ), - SizedBox(width: 16.rpx), - Icon(Icons.expand_more, - color: Colors.white, - size: 48.rpx), - ], - ), - ), - ], - ), - ), - getLine(), - Obx( - () => Container( - width: double.infinity, - height: 90.rpx, - margin: EdgeInsets.only( - left: 40.rpx, right: 35.rpx), - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '生日', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - InkWell( - onTap: () { - // 触摸收起键盘 - FocusScope.of(context) - .requestFocus(FocusNode()); - Future.delayed( - const Duration( - milliseconds: 250), () { - // 延迟执行的代码 - showDateSelectionDialog( - context, - checkDate: controller - .model - .peopleList[index] - ['birthday'] - is DateTime - ? controller.model - .peopleList[index] - ['birthday'] - : DateTime.tryParse( - controller.model.peopleList[index]['birthday'] ?? - '') ?? - DateTime.now(), - checkChange: (DateTime d) { - controller.model - .peopleList[index] - ['birthday'] = d; - controller.updateAll(); - print("$d"); - }).then((d) { - // Timer(Duration.zero, () { - // FocusScope.of(context).unfocus(); - // }); - }); - }); - }, - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Container( - constraints: BoxConstraints( - minWidth: 200.rpx), - child: Text( - controller.model.peopleList[ - index][ - 'birthday'] != - null - ? time_08_Formatter_pattern( - controller.model - .peopleList[ - index] - ['birthday'], - "yyyy年MM月dd日") - : '', - textAlign: - TextAlign.right, - style: TextStyle( - fontFamily: - 'Readex Pro', - color: Colors.white, - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - ), - SizedBox( - width: 16.rpx, - ), - Icon( - Icons.expand_more, - color: Colors.white, - size: 48.rpx, - ), - ], - ), - ), - ], - ), - ), - ), - getLine(), - Container( - width: double.infinity, - height: 90.rpx, - margin: EdgeInsets.only( - left: 40.rpx, right: 35.rpx), - decoration: BoxDecoration(), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '联系人', - style: TextStyle( - fontFamily: 'Readex Pro', - color: Color(0xFF9EA4B7), - fontSize: 30.rpx, - letterSpacing: 0, - ), - ), - Container( - width: 300.rpx, - child: TextField( - obscureText: false, - keyboardType: - TextInputType.number, - textInputAction: - TextInputAction.done, - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 30.rpx, - color: Colors.white), - decoration: InputDecoration( - fillColor: Colors.transparent, - filled: true, - hintText: "请输入联系人", - hintStyle: TextStyle( - color: Colors.white), - border: InputBorder.none, - contentPadding: - EdgeInsets.all(0)), - onChanged: (value) { - controller - .model.peopleList[index] - ['contact'] = value; - controller.updateAll(); - }, - controller: controller.onReDraw( - TextEditingController( - text: controller.model + + getLine(), + Obx( + () => Container( + width: double.infinity, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, + right: 35.rpx), + decoration: BoxDecoration(), + child: InkWell( + onTap: () { + // 触摸收起键盘 + FocusScope.of(context) + .requestFocus( + FocusNode()); + Future.delayed( + const Duration( + milliseconds: + 250), () { + // 延迟执行的代码 + showDateSelectionDialog( + context, + checkDate: controller + .model + .peopleList[index]['birthday'] + is DateTime + ? controller + .model + .peopleList[index] + ['birthday'] + : DateTime.tryParse( + controller.model.peopleList[index]['birthday'] ?? + '') ?? + DateTime.now(), + checkChange: + (DateTime d) { + controller.model .peopleList[ index] - ['contact'] ?? - ""), - (textEditingController) { - textEditingController - .text = controller.model - .peopleList[index] - ['contact'] ?? - ""; - }, "contact_$index"), + ['birthday'] = d; + controller + .updateAll(); + print("$d"); + }).then((d) { + // Timer(Duration.zero, () { + // FocusScope.of(context).unfocus(); + // }); + }); + }); + }, + child: Row( + mainAxisSize: + MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '生日', + style: TextStyle( + fontFamily: + 'Readex Pro', + color: Color( + 0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + Row( + mainAxisSize: + MainAxisSize.max, + children: [ + Container( + constraints: + BoxConstraints( + minWidth: + 200.rpx), + child: Text( + controller.model.peopleList[index] + [ + 'birthday'] != + null + ? time_08_Formatter_pattern( + controller + .model + .peopleList[index]['birthday'], + "yyyy年MM月dd日") + : '', + textAlign: + TextAlign + .right, + style: + TextStyle( + fontFamily: + 'Readex Pro', + color: Colors + .white, + fontSize: + 30.rpx, + letterSpacing: + 0, + ), + ), + ), + SizedBox( + width: 16.rpx, + ), + Icon( + Icons.expand_more, + color: + Colors.white, + size: 48.rpx, + ), + ], + ), + ], + ), + )), ), - ), - ], - ), - ), - getLine(), - ], - ), - ) + getLine(), + Container( + width: double.infinity, + height: 90.rpx, + margin: EdgeInsets.only( + left: 40.rpx, right: 35.rpx), + decoration: BoxDecoration(), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '联系人', + style: TextStyle( + fontFamily: 'Readex Pro', + color: Color(0xFF9EA4B7), + fontSize: 30.rpx, + letterSpacing: 0, + ), + ), + Container( + width: 300.rpx, + child: TextField( + obscureText: false, + keyboardType: + TextInputType.number, + textInputAction: + TextInputAction.done, + textAlign: + TextAlign.right, + style: TextStyle( + fontSize: 30.rpx, + color: Colors.white), + decoration: InputDecoration( + fillColor: Colors + .transparent, + filled: true, + hintText: "请输入联系人", + hintStyle: TextStyle( + color: + Colors.white), + border: + InputBorder.none, + contentPadding: + EdgeInsets.all( + 0)), + onChanged: (value) { + controller.model + .peopleList[ + index] + ['contact'] = value; + controller.updateAll(); + }, + controller: controller.onReDraw( + TextEditingController( + text: controller + .model + .peopleList[index] + [ + 'contact'] ?? + ""), + (textEditingController) { + textEditingController + .text = controller + .model + .peopleList[ + index]['contact'] ?? + ""; + }, "contact_$index"), + ), + ), + ], + ), + ), + getLine(), + ], + ), + ) + ], + ); + }), + SizedBox( + height: 100.rpx, + ), ], - ); - }), - SizedBox( - height: 100.rpx, - ), - ], - )), - ), + )), + )), ), ), )), diff --git a/lib/pages/mh_page/repair_list.dart b/lib/pages/mh_page/repair_list.dart index 46d182e..18effa6 100644 --- a/lib/pages/mh_page/repair_list.dart +++ b/lib/pages/mh_page/repair_list.dart @@ -173,9 +173,7 @@ class DeviceRepairPage extends GetView { ), ], ))), - SizedBox(height: 24.rpx), - InkWell( onTap: () { // bool isOk = true; diff --git a/lib/pages/mh_page/room_picker.dart b/lib/pages/mh_page/room_picker.dart index 936e17f..6a0b87d 100644 --- a/lib/pages/mh_page/room_picker.dart +++ b/lib/pages/mh_page/room_picker.dart @@ -7,16 +7,20 @@ import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; class RoomPickerPage extends StatefulWidget { + final Map data; + RoomPickerPage({Key? key, required this.data}); @override _RoomPickerPageState createState() => _RoomPickerPageState(); } class _RoomPickerPageState extends State { + late Map editedData; RxList rooms = [].obs; @override void initState() { super.initState(); + editedData = Map.from(widget.data); // 创建副本 getRoomList(); } @@ -31,6 +35,7 @@ class _RoomPickerPageState extends State { queryUrl: queryUrl, onSuccess: (res) { rooms.assignAll(res.data); + setState(() => selectedIndex = 0); }, ); } @@ -161,8 +166,32 @@ class _RoomPickerPageState extends State { child: CustomCard( borderRadius: 16.rpx, gradientDirection: GradientDirection.vertical, - onTap: () { + onTap: () async { // Get.toNamed("/applyRepairPage"); + try { + String serviceAddress = + ServiceConstant.service_address; + String serviceName = + ServiceConstant.server_service; + String serviceApi = + ServiceConstant.device_show; + String queryUrl = + "$serviceAddress$serviceName$serviceApi"; + await requestWithLog( + logTitle: "更新设备信息", + method: MyHttpMethod.put, + queryUrl: queryUrl, + data: { + "id": editedData["_id"], + "roomId": rooms[selectedIndex]['_id'], + }, + onSuccess: (res) { + '更新人员信息成功: $res'; + }, + ); + } catch (e) { + print(e); + } }, colors: const [ Color(0xFFFCFCFC), diff --git a/lib/pages/mh_page/searchWidget.dart b/lib/pages/mh_page/searchWidget.dart index ddaeae9..3e5b0b7 100644 --- a/lib/pages/mh_page/searchWidget.dart +++ b/lib/pages/mh_page/searchWidget.dart @@ -130,7 +130,7 @@ class SearchWidget extends GetView { mainAxisSize: MainAxisSize.max, children: [ SizedBox( - height: 50.rpx, + height: 30.rpx, child: VerticalDivider( thickness: 2.rpx, color: stringToColor("#333333"), //固定 diff --git a/lib/pages/mh_page/user/page/edit_userinfo_page.dart b/lib/pages/mh_page/user/page/edit_userinfo_page.dart index 6b9208e..fe2c56f 100644 --- a/lib/pages/mh_page/user/page/edit_userinfo_page.dart +++ b/lib/pages/mh_page/user/page/edit_userinfo_page.dart @@ -83,7 +83,7 @@ class _UpdateUserPageState extends State { ), Positioned( left: 0, - child: returnIconButtom, + child: returnIconButtomNew, ), Positioned( right: 20.rpx, diff --git a/lib/pages/mh_page/user/page/rxhx_mht.dart b/lib/pages/mh_page/user/page/rxhx_mht.dart index a9d6b38..924a696 100644 --- a/lib/pages/mh_page/user/page/rxhx_mht.dart +++ b/lib/pages/mh_page/user/page/rxhx_mht.dart @@ -591,8 +591,13 @@ class _RxhxMhtState extends State { child: Center( child: Text( weeks[index], - style: const TextStyle( - color: Colors.white), + style: TextStyle( + color: controller.model + .rxhxWeeks[ + index] == + 1 + ? Color(0XFF003058) + : Colors.white), ), ), ), diff --git a/lib/pages/repair/apply_repair_page.dart b/lib/pages/repair/apply_repair_page.dart index 26d5318..78fa88a 100644 --- a/lib/pages/repair/apply_repair_page.dart +++ b/lib/pages/repair/apply_repair_page.dart @@ -491,6 +491,7 @@ class _ApplyRepairPageState extends State { cursorColor: themeController.currentColor.sc3, onChanged: onChanged, ), + ), ), ].divide(SizedBox(width: 24.rpx)), diff --git a/lib/routers/mh_routers.dart b/lib/routers/mh_routers.dart index 827784f..ad3a64c 100644 --- a/lib/routers/mh_routers.dart +++ b/lib/routers/mh_routers.dart @@ -68,7 +68,7 @@ var mhroutes = { "/sleepHabitPage": (context) => SleepHabitPage(), '/syms': (context) => Smys(), "/applyRepairPage": (context) => ApplyRepairPage(), - "/roomPickerPage": (context) => RoomPickerPage(), + "/roomPickerPage": (context, {arguments}) => RoomPickerPage(data: arguments), "/editBedPage": (context, {arguments}) => EditBedPage(data: arguments), "/experienceStorePage": (context) => ExperienceStorePage(), "/bookInfoPage": (context, {arguments}) =>