diff --git a/assets/langs/zh_CN.json b/assets/langs/zh_CN.json index a34d48a..18c74b1 100644 --- a/assets/langs/zh_CN.json +++ b/assets/langs/zh_CN.json @@ -176,7 +176,6 @@ "注销账号":"注销账号", "退出成功":"退出成功", "退出失败":"退出失败" - }, "关于我们":{ "标题":"关于我们" diff --git a/assets/mhlangs/zh_CN.json b/assets/mhlangs/zh_CN.json index 3ebb81c..4bdd041 100644 --- a/assets/mhlangs/zh_CN.json +++ b/assets/mhlangs/zh_CN.json @@ -12,7 +12,7 @@ "详情": "详情", "人员资料": "人员资料" }, - "请输入手机号":"请输入手机号", + "请输入手机号":"输入手机号码", "请输入正确的手机号":"请输入正确的手机号", "请输入密码":"请输入密码", "密码格式提示":"1.密码长度必须至少8位\n2.密码需要字母加数字\n3.特殊字符和大写字母至少包含一个", @@ -44,7 +44,7 @@ "提交":"提交", "发送验证码成功":"发送验证码成功", "注册成功":"注册成功", - "再按一次退出程序":"注再按一次退出程序册成功", + "再按一次退出程序":"再按一次退出程序成功", "用户拒绝授权":"用户拒绝授权", "用户取消授权":"用户取消授权", "未命名":"未命名", @@ -53,8 +53,16 @@ "点击更换头像":"点击更换头像", "保存失败":"保存失败", "昵称为空":"昵称为空", - "保存成功":"保存成功" - + "保存成功":"保存成功", + "请先登录":"请先登录", + "密码修改成功":"密码修改成功", + "未知数据":"-", + "必须登录提示":"请先登录!", + "输入验证码":"输入验证码", + "输入新密码":"输入新密码", + "确认验证码":"确认验证码", + "输入手机号码":"输入手机号码", + "操作成功":"操作成功" diff --git a/lib/common/color/ServiceConstant.dart b/lib/common/color/ServiceConstant.dart index d105b9c..ec1d3be 100644 --- a/lib/common/color/ServiceConstant.dart +++ b/lib/common/color/ServiceConstant.dart @@ -37,6 +37,8 @@ class ServiceConstant { static const String user_register = "/api/user/register";//用户注册 + static const String user_forgot = "/api/user/forgot";//找回密码 + static const String user_changePassword = "/api/user/changePassword";//修改密码 diff --git a/lib/component/tool/CustomCard.dart b/lib/component/tool/CustomCard.dart index 2da20f7..6bf4cc6 100644 --- a/lib/component/tool/CustomCard.dart +++ b/lib/component/tool/CustomCard.dart @@ -1,93 +1,3 @@ -// import 'package:flutter/material.dart'; -// import 'package:vbvs_app/common/util/FitTool.dart'; - -// class CustomCard extends StatefulWidget { -// final double borderRadius; // 圆角 -// final VoidCallback onTap; // 点击回调 -// final List colors; // 背景颜色列表 -// final Widget child; // 子组件 -// final bool enableAnimation; // 是否启用动画效果 -// final bool enableGradient; // 是否启用渐变 - -// const CustomCard({ -// Key? key, -// required this.borderRadius, -// required this.onTap, -// required this.colors, -// required this.child, -// this.enableAnimation = true, // 默认启用动画效果 -// this.enableGradient = true, // 默认启用渐变效果 -// }) : super(key: key); - -// @override -// State createState() => _CustomCardState(); -// } - -// class _CustomCardState extends State -// with SingleTickerProviderStateMixin { -// double _scale = 1.0; -// final Duration _animationDuration = const Duration(milliseconds: 50); - -// Future _handleTap() async { -// if (widget.enableAnimation) { -// setState(() { -// _scale = 0.95; -// }); - -// await Future.delayed(_animationDuration); - -// setState(() { -// _scale = 1.0; -// }); -// } - -// widget.onTap(); -// } - -// @override -// Widget build(BuildContext context) { -// final bool isGradient = widget.enableGradient && widget.colors.length > 1; -// final Color baseColor = widget.colors.first; - -// return Material( -// color: Colors.transparent, -// borderRadius: BorderRadius.circular(widget.borderRadius), -// child: InkWell( -// onTap: _handleTap, -// borderRadius: BorderRadius.circular(widget.borderRadius), -// splashColor: widget.colors.first.withOpacity(0.2), -// child: widget.enableAnimation -// ? AnimatedScale( -// scale: _scale, -// duration: _animationDuration, -// curve: Curves.easeInOut, -// child: _buildContent(isGradient, baseColor), -// ) -// : _buildContent(isGradient, baseColor), -// ), -// ); -// } - -// Widget _buildContent(bool isGradient, Color baseColor) { -// return Container( -// decoration: BoxDecoration( -// color: isGradient ? null : baseColor, -// gradient: isGradient -// ? LinearGradient( -// colors: widget.colors, -// begin: Alignment.topLeft, -// end: Alignment.bottomRight, -// ) -// : null, -// borderRadius: BorderRadius.circular(widget.borderRadius), -// ), -// child: Padding( -// padding: EdgeInsets.fromLTRB(0.rpx, 0.rpx, 0.rpx, 5.rpx), -// child: widget.child, -// ), -// ); -// } -// } import 'package:flutter/material.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; diff --git a/lib/controller/login/login_controller.dart b/lib/controller/login/login_controller.dart index 5e28ef5..0e8cdee 100644 --- a/lib/controller/login/login_controller.dart +++ b/lib/controller/login/login_controller.dart @@ -1,12 +1,9 @@ -import 'dart:convert'; - import 'package:EasyDartModule/EasyDartModule.dart'; import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:fluwx/fluwx.dart'; import 'package:get_storage/get_storage.dart'; - import 'package:json_annotation/json_annotation.dart'; import 'package:vbvs_app/common/color/ServiceConstant.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; @@ -16,9 +13,9 @@ import 'package:vbvs_app/common/util/requestWithLog.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/time/countdown_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; -import 'package:vbvs_app/main.dart'; import 'package:vbvs_app/model/api_response.dart'; import 'package:vbvs_app/model/user_data.dart'; + part 'login_controller.g.dart'; @JsonSerializable() @@ -26,7 +23,7 @@ class LoginModel { //版本id int? loginStyle = 1; //1.密码登录 2.短信登录 String? account = '17649984946'; //账户 - String? password = 'wyf123,.'; //密码 + String? password = '123wyf..'; //密码 String? phone; //手机号/邮箱 String? code; //验证码 diff --git a/lib/controller/mh_controller/find_password_controller.dart b/lib/controller/mh_controller/find_password_controller.dart index 508cacd..a6014c0 100644 --- a/lib/controller/mh_controller/find_password_controller.dart +++ b/lib/controller/mh_controller/find_password_controller.dart @@ -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 { attr = GetModel(FindPasswordModel()).obs; } - // Future getCode(BuildContext context) async { - // String message = ""; - // final MyDialogController myDialogController = - // Get.find(); - // 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 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 confirmCode(BuildContext context) async { - // String message = ""; - // final MyDialogController myDialogController = - // Get.find(); - // 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 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; + } } diff --git a/lib/controller/user_info_controller.dart b/lib/controller/user_info_controller.dart index 1b001e1..3957d89 100644 --- a/lib/controller/user_info_controller.dart +++ b/lib/controller/user_info_controller.dart @@ -58,6 +58,7 @@ class UserInfoController extends GetControllerEx { attr = GetModel(UserInfoModel()).obs; } + RxDouble textHalfWidth = 0.0.obs; List device_bind_status = []; int device_bind_flag = 0;//0。未初始化 1.已初始化 diff --git a/lib/main.dart b/lib/main.dart index d9dd201..9500229 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -64,6 +64,7 @@ import 'package:vbvs_app/model/user_data.dart'; import 'package:vbvs_app/pages/mh_page/MattressControl.dart'; import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart'; import 'package:vbvs_app/pages/mh_page/user/controller/mht_register_controller.dart'; +import 'package:vbvs_app/pages/mh_page/user/controller/update_password_controller.dart'; import 'package:vbvs_app/routers/mh_routers.dart'; import 'controller/mh_controller/apply_repair_controller.dart'; @@ -272,20 +273,21 @@ Future dealBindProcess() async { } } +final GlobalKey navigatorKey = GlobalKey(); class MyApp extends StatelessWidget { MyApp({super.key}); final ThemeController themeController = Get.put(ThemeController()); Widget buildmht(BuildContext context, BoxConstraints cons) { return GetMaterialApp( - navigatorKey: AppGlobal.navigatorKey, // ✅ 注入 navigatorKey + navigatorKey: navigatorKey, // ✅ 注入 navigatorKey translations: AppLanguage(), debugShowCheckedModeBanner: false, title: '', theme: themeController.currentTheme, // home: MainPageBBottomChange(), - initialRoute: "/loginPage", - // initialRoute: "/mianPageBottomChange", + // initialRoute: "/loginPage", + initialRoute: "/mianPageBottomChange", onGenerateRoute: mhonGenerateRoute, initialBinding: BindingsBuilder(() => [ // Get.lazyPut(() => UserInfoController()), @@ -326,6 +328,7 @@ class MyApp extends StatelessWidget { Get.lazyPut(() => MHTRegisterController()), Get.lazyPut(() => WeatherModelController()), Get.lazyPut(() => RegisterController()), + Get.lazyPut(() => UpdatePasswordController()), ])); } diff --git a/lib/pages/device/component/MessageSetting.dart b/lib/pages/device/component/MessageSetting.dart index 6529e59..882505a 100644 --- a/lib/pages/device/component/MessageSetting.dart +++ b/lib/pages/device/component/MessageSetting.dart @@ -43,7 +43,7 @@ class _MessageSettingPageState extends State { requestWithLog( logTitle: "查询用户消息配置", method: MyHttpMethod.get, - queryUrl: queryUrl, + queryUrl: queryUrl, onSuccess: (res) { if (res.data == null || res.data.isEmpty) { var data = { diff --git a/lib/pages/mh_page/homepage/new_Home_page.dart b/lib/pages/mh_page/homepage/new_Home_page.dart index 4de9b8b..c3353ea 100644 --- a/lib/pages/mh_page/homepage/new_Home_page.dart +++ b/lib/pages/mh_page/homepage/new_Home_page.dart @@ -5,6 +5,8 @@ import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/component/tool/ClickableContainer.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/device/body_device_controller.dart'; import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; @@ -646,42 +648,58 @@ class _NewHomePageState extends State { Padding( padding: EdgeInsetsDirectional.fromSTEB( 0, 0, 0, 80.rpx), - child: Container( - width: MediaQuery.sizeOf(context).width, - height: 302.rpx, - padding: EdgeInsets.only( - top: 90.rpx, bottom: 80.rpx), - decoration: BoxDecoration( - // color: Colors.white, - borderRadius: - BorderRadius.circular(borderRadius), - border: Border.all( - color: stringToColor("#85F5FF"), // 边框颜色 - width: 1.rpx, // 边框宽度 + child: ClickableContainer( + backgroundColor: Colors.transparent, + highlightColor: Colors.transparent, + padding: EdgeInsets.all(0), + onTap: () { + if (userInfoController.model.login == + null || + userInfoController.model.login == 0) { + TopSlideNotification.show(context, + text: "请先登录".tr, + textColor: + themeController.currentColor.sc9); + Get.toNamed("/loginPage"); + } + }, + child: Container( + width: MediaQuery.sizeOf(context).width, + height: 302.rpx, + padding: EdgeInsets.only( + top: 90.rpx, bottom: 80.rpx), + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(borderRadius), + border: Border.all( + color: stringToColor("#85F5FF"), // 边框颜色 + width: 1.rpx, // 边框宽度 + ), ), - ), - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset( - 'assets/images/icon/add.svg', - width: 42.rpx, - height: 42.rpx, - ), - SizedBox( - height: 32.rpx, - ), - Text( - '添加一台新设备'.tr, - style: TextStyle( - color: stringToColor("#85F5FF"), - fontSize: AppConstants() - .normal_text_fontSize, - letterSpacing: 0, + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + SvgPicture.asset( + 'assets/images/icon/add.svg', + width: 42.rpx, + height: 42.rpx, ), - ), - ], + SizedBox( + height: 32.rpx, + ), + Text( + '添加一台新设备'.tr, + style: TextStyle( + color: stringToColor("#85F5FF"), + fontSize: AppConstants() + .normal_text_fontSize, + letterSpacing: 0, + ), + ), + ], + ), ), ), ), diff --git a/lib/pages/mh_page/new_mine_page.dart b/lib/pages/mh_page/new_mine_page.dart index 0e6f89f..157a3d5 100644 --- a/lib/pages/mh_page/new_mine_page.dart +++ b/lib/pages/mh_page/new_mine_page.dart @@ -7,6 +7,7 @@ import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; @@ -40,7 +41,7 @@ class _MinePageState extends State { text = (nickname != null && nickname.isNotEmpty) ? nickname : '未命名'.tr; } - // _calculateTextHalfWidth(text); + _calculateTextHalfWidth(text); } void _calculateTextHalfWidth(String text) { @@ -60,6 +61,7 @@ class _MinePageState extends State { _textHalfWidth = textPainter.width / 2; }); } + @override Widget build(BuildContext context) { SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( @@ -185,6 +187,18 @@ class _MinePageState extends State { highlightColor: const Color(0xFF055466), padding: EdgeInsets.zero, onTap: () async { + if (userInfoController.model.login == + null || + userInfoController.model.login == 0) { + TopSlideNotification.show( + context, + text: "必须登录提示".tr, + textColor: + themeController.currentColor.sc9, + ); + Get.toNamed("/loginPage"); + return; + } await Get.toNamed("/editUserInfoPage"); await userInfoController.getUserInfo(); userInfoController.updateAll(); @@ -216,7 +230,6 @@ class _MinePageState extends State { ), )), ), - ], ), ), @@ -385,13 +398,7 @@ class _MinePageState extends State { child: SvgPicture.asset( 'assets/img/icon/expand.svg', color: Colors.white, - ) - // Icon( - // Icons.arrow_forward_ios, - // color: Colors.white, - // // size: 14.rpx, - // ), - )), + ))), ], ), ), diff --git a/lib/pages/mh_page/new_settingPage.dart b/lib/pages/mh_page/new_settingPage.dart index fc72277..06c9816 100644 --- a/lib/pages/mh_page/new_settingPage.dart +++ b/lib/pages/mh_page/new_settingPage.dart @@ -103,8 +103,7 @@ class _SettingPageState extends State { padding: EdgeInsetsDirectional.fromSTEB( 40.rpx, 0.rpx, 40.rpx, 0.rpx), onTap: () { - TopSlideNotification.show(context, - text: "待开发功能".tr); + Get.toNamed("/updatePasswordPage"); }, child: Container( child: Padding( diff --git a/lib/pages/mh_page/user/controller/mht_login_controller.dart b/lib/pages/mh_page/user/controller/mht_login_controller.dart index ca98b11..6f95e62 100644 --- a/lib/pages/mh_page/user/controller/mht_login_controller.dart +++ b/lib/pages/mh_page/user/controller/mht_login_controller.dart @@ -23,7 +23,7 @@ class LoginModel { String? account = '17649984946'; //账户 // String? account = '13953240733'; //账户 - String? password = 'wyf123..'; //密码 + String? password = '123wyf..'; //密码 // String? account = '15255134931'; //账户 // String? password = 'mht123,.'; //密码 diff --git a/lib/pages/mh_page/user/controller/update_password_controller.dart b/lib/pages/mh_page/user/controller/update_password_controller.dart new file mode 100644 index 0000000..16d878b --- /dev/null +++ b/lib/pages/mh_page/user/controller/update_password_controller.dart @@ -0,0 +1,163 @@ +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'; +import 'package:vbvs_app/controller/user_info_controller.dart'; + +part 'update_password_controller.g.dart'; + +@JsonSerializable() +class UpdatePasswordModel { + String? phone; //手机号 + String? code; //验证码 + String? pd; //密码 + String? confirm; //验证密码 + bool? pdshow = true; //是否显示密码 + bool? cpdshow = true; //是否显示密码 + + UpdatePasswordModel(); + static UpdatePasswordModel fromJson(Map json) => + _$UpdatePasswordModelFromJson(json); + Map toJson() => _$UpdatePasswordModelToJson(this); +} + +class UpdatePasswordController extends GetControllerEx { + UpdatePasswordController() { + attr = GetModel(UpdatePasswordModel()).obs; + } + + UserInfoController userInfoController = Get.find(); + + //确认验证码 + Future resetPassword(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 (model.pd!.length < 8) { + message = passwordMsg; + TopSlideNotification.show(context, + text: message, textColor: themeController.currentColor.sc9); + return message; + } + + if (!hasLetter || !hasDigit) { + message = passwordMsg; + TopSlideNotification.show(context, + text: message, textColor: themeController.currentColor.sc9); + return message; + } + + if (!(hasSpecialCharacters || hasUppercase)) { + message = passwordMsg; + TopSlideNotification.show(context, + text: message, textColor: themeController.currentColor.sc9); + return message; + } + 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; + } + String serviceAddress = ServiceConstant.service_address; + String serviceName = ServiceConstant.server_service; + String serviceApi = ServiceConstant.user_changePassword; + String queryUrl = "${serviceAddress}${serviceName}${serviceApi}"; + final user = userInfoController.model.user!; + var data = { + "userName": user.email ?? user.phone, + "password": model.pd, + "verify": model.code + }; + 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 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 = '请输入正确的手机号'.tr; + 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": 3}; + await requestWithLog( + data: data, + logTitle: "发送验证码", + method: MyHttpMethod.post, + queryUrl: queryUrl, + onSuccess: (res) { + TopSlideNotification.show(context, text: "发送验证码成功".tr); + }, + onFailure: (res) { + message = res.msg!; + TopSlideNotification.show(context, + text: message, textColor: themeController.currentColor.sc9); + }, + ); + return message; + } +} diff --git a/lib/pages/mh_page/user/controller/update_password_controller.g.dart b/lib/pages/mh_page/user/controller/update_password_controller.g.dart new file mode 100644 index 0000000..4484583 --- /dev/null +++ b/lib/pages/mh_page/user/controller/update_password_controller.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'update_password_controller.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +UpdatePasswordModel _$UpdatePasswordModelFromJson(Map json) => + UpdatePasswordModel() + ..phone = json['phone'] as String? + ..code = json['code'] as String? + ..pd = json['pd'] as String? + ..confirm = json['confirm'] as String? + ..pdshow = json['pdshow'] as bool? + ..cpdshow = json['cpdshow'] as bool?; + +Map _$UpdatePasswordModelToJson( + UpdatePasswordModel instance) => + { + 'phone': instance.phone, + 'code': instance.code, + 'pd': instance.pd, + 'confirm': instance.confirm, + 'pdshow': instance.pdshow, + 'cpdshow': instance.cpdshow, + }; diff --git a/lib/pages/mh_page/user/page/find_password_page.dart b/lib/pages/mh_page/user/page/find_password_page.dart index bcfd35b..fbf8844 100644 --- a/lib/pages/mh_page/user/page/find_password_page.dart +++ b/lib/pages/mh_page/user/page/find_password_page.dart @@ -1,8 +1,11 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; +import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/util/CommonVariables.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/mh_controller/find_password_controller.dart'; import 'package:vbvs_app/controller/time/countdown_controller.dart'; @@ -290,40 +293,49 @@ class FindPasswordPage extends GetView { CountdownController>(); return InkWell( onTap: () async { - // if (countdownController - // .countdown.value != - // 0) { - // return; - // } - // if (CommonVariables - // .isNetWorkOn == - // false) { - // showToast( - // "网络未连接,请开启设备网络后重试"); - // return; - // } - // String msg = - // await controller - // .getCode(context); - // if (msg.isNotEmpty) { - // return; - // } - // countdownController - // .countdown - // .value == - // 0 - // ? countdownController - // .startCountdown( - // AppConstants - // .code_time) - // : null; + if (countdownController + .countdown + .value != + 0) { + return; + } + if (CommonVariables + .isNetWorkOn == + false) { + TopSlideNotification.show( + context, + text: + "网络未连接,请开启设备网络后重试" + .tr, + textColor: + themeController + .currentColor + .sc9); + return; + } + String msg = + await controller + .getCode( + context); + if (msg.isNotEmpty) { + return; + } + countdownController + .countdown + .value == + 0 + ? countdownController + .startCountdown( + AppConstants + .code_time) + : null; }, child: Text( countdownController .countdown .value == 0 - ? '获取验证码' + ? '获取验证码'.tr : '${countdownController.countdown.value}' + '秒'.tr, style: TextStyle( @@ -566,19 +578,21 @@ class FindPasswordPage extends GetView { borderRadius: 16.rpx, gradientDirection: GradientDirection.vertical, - onTap: () { - // if (CommonVariables.isNetWorkOn == - // false) { - // showToast("网络未连接,请开启设备网络后重试"); - // return; - // } - // String msg = await controller - // .confirmCode(context); - // if (msg.isEmpty) { - // // Get.toNamed("/userInfoPage"); - // // Get.toNamed("/resetPasswordPage"); - // Get.toNamed("/loginPage"); - // } + onTap: () async { + if (CommonVariables.isNetWorkOn == + false) { + TopSlideNotification.show( + context, + text: "网络未连接,请开启设备网络后重试".tr, + textColor: themeController + .currentColor.sc9); + return; + } + String msg = await controller + .confirmCode(context); + if (msg.isEmpty) { + Get.toNamed("/loginPage"); + } }, colors: const [ Color(0xFFFCFCFC), diff --git a/lib/pages/mh_page/user/page/mht_login_page.dart b/lib/pages/mh_page/user/page/mht_login_page.dart index 973583f..3c51819 100644 --- a/lib/pages/mh_page/user/page/mht_login_page.dart +++ b/lib/pages/mh_page/user/page/mht_login_page.dart @@ -1308,7 +1308,10 @@ class MHTLoginPage extends GetView { null; loginController.model.phone = null; loginController.model.code = null; - + MHTRegisterController + registerController = Get.find(); + registerController + .model.register_agree = false; Get.offAndToNamed( "/mianPageBottomChange"); } diff --git a/lib/pages/mh_page/user/page/update_password_page.dart b/lib/pages/mh_page/user/page/update_password_page.dart new file mode 100644 index 0000000..486f978 --- /dev/null +++ b/lib/pages/mh_page/user/page/update_password_page.dart @@ -0,0 +1,973 @@ +import 'package:ef/ef.dart'; +import 'package:flutter/material.dart'; +import 'package:flutterflow_ui/flutterflow_ui.dart'; +import 'package:get_storage/get_storage.dart'; +import 'package:vbvs_app/common/color/appColors.dart'; +import 'package:vbvs_app/common/color/appConstants.dart'; +import 'package:vbvs_app/common/color/appFontsize.dart'; +import 'package:vbvs_app/common/util/FitTool.dart'; +import 'package:vbvs_app/common/util/MyUtils.dart'; +import 'package:vbvs_app/component/tool/CustomCard.dart'; +import 'package:vbvs_app/controller/login/login_controller.dart'; +import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; +import 'package:vbvs_app/controller/mh_controller/register_controller.dart'; +import 'package:vbvs_app/controller/time/countdown_controller.dart'; +import 'package:vbvs_app/controller/user_info_controller.dart'; +import 'package:vbvs_app/pages/mh_page/user/controller/update_password_controller.dart'; + +class UpdatePasswordPage extends GetView { + BoxConstraints? bodysize; + final scaffoldKey = GlobalKey(); + + UpdatePasswordPage() { + controller.model.pdshow = true; + controller.model.cpdshow = true; + + // 获取登录用户手机号,设置到 model 中 + UserInfoController userInfoController = Get.find(); + controller.model.phone = userInfoController.model.user!.phone; + } + + @override + Widget build(BuildContext context) { + return LayoutBuilder(builder: (context, cc) { + bodysize = cc; + return GestureDetector( + onTap: () => FocusScope.of(context).unfocus(), + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/new_background.png'), // 本地图片 + fit: BoxFit.fill, // 填满整个 Container + ), + ), + child: Scaffold( + // key: scaffoldKey, + appBar: AppBar( + backgroundColor: Colors.transparent, + // backgroundColor: Colors.transparent, + automaticallyImplyLeading: false, + iconTheme: + IconThemeData(color: themeController.currentColor.sc3), + titleSpacing: 0, + // leading: returnIconButtom, + title: Container( + width: double.infinity, + height: 180.rpx, + child: Stack( + alignment: Alignment.center, + children: [ + /// 居中标题 + Text( + '修改密码'.tr, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: 'Readex Pro', + color: themeController.currentColor.sc3, + letterSpacing: 0, + fontSize: 30.rpx, + ), + ), + + /// 左边返回按钮 + Positioned( + left: 0, + child: returnIconButtom, + ), + ], + ), + ), + + actions: [], + centerTitle: false, + ), + + backgroundColor: Colors.transparent, + body: Container( + width: bodysize!.maxWidth, + height: bodysize!.maxHeight * 1, + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + child: Container( + width: bodysize!.maxWidth, + height: bodysize!.maxHeight * 1, + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 15, 13, 15, 0), + child: Container( + width: bodysize!.maxWidth, + constraints: BoxConstraints( + minWidth: 346, + minHeight: 162, + ), + decoration: BoxDecoration( + color: stringToColor("#003058"), + borderRadius: BorderRadius.circular(16), + ), + child: Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 22, 20, 17, 21), + child: Container( + width: bodysize!.maxWidth, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + ), + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + // height: 31, // 设置高度为 31 + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + constraints: BoxConstraints( + minWidth: 158 + .rpx, // 设置最小宽度为 100 + ), + child: Align( + alignment: + AlignmentDirectional( + -1, 0), + child: Text( + '输入手机号码'.tr, + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: + Colors.white, + fontSize: AppFontsize + .normal_text_size, + letterSpacing: 0, + ), + ), + ), + ), + Flexible( + child: Container( + width: MediaQuery.sizeOf( + context) + .width, + height: + 40, // 这个高度可以移除,或调整为 31 + decoration: BoxDecoration( + color: + Color(0xFFF3F5F6), + borderRadius: + BorderRadius + .circular(8), + ), + child: TextFormField( + readOnly: true, // 设置为只读 + initialValue: controller + .model + .phone!, // 设置初始值 + onChanged: (value) { + controller.model + .phone = value; + }, + obscureText: false, + decoration: + InputDecoration( + labelStyle: + FlutterFlowTheme.of( + context) + .labelMedium + .override( + fontFamily: + 'Readex Pro', + fontSize: + AppFontsize + .normal_text_size, + letterSpacing: + 0, + ), + hintStyle: + FlutterFlowTheme.of( + context) + .labelMedium + .override( + fontFamily: + 'Readex Pro', + letterSpacing: + 0, + ), + enabledBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: Color( + 0x00000000), + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + focusedBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: Color( + 0x00000000), + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + errorBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: FlutterFlowTheme + .of(context) + .error, + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + focusedErrorBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: FlutterFlowTheme + .of(context) + .error, + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + contentPadding: + EdgeInsetsDirectional + .fromSTEB(8, + 0, 0, 8), + ), + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: themeController + .currentColor + .sc4, + fontSize: AppFontsize + .normal_text_size, + letterSpacing: 0, + ), + ), + ), + ), + ].divide(SizedBox(width: 13)), + ), + ), + Container( + // height: 31, // 设置高度为 31 + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + constraints: BoxConstraints( + minWidth: 158 + .rpx, // 设置最小宽度为 100 + ), + child: Align( + alignment: + AlignmentDirectional( + -1, 0), + child: Text( + '输入验证码', + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: + Colors.white, + fontSize: AppFontsize + .normal_text_size, + letterSpacing: 0, + ), + ), + ), + ), + Flexible( + child: Container( + width: MediaQuery.sizeOf( + context) + .width, + height: + 40, // 这里也设置为31,保持一致 + decoration: BoxDecoration( + color: + Color(0xFFF3F5F6), + borderRadius: + BorderRadius + .circular(8), + ), + child: Stack( + children: [ + Align( + alignment: + AlignmentDirectional( + 0, 0), + child: Container( + width: MediaQuery + .sizeOf( + context) + .width, + height: + 31, // 这里的高度也设置为31 + decoration: + BoxDecoration( + color: Color( + 0xFFF3F5F6), + borderRadius: + BorderRadius + .circular( + 12), + ), + child: Align( + alignment: + AlignmentDirectional( + 0, 0), + child: + TextFormField( + onChanged: + (value) { + controller + .model + .code = + value; + }, + obscureText: + false, + decoration: + InputDecoration( + labelStyle: FlutterFlowTheme.of( + context) + .labelMedium + .override( + fontFamily: + 'Readex Pro', + fontSize: + AppFontsize.normal_text_size, + letterSpacing: + 0, + ), + hintText: + '请输验证码', + hintStyle: FlutterFlowTheme.of( + context) + .labelMedium + .override( + fontFamily: + 'Readex Pro', + color: themeController + .currentColor + .sc4, + fontSize: + AppFontsize.normal_text_size, + letterSpacing: + 0, + ), + enabledBorder: + InputBorder + .none, + focusedBorder: + InputBorder + .none, + errorBorder: + InputBorder + .none, + focusedErrorBorder: + InputBorder + .none, + contentPadding: + EdgeInsetsDirectional.fromSTEB( + 8, + 0, + 0, + 12), + ), + style: FlutterFlowTheme.of( + context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + fontSize: + AppFontsize.normal_text_size, + letterSpacing: + 0, + ), + ), + ), + ), + ), + Align( + alignment: + AlignmentDirectional( + 0.25, 0), + child: Container( + width: 1.rpx, + height: 15, + decoration: + BoxDecoration( + color: Color( + 0xFFD3D3D3), + ), + ), + ), + Align( + alignment: + AlignmentDirectional( + 1, 0), + child: Padding( + padding: + EdgeInsetsDirectional + .fromSTEB( + 0, + 0, + 5, + 0), + child: Container( + width: MediaQuery.sizeOf( + context) + .width * + 0.157, + height: + 31, // 这里的高度也设置为31 + constraints: + BoxConstraints( + minWidth: 80, + minHeight: 30, + ), + child: Align( + alignment: + AlignmentDirectional( + 0, 0), + child: + Obx(() { + final CountdownController + countdownController = + Get.find< + CountdownController>(); + return InkWell( + onTap: + () async { + if (countdownController.countdown.value != + 0) { + return; + } + String + msg = + await controller.getCode(context); + if (msg + .isNotEmpty) { + return; + } + if (countdownController.countdown.value == + 0) { + countdownController + .startCountdown(AppConstants.code_time); + } + }, + child: + Text( + countdownController.countdown.value == + 0 + ? '获取验证码' + : '${countdownController.countdown.value}秒', + style: + TextStyle( + fontFamily: + 'Readex Pro', + color: + Color(0xFF333333), + fontSize: + AppFontsize.normal_text_size, + letterSpacing: + 0, + ), + ), + ); + }), + ), + ), + ), + ), + ], + ), + ), + ), + ].divide(SizedBox(width: 13)), + ), + ), + Row( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + constraints: BoxConstraints( + minWidth: + 158.rpx, // 设置最小宽度为 100 + ), + child: Align( + alignment: + AlignmentDirectional( + -1, 0), + child: Text( + '输入新密码', + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: Colors.white, + fontSize: AppFontsize + .normal_text_size, + letterSpacing: 0, + ), + ), + ), + ), + Flexible( + child: Container( + width: MediaQuery.sizeOf( + context) + .width, + height: 40, // 设置高度为31 + decoration: BoxDecoration( + color: Color(0xFFF3F5F6), + borderRadius: + BorderRadius.circular( + 8), + ), + child: Obx(() { + return TextFormField( + onChanged: (value) { + controller.model.pd = + value; + }, + obscureText: controller + .model + .pdshow!, // 根据 pdshow 控制是否隐藏密码 + decoration: + InputDecoration( + hintText: "请输入新密码".tr, + labelStyle: + FlutterFlowTheme.of( + context) + .labelMedium + .override( + fontFamily: + 'Readex Pro', + fontSize: + AppFontsize + .normal_text_size, + letterSpacing: + 0, + ), + hintStyle: + FlutterFlowTheme.of( + context) + .labelMedium + .override( + fontFamily: + 'Readex Pro', + color: themeController + .currentColor + .sc4, + fontSize: + AppFontsize + .normal_text_size, + letterSpacing: + 0, + ), + enabledBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: Color( + 0x00000000), + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + focusedBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: Color( + 0x00000000), + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + errorBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: FlutterFlowTheme + .of(context) + .error, + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + focusedErrorBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: FlutterFlowTheme + .of(context) + .error, + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + contentPadding: + EdgeInsetsDirectional + .fromSTEB( + 8, + 8, + 0, + 0), // 调整底部填充 + suffixIcon: + IconButton( + icon: Icon( + controller.model + .pdshow! + ? Icons + .visibility_off + : Icons + .visibility, + color: Color( + 0xFF333333), + size: 16, + ), + onPressed: () { + controller.model + .pdshow = + !controller + .model + .pdshow!; + controller + .updateAll(); + }, + ), + ), + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: Color( + 0xFF333333), + fontSize: AppFontsize + .normal_text_size, + letterSpacing: 0, + ), + ); + }), + ), + ), + ].divide(SizedBox(width: 13)), + ), + Row( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + constraints: BoxConstraints( + minWidth: + 158.rpx, // 设置最小宽度为 100 + ), + child: Align( + alignment: + AlignmentDirectional( + -1, 0), + child: Text( + '确认新密码', + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: Colors.white, + fontSize: AppFontsize + .normal_text_size, + letterSpacing: 0, + ), + ), + ), + ), + Flexible( + child: Container( + width: MediaQuery.sizeOf( + context) + .width, + height: 40, // 设置高度为31 + decoration: BoxDecoration( + color: Color(0xFFF3F5F6), + borderRadius: + BorderRadius.circular( + 8), + ), + child: Obx(() { + return TextFormField( + onChanged: (value) { + controller.model + .confirm = value; + }, + obscureText: controller + .model + .cpdshow!, // 根据 cpdshow 控制是否隐藏密码 + decoration: + InputDecoration( + hintText: + "请输入确认密码".tr, + labelStyle: + FlutterFlowTheme.of( + context) + .labelMedium + .override( + fontFamily: + 'Readex Pro', + fontSize: + AppFontsize + .normal_text_size, + letterSpacing: + 0, + ), + hintStyle: + FlutterFlowTheme.of( + context) + .labelMedium + .override( + fontFamily: + 'Readex Pro', + color: themeController + .currentColor + .sc4, + fontSize: + AppFontsize + .normal_text_size, + letterSpacing: + 0, + ), + enabledBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: Color( + 0x00000000), + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + focusedBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: Color( + 0x00000000), + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + errorBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: FlutterFlowTheme + .of(context) + .error, + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + focusedErrorBorder: + UnderlineInputBorder( + borderSide: + BorderSide( + color: FlutterFlowTheme + .of(context) + .error, + width: 2, + ), + borderRadius: + BorderRadius + .circular( + 8), + ), + contentPadding: + EdgeInsetsDirectional + .fromSTEB( + 8, + 6, + 0, + 0), // 调整底部填充以适应新的高度 + suffixIcon: + IconButton( + icon: Icon( + controller.model + .cpdshow! + ? Icons + .visibility_off + : Icons + .visibility, + color: Color( + 0xFF333333), + size: 16, + ), + onPressed: () { + // 切换 cpdshow 状态 + controller.model + .cpdshow = + !controller + .model + .cpdshow!; + controller + .updateAll(); + }, + ), + ), + style: FlutterFlowTheme + .of(context) + .bodyMedium + .override( + fontFamily: + 'Readex Pro', + color: Color( + 0xFF333333), + fontSize: AppFontsize + .normal_text_size, + letterSpacing: 0, + ), + ); + }), + ), + ), + ].divide(SizedBox(width: 13)), + ), + ].divide(SizedBox(height: 14)), + ), + ), + ), + ), + ), + ), + ], + ), + ), + ), + ), + Padding( + padding: EdgeInsetsDirectional.fromSTEB( + 15, 0, 15, AppConstants.page_button_bottom_padding), + child: Container( + width: bodysize!.maxWidth, + height: bodysize!.maxHeight * 0.056, + child: CustomCard( + gradientDirection: GradientDirection.vertical, + borderRadius: 8, + onTap: () async { + String msg = + await controller.resetPassword(context); + if (msg.isEmpty) { + // 清空登录状态 + RegisterController registerController = + Get.find(); + registerController.model.register_agree = false; + + LoginController loginController = Get.find(); + UserInfoController userInfoController = + Get.find(); + final box = GetStorage(); + box.remove('user'); + box.remove('token'); + userInfoController.model.token = null; + userInfoController.model.user = null; + userInfoController.model.login = 0; + userInfoController.model.message = 0; + loginController.model.account = null; + loginController.model.password = null; + loginController.model.phone = null; + loginController.model.code = null; + GlobalController globalController = + Get.find(); + globalController.resetParmAll(); + Get.offAllNamed("/loginPage"); + } + }, + colors: [ + stringToColor("FCFCFC"), + stringToColor("CEECE3") + ], // 单色背景 + child: Center( + child: Text( + '确定'.tr, + style: FlutterFlowTheme.of(context) + .titleSmall + .override( + fontFamily: 'Readex Pro', + color: stringToColor("#003058"), + fontSize: AppFontsize.normal_text_size, + letterSpacing: 0, + ), + ), + ), + ), + ), + ) + ], + ), + ), + )), + ); + }); + } +} diff --git a/lib/routers/mh_routers.dart b/lib/routers/mh_routers.dart index f8d4db9..95cc7a2 100644 --- a/lib/routers/mh_routers.dart +++ b/lib/routers/mh_routers.dart @@ -1,7 +1,9 @@ import 'package:ef/ef.dart'; import 'package:flutter/cupertino.dart'; +import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/theme_controller/ThemeController.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; +import 'package:vbvs_app/main.dart'; import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart'; import 'package:vbvs_app/pages/mh_page/HomeDeviceType.dart'; import 'package:vbvs_app/pages/mh_page/LanguagePage.dart'; @@ -24,6 +26,7 @@ import 'package:vbvs_app/pages/mh_page/sleep_habit.dart'; import 'package:vbvs_app/pages/mh_page/smys.dart'; import 'package:vbvs_app/pages/mh_page/user/page/find_password_page.dart'; import 'package:vbvs_app/pages/mh_page/user/page/mht_login_page.dart'; +import 'package:vbvs_app/pages/mh_page/user/page/update_password_page.dart'; import '../pages/mh_page/bluetooth.dart'; import '../pages/mh_page/edit_address_page.dart'; @@ -58,8 +61,9 @@ var mhroutes = { BookSuccessPage(data: arguments["data"]), "/myExperiencePage": (context) => MyExperiencePage(), "/registerPage": (context) => RegisterPage(), - "/findPasswordPage": (context) => FindPasswordPage(), - "/loginPage": (context) => MHTLoginPage(), + "/findPasswordPage": (context) => FindPasswordPage(), + "/loginPage": (context) => MHTLoginPage(), + "/updatePasswordPage": (context) => UpdatePasswordPage(), }; var mhonGenerateRoute = (RouteSettings settings) { final String? name = settings.name; // 获取路由名称,如 /news 或 /search @@ -94,6 +98,24 @@ var mhonGenerateRoute = (RouteSettings settings) { // ); // } // } + if (loginStatus != 1) { + if (settings.name != "/loginPage" && + settings.name != "/otherLoginPage" && + settings.name != "/mianPageBottomChange") { + TopSlideNotification.show( + navigatorKey.currentContext!, + text: "必须登录提示".tr, + textColor: themeController.currentColor.sc9, + ); + return CupertinoPageRoute( + settings: RouteSettings( + name: "/loginPage", + arguments: settings.arguments, + ), + builder: (context) => mhroutes["/loginPage"]!(context), + ); + } + } // 如果有路由参数,传递参数 if (settings.arguments != null) {