Commit 98e78864 by tanghuan

手机号登录,未注册时,进行指引

1 parent f6cdbe0f
...@@ -13,6 +13,7 @@ import 'package:shared_preferences/shared_preferences.dart'; ...@@ -13,6 +13,7 @@ import 'package:shared_preferences/shared_preferences.dart';
class LoginPhoneState extends Equatable { class LoginPhoneState extends Equatable {
final bool agreed; final bool agreed;
final bool showAgreed; final bool showAgreed;
final bool showGuide;
final bool allowSend; final bool allowSend;
final int seconds; final int seconds;
...@@ -20,6 +21,7 @@ class LoginPhoneState extends Equatable { ...@@ -20,6 +21,7 @@ class LoginPhoneState extends Equatable {
const LoginPhoneState({ const LoginPhoneState({
this.agreed = false, this.agreed = false,
this.showAgreed = false, this.showAgreed = false,
this.showGuide = false,
this.allowSend = true, this.allowSend = true,
this.seconds = 0, this.seconds = 0,
}); });
...@@ -27,12 +29,14 @@ class LoginPhoneState extends Equatable { ...@@ -27,12 +29,14 @@ class LoginPhoneState extends Equatable {
LoginPhoneState copyWith({ LoginPhoneState copyWith({
bool? agreed, bool? agreed,
bool? showAgreed, bool? showAgreed,
bool? showGuide,
bool? allowSend, bool? allowSend,
int? seconds, int? seconds,
}) { }) {
return LoginPhoneState( return LoginPhoneState(
agreed: agreed ?? this.agreed, agreed: agreed ?? this.agreed,
showAgreed: showAgreed ?? this.showAgreed, showAgreed: showAgreed ?? this.showAgreed,
showGuide: showGuide ?? this.showGuide,
allowSend: allowSend ?? this.allowSend, allowSend: allowSend ?? this.allowSend,
seconds: seconds ?? this.seconds, seconds: seconds ?? this.seconds,
); );
...@@ -42,6 +46,7 @@ class LoginPhoneState extends Equatable { ...@@ -42,6 +46,7 @@ class LoginPhoneState extends Equatable {
List<Object?> get props => [ List<Object?> get props => [
agreed, agreed,
showAgreed, showAgreed,
showGuide,
allowSend, allowSend,
seconds, seconds,
]; ];
...@@ -99,7 +104,16 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> { ...@@ -99,7 +104,16 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> {
// 发送验证码 // 发送验证码
var result = await _phoneAuthRepository.verifyCode(phone, 0); var result = await _phoneAuthRepository.verifyCode(phone, 0);
if (result['code'] != 0) { if (result['code'] != 0) {
Fluttertoast.showToast(msg: result['error'], gravity: ToastGravity.TOP, backgroundColor: Colors.red); final err = result['error'] ?? '';
// 手机号未注册时,打开指引界面
if(err.contains('手机号尚未注册用户')) {
if(!state.showGuide) {
emit(state.copyWith(showGuide: true));
}
return;
}
Fluttertoast.showToast(msg: err, gravity: ToastGravity.TOP, backgroundColor: Colors.red);
return; return;
} }
...@@ -246,6 +260,10 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> { ...@@ -246,6 +260,10 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> {
emit(state.copyWith(showAgreed: false)); emit(state.copyWith(showAgreed: false));
} }
void cancelShowGuide() {
emit(state.copyWith(showGuide: false));
}
void goLoginMain() { void goLoginMain() {
router.go('/loginMain'); router.go('/loginMain');
} }
......
...@@ -123,6 +123,8 @@ class LoginPhonePage extends StatelessWidget { ...@@ -123,6 +123,8 @@ class LoginPhonePage extends StatelessWidget {
listener: (context, state) { listener: (context, state) {
if (state.showAgreed) { if (state.showAgreed) {
_showAgreementDialog(context, context.read<LoginPhoneCubit>()); _showAgreementDialog(context, context.read<LoginPhoneCubit>());
} else if (state.showGuide) {
_showGuideDialog(context, context.read<LoginPhoneCubit>());
} }
}, },
), ),
...@@ -438,4 +440,73 @@ class LoginPhonePage extends StatelessWidget { ...@@ -438,4 +440,73 @@ class LoginPhonePage extends StatelessWidget {
loginPhoneCubit.cancelAgreed(); loginPhoneCubit.cancelAgreed();
} }
} }
Future<void> _showGuideDialog(BuildContext context, LoginPhoneCubit loginPhoneCubit) async {
final result = await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(5),
),
),
title: Text(
'手机号登录指引',
style: TextStyle(
fontSize: 17,
color: Color(0xFF000000),
// fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
content: Text.rich(
TextSpan(
children: [
TextSpan(
// text: '感谢使用班小二APP,为保护您的个人权益,请仔细阅读并充分理解',
text: '输入的手机号尚未绑定用户,需先通过微信方式登录,并成功绑定手机号之后,才可使用手机号进行登录。点击查看',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
TextSpan(
text: '《手机号登录指引》',
style: TextStyle(color: Color(0xFF7691FA), fontSize: 14),
recognizer: TapGestureRecognizer()
..onTap = () {
router.push(
'/link',
extra: {'url': 'https://bxr.banxiaoer.net/apps/privacysettings.html', 'title': '隐私保障'},
);
},
),
TextSpan(
text: ',了解绑定步骤。',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
],
),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop('OK');
},
style: TextButton.styleFrom(
foregroundColor: Color(0xFF7691FA),
textStyle: TextStyle(fontSize: 17),
minimumSize: Size.fromHeight(40),
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: Text('关闭'),
),
],
);
},
);
loginPhoneCubit.cancelShowGuide();
}
} }
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!