1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import 'package:cpt_auth/modules/login/login_page.dart';
- import 'package:cpt_auth/modules/reset_psd/reset_psd_page.dart';
- import 'package:domain/repository/auth_repository.dart';
- import 'package:get/get.dart';
- import 'package:plugin_basic/service/user_service.dart';
- import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
- import 'package:plugin_platform/engine/toast/toast_engine.dart';
- import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
- import 'package:widgets/dialog/app_default_dialog.dart';
- import 'setting_state.dart';
- class SettingController extends GetxController with DioCancelableMixin {
- final AuthRepository _authRepository = Get.find();
- final SettingState state = SettingState();
- //切换账号
- void switchProjects() {
- ToastEngine.show("切换账号");
- }
- //去重置密码页面
- void gotoResetPasswordPage() {
- ResetPasswordPage.startInstance();
- }
- //确定删除账号
- void doAccountDelete() {
- DialogEngine.show(
- widget: AppDefaultDialog(
- title: "Confirmation".tr,
- message: "Are you sure you want to deactivate your account? You will not be able to login into the app once you proceed with the request.".tr,
- confirmAction: () {
- ToastEngine.show("确定删除账号");
- },
- ));
- }
- //确定退出登录
- void doLogout() {
- DialogEngine.show(
- widget: AppDefaultDialog(
- title: "Confirmation".tr,
- message: "Are you sure you need to exit the system?".tr,
- confirmAction: () {
- _requestLogout();
- },
- ));
- }
- /// 请求接口退出账号
- void _requestLogout() async {
- var result = await _authRepository.userLogout(cancelToken: cancelToken);
- //处理数据
- if (result.isSuccess) {
- //保存Token,去首页
- UserService.to.handleLogoutParams();
- LoginPage.startWithPopAll();
- } else {
- ToastEngine.show(result.errorMsg ?? "Network Load Error".tr);
- }
- }
- }
|