diff --git a/frontend/mining-app/lib/core/router/app_router.dart b/frontend/mining-app/lib/core/router/app_router.dart index a1069baf..3f255173 100644 --- a/frontend/mining-app/lib/core/router/app_router.dart +++ b/frontend/mining-app/lib/core/router/app_router.dart @@ -111,7 +111,7 @@ final appRouterProvider = Provider((ref) { ), GoRoute( path: Routes.forgotPassword, - builder: (context, state) => const ForgotPasswordPage(), + builder: (context, state) => ForgotPasswordPage(initialPhone: state.extra as String?), ), GoRoute( path: Routes.changePassword, diff --git a/frontend/mining-app/lib/presentation/pages/auth/forgot_password_page.dart b/frontend/mining-app/lib/presentation/pages/auth/forgot_password_page.dart index 78919971..80da510d 100644 --- a/frontend/mining-app/lib/presentation/pages/auth/forgot_password_page.dart +++ b/frontend/mining-app/lib/presentation/pages/auth/forgot_password_page.dart @@ -7,7 +7,9 @@ import '../../../core/error/exceptions.dart'; import '../../providers/user_providers.dart'; class ForgotPasswordPage extends ConsumerStatefulWidget { - const ForgotPasswordPage({super.key}); + final String? initialPhone; + + const ForgotPasswordPage({super.key, this.initialPhone}); @override ConsumerState createState() => _ForgotPasswordPageState(); @@ -25,6 +27,15 @@ class _ForgotPasswordPageState extends ConsumerState { int _countDown = 0; bool _sendingSms = false; + @override + void initState() { + super.initState(); + final phone = widget.initialPhone; + if (phone != null && phone.isNotEmpty) { + _phoneController.text = phone; + } + } + @override void dispose() { _phoneController.dispose(); diff --git a/frontend/mining-app/lib/presentation/pages/auth/login_page.dart b/frontend/mining-app/lib/presentation/pages/auth/login_page.dart index df066d29..80510412 100644 --- a/frontend/mining-app/lib/presentation/pages/auth/login_page.dart +++ b/frontend/mining-app/lib/presentation/pages/auth/login_page.dart @@ -70,7 +70,7 @@ class _LoginPageState extends ConsumerState { ElevatedButton( onPressed: () { Navigator.pop(ctx); - context.push(Routes.forgotPassword); + context.push(Routes.forgotPassword, extra: _phoneController.text.trim()); }, style: ElevatedButton.styleFrom(backgroundColor: _orange), child: const Text('找回密码', style: TextStyle(color: Colors.white)), @@ -88,7 +88,7 @@ class _LoginPageState extends ConsumerState { action: SnackBarAction( label: '找回密码', textColor: Colors.white, - onPressed: () => context.push(Routes.forgotPassword), + onPressed: () => context.push(Routes.forgotPassword, extra: _phoneController.text.trim()), ), ), ); @@ -280,7 +280,7 @@ class _LoginPageState extends ConsumerState { Align( alignment: Alignment.centerRight, child: TextButton( - onPressed: () => context.push(Routes.forgotPassword), + onPressed: () => context.push(Routes.forgotPassword, extra: _phoneController.text.trim()), child: Text( '忘记密码?', style: TextStyle(color: AppColors.textSecondaryOf(context)),