fix: 授权管理员—各个类型下点击通讯录无法直接获取通讯录联系人手机号及姓名问题修复及自测
This commit is contained in:
parent
8c0ae4f349
commit
4b3a74cc58
@ -257,15 +257,42 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
final Contact? currentContact =
|
final Contact? currentContact =
|
||||||
await logic.state.contactPicker.selectContact();
|
await logic.state.contactPicker.selectContact();
|
||||||
logic.state.contact = currentContact!;
|
if (currentContact != null) {
|
||||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
setState(() {
|
||||||
logic.state.emailOrPhoneController.text = currentContact
|
logic.state.contact = currentContact;
|
||||||
.phoneNumbers![0]
|
|
||||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
// 处理手机号
|
||||||
}
|
if (currentContact.phoneNumbers != null &&
|
||||||
if (currentContact.fullName!.isNotEmpty) {
|
currentContact.phoneNumbers!.isNotEmpty) {
|
||||||
logic.state.keyNameController.text =
|
// 获取第一个手机号并清理格式
|
||||||
currentContact.fullName!;
|
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<AuthorizedAdminPage>
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
final Contact? currentContact =
|
final Contact? currentContact =
|
||||||
await state.contactPicker.selectContact();
|
await state.contactPicker.selectContact();
|
||||||
setState(() {
|
if (currentContact != null) {
|
||||||
state.contact = currentContact!;
|
setState(() {
|
||||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
state.contact = currentContact;
|
||||||
state.emailOrPhoneController.text = currentContact
|
|
||||||
.phoneNumbers![0]
|
// 处理手机号
|
||||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
if (currentContact.phoneNumbers != null &&
|
||||||
}
|
currentContact.phoneNumbers!.isNotEmpty) {
|
||||||
if (currentContact.fullName!.isNotEmpty) {
|
// 获取第一个手机号并清理格式
|
||||||
state.keyNameController.text = currentContact.fullName!;
|
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 = '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user