feat: 移植注册格式验证和移除验证登录密码功能
This commit is contained in:
commit
576e330e84
@ -149,6 +149,35 @@ class StarLockRegisterLogic extends BaseGetXController {
|
|||||||
state.pwdIsOK && state.phoneOrEmailStr.value.isNotEmpty;
|
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
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
super.onReady();
|
super.onReady();
|
||||||
|
|||||||
@ -135,6 +135,17 @@ class _StarLockRegisterPageState extends State<StarLockRegisterXHJPage> {
|
|||||||
Widget middleTFWidget() {
|
Widget middleTFWidget() {
|
||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
// Obx(() => LoginInput(
|
||||||
|
// controller: state.phoneOrEmailController,
|
||||||
|
// onchangeAction: (v) {
|
||||||
|
// logic.checkNext(state.phoneOrEmailController);
|
||||||
|
// },
|
||||||
|
// leftWidget: SizedBox(),
|
||||||
|
// label: state.isIphoneType.value ? '请输入手机号'.tr : '请输入邮箱'.tr,
|
||||||
|
// keyboardType: TextInputType.number,
|
||||||
|
// inputFormatters: <TextInputFormatter>[
|
||||||
|
// LengthLimitingTextInputFormatter(30),
|
||||||
|
// ])),
|
||||||
Obx(() => LoginInput(
|
Obx(() => LoginInput(
|
||||||
controller: state.phoneOrEmailController,
|
controller: state.phoneOrEmailController,
|
||||||
onchangeAction: (v) {
|
onchangeAction: (v) {
|
||||||
@ -142,9 +153,18 @@ class _StarLockRegisterPageState extends State<StarLockRegisterXHJPage> {
|
|||||||
},
|
},
|
||||||
leftWidget: SizedBox(),
|
leftWidget: SizedBox(),
|
||||||
label: state.isIphoneType.value ? '请输入手机号'.tr : '请输入邮箱'.tr,
|
label: state.isIphoneType.value ? '请输入手机号'.tr : '请输入邮箱'.tr,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: state.isIphoneType.value
|
||||||
|
? TextInputType.number
|
||||||
|
: TextInputType.emailAddress,
|
||||||
inputFormatters: <TextInputFormatter>[
|
inputFormatters: <TextInputFormatter>[
|
||||||
LengthLimitingTextInputFormatter(30),
|
LengthLimitingTextInputFormatter(30),
|
||||||
|
// 根据注册类型添加输入限制
|
||||||
|
if (state.isIphoneType.value)
|
||||||
|
FilteringTextInputFormatter.digitsOnly // 手机号只能输入数字
|
||||||
|
else
|
||||||
|
// 邮箱:只允许字母、数字、@、.、_、-
|
||||||
|
FilteringTextInputFormatter.allow(
|
||||||
|
RegExp(r'[a-zA-Z0-9@._-]'))
|
||||||
])),
|
])),
|
||||||
LoginInput(
|
LoginInput(
|
||||||
controller: state.pwdController,
|
controller: state.pwdController,
|
||||||
@ -190,6 +210,10 @@ class _StarLockRegisterPageState extends State<StarLockRegisterXHJPage> {
|
|||||||
Obx(() => GestureDetector(
|
Obx(() => GestureDetector(
|
||||||
onTap: (state.canSendCode.value && state.canResend.value)
|
onTap: (state.canSendCode.value && state.canResend.value)
|
||||||
? () async {
|
? () async {
|
||||||
|
if (!logic.validatePhoneOrEmailFormat()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value});
|
// Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value});
|
||||||
final result = await Get.toNamed(
|
final result = await Get.toNamed(
|
||||||
Routers.safetyVerificationPage,
|
Routers.safetyVerificationPage,
|
||||||
|
|||||||
@ -563,8 +563,9 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
.showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr, () {
|
.showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr, () {
|
||||||
// 删除锁
|
// 删除锁
|
||||||
state.showTipView.resetGetController();
|
state.showTipView.resetGetController();
|
||||||
state.showTipView.showTFViewAlertDialog(
|
factoryDataResetAction();
|
||||||
state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword);
|
// state.showTipView.showTFViewAlertDialog(
|
||||||
|
// state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword);
|
||||||
});
|
});
|
||||||
} else if (state.lockBasicInfo.value.keyRight == 1) {
|
} else if (state.lockBasicInfo.value.keyRight == 1) {
|
||||||
// 授权管理员弹框提示
|
// 授权管理员弹框提示
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user