app-starlock/lib/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_logic.dart

72 lines
2.1 KiB
Dart
Executable File

import 'dart:async';
import 'package:flutter/material.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/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../tools/regularExpression.dart';
class MinePersonInfoResetPasswordLogic extends BaseGetXController {
final MinePersonInfoResetPasswordState state =
MinePersonInfoResetPasswordState();
Future<void> changePasswordRequest() async {
// if(state.newPwd.value.length < 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;
}
if (!RegularExpression().validateString(state.newPwd.value)) {
showToast('密码需至少包含数字/字母/字符中的2种组合'.tr);
return;
}
final LoginEntity entity = await ApiRepository.to.changePassword(
state.date.value, state.surePwd.value, state.oldPwd.value);
if (entity.errorCode!.codeIsSuccessful) {
showToast('重置成功'.tr);
Get.back();
}
}
void checkNext(TextEditingController controller) {
changeInput(controller);
}
void changeInput(TextEditingController controller) {
if (controller == state.oldPwdController) {
state.oldPwd.value = controller.text;
}
if (controller == state.newPwdController) {
state.newPwd.value = controller.text;
}
if (controller == state.surePwdController) {
state.surePwd.value = controller.text;
}
_resetCanSub();
}
void _resetCanSub() {
state.canSub.value =
state.oldPwdIsOK && state.newPwdIsOK && state.surePwdIsOK;
}
}