添加注销账号
This commit is contained in:
@@ -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;
|
||||
|
||||
/// 获取注销提示信息 HTML(GET /keyboardWarningMessage/byLocale)
|
||||
- (void)fetchCancelAccountWarningWithCompletion:(KBCancelAccountAgreementCompletion)completion;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -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
|
||||
|
||||
/// 清理本地登录态及关联缓存,并回到首页。
|
||||
|
||||
Reference in New Issue
Block a user