添加注销账号

This commit is contained in:
2026-02-28 14:50:27 +08:00
parent 4269fde923
commit 40ef964b8c
9 changed files with 242 additions and 56 deletions

View File

@@ -32,6 +32,7 @@ typedef void(^KBMyPurchaseRecordCompletion)(NSArray<KBConsumptionRecord *> *_Nul
typedef void(^KBMyInviteCodeCompletion)(KBInviteCodeModel *_Nullable inviteCode, NSError *_Nullable error);
typedef void(^KBMyCustomerMailCompletion)(NSString *_Nullable customerMail, NSError *_Nullable error);
typedef void(^KBCancelAccountCompletion)(BOOL success, NSError *_Nullable error);
typedef void(^KBCancelAccountAgreementCompletion)(NSString *_Nullable html, NSError *_Nullable error);
@interface KBMyVM : NSObject
@@ -81,6 +82,9 @@ typedef void(^KBCancelAccountCompletion)(BOOL success, NSError *_Nullable error)
/// 注销账号(/user/cancelAccount
- (void)cancelAccountWithCompletion:(KBCancelAccountCompletion)completion;
/// 获取注销提示信息 HTMLGET /keyboardWarningMessage/byLocale
- (void)fetchCancelAccountWarningWithCompletion:(KBCancelAccountAgreementCompletion)completion;
@end
NS_ASSUME_NONNULL_END

View File

@@ -489,6 +489,37 @@ NSString * const KBUserCharacterDeletedNotification = @"KBUserCharacterDeletedNo
}];
}
- (void)fetchCancelAccountWarningWithCompletion:(KBCancelAccountAgreementCompletion)completion {
KBLanguageCode langCode = [KBLocalizationManager shared].currentLanguageCode;
NSString *locale;
if ([langCode isEqualToString:KBLanguageCodeSimplifiedChinese]) {
locale = @"zh-CN";
} else {
locale = @"en-US";
}
[[KBNetworkManager shared] GET:API_CANCEL_ACCOUNT_WARNING
parameters:@{@"locale": locale}
headers:nil
autoShowBusinessError:NO
completion:^(NSDictionary *jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error) {
if (completion) completion(nil, error);
return;
}
id dataObj = jsonOrData[KBData];
NSString *html = @"";
if ([dataObj isKindOfClass:[NSDictionary class]]) {
id content = dataObj[@"content"];
if ([content isKindOfClass:[NSString class]]) {
html = (NSString *)content;
}
}
if (completion) completion(html, nil);
}];
}
#pragma mark - Private
///