新增获取客服接口

This commit is contained in:
2026-02-24 20:45:15 +08:00
parent 0a16a4f240
commit 1c9013bede
6 changed files with 67 additions and 2 deletions

View File

@@ -33,6 +33,7 @@
#define KB_API_USER_DETAIL @"/user/detail" // 用户详情 #define KB_API_USER_DETAIL @"/user/detail" // 用户详情
#define API_USER_INVITE_CODE @"/user/inviteCode" // 查询邀请码 #define API_USER_INVITE_CODE @"/user/inviteCode" // 查询邀请码
#define API_USER_CUSTOMER_MAIL @"/user/customerMail" // 获取客服邮箱
#define API_CHARACTER_LIST @"/character/list" // 排行榜角色列表(综合) #define API_CHARACTER_LIST @"/character/list" // 排行榜角色列表(综合)
#define API_NOT_LOGIN_CHARACTER_LIST @"/character/listWithNotLogin" //未登录用户人设列表 #define API_NOT_LOGIN_CHARACTER_LIST @"/character/listWithNotLogin" //未登录用户人设列表

View File

@@ -82,6 +82,7 @@
"Network error" = "Network error"; "Network error" = "Network error";
"Saved" = "Saved"; "Saved" = "Saved";
"Copy Success" = "Copy Success"; "Copy Success" = "Copy Success";
"Email Copy Success" = "Email Copy Success";
// Network // Network
"Network unavailable" = "Network unavailable"; "Network unavailable" = "Network unavailable";

View File

@@ -83,6 +83,7 @@
"Network error" = "网络错误"; "Network error" = "网络错误";
"Saved" = "已保存"; "Saved" = "已保存";
"Copy Success" = "复制成功"; "Copy Success" = "复制成功";
"Email Copy Success" = "Email Copy Success";
// 网络相关(英文 key // 网络相关(英文 key
"Network unavailable" = "网络不可用"; "Network unavailable" = "网络不可用";

View File

@@ -24,6 +24,7 @@
@property (nonatomic, strong) NSArray<NSArray<NSDictionary *> *> *data; // @property (nonatomic, strong) NSArray<NSArray<NSDictionary *> *> *data; //
@property (nonatomic, strong) UIImageView *bgImageView; // @property (nonatomic, strong) UIImageView *bgImageView; //
@property (nonatomic, strong) KBMyVM *viewModel; // VM @property (nonatomic, strong) KBMyVM *viewModel; // VM
@property (nonatomic, copy) NSString *customerMail; //
@end @end
@implementation MyVC @implementation MyVC
@@ -43,7 +44,7 @@
// title + SF Symbols + my_record_icon // title + SF Symbols + my_record_icon
self.data = @[ self.data = @[
@[@{ @"title": KBLocalized(@"Consumption Record"), @"icon": @"my_record_icon", @"color": @(0x60A3FF),@"id":@"8" }], @[@{ @"title": KBLocalized(@"Consumption Record"), @"icon": @"my_record_icon", @"color": @(0x60A3FF),@"id":@"8" }],
@[@{ @"title": KBLocalized(@"Notice"), @"icon": @"my_notice_icon", @"color": @(0x60A3FF),@"id":@"1" }], // @[@{ @"title": KBLocalized(@"Notice"), @"icon": @"my_notice_icon", @"color": @(0x60A3FF),@"id":@"1" }],
@[@{ @"title": KBLocalized(@"invite"), @"icon": @"my_share_icon", @"color": @(0xF5A623),@"id":@"2" }], @[@{ @"title": KBLocalized(@"invite"), @"icon": @"my_share_icon", @"color": @(0xF5A623),@"id":@"2" }],
@[@{ @"title": KBLocalized(@"Feedback"), @"icon": @"my_feedback_icon", @"color": @(0xB06AFD),@"id":@"3" }, @[@{ @"title": KBLocalized(@"Feedback"), @"icon": @"my_feedback_icon", @"color": @(0xB06AFD),@"id":@"3" },
@{ @"title": KBLocalized(@"E-mail"), @"icon": @"my_email_icon", @"color": @(0xFF8A65),@"id":@"4" }, @{ @"title": KBLocalized(@"E-mail"), @"icon": @"my_email_icon", @"color": @(0xFF8A65),@"id":@"4" },
@@ -63,6 +64,11 @@
self.header = [[KBMyHeaderView alloc] initWithFrame:CGRectMake(0, 0, KB_SCREEN_WIDTH, 357)]; self.header = [[KBMyHeaderView alloc] initWithFrame:CGRectMake(0, 0, KB_SCREEN_WIDTH, 357)];
self.header.backgroundColor = UIColor.clearColor; // self.header.backgroundColor = UIColor.clearColor; //
self.tableView.tableHeaderView = self.header; self.tableView.tableHeaderView = self.header;
if (!self.viewModel) {
self.viewModel = [[KBMyVM alloc] init];
}
[self loadCustomerMailOnce];
} }
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
@@ -81,6 +87,30 @@
// BaseViewController // BaseViewController
/// 1viewDidLoad
- (void)loadCustomerMailOnce {
__weak typeof(self) weakSelf = self;
[self.viewModel fetchCustomerMailWithCompletion:^(NSString * _Nullable customerMail, NSError * _Nullable error) {
if (error) { return; }
dispatch_async(dispatch_get_main_queue(), ^{
__strong typeof(weakSelf) self = weakSelf;
if (!self) { return; }
self.customerMail = customerMail;
});
}];
}
/// 2 E-mail
- (void)handleEmailCopy {
NSString *mail = [self.customerMail stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (mail.length == 0) {
[KBHUD showInfo:KBLocalized(@"Failed")];
return;
}
UIPasteboard.generalPasteboard.string = mail;
[KBHUD showInfo:KBLocalized(@"Email Copy Success")];
}
#pragma mark - UITableView #pragma mark - UITableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.data.count; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.data.count; }
@@ -185,7 +215,7 @@
[self.navigationController pushViewController:[KBFeedBackVC new] animated:true]; [self.navigationController pushViewController:[KBFeedBackVC new] animated:true];
}else if ([itemID isEqualToString:@"4"]){ }else if ([itemID isEqualToString:@"4"]){
[self handleEmailCopy];
}else if ([itemID isEqualToString:@"5"]){ }else if ([itemID isEqualToString:@"5"]){
}else if ([itemID isEqualToString:@"6"]){ }else if ([itemID isEqualToString:@"6"]){

View File

@@ -30,6 +30,7 @@ typedef void(^KBDeleteThemesCompletion)(BOOL success, NSError *_Nullable error);
typedef void(^KBSubmitFeedbackCompletion)(BOOL success, NSError *_Nullable error); typedef void(^KBSubmitFeedbackCompletion)(BOOL success, NSError *_Nullable error);
typedef void(^KBMyPurchaseRecordCompletion)(NSArray<KBConsumptionRecord *> *_Nullable records, NSError *_Nullable error); typedef void(^KBMyPurchaseRecordCompletion)(NSArray<KBConsumptionRecord *> *_Nullable records, NSError *_Nullable error);
typedef void(^KBMyInviteCodeCompletion)(KBInviteCodeModel *_Nullable inviteCode, NSError *_Nullable error); typedef void(^KBMyInviteCodeCompletion)(KBInviteCodeModel *_Nullable inviteCode, NSError *_Nullable error);
typedef void(^KBMyCustomerMailCompletion)(NSString *_Nullable customerMail, NSError *_Nullable error);
@interface KBMyVM : NSObject @interface KBMyVM : NSObject
@@ -37,6 +38,8 @@ typedef void(^KBMyInviteCodeCompletion)(KBInviteCodeModel *_Nullable inviteCode,
- (void)fetchUserDetailWithCompletion:(KBMyUserDetailCompletion)completion; - (void)fetchUserDetailWithCompletion:(KBMyUserDetailCompletion)completion;
/// 查询邀请码(/user/inviteCode /// 查询邀请码(/user/inviteCode
- (void)fetchInviteCodeWithCompletion:(KBMyInviteCodeCompletion)completion; - (void)fetchInviteCodeWithCompletion:(KBMyInviteCodeCompletion)completion;
/// 获取客服邮箱(/user/customerMail
- (void)fetchCustomerMailWithCompletion:(KBMyCustomerMailCompletion)completion;
/// 用户人设列表(/character/listByUser /// 用户人设列表(/character/listByUser
- (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion; - (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion;

View File

@@ -83,6 +83,35 @@ NSString * const KBUserCharacterDeletedNotification = @"KBUserCharacterDeletedNo
}]; }];
} }
- (void)fetchCustomerMailWithCompletion:(KBMyCustomerMailCompletion)completion {
[[KBNetworkManager shared] GET:API_USER_CUSTOMER_MAIL
parameters:nil
headers:nil
autoShowBusinessError:NO
completion:^(NSDictionary *jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error) {
if (completion) completion(nil, error);
return;
}
// { "message":"ok", "data":"123@mail.com", "code":0 }
id dataObj = jsonOrData[@"data"];
NSString *customerMail = [dataObj isKindOfClass:[NSString class]]
? [(NSString *)dataObj stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
: @"";
if (customerMail.length == 0) {
NSError *e = [NSError errorWithDomain:KBNetworkErrorDomain
code:KBNetworkErrorInvalidResponse
userInfo:@{NSLocalizedDescriptionKey: KBLocalized(@"Invalid response")}];
if (completion) completion(nil, e);
return;
}
if (completion) completion(customerMail, nil);
}];
}
- (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion{ - (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion{
[[KBNetworkManager shared] GET:KB_API_CHARACTER_LISTBYUSER [[KBNetworkManager shared] GET:KB_API_CHARACTER_LISTBYUSER
parameters:nil parameters:nil