59 lines
1.6 KiB
Dart
Executable File
59 lines
1.6 KiB
Dart
Executable File
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.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();
|
|
|
|
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;
|
|
}
|
|
|
|
var entity = await ApiRepository.to.changePassword(
|
|
state.date.value,
|
|
state.surePwd.value,
|
|
state.oldPwd.value);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
showToast("重置成功");
|
|
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;
|
|
}
|
|
}
|