feat: 增强优化注册格式验证

This commit is contained in:
wuyaxi 2025-07-17 09:49:21 +08:00
parent c8626da999
commit e7a39b1c90
2 changed files with 33 additions and 0 deletions

View File

@ -149,6 +149,35 @@ class StarLockRegisterLogic extends BaseGetXController {
state.pwdIsOK && state.phoneOrEmailStr.value.isNotEmpty;
}
// StarLockRegisterLogic
bool validatePhoneOrEmailFormat() {
final String input = state.phoneOrEmailStr.value;
if (state.isIphoneType.value) {
//
if (input.isEmpty) {
showToast('请输入手机号'.tr);
return false;
}
if (!RegExp(r'^[0-9]+$').hasMatch(input)) {
showToast('手机号只能包含数字'.tr);
return false;
}
} else {
// @
if (input.isEmpty) {
showToast('请输入邮箱地址'.tr);
return false;
}
if (!input.contains('@')) {
showToast('邮箱地址必须包含@符号'.tr);
return false;
}
}
return true;
}
@override
void onReady() {
super.onReady();

View File

@ -210,6 +210,10 @@ class _StarLockRegisterPageState extends State<StarLockRegisterXHJPage> {
Obx(() => GestureDetector(
onTap: (state.canSendCode.value && state.canResend.value)
? () async {
if (!logic.validatePhoneOrEmailFormat()) {
return;
}
// Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value});
final result = await Get.toNamed(
Routers.safetyVerificationPage,