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] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=88=91=E7=9A=84--?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98=E7=9A=84=E9=80=9A?= =?UTF-8?q?=E8=AE=AF=E5=BD=95=E8=8E=B7=E5=8F=96=E9=97=AE=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,