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

60 lines
1.7 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';
class MinePersonInfoResetPasswordLogic extends BaseGetXController {
final MinePersonInfoResetPasswordState state = MinePersonInfoResetPasswordState();
Future<void> changePasswordRequest() async {
if(state.newPwd.value.length < 8){
showToast('新密码长度不足8位'.tr);
return;
}
if(state.surePwd.value.length < 8){
showToast('确认长度不足8位'.tr);
return;
}
if(state.surePwd.value != state.newPwd.value){
showToast('两次密码不一致'.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;
}
}