Kaynağa Gözat

删除账号的逻辑

liukai 4 ay önce
ebeveyn
işleme
7956754707

+ 15 - 2
packages/cpt_auth/lib/modules/setting/setting_controller.dart

@@ -31,11 +31,24 @@ class SettingController extends GetxController with DioCancelableMixin {
       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("确定删除账号");
+        _requestDeactivate();
       },
     ));
   }
 
+  void _requestDeactivate() async {
+    var result = await _authRepository.hotelDeactivate(cancelToken: cancelToken);
+
+    //处理数据
+    if (result.isSuccess) {
+      //清除数据,去首页
+      UserService.to.handleLogoutParams();
+      LoginPage.startWithPopAll();
+    } else {
+      ToastEngine.show(result.errorMsg ?? "Network Load Error".tr);
+    }
+  }
+
   //确定退出登录
   void doLogout() {
     DialogEngine.show(
@@ -54,7 +67,7 @@ class SettingController extends GetxController with DioCancelableMixin {
 
     //处理数据
     if (result.isSuccess) {
-      //保存Token,去首页
+      //清除数据,去首页
       UserService.to.handleLogoutParams();
       LoginPage.startWithPopAll();
     } else {

+ 3 - 0
packages/cs_domain/lib/constants/api_constants.dart

@@ -24,6 +24,9 @@ class ApiConstants {
   //用户注册
   static const apiHotelRegister = "/index.php/api/v1/hotel/register";
 
+  //用户注销
+  static const apiHotelDeactivate = "/index.php/api/v1/hotel/deactivate";
+
   // =========================== 用工请求 ↓=========================================
 
   //筛选条件

+ 21 - 0
packages/cs_domain/lib/repository/auth_repository.dart

@@ -138,4 +138,25 @@ class AuthRepository extends GetxService {
     return result.convert();
   }
 
+  /// 酒店用户注销
+  Future<HttpResult> hotelDeactivate({
+    CancelToken? cancelToken,
+  }) async {
+
+    final result = await httpProvider.requestNetResult(
+      ApiConstants.apiHotelDeactivate,
+      method: HttpMethod.POST,
+      networkDebounce: true,
+      isShowLoadingDialog: true,
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      return result.convert();
+    }
+    return result.convert();
+  }
+
 }