添加反馈接口

This commit is contained in:
2025-12-17 20:52:23 +08:00
parent 857822c49c
commit 10ba4cd80f
4 changed files with 63 additions and 2 deletions

View File

@@ -12,6 +12,7 @@
#import "KBAPI.h"
//#import <MJExtension/MJExtension.h>
#import "KBMyMainModel.h"
#import "KBHUD.h"
#import "KBSkinService.h"
#import "KBSkinInstallBridge.h"
@@ -230,6 +231,42 @@ NSString * const KBUserCharacterDeletedNotification = @"KBUserCharacterDeletedNo
}
- (void)submitFeedbackWithContent:(NSString *)content
completion:(KBSubmitFeedbackCompletion)completion {
NSString *trim = [content stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (trim.length == 0) {
if (completion) {
NSError *e = [NSError errorWithDomain:KBNetworkErrorDomain
code:KBNetworkErrorInvalidResponse
userInfo:@{NSLocalizedDescriptionKey: KBLocalized(@"Invalid parameter")}];
completion(NO, e);
}
return;
}
NSDictionary *params = @{@"content": trim};
[KBHUD show];
[[KBNetworkManager shared] POST:API_USER_FEEDBACK
jsonBody:params
headers:nil
autoShowBusinessError:YES
completion:^(NSDictionary * _Nullable json,
NSURLResponse * _Nullable response,
NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
[KBHUD dismiss];
if (error) {
NSString *msg = KBBizMessageFromJSONObject(json) ?: error.localizedDescription ?: KBLocalized(@"Network error");
[KBHUD showInfo:msg];
if (completion) completion(NO, error);
return;
}
NSString *message = json[KBMessage] ?: KBLocalized(@"Success");
[KBHUD showSuccess:message];
if (completion) completion(YES, nil);
});
}];
}
- (void)logout{
[KBHUD show];
[[KBNetworkManager shared] GET:API_LOGOUT