更新用户模块
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
|
||||
part 'find_password_controller.g.dart';
|
||||
|
||||
@@ -28,122 +32,135 @@ class FindPasswordController extends GetControllerEx<FindPasswordModel> {
|
||||
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> getCode(BuildContext context) async {
|
||||
String message = "";
|
||||
if (model.phone == null || model.phone!.isEmpty) {
|
||||
message = "请输入手机号".tr;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
if (!MyUtils.isValidPhoneNumber(model.phone!)) {
|
||||
message = '请输入正确的手机号';
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.send_code;
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {"userName": model.phone, "type": 2};
|
||||
await requestWithLog(
|
||||
logTitle: "忘记密码请求验证码",
|
||||
method: MyHttpMethod.post,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: '发送验证码成功'.tr,
|
||||
);
|
||||
},
|
||||
onFailure: (res) {
|
||||
message = res.msg!;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
},
|
||||
);
|
||||
return message;
|
||||
}
|
||||
|
||||
// //确认验证码
|
||||
// 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;
|
||||
// // }
|
||||
//确认验证码
|
||||
Future<String> confirmCode(BuildContext context) async {
|
||||
String message = "";
|
||||
if (model.phone == null || model.phone!.isEmpty) {
|
||||
message = "请输入手机号".tr;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
if (!MyUtils.isValidPhoneNumber(model.phone!)) {
|
||||
message = '请输入正确的手机号'.tr;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
if (model.code == null || model.code!.isEmpty) {
|
||||
message = "请输入验证码".tr;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
if (model.pd == null || model.pd!.isEmpty) {
|
||||
message = "请输入密码".tr;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
String passwordMsg = "密码格式提示".tr;
|
||||
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 (!hasLowercase) {
|
||||
// // message = "密码必须包含至少一个小写字母";
|
||||
// // showToast(message);
|
||||
// // return message;
|
||||
// // }
|
||||
if (model.pd!.length < 8) {
|
||||
message = passwordMsg;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
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 (!hasLetter || !hasDigit) {
|
||||
message = passwordMsg;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
|
||||
// if (model.pd!.length < 8) {
|
||||
// message = passwordMsg;
|
||||
// showToast(message, closeTime: 5);
|
||||
// return message;
|
||||
// }
|
||||
if (!(hasSpecialCharacters || hasUppercase)) {
|
||||
message = passwordMsg;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
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 '';
|
||||
// }
|
||||
if (model.confirm == null || model.confirm!.isEmpty) {
|
||||
message = "请输入确认密码".tr;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
if (model.pd != model.confirm) {
|
||||
message = "两次密码不一致".tr;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
var data = {
|
||||
"userName": model.phone,
|
||||
"password": model.pd,
|
||||
"verify": model.code
|
||||
};
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_forgot;
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
await requestWithLog(
|
||||
logTitle: "找回密码",
|
||||
method: MyHttpMethod.post,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
TopSlideNotification.show(context, text: "密码修改成功".tr);
|
||||
},
|
||||
onFailure: (res) {
|
||||
message = res.msg!;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
},
|
||||
);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user