Browse Source

[new]增加账户注销功能

zk 10 months ago
parent
commit
637b4fa11d

+ 5 - 0
assets/string/base/string.xml

@@ -231,4 +231,9 @@
     <string name="feed_back_submit_txt">提 交</string>
     <string name="feed_back_submit_txt">提 交</string>
     <string name="feed_back_customer_service">联系客服</string>
     <string name="feed_back_customer_service">联系客服</string>
     <string name="feed_back_success">提交成功,感谢您的反馈!</string>
     <string name="feed_back_success">提交成功,感谢您的反馈!</string>
+    <string name="logout_account_content">
+        1.删除账号所有账号信息数据和定位记录;\n2.删除并放弃账号下的会员权益;\n3.点击“确认注销”即开始注销流程不可撤回,请慎重考虑。
+    </string>
+    <string name="logout_account">注销账号</string>
+    <string name="account_logout_success">注销成功</string>
 </resources>
 </resources>

+ 3 - 0
lib/data/api/atmob_api.dart

@@ -131,4 +131,7 @@ abstract class AtmobApi {
   @POST("/s/v1/contact/mayday/all")
   @POST("/s/v1/contact/mayday/all")
   Future<BaseResponse<ContactMayDayAllResponse>> contactMayDayAll(
   Future<BaseResponse<ContactMayDayAllResponse>> contactMayDayAll(
       @Body() AppBaseRequest request);
       @Body() AppBaseRequest request);
+
+  @POST("/s/v1/user/clear")
+  Future<BaseResponse> userClear(@Body() AppBaseRequest request);
 }
 }

+ 37 - 0
lib/data/api/atmob_api.g.dart

@@ -1017,6 +1017,43 @@ class _AtmobApi implements AtmobApi {
     return _value;
     return _value;
   }
   }
 
 
+  @override
+  Future<BaseResponse<dynamic>> userClear(AppBaseRequest request) async {
+    final _extra = <String, dynamic>{};
+    final queryParameters = <String, dynamic>{};
+    final _headers = <String, dynamic>{};
+    final _data = <String, dynamic>{};
+    _data.addAll(request.toJson());
+    final _options = _setStreamType<BaseResponse<dynamic>>(Options(
+      method: 'POST',
+      headers: _headers,
+      extra: _extra,
+    )
+        .compose(
+          _dio.options,
+          '/s/v1/user/clear',
+          queryParameters: queryParameters,
+          data: _data,
+        )
+        .copyWith(
+            baseUrl: _combineBaseUrls(
+          _dio.options.baseUrl,
+          baseUrl,
+        )));
+    final _result = await _dio.fetch<Map<String, dynamic>>(_options);
+    late BaseResponse<dynamic> _value;
+    try {
+      _value = BaseResponse<dynamic>.fromJson(
+        _result.data!,
+        (json) => json as dynamic,
+      );
+    } on Object catch (e, s) {
+      errorLogger?.logError(e, s, _options);
+      rethrow;
+    }
+    return _value;
+  }
+
   RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
   RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
     if (T != dynamic &&
     if (T != dynamic &&
         !(requestOptions.responseType == ResponseType.bytes ||
         !(requestOptions.responseType == ResponseType.bytes ||

+ 4 - 1
lib/data/repositories/account_repository.dart

@@ -67,7 +67,6 @@ class AccountRepository {
     );
     );
     loginPhoneNum.value = KVUtil.getString(keyAccountLoginPhoneNum, null);
     loginPhoneNum.value = KVUtil.getString(keyAccountLoginPhoneNum, null);
 
 
-
     refreshMemberStatus();
     refreshMemberStatus();
     MapHelper.addLocationListener((location) {
     MapHelper.addLocationListener((location) {
       mineUserInfo.value.lastLocation.value =
       mineUserInfo.value.lastLocation.value =
@@ -203,6 +202,10 @@ class AccountRepository {
     return memberStatusInfo.value == null ||
     return memberStatusInfo.value == null ||
         memberStatusInfo.value?.expired == true;
         memberStatusInfo.value?.expired == true;
   }
   }
+
+  Future<void> userClear() {
+    return atmobApi.userClear(AppBaseRequest()).then(HttpHandler.handle(true));
+  }
 }
 }
 
 
 class RequestCodeTooOftenException implements Exception {
 class RequestCodeTooOftenException implements Exception {

+ 25 - 0
lib/dialog/common_alert_dialog_impl.dart

@@ -196,3 +196,28 @@ void sendUrgentContactPartErrorDialog(List<String> phones,
         CommonAlertDialog.dismiss(tag: tag);
         CommonAlertDialog.dismiss(tag: tag);
       });
       });
 }
 }
+
+void logoutAccountDialog(
+    {required VoidCallback logoutCallback,
+    required VoidCallback cancelCallback}) {
+  CommonAlertDialog.show(
+      titleWidget: Text(StringName.logoutAccount,
+          style: TextStyle(
+              fontSize: 17.sp,
+              color: '#333333'.color,
+              fontWeight: FontWeight.bold)),
+      descWidget: Text(
+        StringName.logoutAccountContent,
+        style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
+      ),
+      cancelOnTap: () {
+        CommonAlertDialog.dismiss();
+        logoutCallback.call();
+      },
+      confirmText: StringName.dialogCancel,
+      cancelText: StringName.logoutAccount,
+      confirmOnTap: () {
+        CommonAlertDialog.dismiss();
+        cancelCallback.call();
+      });
+}

+ 4 - 0
lib/dialog/common_confirm_dialog.dart

@@ -11,6 +11,7 @@ class CommonConfirmDialog {
       {required Widget titleWidget,
       {required Widget titleWidget,
       required Widget descWidget,
       required Widget descWidget,
       required String confirmText,
       required String confirmText,
+      String? cancelText,
       VoidCallback? cancelOnTap,
       VoidCallback? cancelOnTap,
       required VoidCallback confirmOnTap,
       required VoidCallback confirmOnTap,
       String tag = _tag}) {
       String tag = _tag}) {
@@ -21,6 +22,7 @@ class CommonConfirmDialog {
               titleWidget: titleWidget,
               titleWidget: titleWidget,
               descWidget: descWidget,
               descWidget: descWidget,
               confirmText: confirmText,
               confirmText: confirmText,
+              cancelText: cancelText,
               cancelOnTap: cancelOnTap,
               cancelOnTap: cancelOnTap,
               confirmOnTap: confirmOnTap);
               confirmOnTap: confirmOnTap);
         });
         });
@@ -35,6 +37,7 @@ class _CommonConfirmDialog extends Dialog {
   final Widget titleWidget;
   final Widget titleWidget;
   final Widget descWidget;
   final Widget descWidget;
   final String confirmText;
   final String confirmText;
+  final String? cancelText;
   final VoidCallback? cancelOnTap;
   final VoidCallback? cancelOnTap;
   final VoidCallback confirmOnTap;
   final VoidCallback confirmOnTap;
 
 
@@ -43,6 +46,7 @@ class _CommonConfirmDialog extends Dialog {
     required this.descWidget,
     required this.descWidget,
     required this.confirmText,
     required this.confirmText,
     this.cancelOnTap,
     this.cancelOnTap,
+    this.cancelText,
     required this.confirmOnTap,
     required this.confirmOnTap,
   });
   });
 
 

+ 2 - 2
lib/dialog/common_confirm_dialog_impl.dart

@@ -112,6 +112,6 @@ void showAgreeAddFriendTipDialog({required VoidCallback onConfirm}) {
         StringName.messageAddFriendSureContent,
         StringName.messageAddFriendSureContent,
         style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
         style: TextStyle(fontSize: 14.sp, color: '#404040'.color),
       ),
       ),
-      confirmText: StringName.gotIt,
+      confirmText: StringName.dialogSure,
       confirmOnTap: onConfirm);
       confirmOnTap: onConfirm);
-}
+}

+ 14 - 1
lib/module/mine/mine_controller.dart

@@ -3,12 +3,14 @@ import 'package:get/get_core/src/get_main.dart';
 import 'package:injectable/injectable.dart';
 import 'package:injectable/injectable.dart';
 import 'package:location/base/base_controller.dart';
 import 'package:location/base/base_controller.dart';
 import 'package:location/data/bean/member_status_info.dart';
 import 'package:location/data/bean/member_status_info.dart';
+import 'package:location/handler/error_handler.dart';
 import 'package:location/module/feedback/feed_back_page.dart';
 import 'package:location/module/feedback/feed_back_page.dart';
 import 'package:location/module/login/login_page.dart';
 import 'package:location/module/login/login_page.dart';
 import 'package:location/module/urgent_contact/urgent_contact_page.dart';
 import 'package:location/module/urgent_contact/urgent_contact_page.dart';
 import 'package:location/resource/string.gen.dart';
 import 'package:location/resource/string.gen.dart';
 import '../../data/repositories/account_repository.dart';
 import '../../data/repositories/account_repository.dart';
 import '../../dialog/common_alert_dialog_impl.dart';
 import '../../dialog/common_alert_dialog_impl.dart';
+import '../../dialog/common_confirm_dialog_impl.dart';
 import '../../sdk/qiyu/qi_yu_helper.dart';
 import '../../sdk/qiyu/qi_yu_helper.dart';
 import '../../sdk/wechat/wechat_share_util.dart';
 import '../../sdk/wechat/wechat_share_util.dart';
 import '../../utils/toast_util.dart';
 import '../../utils/toast_util.dart';
@@ -55,7 +57,18 @@ class MineController extends BaseController {
 
 
   onAboutClick() {}
   onAboutClick() {}
 
 
-  onLogoutAccountClick() {}
+  onLogoutAccountClick() {
+    logoutAccountDialog(
+        logoutCallback: () {
+          accountRepository.userClear().then((_) {
+            ToastUtil.show(StringName.accountLogoutSuccess);
+            accountRepository.logout();
+          }).catchError((error) {
+            ErrorHandler.toastError(error);
+          });
+        },
+        cancelCallback: () {});
+  }
 
 
   onFunExitAccountClick() {
   onFunExitAccountClick() {
     exitAccountDialog(confirmOnTap: () {
     exitAccountDialog(confirmOnTap: () {

+ 7 - 2
lib/resource/string.gen.dart

@@ -189,9 +189,11 @@ class StringName {
   static final String feedBackTitle = 'feed_back_title'.tr; // 意见或建议:
   static final String feedBackTitle = 'feed_back_title'.tr; // 意见或建议:
   static final String feedBackHint = 'feed_back_hint'.tr; // 请详细描述您的问题
   static final String feedBackHint = 'feed_back_hint'.tr; // 请详细描述您的问题
   static final String feedBackSubmitTxt = 'feed_back_submit_txt'.tr; // 提 交
   static final String feedBackSubmitTxt = 'feed_back_submit_txt'.tr; // 提 交
-  static final String feedBackCustomerService =
-      'feed_back_customer_service'.tr; // 联系客服
+  static final String feedBackCustomerService = 'feed_back_customer_service'.tr; // 联系客服
   static final String feedBackSuccess = 'feed_back_success'.tr; // 提交成功,感谢您的反馈!
   static final String feedBackSuccess = 'feed_back_success'.tr; // 提交成功,感谢您的反馈!
+  static final String logoutAccountContent = 'logout_account_content'.tr; // 1.删除账号所有账号信息数据和定位记录;\n2.删除并放弃账号下的会员权益;\n3.点击“确认注销”即开始注销流程不可撤回,请慎重考虑。
+  static final String logoutAccount = 'logout_account'.tr; // 注销账号
+  static final String accountLogoutSuccess = 'account_logout_success'.tr; // 注销成功
 }
 }
 class StringMultiSource {
 class StringMultiSource {
   StringMultiSource._();
   StringMultiSource._();
@@ -386,6 +388,9 @@ class StringMultiSource {
       'feed_back_submit_txt': '提 交',
       'feed_back_submit_txt': '提 交',
       'feed_back_customer_service': '联系客服',
       'feed_back_customer_service': '联系客服',
       'feed_back_success': '提交成功,感谢您的反馈!',
       'feed_back_success': '提交成功,感谢您的反馈!',
+      'logout_account_content': '1.删除账号所有账号信息数据和定位记录;\n2.删除并放弃账号下的会员权益;\n3.点击“确认注销”即开始注销流程不可撤回,请慎重考虑。',
+      'logout_account': '注销账号',
+      'account_logout_success': '注销成功',
     },
     },
   };
   };
 }
 }