修改邀请

This commit is contained in:
2025-12-25 13:01:14 +08:00
parent af5f637d31
commit 9968883bab
9 changed files with 78 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
//
// KBInviteCodeModel.h
// keyBoard
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 邀请码信息
@interface KBInviteCodeModel : NSObject
@property (nonatomic, copy, nullable) NSString *inviteCode;
@property (nonatomic, copy, nullable) NSString *h5Link;
@property (nonatomic, assign) NSInteger status;
@property (nonatomic, assign) NSInteger usedCount;
@property (nonatomic, strong, nullable) NSNumber *maxUses;
@property (nonatomic, copy, nullable) NSString *expiresAt;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,17 @@
//
// KBInviteCodeModel.m
// keyBoard
//
#import "KBInviteCodeModel.h"
#import <MJExtension/MJExtension.h>
@implementation KBInviteCodeModel
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
return @{
@"inviteCode": @"code"
};
}
@end

View File

@@ -43,7 +43,7 @@
self.data = @[
@[@{ @"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(@"Share App"), @"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(@"E-mail"), @"icon": @"my_email_icon", @"color": @(0xFF8A65),@"id":@"4" },
@{ @"title": KBLocalized(@"Agreement"), @"icon": @"my_agreement_icon", @"color": @(0x4CD964),@"id":@"5" },

View File

@@ -9,6 +9,7 @@
#import "KBCharacter.h"
#import "KBMyTheme.h"
#import "KBConsumptionRecord.h"
#import "KBInviteCodeModel.h"
@class KBUser;
NS_ASSUME_NONNULL_BEGIN
@@ -28,11 +29,14 @@ typedef void(^KBMyPurchasedThemesCompletion)(NSArray<KBMyTheme *> *_Nullable the
typedef void(^KBDeleteThemesCompletion)(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(^KBMyInviteCodeCompletion)(KBInviteCodeModel *_Nullable inviteCode, NSError *_Nullable error);
@interface KBMyVM : NSObject
/// 获取当前用户详情(/user/detail
- (void)fetchUserDetailWithCompletion:(KBMyUserDetailCompletion)completion;
/// 查询邀请码(/user/inviteCode
- (void)fetchInviteCodeWithCompletion:(KBMyInviteCodeCompletion)completion;
/// 用户人设列表(/character/listByUser
- (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion;

View File

@@ -51,6 +51,31 @@ NSString * const KBUserCharacterDeletedNotification = @"KBUserCharacterDeletedNo
}];
}
- (void)fetchInviteCodeWithCompletion:(KBMyInviteCodeCompletion)completion {
[[KBNetworkManager shared] GET:API_USER_INVITE_CODE
parameters:nil
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] ?: jsonOrData[@"data"];
if (![dataObj isKindOfClass:[NSDictionary class]]) {
NSError *e = [NSError errorWithDomain:KBNetworkErrorDomain
code:KBNetworkErrorInvalidResponse
userInfo:@{NSLocalizedDescriptionKey: KBLocalized(@"Invalid response")}];
if (completion) completion(nil, e);
return;
}
KBInviteCodeModel *model = [KBInviteCodeModel mj_objectWithKeyValues:(NSDictionary *)dataObj];
if (completion) completion(model, nil);
}];
}
- (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion{
[[KBNetworkManager shared] GET:KB_API_CHARACTER_LISTBYUSER
parameters:nil