Commit b0ebbacd by tanghuan

账号与安全中提示绑定孩子信息

1 parent 6cfc527e
...@@ -12,9 +12,13 @@ class AccountState extends Equatable { ...@@ -12,9 +12,13 @@ class AccountState extends Equatable {
final String nickname; final String nickname;
final String imgIcon; final String imgIcon;
// 孩子信息
final String className; final String className;
final String stuName; final String stuName;
// 是否绑定孩子
final bool bindStu;
const AccountState({ const AccountState({
this.loaded = false, this.loaded = false,
this.name = '', this.name = '',
...@@ -23,7 +27,7 @@ class AccountState extends Equatable { ...@@ -23,7 +27,7 @@ class AccountState extends Equatable {
this.imgIcon = '', this.imgIcon = '',
this.className = '', this.className = '',
this.stuName = '', this.stuName = '',
this.bindStu = true,
}); });
AccountState copyWith({ AccountState copyWith({
...@@ -34,6 +38,7 @@ class AccountState extends Equatable { ...@@ -34,6 +38,7 @@ class AccountState extends Equatable {
String? imgIcon, String? imgIcon,
String? className, String? className,
String? stuName, String? stuName,
bool? bindStu,
}) { }) {
return AccountState( return AccountState(
loaded: loaded ?? this.loaded, loaded: loaded ?? this.loaded,
...@@ -43,6 +48,7 @@ class AccountState extends Equatable { ...@@ -43,6 +48,7 @@ class AccountState extends Equatable {
imgIcon: imgIcon ?? this.imgIcon, imgIcon: imgIcon ?? this.imgIcon,
className: className ?? this.className, className: className ?? this.className,
stuName: stuName ?? this.stuName, stuName: stuName ?? this.stuName,
bindStu: bindStu ?? this.bindStu,
); );
} }
...@@ -55,6 +61,7 @@ class AccountState extends Equatable { ...@@ -55,6 +61,7 @@ class AccountState extends Equatable {
imgIcon, imgIcon,
className, className,
stuName, stuName,
bindStu,
]; ];
} }
...@@ -76,6 +83,7 @@ class AccountCubit extends Cubit<AccountState> { ...@@ -76,6 +83,7 @@ class AccountCubit extends Cubit<AccountState> {
var code = result['code']; var code = result['code'];
var data = result['data']; var data = result['data'];
if (code != 0) { if (code != 0) {
emit(state.copyWith(loaded: true, bindStu: false));
return; return;
} }
......
...@@ -57,158 +57,170 @@ class AccountPage extends StatelessWidget { ...@@ -57,158 +57,170 @@ class AccountPage extends StatelessWidget {
), ),
), ),
body: state.loaded body: state.loaded
? Column( ? (state.bindStu
children: [ ? Column(
// 用户头像和昵称部分 children: [
Container( // 用户头像和昵称部分
padding: EdgeInsets.all(16.0), Container(
child: Column( padding: EdgeInsets.all(16.0),
children: [ child: Column(
CircleAvatar( children: [
radius: 26.0, CircleAvatar(
backgroundImage: NetworkImage(state.imgIcon), radius: 26.0,
), backgroundImage: NetworkImage(state.imgIcon),
SizedBox(height: 16.0),
Text(
state.name,
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
Text(
state.nickname,
style: TextStyle(fontSize: 12.0),
),
...childInfoTable,
],
),
),
// 设置项列表
Expanded(
child: Padding(
padding: EdgeInsets.all(20),
child: ListView(
children: [
Card(
color: Color(0xFFF7F9FF),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
), ),
child: ListTile( SizedBox(height: 16.0),
leading: Icon(Icons.person), Text(
title: Text('用户信息设置'), state.name,
subtitle: Text( style: TextStyle(
'点击设置用户信息', fontSize: 18.0,
style: TextStyle( fontWeight: FontWeight.bold,
fontSize: 14.0,
color: Colors.grey,
),
), ),
trailing: Icon(Icons.arrow_forward_ios, size: 14),
onTap: () {
context.read<AccountCubit>().goSetUserInfo();
},
), ),
), Text(
Card( state.nickname,
color: Color(0xFFF7F9FF), style: TextStyle(fontSize: 12.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
), ),
child: ListTile( ...childInfoTable,
leading: Icon(Icons.mobile_friendly), ],
title: Text('手机号绑定'), ),
subtitle: Text( ),
state.phone != '' // 设置项列表
? '${state.phone.substring(0, 3)}****${state.phone.substring(7, 11)}' Expanded(
: '未绑定', child: Padding(
style: TextStyle( padding: EdgeInsets.all(20),
fontSize: 14.0, child: ListView(
color: Colors.grey, children: [
Card(
color: Color(0xFFF7F9FF),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),
child: ListTile(
leading: Icon(Icons.person),
title: Text('用户信息设置'),
subtitle: Text(
'点击设置用户信息',
style: TextStyle(
fontSize: 14.0,
color: Colors.grey,
),
),
trailing: Icon(Icons.arrow_forward_ios, size: 14),
onTap: () {
context.read<AccountCubit>().goSetUserInfo();
},
), ),
), ),
trailing: Icon(Icons.arrow_forward_ios, size: 14), Card(
onTap: () { color: Color(0xFFF7F9FF),
context.read<AccountCubit>().goBind(); shape: RoundedRectangleBorder(
}, borderRadius: BorderRadius.circular(6),
), ),
), child: ListTile(
SizedBox(height: 16), leading: Icon(Icons.mobile_friendly),
Padding( title: Text('手机号绑定'),
padding: EdgeInsets.all(80), subtitle: Text(
child: SizedBox( state.phone != ''
width: double.infinity, ? '${state.phone.substring(0, 3)}****${state.phone.substring(7, 11)}'
height: 47, : '未绑定',
child: ElevatedButton( style: TextStyle(
onPressed: () async { fontSize: 14.0,
// 判断是否有绑定手机号 color: Colors.grey,
if (state.phone != '') { ),
context.read<AccountCubit>().goLogoff(); ),
return; trailing: Icon(Icons.arrow_forward_ios, size: 14),
} onTap: () {
context.read<AccountCubit>().goBind();
},
),
),
SizedBox(height: 16),
Padding(
padding: EdgeInsets.all(80),
child: SizedBox(
width: double.infinity,
height: 47,
child: ElevatedButton(
onPressed: () async {
// 判断是否有绑定手机号
if (state.phone != '') {
context.read<AccountCubit>().goLogoff();
return;
}
final accountCubit = context.read<AccountCubit>(); final accountCubit = context.read<AccountCubit>();
bool? confirm = await showDialog<bool>( bool? confirm = await showDialog<bool>(
context: context, context: context,
builder: (BuildContext ctx) { builder: (BuildContext ctx) {
return AlertDialog( return AlertDialog(
title: Text('确认注销'), title: Text('确认注销'),
content: Text('您确定要注销当前用户吗?'), content: Text('您确定要注销当前用户吗?'),
actions: [ actions: [
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(ctx).pop(false); Navigator.of(ctx).pop(false);
}, },
child: Text('取消'), child: Text('取消'),
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(ctx).pop(true); Navigator.of(ctx).pop(true);
}, },
child: Text('确认'), child: Text('确认'),
), ),
], ],
);
},
); );
},
);
if (confirm == true) { if (confirm == true) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text('已申请注销,等待流程处理'), content: Text('已申请注销,等待流程处理'),
backgroundColor: Colors.green, backgroundColor: Colors.green,
),
);
accountCubit.unbind();
}
},
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFFE74C3C),
foregroundColor: Colors.white,
textStyle: TextStyle(fontSize: 19),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(23.5),
), ),
); ),
accountCubit.unbind(); child: Text(
} '注销用户',
}, style: TextStyle(
style: ElevatedButton.styleFrom( fontSize: 19,
backgroundColor: Color(0xFFE74C3C), fontWeight: FontWeight.w400,
foregroundColor: Colors.white, color: Color(0xFFFFFFFF),
textStyle: TextStyle(fontSize: 19), ),
shape: RoundedRectangleBorder( strutStyle: StrutStyle(height: 22 / 19),
borderRadius: BorderRadius.circular(23.5), ),
),
),
child: Text(
'注销用户',
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.w400,
color: Color(0xFFFFFFFF),
), ),
strutStyle: StrutStyle(height: 22 / 19),
), ),
), ),
), ],
), ),
], ),
),
],
)
: Container(
alignment: Alignment(0, -0.6),
child: Text(
'暂未关联孩子信息\n\n请在首页操作绑定孩子信息',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.0,
color: Colors.grey,
), ),
), ),
), ))
],
)
: const Center( : const Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!