添加反馈接口

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

@@ -23,6 +23,7 @@
#define API_SEND_EMAIL_VERIFYMAIL @"/user/sendVerifyMail" // 发送验证码 #define API_SEND_EMAIL_VERIFYMAIL @"/user/sendVerifyMail" // 发送验证码
#define API_VERIFY_EMAIL_CODE @"/user/verifyMailCode" // 验证验证码 #define API_VERIFY_EMAIL_CODE @"/user/verifyMailCode" // 验证验证码
#define API_RESET_PWD @"/user/resetPassWord" // 重置密码 #define API_RESET_PWD @"/user/resetPassWord" // 重置密码
#define API_USER_FEEDBACK @"/user/feedback" // 提交反馈

View File

@@ -1,5 +1,7 @@
#import "KBFeedBackVC.h" #import "KBFeedBackVC.h"
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
#import "KBMyVM.h"
#import "KBHUD.h"
@interface KBFeedBackVC () <UITextViewDelegate> @interface KBFeedBackVC () <UITextViewDelegate>
@@ -17,6 +19,8 @@
/// ///
@property (nonatomic, assign) NSInteger maxCount; @property (nonatomic, assign) NSInteger maxCount;
@property (nonatomic, strong) KBMyVM *viewModel;
@end @end
@implementation KBFeedBackVC @implementation KBFeedBackVC
@@ -81,8 +85,16 @@
/// ///
- (void)onTapCommit { - (void)onTapCommit {
NSString *content = self.textView.text ?: @""; NSString *content = [self.textView.text ?: @"" stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
// TODO: + if (content.length == 0) {
[KBHUD showInfo:KBLocalized(@"Please Enter The Content")];
return;
}
__weak typeof(self) weakSelf = self;
[self.viewModel submitFeedbackWithContent:content completion:^(BOOL success, NSError * _Nullable error) {
if (!success) { return; }
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
} }
#pragma mark - UITextViewDelegate #pragma mark - UITextViewDelegate
@@ -161,4 +173,11 @@
return _commitButton; return _commitButton;
} }
- (KBMyVM *)viewModel {
if (!_viewModel) {
_viewModel = [[KBMyVM alloc] init];
}
return _viewModel;
}
@end @end

View File

@@ -25,6 +25,7 @@ typedef void(^KBUpdateCharacterSortCompletion)(BOOL success, NSError * _Nullable
typedef void(^KBDeleteUserCharacterCompletion)(BOOL success, NSError * _Nullable error); typedef void(^KBDeleteUserCharacterCompletion)(BOOL success, NSError * _Nullable error);
typedef void(^KBMyPurchasedThemesCompletion)(NSArray<KBMyTheme *> *_Nullable themes, NSError *_Nullable error); typedef void(^KBMyPurchasedThemesCompletion)(NSArray<KBMyTheme *> *_Nullable themes, NSError *_Nullable error);
typedef void(^KBDeleteThemesCompletion)(BOOL success, NSError *_Nullable error); typedef void(^KBDeleteThemesCompletion)(BOOL success, NSError *_Nullable error);
typedef void(^KBSubmitFeedbackCompletion)(BOOL success, NSError *_Nullable error);
@interface KBMyVM : NSObject @interface KBMyVM : NSObject
@@ -52,6 +53,9 @@ typedef void(^KBDeleteThemesCompletion)(BOOL success, NSError *_Nullable error);
/// 更新用户信息 -(头像、用户名、性别) /// 更新用户信息 -(头像、用户名、性别)
- (void)updateUserInfo:(KBUser *)user completion:(KBUpdateUserInfoCompletion)completion; - (void)updateUserInfo:(KBUser *)user completion:(KBUpdateUserInfoCompletion)completion;
/// 提交反馈POST /user/feedback
- (void)submitFeedbackWithContent:(NSString *)content
completion:(KBSubmitFeedbackCompletion)completion;
/// 退出登录 /// 退出登录
- (void)logout; - (void)logout;

View File

@@ -12,6 +12,7 @@
#import "KBAPI.h" #import "KBAPI.h"
//#import <MJExtension/MJExtension.h> //#import <MJExtension/MJExtension.h>
#import "KBMyMainModel.h" #import "KBMyMainModel.h"
#import "KBHUD.h"
#import "KBSkinService.h" #import "KBSkinService.h"
#import "KBSkinInstallBridge.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{ - (void)logout{
[KBHUD show]; [KBHUD show];
[[KBNetworkManager shared] GET:API_LOGOUT [[KBNetworkManager shared] GET:API_LOGOUT