feat(mining-app): 找回密码页自动预填登录页的手机号
从登录页跳转至找回密码时,通过 go_router extra 传递手机号, 确保用户无需重新输入,且与数据库记录 100% 一致。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
761fc4369c
commit
424b7fe9d0
|
|
@ -111,7 +111,7 @@ final appRouterProvider = Provider<GoRouter>((ref) {
|
|||
),
|
||||
GoRoute(
|
||||
path: Routes.forgotPassword,
|
||||
builder: (context, state) => const ForgotPasswordPage(),
|
||||
builder: (context, state) => ForgotPasswordPage(initialPhone: state.extra as String?),
|
||||
),
|
||||
GoRoute(
|
||||
path: Routes.changePassword,
|
||||
|
|
|
|||
|
|
@ -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<ForgotPasswordPage> createState() => _ForgotPasswordPageState();
|
||||
|
|
@ -25,6 +27,15 @@ class _ForgotPasswordPageState extends ConsumerState<ForgotPasswordPage> {
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||
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<LoginPage> {
|
|||
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<LoginPage> {
|
|||
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)),
|
||||
|
|
|
|||
Loading…
Reference in New Issue