Files
peko-ios/YuMi/Modules/YMMine/Presenter/XPMinePresent.m
2023-09-12 18:12:11 +08:00

143 lines
5.2 KiB
Objective-C

//
// YMMinePresent.m
// YUMI
//
// Created by YUMI on 2021/9/16.
//
#import "XPMinePresent.h"
///Tool
#import "AccountInfoStorage.h"
#import "StatisticsServiceHelper.h"
///Api
#import "Api+Mine.h"
#import "Api+Guild.h"
#import "Api+Home.h"
#import "Api+LittleGame.h"
///Model
#import "XPMineItemModel.h"
#import "UserInfoModel.h"
#import "ClanDetailInfoModel.h"
#import "XPMineFuntionItemModel.h"
#import "HomeBannerInfoModel.h"
#import "WalletInfoModel.h"
#import "ClanDetailInfoModel.h"
#import "LittleGameInfoModel.h"
#import "HomeLittleGameRoomModel.h"
///Protocol
#import "XPMineProtocol.h"
#import "Api+NobleCenter.h"
#import "NobleCenterModel.h"
@implementation XPMinePresent
/// 获取用户信息
- (void)getUserInfo {
NSString * uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
return;
}
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
[[self getView] onGetUserInfoSuccess:infoModel];
}errorToast:NO] uid:uid];
}
/// 获取钱包信息
- (void)getUserWalletInfoWithGroup:(dispatch_group_t) group {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
if (!uid.length) {
[[self getView]getUserWalletInfoFailWithGroup:group];
return;
}
[Api getUserWalletInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
WalletInfoModel * model = [WalletInfoModel modelWithDictionary:data.data];
[[self getView] getUserWalletInfo:model WithGroup:group];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView]getUserWalletInfoFailWithGroup:group];
}] uid:uid ticket:ticket];
}
/// 获取家族详细的信息
- (void)getClanDetailInfoWithGroup:(dispatch_group_t) group {
NSString * uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
[[self getView]onGetClanDetailInfofailWithGroup:group];
return;
}
[Api getClanDetailInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
ClanDetailInfoModel * clanDetailInfo = [ClanDetailInfoModel modelWithDictionary:data.data];
[[self getView] onGetClanDetailInfoSuccess:clanDetailInfo WithGroup:group];
}fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView]onGetClanDetailInfofailWithGroup:group];
}] uid:uid];
}
///获取个人功能列表
- (void)getPersonItemListWithGroup:(dispatch_group_t) group {
NSString * uid = [[AccountInfoStorage instance] getUid];
if (!uid.length){
[[self getView] onGetMineFuntionItemFailWithGroup:group];
return;
}
[Api requestPersonalFunctionItem:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NSArray *array = [XPMineFuntionItemModel modelsWithArray:data.data];
[[self getView] onGetMineFuntionItemSuccess:array WithGroup:group];
}fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] onGetMineFuntionItemFailWithGroup:group];
}] uid:uid];
}
///获取贵族信息
- (void)getNobleInfoWithGroup:(dispatch_group_t) group {
[Api nobleCenterLevelList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NobleCenterModel *model = [NobleCenterModel modelWithDictionary:data.data];
[[self getView] getNobleCenterInfoSuccess:model WithGroup:group];
}fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] getNobleCenterInfoFailWithGroup:group];
}]];
}
///获取个人中心banner
- (void)getMineBannerListWithGroup:(dispatch_group_t) group {
NSString * uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
[[self getView] onGetPersonalBannerListFailWithGroup:group];
return;
}
[Api requestMineBannerList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NSArray * array = [HomeBannerInfoModel modelsWithArray:data.data];
[[self getView] onGetPersonalBannerListSuccess:array WithGroup:group];
}fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] onGetPersonalBannerListFailWithGroup:group];
} errorToast:NO] uid:uid type:@"10"];
}
///获取小游戏列表
- (void)getLittleGameListWithGroup:(dispatch_group_t) group {
NSString * uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
[[self getView] onGetLittleGameListFailWithGroup:group];
return;
}
[Api getLittleGameList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NSArray * array = [LittleGameInfoModel modelsWithArray:data.data];
[[self getView] onGetLittleGameListSuccess:array WithGroup:group];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] onGetLittleGameListFailWithGroup:group];
} errorToast:NO]];
}
///快速匹配小游戏房
/// @param mgId 游戏ID
- (void)quickMatchLittleGameWithMgId:(NSString *)mgId {
NSString * uid = [AccountInfoStorage instance].getUid;
[Api requestMineQuickMatchLittleGame:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
HomeLittleGameRoomModel *gameRoom = [HomeLittleGameRoomModel modelWithDictionary:data.data];
[[self getView] quickMatchLittleGameRoomSuccess:gameRoom mgId:mgId];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_quick_entry_click eventAttributes:@{@"mgId" : mgId}];
}] uid:uid mgId:mgId];
}
@end