1、优化注册、忘记密码、重置密码功能,密码限制及密码不一样时显示问题

This commit is contained in:
魏少阳 2024-09-13 14:50:36 +08:00
parent 75b400c0e9
commit eb401fb8ef
16 changed files with 165 additions and 81 deletions

View File

@ -905,5 +905,6 @@
"感应到门前约0.5米有人时,将自动启动面部识别开锁。": "When someone is sensed about 0.5 meters in front of the door, the face recognition unlocking will be automatically started.", "感应到门前约0.5米有人时,将自动启动面部识别开锁。": "When someone is sensed about 0.5 meters in front of the door, the face recognition unlocking will be automatically started.",
"感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。": "The sensing distance has been turned off, you need to manually touch any key on the keyboard to perform face recognition unlocking.", "感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。": "The sensing distance has been turned off, you need to manually touch any key on the keyboard to perform face recognition unlocking.",
"防误开已打开,开锁后": "The anti-mistake opening has been turned on, and after unlocking", "防误开已打开,开锁后": "The anti-mistake opening has been turned on, and after unlocking",
"秒内不可使用面容开锁": "Face unlocking cannot be used within seconds" "秒内不可使用面容开锁": "Face unlocking cannot be used within seconds",
"密码需至少包含数字/字母/字符中的2种组合": "The password must contain at least 2 combinations of numbers/letters/characters"
} }

View File

@ -941,5 +941,7 @@
"感应到门前约0.5米有人时,将自动启动面部识别开锁。": "感应到门前约0.5米有人时,将自动启动面部识别开锁。", "感应到门前约0.5米有人时,将自动启动面部识别开锁。": "感应到门前约0.5米有人时,将自动启动面部识别开锁。",
"感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。": "感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。", "感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。": "感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。",
"防误开已打开,开锁后": "防误开已打开,开锁后", "防误开已打开,开锁后": "防误开已打开,开锁后",
"秒内不可使用面容开锁": "秒内不可使用面容开锁" "秒内不可使用面容开锁": "秒内不可使用面容开锁",
"密码需至少包含数字/字母/字符中的2种组合": "密码需至少包含数字/字母/字符中的2种组合"
} }

View File

@ -901,5 +901,8 @@
"感应到门前约0.5米有人时,将自动启动面部识别开锁。": "感应到门前约0.5米有人时,将自动启动面部识别开锁。", "感应到门前约0.5米有人时,将自动启动面部识别开锁。": "感应到门前约0.5米有人时,将自动启动面部识别开锁。",
"感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。": "感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。", "感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。": "感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。",
"防误开已打开,开锁后": "防误开已打开,开锁后", "防误开已打开,开锁后": "防误开已打开,开锁后",
"秒内不可使用面容开锁": "秒内不可使用面容开锁" "秒内不可使用面容开锁": "秒内不可使用面容开锁",
"密码需至少包含数字/字母/字符中的2种组合": "密码需至少包含数字/字母/字符中的2种组合"
} }

View File

@ -2,12 +2,14 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/login/forgetPassword/starLock_forgetPassword_state.dart'; import 'package:star_lock/login/forgetPassword/starLock_forgetPassword_state.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart'; import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart';
import '../../network/api_repository.dart'; import '../../network/api_repository.dart';
import '../../tools/baseGetXController.dart'; import '../../tools/baseGetXController.dart';
import '../../tools/regularExpression.dart';
import '../../tools/showTipView.dart'; import '../../tools/showTipView.dart';
import '../register/entity/checkIP_entity.dart'; import '../register/entity/checkIP_entity.dart';
@ -33,6 +35,16 @@ class StarLockForgetPasswordLogic extends BaseGetXController {
} }
Future<void> resetPassword() async { Future<void> resetPassword() async {
if(state.pwd.value != state.surePwd.value){
showToast('两次密码不一致哦'.tr);
return;
}
if(!RegularExpression().validateString(state.pwd.value)){
showToast('密码需至少包含数字/字母/字符中的2种组合'.tr);
return;
}
final LoginEntity entity = await ApiRepository.to.resetPassword( final LoginEntity entity = await ApiRepository.to.resetPassword(
state.countryCode.value, state.countryCode.value,
state.phoneStr.value, state.phoneStr.value,
@ -82,7 +94,6 @@ class StarLockForgetPasswordLogic extends BaseGetXController {
}else{ }else{
state.codeType.value = '1'; state.codeType.value = '1';
} }
state.phoneStrIsOK.value = state.phoneStr.value.isNotEmpty;
} }
if (controller == state.pwdController) { if (controller == state.pwdController) {
state.pwd.value = controller.text; state.pwd.value = controller.text;
@ -93,10 +104,16 @@ class StarLockForgetPasswordLogic extends BaseGetXController {
if (controller == state.codeController) { if (controller == state.codeController) {
state.verificationCode.value = controller.text; state.verificationCode.value = controller.text;
} }
_resetCanSendCode();
_resetCanSub(); _resetCanSub();
AppLog.log('state.canSub.value:${state.canSub.value} state.pwdIsOK:${state.pwdIsOK} state.codeIsOK:${state.codeIsOK} state.phoneStr.value:${state.phoneStr.value}');
} }
void _resetCanSub() { void _resetCanSub() {
state.canSub.value = state.pwdIsOK && state.codeIsOK; state.canSub.value = state.pwdIsOK && state.codeIsOK && state.phoneStr.value.isNotEmpty;
}
void _resetCanSendCode() {
state.canSendCode.value = state.pwdIsOK && state.phoneStr.value.isNotEmpty;
} }
} }

View File

@ -185,7 +185,7 @@ class _StarLockForgetPasswordPageState
width: 10.w, width: 10.w,
), ),
Obx(() => GestureDetector( Obx(() => GestureDetector(
onTap: (state.phoneStrIsOK.value && state.canResend.value) onTap: (state.canSendCode.value && state.canResend.value)
? () async { ? () async {
// 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 Object? result = await Navigator.pushNamed( final Object? result = await Navigator.pushNamed(
@ -204,7 +204,7 @@ class _StarLockForgetPasswordPageState
// height: 60.h, // height: 60.h,
padding: EdgeInsets.all(10.h), padding: EdgeInsets.all(10.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: state.phoneStrIsOK.value color: (state.canSendCode.value && state.canResend.value)
? AppColors.mainColor ? AppColors.mainColor
: AppColors.btnDisableColor, : AppColors.btnDisableColor,
borderRadius: BorderRadius.circular(5)), borderRadius: BorderRadius.circular(5)),

View File

@ -1,10 +1,15 @@
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../translations/trans_lib.dart'; import '../../translations/trans_lib.dart';
import '../selectCountryRegion/common/index.dart';
class StarLockForgetPasswordState { class StarLockForgetPasswordState {
StarLockForgetPasswordState() {
resetResend();
}
final TextEditingController phoneController = TextEditingController(); final TextEditingController phoneController = TextEditingController();
final TextEditingController pwdController = TextEditingController(); final TextEditingController pwdController = TextEditingController();
final TextEditingController sureController = TextEditingController(); final TextEditingController sureController = TextEditingController();
@ -14,30 +19,27 @@ class StarLockForgetPasswordState {
return DateTime.now().millisecondsSinceEpoch; return DateTime.now().millisecondsSinceEpoch;
} }
var countryCode = "86".obs; RxString countryCode = '86'.obs;
var countryName = '中国'.tr.obs; RxString countryName = '中国'.tr.obs;
var codeType = '2'.obs; // 1: 2: RxString codeType = '2'.obs; // 1: 2:
var pwd = ''.obs; RxString pwd = ''.obs;
var surePwd = ''.obs; RxString surePwd = ''.obs;
var verificationCode = ''.obs; RxString verificationCode = ''.obs;
var xWidth = ''.obs; // RxString xWidth = ''.obs; //
var canSub = false.obs; RxString phoneStr = ''.obs;
var phoneStr = ''.obs; RxBool canSub = false.obs;//
var phoneStrIsOK = false.obs; RxBool canSendCode = false.obs;//
var date = currentTimeMillis().toString().obs; RxString date = currentTimeMillis().toString().obs;
// bool get isEmail => RegexUtil.isEmail(phoneStr.value);
// bool get isIphone => RegexUtil.isMobileSimple(phoneStr.value); // bool get isIphone => RegexUtil.isMobileSimple(phoneStr.value);
bool get pwdIsOK => pwd.value.isNotEmpty && (pwd.value == surePwd.value); bool get pwdIsOK => pwd.value.isNotEmpty && surePwd.value.isNotEmpty && pwd.value.length >= 8 && surePwd.value.length >= 8;
bool get codeIsOK => verificationCode.value.isNotEmpty; bool get codeIsOK => verificationCode.value.isNotEmpty && verificationCode.value.length >= 6;
var canResend = false.obs; RxBool canResend = false.obs;//
var btnText = ''.obs; RxString btnText = ''.obs;
var totalSeconds = 120; int totalSeconds = 120;
var currentSecond = 120; int currentSecond = 120;
StarLockForgetPasswordState() {
resetResend();
}
void resetResend() { void resetResend() {
canResend.value = totalSeconds == currentSecond; canResend.value = totalSeconds == currentSecond;

View File

@ -143,7 +143,7 @@ class _StarLockForgetPasswordPageState
]), ]),
), ),
Obx(() => GestureDetector( Obx(() => GestureDetector(
onTap: (state.phoneStrIsOK.value && state.canResend.value) onTap: (state.canSendCode.value && state.canResend.value)
? () async { ? () async {
final Object? result = await Navigator.pushNamed( final Object? result = await Navigator.pushNamed(
context, Routers.safetyVerificationPage, context, Routers.safetyVerificationPage,
@ -159,11 +159,16 @@ class _StarLockForgetPasswordPageState
child: Container( child: Container(
width: 180.w, width: 180.w,
padding: EdgeInsets.all(10.h), padding: EdgeInsets.all(10.h),
decoration: BoxDecoration(
color: (state.canSendCode.value && state.canResend.value)
? AppColors.mainColor
: AppColors.btnDisableColor,
borderRadius: BorderRadius.circular(5)),
child: Center( child: Center(
child: Text(state.btnText.value, child: Text(state.btnText.value,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: AppColors.mainColor, color: Colors.white,
fontSize: 24.sp, fontSize: 24.sp,
)), )),
), ),

View File

@ -1,19 +1,20 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart'; import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/blue/blue_manage.dart'; import 'package:star_lock/blue/blue_manage.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart'; import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart';
import 'package:star_lock/tools/eventBusEventManage.dart'; import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/tools/push/xs_jPhush.dart'; import 'package:star_lock/tools/push/xs_jPhush.dart';
import 'package:star_lock/tools/storage.dart';
import '../../network/api_repository.dart'; import '../../network/api_repository.dart';
import '../../tools/baseGetXController.dart'; import '../../tools/baseGetXController.dart';
import '../../tools/regularExpression.dart';
import '../../tools/showTipView.dart'; import '../../tools/showTipView.dart';
import 'entity/checkIP_entity.dart'; import 'entity/checkIP_entity.dart';
import 'starLock_register_state.dart'; import 'starLock_register_state.dart';
@ -40,12 +41,15 @@ class StarLockRegisterLogic extends BaseGetXController {
} }
Future<void> register() async { Future<void> register() async {
AppLog.log(
'state.pwd.value:${state.pwd.value} state.surePwd.value:${state.surePwd.value}');
if (state.pwd.value != state.surePwd.value) { if (state.pwd.value != state.surePwd.value) {
showToast('密码不一致哦'.tr); showToast('密码不一致哦'.tr);
return; return;
} }
if(!RegularExpression().validateString(state.pwd.value)){
showToast('密码需至少包含数字/字母/字符中的2种组合'.tr);
return;
}
final LoginEntity entity = await ApiRepository.to.register( final LoginEntity entity = await ApiRepository.to.register(
receiverType: state.isIphoneType.value == true ? 1 : 2, receiverType: state.isIphoneType.value == true ? 1 : 2,
countryCode: int.parse(state.countryCode.value), countryCode: int.parse(state.countryCode.value),
@ -101,7 +105,6 @@ class StarLockRegisterLogic extends BaseGetXController {
void changeInput(TextEditingController controller) { void changeInput(TextEditingController controller) {
if (controller == state.phoneOrEmailController) { if (controller == state.phoneOrEmailController) {
state.phoneOrEmailStr.value = controller.text; state.phoneOrEmailStr.value = controller.text;
state.phoneOrEmailStrIsOK.value = state.phoneOrEmailStr.value.isNotEmpty;
} }
if (controller == state.pwdController) { if (controller == state.pwdController) {
state.pwd.value = controller.text; state.pwd.value = controller.text;
@ -113,12 +116,17 @@ class StarLockRegisterLogic extends BaseGetXController {
state.verificationCode.value = controller.text; state.verificationCode.value = controller.text;
} }
_resetCanSub(); _resetCanSub();
_resetCanSendCode();
} }
//
void _resetCanSub() { void _resetCanSub() {
state.canSub.value = state.pwdIsOK && state.canSub.value = state.pwdIsOK && state.codeIsOK && state.phoneOrEmailStr.value.isNotEmpty;
state.codeIsOK && }
(state.isIphoneType.value ? state.isIphone : state.isEmail);
//
void _resetCanSendCode() {
state.canSendCode.value = state.pwdIsOK && state.phoneOrEmailStr.value.isNotEmpty;
} }
@override @override

View File

@ -295,7 +295,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
), ),
Obx(() => GestureDetector( Obx(() => GestureDetector(
onTap: onTap:
state.phoneOrEmailStrIsOK.value && state.canResend.value (state.canSendCode.value && state.canResend.value)
? () async { ? () async {
// 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 Object? result = await Navigator.pushNamed( final Object? result = await Navigator.pushNamed(
@ -314,7 +314,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
// height: 60.h, // height: 60.h,
padding: EdgeInsets.all(10.h), padding: EdgeInsets.all(10.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: state.phoneOrEmailStrIsOK.value color: (state.canSendCode.value && state.canResend.value)
? AppColors.mainColor ? AppColors.mainColor
: Colors.grey, : Colors.grey,
borderRadius: BorderRadius.circular(5)), borderRadius: BorderRadius.circular(5)),

View File

@ -18,21 +18,22 @@ class StarLockRegisterState {
RxString countryName = '中国'.tr.obs; RxString countryName = '中国'.tr.obs;
RxString phoneOrEmailStr = ''.obs; RxString phoneOrEmailStr = ''.obs;
RxBool phoneOrEmailStrIsOK = false.obs; // RxBool phoneOrEmailStrIsOK = false.obs;
RxString pwd = ''.obs; RxString pwd = ''.obs;
RxString surePwd = ''.obs; RxString surePwd = ''.obs;
RxString verificationCode = ''.obs; RxString verificationCode = ''.obs;
RxString xWidth = ''.obs; // RxString xWidth = ''.obs; //
RxBool isIphoneType = true.obs; RxBool isIphoneType = true.obs;
RxBool canSub = false.obs; RxBool canSub = false.obs;//
RxBool agree = false.obs; RxBool agree = false.obs;
RxBool canSendCode = false.obs;//
bool get isEmail => RegexUtil.isEmail(phoneOrEmailStr.value); // bool get isEmail => RegexUtil.isEmail(phoneOrEmailStr.value);
bool get isIphone => RegexUtil.isMobileSimple(phoneOrEmailStr.value); // bool get isIphone => RegexUtil.isMobileSimple(phoneOrEmailStr.value);
bool get pwdIsOK => pwd.value.isNotEmpty && surePwd.value.isNotEmpty; bool get pwdIsOK => pwd.value.isNotEmpty && surePwd.value.isNotEmpty && pwd.value.length >= 8 && surePwd.value.length >= 8;
bool get codeIsOK => verificationCode.value.isNotEmpty; bool get codeIsOK => verificationCode.value.isNotEmpty && verificationCode.value.length >= 6 ;
RxBool canResend = false.obs; RxBool canResend = false.obs;//
RxString btnText = ''.obs; RxString btnText = ''.obs;
int totalSeconds = 120; int totalSeconds = 120;
int currentSecond = 120; int currentSecond = 120;

View File

@ -195,7 +195,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterXHJPage> {
), ),
Obx(() => GestureDetector( Obx(() => GestureDetector(
onTap: onTap:
state.phoneOrEmailStrIsOK.value && state.canResend.value (state.canSendCode.value && state.canResend.value)
? () async { ? () async {
// Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value}); // Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value});
if (state.pwd.value != state.surePwd.value) { if (state.pwd.value != state.surePwd.value) {
@ -214,13 +214,17 @@ class _StarLockRegisterPageState extends State<StarLockRegisterXHJPage> {
} }
: null, : null,
child: Container( child: Container(
color: Colors.transparent,
padding: EdgeInsets.all(10.h), padding: EdgeInsets.all(10.h),
decoration: BoxDecoration(
color: (state.canSendCode.value && state.canResend.value)
? AppColors.mainColor
: AppColors.btnDisableColor,
borderRadius: BorderRadius.circular(5)),
child: Center( child: Center(
child: Text(state.btnText.value, child: Text(state.btnText.value,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: AppColors.mainColor, color: Colors.white,
fontSize: 22.sp, fontSize: 22.sp,
)), )),
), ),

View File

@ -2,35 +2,48 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_state.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_state.dart';
import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import '../../../tools/regularExpression.dart';
class MinePersonInfoResetPasswordLogic extends BaseGetXController { class MinePersonInfoResetPasswordLogic extends BaseGetXController {
final MinePersonInfoResetPasswordState state = MinePersonInfoResetPasswordState(); final MinePersonInfoResetPasswordState state = MinePersonInfoResetPasswordState();
void changePasswordRequest() async { Future<void> changePasswordRequest() async {
if(state.newPwd.value.length < 8){ // if(state.newPwd.value.length < 8){
showToast("新密码长度不足8位"); // showToast('新密码长度不足8位');
// return;
// }
//
// if(state.surePwd.value.length < 8){
// showToast('确认长度不足8位');
// return;
// }
//
// if(state.surePwd.value != state.newPwd.value){
// showToast('两次密码不一致');
// return;
// }
if(state.newPwd.value != state.surePwd.value){
showToast('两次密码不一致哦'.tr);
return; return;
} }
if(state.surePwd.value.length < 8){ if(!RegularExpression().validateString(state.newPwd.value)){
showToast("确认长度不足8位"); showToast('密码需至少包含数字/字母/字符中的2种组合'.tr);
return; return;
} }
if(state.surePwd.value != state.newPwd.value){ final LoginEntity entity = await ApiRepository.to.changePassword(
showToast("两次密码不一致");
return;
}
var entity = await ApiRepository.to.changePassword(
state.date.value, state.date.value,
state.surePwd.value, state.surePwd.value,
state.oldPwd.value); state.oldPwd.value);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast("重置成功"); showToast('重置成功');
Get.back(); Get.back();
} }
} }
@ -53,6 +66,6 @@ class MinePersonInfoResetPasswordLogic extends BaseGetXController {
} }
void _resetCanSub() { void _resetCanSub() {
state.canSub.value = state.oldPwdIsOK && state.newPwdIsOK; state.canSub.value = state.oldPwdIsOK && state.newPwdIsOK && state.surePwdIsOK;
} }
} }

View File

@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/flavors.dart'; import 'package:star_lock/flavors.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_logic.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_logic.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_state.dart';
import '../../../appRouters.dart'; import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart'; import '../../../app_settings/app_colors.dart';
@ -22,8 +23,8 @@ class MinePersonInfoResetPasswordPage extends StatefulWidget {
class _MinePersonInfoResetPasswordPageState class _MinePersonInfoResetPasswordPageState
extends State<MinePersonInfoResetPasswordPage> { extends State<MinePersonInfoResetPasswordPage> {
final logic = Get.put(MinePersonInfoResetPasswordLogic()); final MinePersonInfoResetPasswordLogic logic = Get.put(MinePersonInfoResetPasswordLogic());
final state = Get.find<MinePersonInfoResetPasswordLogic>().state; final MinePersonInfoResetPasswordState state = Get.find<MinePersonInfoResetPasswordLogic>().state;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -46,7 +47,7 @@ class _MinePersonInfoResetPasswordPageState
body: Container( body: Container(
margin: EdgeInsets.only(left: 30.w, right: 30.w), margin: EdgeInsets.only(left: 30.w, right: 30.w),
child: Column( child: Column(
children: [ children: <Widget>[
loginView(), loginView(),
SizedBox(height: 50.w), SizedBox(height: 50.w),
Obx(() => SubmitBtn( Obx(() => SubmitBtn(
@ -61,7 +62,7 @@ class _MinePersonInfoResetPasswordPageState
SizedBox(height: 40.w), SizedBox(height: 40.w),
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: <Widget>[
GestureDetector( GestureDetector(
child: SizedBox( child: SizedBox(
// width: 150.w, // width: 150.w,
@ -87,7 +88,7 @@ class _MinePersonInfoResetPasswordPageState
Widget loginView() { Widget loginView() {
Widget view = Column( Widget view = Column(
children: [ children: <Widget>[
LoginInput( LoginInput(
controller: state.oldPwdController, controller: state.oldPwdController,
onchangeAction: (textStr) { onchangeAction: (textStr) {
@ -99,7 +100,8 @@ class _MinePersonInfoResetPasswordPageState
style: TextStyle(fontSize: 22.sp), style: TextStyle(fontSize: 22.sp),
), ),
hintText: '', hintText: '',
inputFormatters: [ isLogin: true,
inputFormatters: <TextInputFormatter>[
LengthLimitingTextInputFormatter(20), LengthLimitingTextInputFormatter(20),
]), ]),
LoginInput( LoginInput(
@ -113,7 +115,8 @@ class _MinePersonInfoResetPasswordPageState
style: TextStyle(fontSize: 22.sp), style: TextStyle(fontSize: 22.sp),
), ),
hintText: '', hintText: '',
inputFormatters: [ isLogin: true,
inputFormatters: <TextInputFormatter>[
LengthLimitingTextInputFormatter(20), LengthLimitingTextInputFormatter(20),
]), ]),
LoginInput( LoginInput(
@ -128,7 +131,8 @@ class _MinePersonInfoResetPasswordPageState
style: TextStyle(fontSize: 22.sp), style: TextStyle(fontSize: 22.sp),
), ),
hintText: '', hintText: '',
inputFormatters: [ isLogin: true,
inputFormatters: <TextInputFormatter>[
LengthLimitingTextInputFormatter(20), LengthLimitingTextInputFormatter(20),
]), ]),
Container( Container(

View File

@ -10,15 +10,15 @@ class MinePersonInfoResetPasswordState {
return DateTime.now().millisecondsSinceEpoch; return DateTime.now().millisecondsSinceEpoch;
} }
var oldPwd = ''.obs; RxString oldPwd = ''.obs;
var newPwd = ''.obs; RxString newPwd = ''.obs;
var surePwd = ''.obs; RxString surePwd = ''.obs;
var canSub = false.obs; RxBool canSub = false.obs;
var date = currentTimeMillis().toString().obs; RxString date = currentTimeMillis().toString().obs;
bool get oldPwdIsOK => oldPwd.value.isNotEmpty; bool get oldPwdIsOK => oldPwd.value.isNotEmpty && oldPwd.value.length >= 8;
bool get newPwdIsOK => bool get newPwdIsOK => newPwd.value.isNotEmpty && newPwd.value.length >= 8;
newPwd.value.isNotEmpty && (newPwd.value == surePwd.value); bool get surePwdIsOK => surePwd.value.isNotEmpty && surePwd.value.length >= 8;
void onClose() {} void onClose() {}
} }

View File

@ -16,4 +16,26 @@ class RegularExpression {
r'https?:\/\/\S+', r'https?:\/\/\S+',
caseSensitive: false, caseSensitive: false,
); );
//
bool validateString(String value) {
//
RegExp regExpNum = RegExp(r'\d'); //
RegExp regExpLetter = RegExp(r'[a-zA-Z]'); //
RegExp regExpSymbol = RegExp(r'[!@#\$&*~]'); //
//
bool hasNum = regExpNum.hasMatch(value);
bool hasLetter = regExpLetter.hasMatch(value);
bool hasSymbol = regExpSymbol.hasMatch(value);
//
int count = 0;
if (hasNum) count++;
if (hasLetter) count++;
if (hasSymbol) count++;
// 2true
return count >= 2;
}
} }

View File

@ -28,6 +28,7 @@ class LoginInput extends StatefulWidget {
BlockStrCallback? onchangeAction; BlockStrCallback? onchangeAction;
BlockStrCallback? onSubmitted; BlockStrCallback? onSubmitted;
BlockClickCallback? onTapAction; BlockClickCallback? onTapAction;
bool? isLogin;// false
LoginInput({ LoginInput({
Key? key, Key? key,
@ -46,6 +47,7 @@ class LoginInput extends StatefulWidget {
this.onchangeAction, this.onchangeAction,
this.onTapAction, this.onTapAction,
this.onSubmitted, this.onSubmitted,
this.isLogin = false,
}) : super(key: key); }) : super(key: key);
@override @override
@ -123,7 +125,7 @@ class _LoginInputState extends State<LoginInput> {
if (isPwd) if (isPwd)
Padding( Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: F.sw(skyCall: () => 27.h, xhjCall: () => 39.h)), top: F.sw(skyCall: () => 27.h, xhjCall: () => widget.isLogin! ? 27.h : 39.h)),
child: Text( child: Text(
pwd, pwd,
style: TextStyle( style: TextStyle(