Files
tuiche/lib/controller/mh_controller/find_password_controller.dart
2025-06-06 09:18:06 +08:00

150 lines
4.8 KiB
Dart

import 'package:ef/ef.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:json_annotation/json_annotation.dart';
part 'find_password_controller.g.dart';
@JsonSerializable()
class FindPasswordModel {
String? phone; //手机号
String? code; //验证码
bool? register_agree; //注册协议
String? pd; //密码
String? confirm; //验证密码
bool? pdshow = true; //是否显示密码
bool? cpdshow = true; //是否显示密码
FindPasswordModel();
static FindPasswordModel fromJson(Map<String, dynamic> json) =>
_$FindPasswordModelFromJson(json);
Map<String, dynamic> toJson() => _$FindPasswordModelToJson(this);
}
class FindPasswordController extends GetControllerEx<FindPasswordModel> {
// final UserRepository repository = UserRepository();
FindPasswordController() {
attr = GetModel(FindPasswordModel()).obs;
}
// Future<String> getCode(BuildContext context) async {
// String message = "";
// final MyDialogController myDialogController =
// Get.find<MyDialogController>();
// if (model.phone == null || model.phone!.isEmpty) {
// message = "请输入手机号";
// showToast(message);
// return message;
// }
// if (!MyUtils.isValidPhoneNumber(model.phone!)) {
// message = '请输入正确的手机号';
// showToast(message);
// return message;
// }
// message = await repository.sendResetCode(model.phone!);
// if (message.isNotEmpty) {
// showToast("发送验证码失败或已到限制数量,请稍候或一小时/一天后再试!");
// return message;
// } else {
// showToast("发送验证码成功!", color: color_success);
// }
// return '';
// }
// //确认验证码
// Future<String> confirmCode(BuildContext context) async {
// String message = "";
// final MyDialogController myDialogController =
// Get.find<MyDialogController>();
// if (model.phone == null || model.phone!.isEmpty) {
// message = "请输入手机号";
// showToast(message);
// return message;
// }
// if (!MyUtils.isValidPhoneNumber(model.phone!)) {
// message = '请输入正确的手机号';
// showToast(message);
// return message;
// }
// if (model.code == null || model.code!.isEmpty) {
// message = "请输入验证码";
// showToast(message);
// return message;
// }
// if (model.pd == null || model.pd!.isEmpty) {
// message = "请输入密码";
// showToast(message);
// return message;
// }
// // if (model.pd!.length < 8) {
// // message = "密码长度必须至少8位";
// // showToast(message);
// // return message;
// // }
// // bool hasUppercase = model.pd!.contains(RegExp(r'[A-Z]'));
// // bool hasLowercase = model.pd!.contains(RegExp(r'[a-z]'));
// // bool hasSpecialCharacters =
// // model.pd!.contains(RegExp(r'[!@#$%^&*(),.?":{}|<>]'));
// // if (!hasUppercase) {
// // message = "密码必须包含至少一个大写字母";
// // showToast(message);
// // return message;
// // }
// // if (!hasLowercase) {
// // message = "密码必须包含至少一个小写字母";
// // showToast(message);
// // return message;
// // }
// // if (!hasSpecialCharacters) {
// // message = "密码必须包含至少一个特殊字符";
// // showToast(message);
// // return message;
// // }
// String passwordMsg = "1.密码长度必须至少8位\n2.密码需要字母加数字\n3.特殊字符或大写字母至少包含一个";
// bool hasUppercase = model.pd!.contains(RegExp(r'[A-Z]'));
// bool hasDigit = model.pd!.contains(RegExp(r'[0-9]'));
// bool hasSpecialCharacters =
// model.pd!.contains(RegExp(r'[!@#$%^&*(),.?":{}|<>]'));
// bool hasLetter = model.pd!.contains(RegExp(r'[a-zA-Z]'));
// if (model.pd!.length < 8) {
// message = passwordMsg;
// showToast(message, closeTime: 5);
// return message;
// }
// if (!hasLetter || !hasDigit) {
// message = passwordMsg;
// showToast(message);
// return message;
// }
// if (!(hasSpecialCharacters || hasUppercase)) {
// message = passwordMsg;
// showToast(message);
// return message;
// }
// if (model.confirm == null || model.confirm!.isEmpty) {
// message = "请输入确认密码";
// showToast(message);
// return message;
// }
// if (model.pd != model.confirm) {
// message = "两次密码不一致";
// showToast(message);
// return message;
// }
// message =
// await repository.confirmCode(model.phone!, model.code!, model.pd!);
// if (message.isNotEmpty) {
// showToast("更新失败,请稍后再试");
// return message;
// }
// return '';
// }
}