| | |
| | | } |
| | | setState(() => _loading = true); |
| | | try { |
| | | // 找回密码:提交重置申请(含期望的新密码),由管理员在后台同意后生效 |
| | | final res = isRegister |
| | | ? await ApiService.register({ |
| | | 'phone': phone.text.trim(), |
| | |
| | | }); |
| | | if (!mounted) return; |
| | | if (res['code'] == 0) { |
| | | if (!isRegister) { |
| | | // 弹出提示:联系管理员重置密码 |
| | | _showContactAdminDialog(); |
| | | } else { |
| | | showToast(context, res['msg'] ?? '操作成功'); |
| | | Navigator.pop(context); |
| | | } |
| | | } else { |
| | | showToast(context, res['msg'] ?? '操作失败', error: true); |
| | | _refreshCaptcha(); |
| | |
| | | } |
| | | } |
| | | |
| | | /// 找回密码申请提交成功后的提示弹窗 |
| | | void _showContactAdminDialog() { |
| | | showDialog( |
| | | context: context, |
| | | builder: (ctx) => AlertDialog( |
| | | backgroundColor: const Color(0xFF1B1E2E), |
| | | shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), |
| | | title: const Row( |
| | | children: [ |
| | | Icon(Icons.info_outline, color: AppColors.yellow, size: 20), |
| | | SizedBox(width: 8), |
| | | Text('申请已提交', style: TextStyle(color: Colors.white, fontSize: 15)), |
| | | ], |
| | | ), |
| | | content: const Text('找回密码申请已提交,请联系管理员重置密码!', |
| | | style: TextStyle(color: AppColors.textGray, fontSize: 13, height: 1.6)), |
| | | actions: [ |
| | | TextButton( |
| | | onPressed: () { |
| | | Navigator.pop(ctx); // 关闭提示 |
| | | Navigator.pop(context, true); // 关闭找回密码弹窗 |
| | | }, |
| | | child: const Text('知道了', |
| | | style: TextStyle(color: AppColors.accent, fontSize: 13)), |
| | | ), |
| | | ], |
| | | ), |
| | | ); |
| | | } |
| | | |
| | | @override |
| | | Widget build(BuildContext context) { |
| | | return Dialog( |
| | |
| | | ), |
| | | child: Row( |
| | | children: [ |
| | | Icon(isRegister ? Icons.person_add_alt : Icons.lock_reset, |
| | | size: 16, color: AppColors.textGray), |
| | | Icon(isRegister ? Icons.person_add_alt : Icons.person_outline, |
| | | size: 16, color: Colors.white), |
| | | const SizedBox(width: 8), |
| | | Text(isRegister ? '注册账号' : '找回密码', |
| | | style: const TextStyle( |
| | |
| | | // Logo |
| | | ClipOval( |
| | | child: Image.asset('assets/images/logo.png', |
| | | width: 60, |
| | | height: 60, |
| | | width: 72, |
| | | height: 72, |
| | | fit: BoxFit.cover, |
| | | errorBuilder: (_, __, ___) => Container( |
| | | width: 60, |
| | | height: 60, |
| | | width: 72, |
| | | height: 72, |
| | | color: AppColors.pink, |
| | | child: const Center( |
| | | child: Text('99', |
| | |
| | | color: Colors.white, |
| | | fontWeight: FontWeight.bold))))), |
| | | ), |
| | | const SizedBox(height: 24), |
| | | const SizedBox(height: 26), |
| | | _field(phone, '手机号', Icons.phone_iphone), |
| | | const SizedBox(height: 14), |
| | | _field(pwd, isRegister ? '密码' : '请输入新密码', |
| | |
| | | Icons.lock_outline, |
| | | obscure: true), |
| | | const SizedBox(height: 14), |
| | | // 验证码 |
| | | Row( |
| | | children: [ |
| | | Expanded(child: _field(captcha, '图形验证码', Icons.verified_outlined)), |
| | | const SizedBox(width: 10), |
| | | GestureDetector( |
| | | // 图形验证码(输入框内右侧嵌验证码图,点击图片可刷新) |
| | | _field(captcha, '图形验证码', Icons.verified_outlined, |
| | | suffix: GestureDetector( |
| | | onTap: _refreshCaptcha, |
| | | child: Container( |
| | | width: 110, |
| | | height: 46, |
| | | width: 90, |
| | | height: 32, |
| | | margin: const EdgeInsets.only(right: 7), |
| | | decoration: BoxDecoration( |
| | | color: Colors.white, |
| | | borderRadius: BorderRadius.circular(6), |
| | | color: const Color(0xFF14161F), |
| | | borderRadius: BorderRadius.circular(4), |
| | | ), |
| | | padding: const EdgeInsets.symmetric( |
| | | horizontal: 6, vertical: 4), |
| | | padding: const EdgeInsets.symmetric(horizontal: 4), |
| | | child: ClipRRect( |
| | | borderRadius: BorderRadius.circular(3), |
| | | child: captchaImage ?? |
| | |
| | | fontSize: 11))), |
| | | ), |
| | | ), |
| | | ), |
| | | ], |
| | | ), |
| | | )), |
| | | const SizedBox(height: 24), |
| | | SizedBox( |
| | | width: double.infinity, |
| | |
| | | } |
| | | |
| | | Widget _field(TextEditingController ctrl, String hint, IconData icon, |
| | | {bool obscure = false}) { |
| | | {bool obscure = false, Widget? suffix}) { |
| | | return Container( |
| | | height: 46, |
| | | decoration: BoxDecoration( |
| | |
| | | ), |
| | | ), |
| | | ), |
| | | if (suffix != null) suffix, |
| | | ], |
| | | ), |
| | | ); |