Commit 8081bf8e by tanghuan

增加注销用户操作

1 parent ca90354c
......@@ -90,4 +90,16 @@ class AccountCubit extends Cubit<AccountState> {
emit(state.copyWith(phone: result));
}
}
Future<void> unbind() async {
var sharedPreferences = getIt.get<SharedPreferences>();
var userCode = sharedPreferences.getString('auth_userCode') ?? '';
_phoneAuthRepository.unbind(userCode);
// 当前只会成功,不会失败
// 解绑成功,跳转登录界面
router.go('/loginMain');
}
}
......@@ -86,4 +86,20 @@ class PhoneAuthRepository {
);
return resp.statusCode == 200 ? resp.data : null;
}
///
/// {
/// "code": 0,
/// "error": "操作成功"
/// }
///
Future<dynamic> unbind(String userid) async {
Response resp = await _appService.post(
'/api/v1/comm/phone/unbind',
{
"userid": userid,
},
);
return resp.data;
}
}
......@@ -77,7 +77,63 @@ class AccountPage extends StatelessWidget {
},
),
),
// Divider(),
SizedBox(height: 16),
Padding(
padding: EdgeInsets.all(80),
child: SizedBox(
width: double.infinity,
height: 47,
child: ElevatedButton(
onPressed: () async {
final accountCubit = context.read<AccountCubit>();
bool? confirm = await showDialog<bool>(
context: context,
builder: (BuildContext ctx) {
return AlertDialog(
title: Text('确认注销'),
content: Text('您确定要注销当前用户吗?'),
actions: [
TextButton(
onPressed: () {
Navigator.of(ctx).pop(false);
},
child: Text('取消'),
),
TextButton(
onPressed: () {
Navigator.of(ctx).pop(true);
},
child: Text('确认'),
),
],
);
},
);
if (confirm == true) {
accountCubit.unbind();
}
},
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFF7691FA),
foregroundColor: Colors.white,
textStyle: TextStyle(fontSize: 19),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(23.5),
),
),
child: Text(
'注销用户',
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.w400,
color: Color(0xFFFFFFFF),
),
strutStyle: StrutStyle(height: 22 / 19),
),
),
),
),
],
),
),
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!