Commit 578f1729fa50ae84b9170de38dd17aedc6b417ba
1 parent
2caf5896
fix:修复老bug:修改密码后跳(密码)登录页而非首页
Showing
7 changed files
with
19 additions
and
11 deletions
android/app/build.gradle
... | ... | @@ -93,5 +93,5 @@ dependencies { |
93 | 93 | implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' |
94 | 94 | // kotlin扩展(可选) |
95 | 95 | implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' |
96 | - implementation 'io.keyss.android.library:bjgame:1.0.2' | |
96 | + implementation 'io.keyss.android.library:bjgame:1.0.3' | |
97 | 97 | } | ... | ... |
lib/common/core/user_util.dart
... | ... | @@ -54,7 +54,7 @@ class UserUtil { |
54 | 54 | SpUtil.getInstance().remove(SpConst.prefsKeyUserInfo); |
55 | 55 | } |
56 | 56 | |
57 | - static void logout() { | |
57 | + static void logout([bool showPasswordLoginPage = false]) { | |
58 | 58 | _clearUserData(); |
59 | 59 | // 判断下不在Splash页就跳转 |
60 | 60 | /*var currentPageName = ModalRoute.of(AppRouter.context)?.settings.name; |
... | ... | @@ -62,6 +62,6 @@ class UserUtil { |
62 | 62 | if (currentPageName != AppRouteName.splash) { |
63 | 63 | Navigator.of(AppRouter.context).pushNamedAndRemoveUntil(AppRouteName.login, (route) => false); |
64 | 64 | }*/ |
65 | - Navigator.of(AppRouter.context).pushNamedAndRemoveUntil(AppRouteName.login, (route) => false); | |
65 | + Navigator.of(AppRouter.context).pushNamedAndRemoveUntil(AppRouteName.login, (route) => false, arguments: {'showPasswordPage': showPasswordLoginPage}); | |
66 | 66 | } |
67 | 67 | } | ... | ... |
lib/pages/login/loginpage/bloc/login_bloc.dart
... | ... | @@ -45,7 +45,8 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { |
45 | 45 | |
46 | 46 | bool get canSendSms => _canSendSms; |
47 | 47 | |
48 | - LoginBloc() : super(LoginInitial()) { | |
48 | + LoginBloc(bool preferencesPasswordLogin) : super(LoginInitial()) { | |
49 | + _isSmsLoginType = !preferencesPasswordLogin; | |
49 | 50 | on<RequestLoginEvent>(_requestLoginApi); |
50 | 51 | on<ChangeLoginTypeEvent>(_changeLoginType); |
51 | 52 | on<PhoneNumChangeEvent>(_changePhoneNumber); | ... | ... |
lib/pages/login/loginpage/login_page.dart
... | ... | @@ -11,12 +11,16 @@ import 'package:wow_english/route/route.dart'; |
11 | 11 | import 'bloc/login_bloc.dart'; |
12 | 12 | |
13 | 13 | class LoginPage extends StatelessWidget { |
14 | - const LoginPage({super.key}); | |
14 | + | |
15 | + // 优先展示密码登录 | |
16 | + final bool preferencesPasswordLogin; | |
17 | + | |
18 | + const LoginPage({super.key, this.preferencesPasswordLogin = false}); | |
15 | 19 | |
16 | 20 | @override |
17 | 21 | Widget build(BuildContext context) { |
18 | 22 | return BlocProvider( |
19 | - create: (context) => LoginBloc(), | |
23 | + create: (context) => LoginBloc(preferencesPasswordLogin), | |
20 | 24 | child: _LoginPageView(), |
21 | 25 | ); |
22 | 26 | } |
... | ... | @@ -30,7 +34,7 @@ class _LoginPageView extends StatelessWidget { |
30 | 34 | if (state is LoginResultChangeState) { |
31 | 35 | // 调试用 |
32 | 36 | // Navigator.of(context).pushNamed(AppRouteName.home); |
33 | - pushNamedAndRemoveUntil(AppRouteName.home, (route) => false); | |
37 | + pushNamedAndRemoveUntil(AppRouteName.moduleSelect, (route) => false); | |
34 | 38 | } |
35 | 39 | }, |
36 | 40 | child: _buildLoginViewWidget(), | ... | ... |
lib/pages/login/setpwd/set_pwd_page.dart
... | ... | @@ -7,6 +7,7 @@ import 'package:wow_english/common/widgets/textfield_customer_widget.dart'; |
7 | 7 | import 'package:wow_english/route/route.dart'; |
8 | 8 | import 'package:wow_english/utils/toast_util.dart'; |
9 | 9 | |
10 | +import '../../../common/core/user_util.dart'; | |
10 | 11 | import 'bloc/set_pwd_bloc.dart'; |
11 | 12 | |
12 | 13 | enum SetPwdPageType { |
... | ... | @@ -59,9 +60,9 @@ class _SetPassWordPageView extends StatelessWidget { |
59 | 60 | if (bloc.pageType == SetPwdPageType.initPwd) { |
60 | 61 | showToast('密码设置成功'); |
61 | 62 | } else { |
62 | - showToast('密码修改成功'); | |
63 | + showToast('密码修改成功,请重新登录'); | |
63 | 64 | } |
64 | - pushNamedAndRemoveUntil(AppRouteName.home, (route) => false); | |
65 | + UserUtil.logout(true); | |
65 | 66 | } else if (state is PasswordSetFailedState) { |
66 | 67 | state.message.toast(); |
67 | 68 | } | ... | ... |
lib/pages/user/modify/modify_user_information_page.dart
lib/route/route.dart
... | ... | @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; |
2 | 2 | import 'package:flutter/material.dart'; |
3 | 3 | import 'package:wow_english/app/splash_page.dart'; |
4 | 4 | import 'package:wow_english/common/pages/wow_web_page.dart'; |
5 | +import 'package:wow_english/generated/json/base/json_convert_content.dart'; | |
5 | 6 | import 'package:wow_english/models/product_entity.dart'; |
6 | 7 | import 'package:wow_english/pages/games/view.dart'; |
7 | 8 | import 'package:wow_english/pages/home/home_page.dart'; |
... | ... | @@ -91,7 +92,9 @@ class AppRouter { |
91 | 92 | transitionDuration: Duration.zero, |
92 | 93 | transitionsBuilder: (_, __, ___, child) => child); |
93 | 94 | case AppRouteName.login: |
94 | - return CupertinoPageRoute(builder: (_) => const LoginPage()); | |
95 | + // 是否默认密码登录,修改密码后跳登录页,优先密码登录体验好点 | |
96 | + final bool showPasswordPage = (settings.arguments as Map?)?.getOrNull('showPasswordPage') as bool? ?? false; | |
97 | + return CupertinoPageRoute(builder: (_) => LoginPage(preferencesPasswordLogin: showPasswordPage)); | |
95 | 98 | case AppRouteName.moduleSelect: |
96 | 99 | return CupertinoPageRoute(builder: (_) => const ModuleSelectPage()); |
97 | 100 | case AppRouteName.games: | ... | ... |