From 8c0ae4f349113d4095bc345f1f846d5f8cb85d0c Mon Sep 17 00:00:00 2001 From: DaisyWu <18682150237@163.com> Date: Mon, 26 May 2025 15:58:52 +0800 Subject: [PATCH 01/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=83=A8=E9=97=A8=E9=97=AE=E9=A2=98-=E5=8F=91?= =?UTF-8?q?=E9=80=81=E9=92=A5=E5=8C=99=E5=90=84=E4=B8=AA=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=B8=8B=E7=82=B9=E5=87=BB=E9=80=9A=E8=AE=AF=E5=BD=95=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=9B=B4=E6=8E=A5=E8=8E=B7=E5=8F=96=E9=80=9A=E8=AE=AF?= =?UTF-8?q?=E5=BD=95=E8=81=94=E7=B3=BB=E4=BA=BA=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E5=8F=8A=E5=A7=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/sendElectronicKeyView_page.dart | 59 +++++++++++++------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart index da455907..c6fc5cbe 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart @@ -163,8 +163,8 @@ class _SendElectronicKeyViewState extends State color: Colors.white, border: Border( bottom: BorderSide( - color: AppColors.greyLineColor, // 设置边框颜色 - width: 2.0.h, // 设置边框宽度 + color: AppColors.greyLineColor, + width: 2.0.h, ), )), child: Row( @@ -174,17 +174,14 @@ class _SendElectronicKeyViewState extends State Expanded( child: TextField( controller: logic.getCurrentController(1), - //输入框一行 maxLines: 1, inputFormatters: [ FilteringTextInputFormatter.deny('\n'), LengthLimitingTextInputFormatter(30), ], - // controller: _controller, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( - //输入里面输入文字内边距设置 hintText: rightTitle, hintStyle: TextStyle(fontSize: 22.sp), focusedBorder: const OutlineInputBorder( @@ -205,9 +202,7 @@ class _SendElectronicKeyViewState extends State fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), ), ), - SizedBox( - width: 10.w, - ), + SizedBox(width: 10.w), Container( width: 32.w, height: 32.w, @@ -222,22 +217,48 @@ class _SendElectronicKeyViewState extends State onTap: () async { final Contact? currentContact = await logic.state.contactPicker.selectContact(); - logic.state.contact = currentContact!; - if (currentContact.phoneNumbers!.isNotEmpty) { - logic.state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r'\s+\b|\b\s'), ''); - } - if (currentContact.fullName!.isNotEmpty) { - logic.state.keyNameController.text = - currentContact.fullName!; + if (currentContact != null) { + logic.state.contact = currentContact; + + // 处理手机号 + if (currentContact.phoneNumbers != null && + currentContact.phoneNumbers!.isNotEmpty) { + // 获取第一个手机号并清理格式 + String phoneNumber = currentContact.phoneNumbers![0]; + // 移除所有空格、括号、连字符等特殊字符 + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), ''); + // 如果号码以+开头,保留+号 + if (phoneNumber.startsWith('+')) { + phoneNumber = '+' + + phoneNumber + .substring(1) + .replaceAll(RegExp(r'[^\d]'), ''); + } else { + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); + } + logic.state.emailOrPhoneController.text = phoneNumber; + } else { + logic.state.emailOrPhoneController.text = ''; + } + + // 处理姓名 + if (currentContact.fullName != null && + currentContact.fullName!.isNotEmpty) { + logic.state.keyNameController.text = + currentContact.fullName!; + } + + // 更新UI + logic.update(); } }, ), ), Container( - color: AppColors.greyLineColor, // 设置边框颜色 - height: 2.0.h, // + color: AppColors.greyLineColor, + height: 2.0.h, ) ], ), From 4b3a74cc584275cf78d5c685dc6d24be9bfeeb19 Mon Sep 17 00:00:00 2001 From: DaisyWu <18682150237@163.com> Date: Mon, 26 May 2025 16:11:54 +0800 Subject: [PATCH 02/13] =?UTF-8?q?fix:=20=E6=8E=88=E6=9D=83=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E2=80=94=E5=90=84=E4=B8=AA=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=B8=8B=E7=82=B9=E5=87=BB=E9=80=9A=E8=AE=AF=E5=BD=95=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=9B=B4=E6=8E=A5=E8=8E=B7=E5=8F=96=E9=80=9A=E8=AE=AF?= =?UTF-8?q?=E5=BD=95=E8=81=94=E7=B3=BB=E4=BA=BA=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E5=8F=8A=E5=A7=93=E5=90=8D=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8F=8A=E8=87=AA=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authorizedAdmin/authorizedAdmin_page.dart | 92 +++++++++++++++---- 1 file changed, 72 insertions(+), 20 deletions(-) diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index b908e07a..e13c01bd 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -257,15 +257,42 @@ class _AuthorizedAdminPageState extends State onTap: () async { final Contact? currentContact = await logic.state.contactPicker.selectContact(); - logic.state.contact = currentContact!; - if (currentContact.phoneNumbers!.isNotEmpty) { - logic.state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r'\s+\b|\b\s'), ''); - } - if (currentContact.fullName!.isNotEmpty) { - logic.state.keyNameController.text = - currentContact.fullName!; + if (currentContact != null) { + setState(() { + logic.state.contact = currentContact; + + // 处理手机号 + if (currentContact.phoneNumbers != null && + currentContact.phoneNumbers!.isNotEmpty) { + // 获取第一个手机号并清理格式 + String phoneNumber = currentContact.phoneNumbers![0]; + // 移除所有空格、括号、连字符等特殊字符 + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), ''); + // 如果号码以+开头,保留+号 + if (phoneNumber.startsWith('+')) { + phoneNumber = '+' + + phoneNumber + .substring(1) + .replaceAll(RegExp(r'[^\d]'), ''); + } else { + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); + } + logic.state.emailOrPhoneController.text = phoneNumber; + } else { + logic.state.emailOrPhoneController.text = ''; + } + + // 处理姓名 + if (currentContact.fullName != null && + currentContact.fullName!.isNotEmpty) { + logic.state.keyNameController.text = + currentContact.fullName!; + } else { + logic.state.keyNameController.text = ''; + } + }); } }, ), @@ -602,17 +629,42 @@ class _AuthorizedAdminPageState extends State onTap: () async { final Contact? currentContact = await state.contactPicker.selectContact(); - setState(() { - state.contact = currentContact!; - if (currentContact.phoneNumbers!.isNotEmpty) { - state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r'\s+\b|\b\s'), ''); - } - if (currentContact.fullName!.isNotEmpty) { - state.keyNameController.text = currentContact.fullName!; - } - }); + if (currentContact != null) { + setState(() { + state.contact = currentContact; + + // 处理手机号 + if (currentContact.phoneNumbers != null && + currentContact.phoneNumbers!.isNotEmpty) { + // 获取第一个手机号并清理格式 + String phoneNumber = currentContact.phoneNumbers![0]; + // 移除所有空格、括号、连字符等特殊字符 + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), ''); + // 如果号码以+开头,保留+号 + if (phoneNumber.startsWith('+')) { + phoneNumber = '+' + + phoneNumber + .substring(1) + .replaceAll(RegExp(r'[^\d]'), ''); + } else { + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); + } + state.emailOrPhoneController.text = phoneNumber; + } else { + state.emailOrPhoneController.text = ''; + } + + // 处理姓名 + if (currentContact.fullName != null && + currentContact.fullName!.isNotEmpty) { + state.keyNameController.text = currentContact.fullName!; + } else { + state.keyNameController.text = ''; + } + }); + } }, ), ) From 307a96d562be11970deff127228f40430ce2af53 Mon Sep 17 00:00:00 2001 From: DaisyWu <18682150237@163.com> Date: Mon, 26 May 2025 16:12:45 +0800 Subject: [PATCH 03/13] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sendElectronicKey/view/sendElectronicKeyView_page.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart index c6fc5cbe..5d6e9d30 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart @@ -248,6 +248,8 @@ class _SendElectronicKeyViewState extends State currentContact.fullName!.isNotEmpty) { logic.state.keyNameController.text = currentContact.fullName!; + } else { + logic.state.keyNameController.text = ''; } // 更新UI From e4649655b43128af318fd49c99ebfae03ce47fda Mon Sep 17 00:00:00 2001 From: Liuyf Date: Mon, 26 May 2025 16:27:35 +0800 Subject: [PATCH 04/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=93=9D?= =?UTF-8?q?=E7=89=99=E5=BC=80=E9=94=81=E6=88=90=E5=8A=9F=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E9=94=81=E8=AE=B0=E5=BD=95=E5=90=8C=E6=AD=A5=E4=B8=8D=E5=AE=8C?= =?UTF-8?q?=E6=95=B4bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main/lockDetail/lockDetail/lockDetail_logic.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index f3668a2c..5355f785 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -378,7 +378,7 @@ class LockDetailLogic extends BaseGetXController { if (i == getList.length - 1) { //设置最后的时间戳 - state.operateDate = operateDate; + state.operateDate = time; } } catch (e) { AppLog.log('操作记录:$indexList,解析失败,跳过该跳记录,进行下一条记录解析。'); From 2c316d427f68e23a955b59c4bed2ca0b6c6cb5d0 Mon Sep 17 00:00:00 2001 From: DaisyWu <18682150237@163.com> Date: Mon, 26 May 2025 19:51:06 +0800 Subject: [PATCH 05/13] =?UTF-8?q?fix:=20=E5=AE=89=E5=8D=93=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E9=80=9A=E8=AE=AF=E5=BD=95=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E6=8E=92=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 3 + .../view/sendElectronicKeyView_page.dart | 187 +++++++++++++----- .../view/sendElectronicKeyView_state.dart | 4 +- 3 files changed, 145 insertions(+), 49 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a2a967bc..341d6fae 100755 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -29,6 +29,9 @@ + + + diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart index 5d6e9d30..c4e62f99 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart @@ -20,6 +20,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import 'package:star_lock/tools/regularExpression.dart'; import 'package:star_lock/tools/showTipView.dart'; import 'package:star_lock/tools/submitBtn.dart'; +import 'package:permission_handler/permission_handler.dart'; class SendElectronicKeyView extends StatefulWidget { SendElectronicKeyView({required this.type, Key? key}) : super(key: key); @@ -31,6 +32,14 @@ class SendElectronicKeyView extends StatefulWidget { class _SendElectronicKeyViewState extends State with AutomaticKeepAliveClientMixin { + late FlutterContactPicker _contactPicker; + + @override + void initState() { + super.initState(); + _contactPicker = FlutterContactPicker(); + } + @override Widget build(BuildContext context) { super.build(context); @@ -215,45 +224,81 @@ class _SendElectronicKeyViewState extends State alignment: Alignment.center, child: InkWell( onTap: () async { - final Contact? currentContact = - await logic.state.contactPicker.selectContact(); - if (currentContact != null) { - logic.state.contact = currentContact; + try { + final PermissionStatus status = + await Permission.contacts.request(); + if (status.isGranted) { + // 保存当前路由 + final currentRoute = ModalRoute.of(context); - // 处理手机号 - if (currentContact.phoneNumbers != null && - currentContact.phoneNumbers!.isNotEmpty) { - // 获取第一个手机号并清理格式 - String phoneNumber = currentContact.phoneNumbers![0]; - // 移除所有空格、括号、连字符等特殊字符 - phoneNumber = - phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), ''); - // 如果号码以+开头,保留+号 - if (phoneNumber.startsWith('+')) { - phoneNumber = '+' + - phoneNumber - .substring(1) - .replaceAll(RegExp(r'[^\d]'), ''); - } else { - phoneNumber = - phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); + final Contact? currentContact = + await _contactPicker.selectContact(); + + // 检查路由是否仍然存在且组件是否挂载 + if (currentRoute?.isCurrent == true && mounted) { + // 检查 GetX 控制器是否仍然存在 + if (Get.isRegistered( + tag: widget.type)) { + final logic = Get.find( + tag: widget.type); + + if (currentContact != null) { + // 处理手机号 + if (currentContact.phoneNumbers != null && + currentContact.phoneNumbers!.isNotEmpty) { + String phoneNumber = + currentContact.phoneNumbers![0]; + // 移除所有空格、括号、连字符等特殊字符 + phoneNumber = phoneNumber.replaceAll( + RegExp(r'[\s\(\)\-]'), ''); + // 如果号码以+开头,保留+号 + if (phoneNumber.startsWith('+')) { + phoneNumber = '+' + + phoneNumber + .substring(1) + .replaceAll(RegExp(r'[^\d]'), ''); + } else { + phoneNumber = phoneNumber.replaceAll( + RegExp(r'[^\d]'), ''); + } + logic.state.emailOrPhoneController.text = + phoneNumber; + logic.state.emailOrPhone.value = phoneNumber; + } + + // 处理姓名 + if (currentContact.fullName != null && + currentContact.fullName!.isNotEmpty) { + logic.state.keyNameController.text = + currentContact.fullName!; + } + + // 更新UI + logic.update(); + } + } } - logic.state.emailOrPhoneController.text = phoneNumber; } else { - logic.state.emailOrPhoneController.text = ''; + // 权限被拒绝,显示提示 + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('需要通讯录权限才能选择联系人'.tr), + duration: const Duration(seconds: 2), + ), + ); + } } - - // 处理姓名 - if (currentContact.fullName != null && - currentContact.fullName!.isNotEmpty) { - logic.state.keyNameController.text = - currentContact.fullName!; - } else { - logic.state.keyNameController.text = ''; + } catch (e) { + print('Error selecting contact: $e'); + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('获取通讯录失败,请检查权限设置'.tr), + duration: const Duration(seconds: 2), + ), + ); } - - // 更新UI - logic.update(); } }, ), @@ -639,17 +684,65 @@ class _SendElectronicKeyViewState extends State alignment: Alignment.center, child: InkWell( onTap: () async { - final Contact? currentContact = - await logic.state.contactPicker.selectContact(); - logic.state.contact = currentContact!; - if (currentContact.phoneNumbers!.isNotEmpty) { - logic.state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r'\s+\b|\b\s'), ''); - } - if (currentContact.fullName!.isNotEmpty) { - logic.state.keyNameController.text = - currentContact.fullName!; + try { + final PermissionStatus status = + await Permission.contacts.request(); + if (status.isGranted) { + final Contact? currentContact = + await _contactPicker.selectContact(); + if (currentContact != null && mounted) { + // 处理手机号 + if (currentContact.phoneNumbers != null && + currentContact.phoneNumbers!.isNotEmpty) { + String phoneNumber = currentContact.phoneNumbers![0]; + // 移除所有空格、括号、连字符等特殊字符 + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), ''); + // 如果号码以+开头,保留+号 + if (phoneNumber.startsWith('+')) { + phoneNumber = '+' + + phoneNumber + .substring(1) + .replaceAll(RegExp(r'[^\d]'), ''); + } else { + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); + } + logic.state.emailOrPhoneController.text = phoneNumber; + logic.state.emailOrPhone.value = phoneNumber; + } + + // 处理姓名 + if (currentContact.fullName != null && + currentContact.fullName!.isNotEmpty) { + logic.state.keyNameController.text = + currentContact.fullName!; + } + + // 更新UI + logic.update(); + } + } else { + // 权限被拒绝,显示提示 + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('需要通讯录权限才能选择联系人'.tr), + duration: const Duration(seconds: 2), + ), + ); + } + } + } catch (e) { + print('Error selecting contact: $e'); + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('获取通讯录失败,请检查权限设置'.tr), + duration: const Duration(seconds: 2), + ), + ); + } } }, ), @@ -759,7 +852,7 @@ class _SendElectronicKeyViewState extends State child: Text( '取消'.tr, style: TextStyle( - color: Colors.black, fontSize: ScreenUtil().setSp(24)), + color: Colors.black, fontSize: 24.sp), ), onPressed: () { Navigator.pop(context); @@ -802,7 +895,7 @@ class _SendElectronicKeyViewState extends State Text( titleStr, style: TextStyle( - fontSize: ScreenUtil().setSp(20), color: Colors.black), + fontSize: 20.sp, color: Colors.black), ), ], ), diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart index 7ada2123..61121249 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart @@ -15,8 +15,8 @@ class SendElectronicKeyViewState { TextEditingController realNameController = TextEditingController(); //真实姓名输入框 TextEditingController idCardController = TextEditingController(); //身份证号输入框 - final FlutterContactPicker contactPicker = FlutterContactPicker(); - late Contact contact; + // final FlutterContactPicker contactPicker = FlutterContactPicker(); + // late Contact contact; RxBool isRemoteUnlock = false.obs; //是否允许远程开锁 RxBool isAuthentication = false.obs; //是否可以实名认证 From 9135f6f2a903464eec18f3ea771b040f910e7d00 Mon Sep 17 00:00:00 2001 From: Liuyf Date: Tue, 27 May 2025 10:33:54 +0800 Subject: [PATCH 06/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=93=9D?= =?UTF-8?q?=E7=89=99=E5=BC=80=E9=94=81=E6=88=90=E5=8A=9F=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E4=B8=80=E6=9D=A1=E9=94=81=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=81=B6=E5=B0=94=E4=B8=8D=E5=90=8C=E6=AD=A5bug=E8=AF=8A?= =?UTF-8?q?=E6=96=AD=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/blue/blue_manage.dart | 12 +++++++++--- .../lockDetail/lockDetail/lockDetail_logic.dart | 13 ++++++++++++- lib/main_local.dart | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index 6f258b2c..f90753b4 100755 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -123,14 +123,18 @@ class BlueManage { .eventBus! .on() .listen((EventSendModel model) { + AppLog.log('eventBus接收发送数据:${model}'); if (model.sendChannel == DataChannel.ble) { FlutterBluePlus.isSupported.then((bool isAvailable) async { if (isAvailable) { if (_adapterState == BluetoothAdapterState.on) { // 蓝牙已开启,可以进行蓝牙操作 + AppLog.log('蓝牙已开启,开始收发送数据:${model.data}'); writeCharacteristicWithResponse(model.data); } else { - try {} catch (e) { + try { + AppLog.log('蓝牙已关闭,停止发送数据:${model.data}'); + } catch (e) { AppLog.log('蓝牙打开失败'); } } @@ -315,8 +319,10 @@ class BlueManage { } /// 判断是否包含指定的uuid - bool _isMatch(List serviceUuids, {DeviceType deviceType = DeviceType.blue}) { - final List prefixes = getDeviceType(deviceType).map((e) => e.toLowerCase()).toList(); + bool _isMatch(List serviceUuids, + {DeviceType deviceType = DeviceType.blue}) { + final List prefixes = + getDeviceType(deviceType).map((e) => e.toLowerCase()).toList(); for (String uuid in serviceUuids) { final String cleanUuid = uuid.replaceAll('-', '').toLowerCase(); if (cleanUuid.length == 8) { diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 5355f785..3cf6e155 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -59,7 +59,7 @@ class LockDetailLogic extends BaseGetXController { // 开完锁之后上传记录 if (reply is SenderReferEventRecordTimeReply && state.ifCurrentScreen.value == true) { - _replyReferEventRecordTime(reply); + await _replyReferEventRecordTime(reply); } }); } @@ -116,7 +116,9 @@ class LockDetailLogic extends BaseGetXController { state.animationController!.stop(); //锁数据更新 + AppLog.log('开锁成功,开始同步所记录:getLockRecordLastUploadDataTime'); getLockRecordLastUploadDataTime(); + AppLog.log('开锁成功,结束同步所记录:getLockRecordLastUploadDataTime'); // 只有接听状态时才可以重发开门指令 if (StartChartManage().talkStatus.status == TalkStatus.answeredSuccessfully) { @@ -338,6 +340,7 @@ class LockDetailLogic extends BaseGetXController { reply.data.removeRange(0, 7); // 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面 if (reply.data.length < 17) { + AppLog.log('数据长度不够17:${reply.data}'); return; } final List> getList = splitList(reply.data, 17); @@ -384,6 +387,7 @@ class LockDetailLogic extends BaseGetXController { AppLog.log('操作记录:$indexList,解析失败,跳过该跳记录,进行下一条记录解析。'); } } + AppLog.log('上传数据长度:${uploadList.length}'); lockRecordUploadData(uploadList); if (dataLength == state.logCountPage) { @@ -510,6 +514,8 @@ class LockDetailLogic extends BaseGetXController { }); BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + AppLog.log( + '开始发送同步锁记录命令,蓝牙状态是否链接:${connectionState == BluetoothConnectionState.connected}'); if (connectionState == BluetoothConnectionState.connected) { final List? privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -524,6 +530,8 @@ class LockDetailLogic extends BaseGetXController { final List getPublicKeyList = changeStringListToIntList(publicKey!); + AppLog.log( + '发送同步锁记录命令:${BlueManage().connectDeviceName}'); IoSenderManage.senderReferEventRecordTimeCommand( keyID: BlueManage().connectDeviceName, userID: await Storage.getUid(), @@ -602,11 +610,14 @@ class LockDetailLogic extends BaseGetXController { final LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to.getLockRecordLastUploadDataTime( lockId: state.keyInfos.value.lockId.toString()); + AppLog.log('开始获取服务端所记录更新时间:${entity}'); if (entity.errorCode!.codeIsSuccessful) { state.operateDate = entity.data!.operateDate! ~/ 1000; state.currentDate = entity.data!.currentDate! ~/ 1000; + AppLog.log('发送同步所记录命令:---'); senderReferEventRecordTime(); } + AppLog.log('结束获取服务端所记录更新时间:${entity}'); } // 操作记录上传 diff --git a/lib/main_local.dart b/lib/main_local.dart index 9e30d007..f56b6d65 100755 --- a/lib/main_local.dart +++ b/lib/main_local.dart @@ -4,7 +4,7 @@ import 'flavors.dart'; import 'main.dart' as runner; Future main() async { - F.appFlavor = Flavor.xhj; + F.appFlavor = Flavor.xhj_pre; // AppLog.log('local调用了main函数'); await runner.main(); } From dc77d6e318b18613af13303fa963ae50987241e9 Mon Sep 17 00:00:00 2001 From: Liuyf Date: Tue, 27 May 2025 14:14:51 +0800 Subject: [PATCH 07/13] =?UTF-8?q?fix:=20=E5=8F=91=E9=80=81=E7=94=B5?= =?UTF-8?q?=E5=AD=90=E9=92=A5=E5=8C=99=E7=9B=B4=E6=8E=A5=E7=82=B9=E9=80=9A?= =?UTF-8?q?=E8=AE=AF=E5=BD=95=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0=E7=94=B5?= =?UTF-8?q?=E8=AF=9D=E5=8F=B7=E7=A0=81=EF=BC=8C=E8=A6=81=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../status/star_chart_talk_status.dart | 2 +- pubspec.lock | 80 ++----------------- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 74 deletions(-) diff --git a/lib/talk/starChart/status/star_chart_talk_status.dart b/lib/talk/starChart/status/star_chart_talk_status.dart index 54ee1751..939c130b 100644 --- a/lib/talk/starChart/status/star_chart_talk_status.dart +++ b/lib/talk/starChart/status/star_chart_talk_status.dart @@ -4,7 +4,7 @@ import 'package:star_lock/talk/starChart/constant/talk_status.dart'; class StartChartTalkStatus { // 私有字段,用于存储当前状态 - TalkStatus _status = TalkStatus.uninitialized; + TalkStatus _status = TalkStatus.none; // 私有化默认构造函数,防止外部创建实例 StartChartTalkStatus._(); diff --git a/pubspec.lock b/pubspec.lock index b1ead27d..b099b594 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -24,30 +24,6 @@ packages: relative: true source: path version: "0.0.1" - amap_flutter_base: - dependency: transitive - description: - name: amap_flutter_base - sha256: "9ef2439b8de7100cdd1b4357701b8ca8c059c0f2d9d0257b81750bbf0c6f53bb" - url: "https://pub.dev" - source: hosted - version: "3.0.0" - amap_flutter_location: - dependency: "direct main" - description: - name: amap_flutter_location - sha256: f35ff00e196d579608e0bc28ccbc1f6f53787644702f947de941f775769cc701 - url: "https://pub.dev" - source: hosted - version: "3.0.0" - amap_flutter_map: - dependency: "direct main" - description: - name: amap_flutter_map - sha256: "9cebb0b2f5fc7d3ae0427e99c41edc883e8f5459f6a28bc850f0f9e16918cf2f" - url: "https://pub.dev" - source: hosted - version: "3.0.0" app_settings: dependency: "direct main" description: @@ -573,6 +549,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_app_badger: + dependency: "direct main" + description: + name: flutter_app_badger + sha256: "64d4a279bab862ed28850431b9b446b9820aaae0bf363322d51077419f930fa8" + url: "https://pub.dev" + source: hosted + version: "1.5.0" flutter_blue_plus: dependency: "direct main" description: @@ -788,30 +772,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" - google_maps: - dependency: transitive - description: - name: google_maps - sha256: "47eef3836b49bb030d5cb3afc60b8451408bf34cf753e571b645d6529eb4251a" - url: "https://pub.dev" - source: hosted - version: "7.1.0" - google_maps_flutter: - dependency: "direct main" - description: - name: google_maps_flutter - sha256: c1972cbad779bc5346c49045f26ae45550a0958b1cbca5b524dd3c8954995d28 - url: "https://pub.dev" - source: hosted - version: "2.6.1" - google_maps_flutter_android: - dependency: transitive - description: - name: google_maps_flutter_android - sha256: "0bcadb80eba39afda77dede89a6caafd3b68f2786b90491eceea4a01c3db181c" - url: "https://pub.dev" - source: hosted - version: "2.8.0" google_maps_flutter_ios: dependency: "direct overridden" description: @@ -828,14 +788,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.9.5" - google_maps_flutter_web: - dependency: transitive - description: - name: google_maps_flutter_web - sha256: f3155c12119d8a5c2732fdf39ceb5cc095bc662059a03b4ea23294ecebe1d199 - url: "https://pub.dev" - source: hosted - version: "0.5.8" html: dependency: transitive description: @@ -973,14 +925,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.7" - js_wrapping: - dependency: transitive - description: - name: js_wrapping - sha256: e385980f7c76a8c1c9a560dfb623b890975841542471eade630b2871d243851c - url: "https://pub.dev" - source: hosted - version: "0.7.4" json_annotation: dependency: transitive description: @@ -1381,14 +1325,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.27.7" - sanitize_html: - dependency: transitive - description: - name: sanitize_html - sha256: "12669c4a913688a26555323fb9cec373d8f9fbe091f2d01c40c723b33caa8989" - url: "https://pub.dev" - source: hosted - version: "2.1.0" scrollable_positioned_list: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 7819d6e8..0cdf858a 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -155,7 +155,7 @@ dependencies: # 选择日期时间 flutter_cupertino_datetime_picker: ^3.0.0 # 选择原生通讯录 - flutter_native_contact_picker: ^0.0.4 + flutter_native_contact_picker: 0.0.7 #底部弹出选择器 flutter_picker: ^2.1.0 #生成二维码 From 879f42bd81e5c3c802537e4b92854a4fc47fce66 Mon Sep 17 00:00:00 2001 From: DaisyWu <18682150237@163.com> Date: Wed, 28 May 2025 11:03:09 +0800 Subject: [PATCH 08/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DiOS=E7=AB=AF?= =?UTF-8?q?=E9=80=9A=E8=AE=AF=E5=BD=95=E7=82=B9=E5=87=BB=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/sendElectronicKeyView_page.dart | 158 ++++++------------ .../view/sendElectronicKeyView_state.dart | 4 +- 2 files changed, 49 insertions(+), 113 deletions(-) diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart index c4e62f99..118b2123 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart @@ -32,13 +32,7 @@ class SendElectronicKeyView extends StatefulWidget { class _SendElectronicKeyViewState extends State with AutomaticKeepAliveClientMixin { - late FlutterContactPicker _contactPicker; - @override - void initState() { - super.initState(); - _contactPicker = FlutterContactPicker(); - } @override Widget build(BuildContext context) { @@ -224,81 +218,44 @@ class _SendElectronicKeyViewState extends State alignment: Alignment.center, child: InkWell( onTap: () async { - try { - final PermissionStatus status = - await Permission.contacts.request(); - if (status.isGranted) { - // 保存当前路由 - final currentRoute = ModalRoute.of(context); + final Contact? currentContact = + await logic.state.contactPicker.selectContact(); + if (currentContact != null) { + setState(() { + logic.state.contact = currentContact; - final Contact? currentContact = - await _contactPicker.selectContact(); - - // 检查路由是否仍然存在且组件是否挂载 - if (currentRoute?.isCurrent == true && mounted) { - // 检查 GetX 控制器是否仍然存在 - if (Get.isRegistered( - tag: widget.type)) { - final logic = Get.find( - tag: widget.type); - - if (currentContact != null) { - // 处理手机号 - if (currentContact.phoneNumbers != null && - currentContact.phoneNumbers!.isNotEmpty) { - String phoneNumber = - currentContact.phoneNumbers![0]; - // 移除所有空格、括号、连字符等特殊字符 - phoneNumber = phoneNumber.replaceAll( - RegExp(r'[\s\(\)\-]'), ''); - // 如果号码以+开头,保留+号 - if (phoneNumber.startsWith('+')) { - phoneNumber = '+' + - phoneNumber - .substring(1) - .replaceAll(RegExp(r'[^\d]'), ''); - } else { - phoneNumber = phoneNumber.replaceAll( - RegExp(r'[^\d]'), ''); - } - logic.state.emailOrPhoneController.text = - phoneNumber; - logic.state.emailOrPhone.value = phoneNumber; - } - - // 处理姓名 - if (currentContact.fullName != null && - currentContact.fullName!.isNotEmpty) { - logic.state.keyNameController.text = - currentContact.fullName!; - } - - // 更新UI - logic.update(); - } + // 处理手机号 + if (currentContact.phoneNumbers != null && + currentContact.phoneNumbers!.isNotEmpty) { + // 获取第一个手机号并清理格式 + String phoneNumber = currentContact.phoneNumbers![0]; + // 移除所有空格、括号、连字符等特殊字符 + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), ''); + // 如果号码以+开头,保留+号 + if (phoneNumber.startsWith('+')) { + phoneNumber = '+' + + phoneNumber + .substring(1) + .replaceAll(RegExp(r'[^\d]'), ''); + } else { + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); } + logic.state.emailOrPhoneController.text = phoneNumber; + } else { + logic.state.emailOrPhoneController.text = ''; } - } else { - // 权限被拒绝,显示提示 - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('需要通讯录权限才能选择联系人'.tr), - duration: const Duration(seconds: 2), - ), - ); + + // 处理姓名 + if (currentContact.fullName != null && + currentContact.fullName!.isNotEmpty) { + logic.state.keyNameController.text = + currentContact.fullName!; + } else { + logic.state.keyNameController.text = ''; } - } - } catch (e) { - print('Error selecting contact: $e'); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('获取通讯录失败,请检查权限设置'.tr), - duration: const Duration(seconds: 2), - ), - ); - } + }); } }, ), @@ -684,16 +641,16 @@ class _SendElectronicKeyViewState extends State alignment: Alignment.center, child: InkWell( onTap: () async { - try { - final PermissionStatus status = - await Permission.contacts.request(); - if (status.isGranted) { - final Contact? currentContact = - await _contactPicker.selectContact(); - if (currentContact != null && mounted) { + final Contact? currentContact = + await logic.state.contactPicker.selectContact(); + if (currentContact != null) { + setState(() { + logic.state.contact = currentContact; + // 处理手机号 if (currentContact.phoneNumbers != null && currentContact.phoneNumbers!.isNotEmpty) { + // 获取第一个手机号并清理格式 String phoneNumber = currentContact.phoneNumbers![0]; // 移除所有空格、括号、连字符等特殊字符 phoneNumber = @@ -709,7 +666,8 @@ class _SendElectronicKeyViewState extends State phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); } logic.state.emailOrPhoneController.text = phoneNumber; - logic.state.emailOrPhone.value = phoneNumber; + } else { + logic.state.emailOrPhoneController.text = ''; } // 处理姓名 @@ -717,34 +675,12 @@ class _SendElectronicKeyViewState extends State currentContact.fullName!.isNotEmpty) { logic.state.keyNameController.text = currentContact.fullName!; + } else { + logic.state.keyNameController.text = ''; } - - // 更新UI - logic.update(); - } - } else { - // 权限被拒绝,显示提示 - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('需要通讯录权限才能选择联系人'.tr), - duration: const Duration(seconds: 2), - ), - ); - } + }); } - } catch (e) { - print('Error selecting contact: $e'); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('获取通讯录失败,请检查权限设置'.tr), - duration: const Duration(seconds: 2), - ), - ); - } - } - }, + }, ), ) else diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart index 61121249..7ada2123 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart @@ -15,8 +15,8 @@ class SendElectronicKeyViewState { TextEditingController realNameController = TextEditingController(); //真实姓名输入框 TextEditingController idCardController = TextEditingController(); //身份证号输入框 - // final FlutterContactPicker contactPicker = FlutterContactPicker(); - // late Contact contact; + final FlutterContactPicker contactPicker = FlutterContactPicker(); + late Contact contact; RxBool isRemoteUnlock = false.obs; //是否允许远程开锁 RxBool isAuthentication = false.obs; //是否可以实名认证 From 9a11a5b0f7ecd96b9f85c44ad2ecada6c45aa912 Mon Sep 17 00:00:00 2001 From: DaisyWu <18682150237@163.com> Date: Wed, 28 May 2025 14:44:06 +0800 Subject: [PATCH 09/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=88=91?= =?UTF-8?q?=E7=9A=84--=E6=8E=88=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=9A=84=E9=80=9A=E8=AE=AF=E5=BD=95=E8=8E=B7=E5=8F=96=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../volumeAuthorizationLock_page.dart | 55 ++++++++++++++----- .../addAuthorizedAdministrator_page.dart | 48 +++++++++++++--- .../recipientInformation_page.dart | 39 ++++++++++--- 3 files changed, 111 insertions(+), 31 deletions(-) diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index e2cbf86f..1cf65f45 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -286,20 +286,47 @@ class _VolumeAuthorizationLockPageState ), alignment: Alignment.center, child: InkWell( - onTap: () async { - final Contact? currentContact = - await state.contactPicker.selectContact(); - // setState(() { - if (currentContact!.phoneNumbers!.isNotEmpty) { - state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r'\s+\b|\b\s'), ''); - } - if (currentContact.fullName!.isNotEmpty) { - state.keyNameController.text = currentContact.fullName!; - } - // }); - }, + onTap: () async { + final Contact? currentContact = + await logic.state.contactPicker.selectContact(); + if (currentContact != null) { + setState(() { + logic.state.contact = currentContact; + + // 处理手机号 + if (currentContact.phoneNumbers != null && + currentContact.phoneNumbers!.isNotEmpty) { + // 获取第一个手机号并清理格式 + String phoneNumber = currentContact.phoneNumbers![0]; + // 移除所有空格、括号、连字符等特殊字符 + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), ''); + // 如果号码以+开头,保留+号 + if (phoneNumber.startsWith('+')) { + phoneNumber = '+' + + phoneNumber + .substring(1) + .replaceAll(RegExp(r'[^\d]'), ''); + } else { + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); + } + logic.state.emailOrPhoneController.text = phoneNumber; + } else { + logic.state.emailOrPhoneController.text = ''; + } + + // 处理姓名 + if (currentContact.fullName != null && + currentContact.fullName!.isNotEmpty) { + logic.state.keyNameController.text = + currentContact.fullName!; + } else { + logic.state.keyNameController.text = ''; + } + }); + } + }, ), ) else diff --git a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart index c9cdb870..7c1609c6 100755 --- a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart @@ -270,16 +270,46 @@ class _AddAuthorizedAdministratorPageState alignment: Alignment.center, child: InkWell( onTap: () async { - final Contact? currentContact = - await state.contactPicker.selectContact(); - setState(() { - if (currentContact!.phoneNumbers!.isNotEmpty) { - state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r'\s+\b|\b\s'), ''); + final Contact? currentContact = + await logic.state.contactPicker.selectContact(); + if (currentContact != null) { + setState(() { + logic.state.contact = currentContact; + + // 处理手机号 + if (currentContact.phoneNumbers != null && + currentContact.phoneNumbers!.isNotEmpty) { + // 获取第一个手机号并清理格式 + String phoneNumber = currentContact.phoneNumbers![0]; + // 移除所有空格、括号、连字符等特殊字符 + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), ''); + // 如果号码以+开头,保留+号 + if (phoneNumber.startsWith('+')) { + phoneNumber = '+' + + phoneNumber + .substring(1) + .replaceAll(RegExp(r'[^\d]'), ''); + } else { + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); + } + logic.state.emailOrPhoneController.text = phoneNumber; + } else { + logic.state.emailOrPhoneController.text = ''; + } + + // 处理姓名 + if (currentContact.fullName != null && + currentContact.fullName!.isNotEmpty) { + logic.state.keyNameController.text = + currentContact.fullName!; + } else { + logic.state.keyNameController.text = ''; + } + }); } - }); - }, + }, ), ) else diff --git a/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart b/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart index 38862cb7..846a4e0f 100755 --- a/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart +++ b/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart @@ -146,14 +146,37 @@ class _RecipientInformationPageState extends State { ), GestureDetector( onTap: () async { - Contact? currentContact = await state.contactPicker.selectContact(); - state.contact = currentContact!; - if (currentContact.phoneNumbers!.isNotEmpty) { - state.numberController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r'\s+\b|\b\s'), ''); - } - }, + final Contact? currentContact = + await logic.state.contactPicker.selectContact(); + if (currentContact != null) { + setState(() { + logic.state.contact = currentContact; + + // 处理手机号 + if (currentContact.phoneNumbers != null && + currentContact.phoneNumbers!.isNotEmpty) { + // 获取第一个手机号并清理格式 + String phoneNumber = currentContact.phoneNumbers![0]; + // 移除所有空格、括号、连字符等特殊字符 + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), ''); + // 如果号码以+开头,保留+号 + if (phoneNumber.startsWith('+')) { + phoneNumber = '+' + + phoneNumber + .substring(1) + .replaceAll(RegExp(r'[^\d]'), ''); + } else { + phoneNumber = + phoneNumber.replaceAll(RegExp(r'[^\d]'), ''); + } + logic.state.numberController.text = phoneNumber; + } else { + logic.state.numberController.text = ''; + } + }); + } + }, child: Image.asset( 'images/icon_addressBook.png', width: 28.w, From 6290fe36e5306c2dbee8535cf77081aecc79eee0 Mon Sep 17 00:00:00 2001 From: Liuyf Date: Thu, 29 May 2025 16:59:15 +0800 Subject: [PATCH 10/13] =?UTF-8?q?fix:=20ios=20release=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/fastlane/Fastfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index 4f8650e0..895ba92e 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -143,7 +143,8 @@ platform :ios do sh("flutter","pub","get") end Dir.chdir ".." do - sh("bundle", "exec" ,"pod", "install") + #sh("bundle", "exec" ,"pod", "install") + sh("pod", "install") end Dir.chdir "../.." do sh("flutter", "build", "ios", "--no-tree-shake-icons", "--no-codesign", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") From 1dbb7497ffdd1ce971ea76bccdc6daafcd5fa36f Mon Sep 17 00:00:00 2001 From: Liuyf Date: Fri, 30 May 2025 08:51:23 +0800 Subject: [PATCH 11/13] =?UTF-8?q?fix:=20=E5=86=99=E5=85=A5=E9=80=9A?= =?UTF-8?q?=E8=AE=AF=E5=BD=95=E6=9D=83=E9=99=90=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 341d6fae..76a4b29b 100755 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -31,7 +31,6 @@ - From f8b3303d0ba9b3e87f86e353876425a09cb0a91d Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 30 May 2025 14:36:08 +0800 Subject: [PATCH 12/13] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0tag=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=97=B6=E8=BE=93=E5=87=BA=E6=97=A5=E5=BF=97,ci?= =?UTF-8?q?=E4=B8=AD=E5=88=A4=E6=96=ADtag=E7=9A=84=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=BA=E5=A2=9E=E5=8A=A0sky=E5=90=8E?= =?UTF-8?q?=E7=BC=80=E4=B9=8B=E5=90=8E=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- tag_generator.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e68a2798..2131843f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ variables: - if: $CI_COMMIT_BRANCH == "release_sky" - if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/ - if: $CI_COMMIT_BRANCH == "canary_release_sky" - - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?(_sky)?$/ .notify_rule: tags: diff --git a/tag_generator.sh b/tag_generator.sh index 5fd79429..84811faf 100755 --- a/tag_generator.sh +++ b/tag_generator.sh @@ -30,11 +30,18 @@ newest_sky_tag=$(echo "$sky_tags" | head -n 1) if [ -z "$newest_sky_tag" ]; then # 取最新的 tag(不管是否带_sky) latest_tag=$(echo "$tags" | head -n 1) + echo "DEBUG: tags=[$tags]" + echo "DEBUG: latest_tag=[$latest_tag]" if [ -n "$latest_tag" ]; then # 提取版本号部分(去掉前缀v和后缀_sky等) version_part=${latest_tag#v} # 去掉v version_part=${version_part%_sky} # 去掉_sky(如果有) + version_part=$(echo "$version_part" | tr -d ' \n\r') + echo "DEBUG: version_part=[$version_part]" IFS='.' read -r major minor patch <<< "$version_part" + if [ -z "$major" ]; then major=1; fi + if [ -z "$minor" ]; then minor=0; fi + if [ -z "$patch" ]; then patch=0; fi next_tag="v$major.$minor.$patch_sky" else next_tag="v1.0.0_sky" @@ -44,7 +51,12 @@ else # 例如 v1.5.556_sky -> 1.5.556 version_part=${newest_sky_tag%_sky} # 去掉 _sky 后缀 version_part=${version_part#v} # 去掉 v 前缀 + version_part=$(echo "$version_part" | tr -d ' \n\r') + echo "DEBUG: version_part=[$version_part]" IFS='.' read -r major minor patch <<< "$version_part" # 拆分出主、次、修订号 + if [ -z "$major" ]; then major=1; fi + if [ -z "$minor" ]; then minor=0; fi + if [ -z "$patch" ]; then patch=0; fi compare_json="" # 用于存储 commit 对比结果 # 判断命令参数,决定对比范围 if [[ "$1" == "generate_tag" ]];then From 5231e62550665c5284640cf145e56b9c43fb42e4 Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 30 May 2025 14:44:46 +0800 Subject: [PATCH 13/13] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4tag=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tag_generator.sh | 50 ++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/tag_generator.sh b/tag_generator.sh index 84811faf..03937d48 100755 --- a/tag_generator.sh +++ b/tag_generator.sh @@ -28,68 +28,60 @@ newest_sky_tag=$(echo "$sky_tags" | head -n 1) # 如果没有 _sky 结尾的 tag,则从最新的 tag 提取版本号,生成 vX.Y.Z_sky if [ -z "$newest_sky_tag" ]; then - # 取最新的 tag(不管是否带_sky) latest_tag=$(echo "$tags" | head -n 1) echo "DEBUG: tags=[$tags]" echo "DEBUG: latest_tag=[$latest_tag]" if [ -n "$latest_tag" ]; then - # 提取版本号部分(去掉前缀v和后缀_sky等) - version_part=${latest_tag#v} # 去掉v - version_part=${version_part%_sky} # 去掉_sky(如果有) + version_part=${latest_tag#v} + version_part=${version_part%_sky} version_part=$(echo "$version_part" | tr -d ' \n\r') echo "DEBUG: version_part=[$version_part]" - IFS='.' read -r major minor patch <<< "$version_part" - if [ -z "$major" ]; then major=1; fi - if [ -z "$minor" ]; then minor=0; fi - if [ -z "$patch" ]; then patch=0; fi - next_tag="v$major.$minor.$patch_sky" + major=$(echo "$version_part" | awk -F. '{print $1}') + minor=$(echo "$version_part" | awk -F. '{print $2}') + patch=$(echo "$version_part" | awk -F. '{print $3}') + [ -z "$major" ] && major=1 + [ -z "$minor" ] && minor=0 + [ -z "$patch" ] && patch=0 + next_tag="v${major}.${minor}.${patch}_sky" else next_tag="v1.0.0_sky" fi else # 解析版本号部分(去掉 _sky 后缀和 v 前缀) - # 例如 v1.5.556_sky -> 1.5.556 - version_part=${newest_sky_tag%_sky} # 去掉 _sky 后缀 - version_part=${version_part#v} # 去掉 v 前缀 + version_part=${newest_sky_tag%_sky} + version_part=${version_part#v} version_part=$(echo "$version_part" | tr -d ' \n\r') echo "DEBUG: version_part=[$version_part]" - IFS='.' read -r major minor patch <<< "$version_part" # 拆分出主、次、修订号 - if [ -z "$major" ]; then major=1; fi - if [ -z "$minor" ]; then minor=0; fi - if [ -z "$patch" ]; then patch=0; fi - compare_json="" # 用于存储 commit 对比结果 - # 判断命令参数,决定对比范围 + major=$(echo "$version_part" | awk -F. '{print $1}') + minor=$(echo "$version_part" | awk -F. '{print $2}') + patch=$(echo "$version_part" | awk -F. '{print $3}') + [ -z "$major" ] && major=1 + [ -z "$minor" ] && minor=0 + [ -z "$patch" ] && patch=0 + compare_json="" if [[ "$1" == "generate_tag" ]];then - # 生成 tag 时,对比最新 _sky tag 和 master 之间的提交 echo "generate_tag:$newest_sky_tag-to-master\n" compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=$newest_sky_tag&to=master") elif [[ "$1" == "generate_version" ]]; then - # 生成版本号时,对比 master 和当前分支之间的提交 echo "generate_version:master-to-$CI_COMMIT_BRANCH\n" compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=master&to=$CI_COMMIT_BRANCH") fi echo "compare_json:$compare_json\n" - new_patch=$patch # 新的 patch 号 - new_minor=$minor # 新的 minor 号 - # 遍历所有 commit,根据提交信息递增版本号 + new_patch=$patch + new_minor=$minor while IFS= read -r commit_json; do - # 解析每个 commit 的 id 和 message commit_id=$(echo "$commit_json" | jq -r '.id') commit_message=$(echo "$commit_json" | jq -r '.message') echo "----$commit_message" - # 如果有 feat: 类型提交,minor 递增(只递增一次) if [[ "$commit_message" =~ ("feat:"*) ]] && [[ $new_minor == $minor ]]; then ((new_minor++)) - # 如果有 fix: 类型提交,patch 递增 elif [[ "$commit_message" =~ ("fix:"*) ]]; then ((new_patch++)) - # 其他类型提交(非 Merge/Revert),patch 递增 elif [[ ! "$commit_message" =~ ("Merge"* | "Revert"*) ]]; then ((new_patch++)) fi done < <(echo "$compare_json" | jq -c '.commits[] | {id: .id, message: .message}') - # 组装新的 tag,格式为 v.._sky - next_tag="v$major.$new_minor.$new_patch_sky" + next_tag="v${major}.${new_minor}.${new_patch}_sky" fi echo "New Tag:$newest_sky_tag;New version: $next_tag;command: $1"