811 lines
28 KiB
Objective-C
811 lines
28 KiB
Objective-C
//
|
||
// XPMineViewController.m
|
||
// YuMi
|
||
//
|
||
// Created by YuMi on 2021/9/16.
|
||
//
|
||
|
||
#import "XPMineViewController.h"
|
||
///Third
|
||
#import <Masonry/Masonry.h>
|
||
///Tool
|
||
#import "TTPopup.h"
|
||
#import "YUMIHtmlUrl.h"
|
||
#import "UIButton+EnlargeTouchArea.h"
|
||
#import "StatisticsServiceHelper.h"
|
||
#import "YUMIConstant.h"
|
||
#import "Api+Room.h"
|
||
#import "Api+NobleCenter.h"
|
||
#import "Api+RoomSetting.h"
|
||
#import "AccountInfoStorage.h"
|
||
#import "ClientConfig.h"
|
||
#import "NobleCenterModel.h"
|
||
#import "NobleInfo.h"
|
||
///Model
|
||
#import "XPMineItemModel.h"
|
||
#import "UserInfoModel.h"
|
||
#import "XPMineVisitorUnReadModel.h"
|
||
#import "ClanDetailInfoModel.h"
|
||
#import "HomeBannerInfoModel.h"
|
||
#import "XPMineFuntionItemModel.h"
|
||
#import "WalletInfoModel.h"
|
||
|
||
///P
|
||
#import "XPMineProtocol.h"
|
||
#import "XPMinePresent.h"
|
||
///View
|
||
#import "XPMineHeadItemTableViewCell.h"
|
||
#import "XPMineHeadView.h"
|
||
#import "XPHomeBannerTableViewCell.h"
|
||
#import "XPMineNewUserRechargeView.h"
|
||
#import "XPMineTheGuildCell.h"
|
||
#import "XPMinePersonalCenterCell.h"
|
||
#import "XPMineListCell.h"
|
||
///VC
|
||
#import "XPMineSettingViewController.h"
|
||
#import "XPMineUserInfoViewController.h"
|
||
|
||
#import "XPWebViewController.h"
|
||
#import "XPRoomViewController.h"
|
||
#import "XPMineDressUpViewController.h"
|
||
#import "XPDressUpShopViewController.h"
|
||
#import "XPMineFansViewController.h"
|
||
#import "XPMineAttentionViewController.h"
|
||
#import "XPMineVisitorViewController.h"
|
||
#import "XPMineFansTeamViewController.h"
|
||
#import "XPMineClanViewController.h"
|
||
#import "XPMineGuildViewController.h"
|
||
#import "XPMineFootPrintViewController.h"
|
||
#import "XPMineCollectRoomListViewController.h"
|
||
#import "XPMineMainGuildListVC.h"
|
||
#import "XPMineGiveDiamondVC.h"
|
||
#import "XPIAPRechargeViewController.h"
|
||
#import "XPIncomeRecordVC.h"
|
||
#import "XPNobleCenterViewController.h"
|
||
#import "LittleGameInfoModel.h"
|
||
#import "HomeLittleGameRoomModel.h"
|
||
#import "XPLittleGameRoomOpenView.h"
|
||
#import "XPMineGameTableViewCell.h"
|
||
#import "PISwitchingEnvironmentVC.h"
|
||
UIKIT_EXTERN NSString *kRequestRicket;
|
||
|
||
@interface XPMineViewController ()<UITableViewDelegate, UITableViewDataSource, XPMineProtocol, XPMineHeadItemTableViewCellDelegate, XPMineHeadViewDelegate, XPHomeBannerTableViewCellDelegate>
|
||
///顶部背景
|
||
@property (nonatomic, strong) UIView *bgImageView;
|
||
|
||
@property (nonatomic,strong) UITableView *tableView;
|
||
///个人功能
|
||
@property (nonatomic, strong) NSMutableArray<XPMineFuntionItemModel *> *functionArray;
|
||
///banner列表
|
||
@property (nonatomic, strong) NSMutableArray<HomeBannerInfoModel *> *bannerArray;
|
||
///头部
|
||
@property (nonatomic,strong) XPMineHeadView *headView;
|
||
///用户信息
|
||
@property (nonatomic,strong) UserInfoModel *userInfo;
|
||
///家族信息
|
||
@property (nonatomic,strong) ClanDetailMainInfoModel *clanInfo;
|
||
///我的公会
|
||
@property (nonatomic,strong) XPMineItemModel *guildItemModel;
|
||
///转赠钻石权限
|
||
@property(nonatomic,assign)BOOL isHavePermission;
|
||
///点击我的房间时,防止出现多次点击
|
||
@property (nonatomic,assign) BOOL isRefreshRoomInfo;
|
||
|
||
///游戏列表
|
||
@property (nonatomic, strong) NSMutableArray<LittleGameInfoModel *> *littleGameArray;
|
||
|
||
|
||
@end
|
||
|
||
@implementation XPMineViewController
|
||
|
||
|
||
- (void)dealloc {
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||
}
|
||
|
||
- (BOOL)isHiddenNavBar {
|
||
return YES;
|
||
}
|
||
|
||
- (XPMinePresent *)createPresenter {
|
||
return [[XPMinePresent alloc] init];;
|
||
}
|
||
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
[self initSubViews];
|
||
[self initSubViewConstraints];
|
||
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||
|
||
}
|
||
|
||
- (void)viewWillAppear:(BOOL)animated {
|
||
[super viewWillAppear:animated];
|
||
self.isRefreshRoomInfo = NO;
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_recharge_card_show];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_noble_card_show];
|
||
|
||
|
||
}
|
||
|
||
- (void)viewDidAppear:(BOOL)animated {
|
||
[super viewDidAppear:animated];
|
||
if([AccountInfoStorage instance].isRequestRicket == YES)return;
|
||
[self getDataInfo];
|
||
}
|
||
-(void)getDataInfo{
|
||
[self.presenter getUserInfo];
|
||
|
||
}
|
||
#pragma mark- 检查是否有转赠钻石权限
|
||
|
||
-(void)checkHaveGiveDiamondsPermission{
|
||
ClientConfig *config = [ClientConfig shareConfig];
|
||
NSArray *uidList = config.configInfo.giveDiamondErbanNoList;
|
||
for (id uid in uidList) {
|
||
NSString *getUid = [uid stringValue];
|
||
if([getUid isEqualToString:@(self.userInfo.erbanNo).stringValue]){
|
||
self.isHavePermission = YES;
|
||
break;
|
||
}
|
||
}
|
||
if(self.isHavePermission == YES)return;
|
||
for (id uid in config.configInfo.giveGiftErbanNoList) {
|
||
NSString *getUid = [uid stringValue];
|
||
if([getUid isEqualToString:@(self.userInfo.erbanNo).stringValue]){
|
||
self.isHavePermission = YES;
|
||
break;
|
||
}
|
||
}
|
||
if(self.isHavePermission == YES)return;
|
||
if(self.userInfo.userLevelVo.experLevelSeq >= config.configInfo.giveDiamondExperLevel){
|
||
self.isHavePermission = YES;
|
||
return;
|
||
}
|
||
if(self.userInfo.userLevelVo.experLevelSeq >= config.configInfo.giveGiftExperLevel){
|
||
self.isHavePermission = YES;
|
||
}
|
||
}
|
||
|
||
#pragma mark - Response
|
||
- (void)settingButtonAction {
|
||
XPMineSettingViewController * settingVC = [[XPMineSettingViewController alloc] init];
|
||
settingVC.userInfo = self.userInfo;
|
||
[self.navigationController pushViewController:settingVC animated:YES];
|
||
}
|
||
|
||
#pragma mark - Private Method
|
||
- (void)initSubViews {
|
||
XPMineFuntionItemModel *setItem = [XPMineFuntionItemModel new];
|
||
setItem.centerName = YMLocalizedString(@"XPMineSettingViewController0");
|
||
setItem.centerPic = @"mineview_set";
|
||
setItem.skipType = XPMineItemType_My_Set;
|
||
[self.functionArray addObject:setItem];
|
||
|
||
|
||
|
||
[self.view addSubview:self.bgImageView];
|
||
[self.view addSubview:self.tableView];
|
||
// [self.view addSubview:self.settingButton];
|
||
self.tableView.tableHeaderView = self.headView;
|
||
if (@available(iOS 15.0, *)) {//移除iOS15列表头默认增加的22高度
|
||
self.tableView.sectionHeaderTopPadding = 0;
|
||
}
|
||
|
||
}
|
||
|
||
- (void)initSubViewConstraints {
|
||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.leading.trailing.top.mas_equalTo(0);
|
||
}];
|
||
|
||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.mas_equalTo(self.view);
|
||
make.leading.trailing.bottom.mas_equalTo(self.view);
|
||
}];
|
||
}
|
||
|
||
- (void)pushViewControllerWithType:(NSInteger)type functionItem:(XPMineFuntionItemModel *)item {
|
||
|
||
if([item.centerName isEqualToString:@"切换环境"]){
|
||
PISwitchingEnvironmentVC *vc = [PISwitchingEnvironmentVC new];
|
||
[self.navigationController pushViewController:vc animated:YES];
|
||
return;
|
||
}
|
||
|
||
switch (type) {
|
||
case XPMineItemType_My_Set:{
|
||
[self settingButtonAction];
|
||
break;
|
||
}
|
||
case XPMineItemType_Match_Relevance_Account:
|
||
[self pushWebViewWIthUrl:item.centerUrl];
|
||
break;
|
||
case XPMineItemType_Foot_Print:
|
||
{
|
||
XPMineFootPrintViewController *vc = [[XPMineFootPrintViewController alloc] init];
|
||
[self.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
break;
|
||
|
||
case XPMineItemType_Account:
|
||
{
|
||
[self pushThirdPartyPayVC];
|
||
}
|
||
break;
|
||
case XPMineItemType_Personinfo:
|
||
{
|
||
XPMineUserInfoViewController * infoVC = [[XPMineUserInfoViewController alloc] init];
|
||
infoVC.uid = self.userInfo.uid;
|
||
[self.navigationController pushViewController:infoVC animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_My_Room:
|
||
{
|
||
NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid];
|
||
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||
if (code == 200) {
|
||
RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data];
|
||
if (roomInfo.isReselect) {
|
||
XPLittleGameRoomOpenView * roomOpenView = [[XPLittleGameRoomOpenView alloc] init];
|
||
roomOpenView.roomInfo = roomInfo;
|
||
roomOpenView.currentVC = self;
|
||
[TTPopup popupView:roomOpenView style:TTPopupStyleActionSheet];
|
||
} else {
|
||
[XPRoomViewController openRoom:roomUid viewController:self];
|
||
}
|
||
} else {
|
||
[self showErrorToast:msg];
|
||
}
|
||
} uid:roomUid intoUid:roomUid];
|
||
}
|
||
break;
|
||
case XPMineItemType_Collect_Room://收藏房间
|
||
{
|
||
XPMineCollectRoomListViewController *collectVC = [[XPMineCollectRoomListViewController alloc] init];
|
||
[self.navigationController pushViewController:collectVC animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_My_Dressup:
|
||
{
|
||
XPMineDressUpViewController * dressUpVC = [[XPMineDressUpViewController alloc] init];
|
||
[self.navigationController pushViewController:dressUpVC animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_DressUp_Market:
|
||
{
|
||
XPDressUpShopViewController *dressUpShopVc = [[XPDressUpShopViewController alloc] init];
|
||
[self.navigationController pushViewController:dressUpShopVc animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_Fans_List:
|
||
{
|
||
XPMineFansViewController * fansVC = [[XPMineFansViewController alloc] init];
|
||
fansVC.view.backgroundColor = [UIColor whiteColor];
|
||
[self.navigationController pushViewController:fansVC animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_Attention_List:
|
||
{
|
||
XPMineAttentionViewController * attentionVC = [[XPMineAttentionViewController alloc] init];
|
||
[self.navigationController pushViewController:attentionVC animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_Visitor:
|
||
{
|
||
self.headView.visitorUnReadCount = 0;
|
||
XPMineVisitorViewController *visitorVC = [[XPMineVisitorViewController alloc] init];
|
||
[self.navigationController pushViewController:visitorVC animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_Noble_Center:
|
||
{
|
||
XPNobleCenterViewController *nobleCenterVC = [[XPNobleCenterViewController alloc] init];
|
||
[self.navigationController pushViewController:nobleCenterVC animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_FansTeam: {
|
||
XPMineFansTeamViewController *fansTeamVc = [[XPMineFansTeamViewController alloc] init];
|
||
[self.navigationController pushViewController:fansTeamVc animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_My_Guild:
|
||
{
|
||
[self clickHallAction];
|
||
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
- (void)pushWebViewWIthUrl:(NSString *)url {
|
||
XPWebViewController * webVC = [[XPWebViewController alloc] init];
|
||
webVC.url = url;
|
||
[self.navigationController pushViewController:webVC animated:YES];
|
||
}
|
||
|
||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||
return 3;
|
||
}
|
||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||
if (section == 2){
|
||
return self.functionArray.count;
|
||
}
|
||
return 1;
|
||
}
|
||
|
||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
if (indexPath.section == 0) {
|
||
return 44;
|
||
|
||
}else if (indexPath.section == 1) {
|
||
return self.isHavePermission ? 134 : 99;
|
||
}
|
||
return 60;
|
||
}
|
||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
if (indexPath.section == 0) {
|
||
|
||
XPMineTheGuildCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineTheGuildCell class])];
|
||
cell.clanInfo = self.clanInfo;
|
||
|
||
return cell;
|
||
}else if (indexPath.section == 1) {
|
||
XPMinePersonalCenterCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMinePersonalCenterCell class])];
|
||
cell.isHaveGiveDiamond = self.isHavePermission;
|
||
@kWeakify(self)
|
||
cell.clickAction = ^(int type){
|
||
@kStrongify(self)
|
||
if (type == 0){
|
||
[self pushMyRoomVC];
|
||
} else if (type == 1){
|
||
[self pushEarningsRecordVC];
|
||
}else{
|
||
[self pushGiveDiamondVC];
|
||
}
|
||
};
|
||
|
||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
return cell;
|
||
} else {
|
||
XPMineListCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineListCell class])];
|
||
if (indexPath.row == 0 && self.functionArray.count > 1){
|
||
[cell setCornerWithIsTop:YES isBottom:NO];
|
||
}else if (indexPath.row == self.functionArray.count-1){
|
||
if(self.functionArray.count == 1){
|
||
[cell setCornerWithIsTop:YES isBottom:YES];
|
||
}else{
|
||
[cell setCornerWithIsTop:NO isBottom:YES];
|
||
}
|
||
}else{
|
||
[cell setCornerWithIsTop:NO isBottom:NO];
|
||
}
|
||
|
||
XPMineFuntionItemModel *model = self.functionArray[indexPath.row];
|
||
cell.itemModel = model;
|
||
return cell;
|
||
}
|
||
}
|
||
|
||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
||
return 16;
|
||
}
|
||
|
||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
||
UIView * view = [[UIView alloc] init];
|
||
view.backgroundColor = [UIColor clearColor];
|
||
return view;
|
||
}
|
||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
if (indexPath.section == 0){
|
||
[self clickHallAction];
|
||
return;
|
||
}
|
||
if (indexPath.section != 2)return;
|
||
XPMineFuntionItemModel *item = self.functionArray[indexPath.row];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_function_click eventAttributes:@{@"functionName" : item.centerName}];
|
||
[self pushViewControllerWithType:item.skipType functionItem:item];
|
||
}
|
||
///跳转到公会
|
||
-(void)clickHallAction{
|
||
if(self.clanInfo == nil)return;
|
||
if([self.clanInfo.clanMode isEqualToString:@"clan_hall"]){
|
||
if( self.clanInfo.clan.clan.elderUid > 0){
|
||
XPMineClanViewController * clanVC = [[XPMineClanViewController alloc] init];
|
||
clanVC.uid = self.clanInfo.clan.clan.elderUid;
|
||
[self.navigationController pushViewController:clanVC animated:YES];
|
||
return;
|
||
}else {
|
||
if(self.clanInfo.clan.hall.ownerUid > 0){
|
||
XPMineGuildViewController * hallVC = [[XPMineGuildViewController alloc] init];
|
||
hallVC.ownerUid = self.clanInfo.clan.hall.ownerUid;
|
||
hallVC.guildId = self.clanInfo.clan.hall.hallId;
|
||
[self.navigationController pushViewController:hallVC animated:YES];
|
||
return;
|
||
}
|
||
}
|
||
XPMineMainGuildListVC *gulidListVC = [XPMineMainGuildListVC new];
|
||
[self.navigationController pushViewController:gulidListVC animated:YES];
|
||
return;
|
||
}
|
||
if([self.clanInfo.clanMode isEqualToString:@"family"]){
|
||
XPWebViewController *webViewVC = [XPWebViewController new];
|
||
NSString *url = self.clanInfo.family.familyId ? self.clanInfo.family.myFamilyUrl : self.clanInfo.family.familyListUrl;
|
||
if([url hasPrefix:@"/"]){
|
||
url = [url substringFromIndex:1];
|
||
}
|
||
webViewVC.url = url;
|
||
[self.navigationController pushViewController:webViewVC animated:YES];
|
||
|
||
}
|
||
|
||
}
|
||
///转赠钻石
|
||
-(void)pushGiveDiamondVC{
|
||
XPMineGiveDiamondVC *giveDiamondVC = [[XPMineGiveDiamondVC alloc]init];
|
||
giveDiamondVC.userInfo = self.userInfo;
|
||
[self.navigationController pushViewController:giveDiamondVC animated:YES];
|
||
}
|
||
///点击充值
|
||
-(void)pushThirdPartyPayVC{
|
||
[self pushEarningsRecordVC];
|
||
}
|
||
///点击钱包
|
||
-(void)pushEarningsRecordVC{
|
||
|
||
XPIncomeRecordVC *incomeRecordVC = [XPIncomeRecordVC new];
|
||
|
||
[self.navigationController pushViewController:incomeRecordVC animated:YES];
|
||
|
||
}
|
||
///点击我的房间
|
||
-(void)pushMyRoomVC{
|
||
if(self.isRefreshRoomInfo == YES)return;
|
||
self.isRefreshRoomInfo = YES;
|
||
NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid];
|
||
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||
self.isRefreshRoomInfo = NO;
|
||
if (code == 200) {
|
||
RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data];
|
||
if (roomInfo.isReselect) {
|
||
XPLittleGameRoomOpenView * roomOpenView = [[XPLittleGameRoomOpenView alloc] init];
|
||
roomOpenView.roomInfo = roomInfo;
|
||
roomOpenView.currentVC = self;
|
||
[TTPopup popupView:roomOpenView style:TTPopupStyleActionSheet];
|
||
} else {
|
||
[XPRoomViewController openRoom:roomUid viewController:self];
|
||
}
|
||
} else {
|
||
[self showErrorToast:msg];
|
||
}
|
||
} uid:roomUid intoUid:roomUid];
|
||
}
|
||
#pragma mark - XPMineHeadViewDelegate
|
||
///点击头像
|
||
- (void)xPMineHeadView:(XPMineHeadView *)view didClickAvatar:(UserInfoModel *)info {
|
||
[self pushViewControllerWithType:XPMineItemType_Personinfo functionItem:nil];
|
||
}
|
||
|
||
///点击了粉丝
|
||
- (void)xpMineHeadViewClickFans {
|
||
[self pushViewControllerWithType:XPMineItemType_Fans_List functionItem:nil];
|
||
}
|
||
|
||
///点击了关注
|
||
- (void)xpMineHeadViewClickAttention {
|
||
[self pushViewControllerWithType:XPMineItemType_Attention_List functionItem:nil];
|
||
}
|
||
|
||
///点击了技能卡
|
||
- (void)xpMineHeadViewClickSkillCard {
|
||
[self pushViewControllerWithType:XPMineItemType_Skill_Card functionItem:nil];
|
||
}
|
||
|
||
|
||
///点击了账户中心
|
||
- (void)xpMineHeadViewClickAcount {
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_recharge_card_click];
|
||
[self pushViewControllerWithType:XPMineItemType_Account functionItem:nil];
|
||
}
|
||
|
||
///点击了VIP中心
|
||
- (void)xPMineHeadViewCliekNobleCenter {
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventvipEntranceMeClick];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_noble_card_click];
|
||
[self pushViewControllerWithType:XPMineItemType_Noble_Center functionItem:nil];
|
||
}
|
||
|
||
#pragma mark - XPMineProtocol
|
||
///获取个人中心功能
|
||
- (void)onGetMineFuntionItemSuccess:(NSArray<XPMineFuntionItemModel *> *)items {
|
||
[self.functionArray removeAllObjects];
|
||
[self.functionArray addObjectsFromArray:items];
|
||
[self.functionArray enumerateObjectsUsingBlock:^(XPMineFuntionItemModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||
if (obj.skipType == XPMineItemType_CP || obj.skipType == XPMineItemType_My_Room) {
|
||
[self.functionArray removeObject:obj];
|
||
}
|
||
if([obj.centerName isEqualToString:@"切换分区"]){
|
||
[self.functionArray removeObject:obj];
|
||
}
|
||
}];
|
||
NSMutableArray *array = [NSMutableArray array];
|
||
for (XPMineFuntionItemModel *item in self.functionArray) {
|
||
[array addObject:item.centerName];
|
||
}
|
||
NSString *trackName = [array componentsJoinedByString:@","];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_function_show eventAttributes:@{@"functionName" : trackName}];
|
||
#ifdef DEBUG
|
||
XPMineFuntionItemModel *item = [XPMineFuntionItemModel new];
|
||
item.centerName = @"切换环境";
|
||
item.centerPic = @"mineview_set";
|
||
[self.functionArray addObject:item];
|
||
#else
|
||
#endif
|
||
[self.tableView reloadData];
|
||
}
|
||
- (void)onGetMineFuntionItemFail{
|
||
|
||
}
|
||
///获取小游戏列表
|
||
- (void)onGetLittleGameListSuccess:(NSArray<LittleGameInfoModel *> *)items {
|
||
[self.littleGameArray removeAllObjects];
|
||
[self.littleGameArray addObjectsFromArray:items];
|
||
|
||
NSMutableArray *array = [NSMutableArray array];
|
||
for (LittleGameInfoModel *item in self.littleGameArray) {
|
||
[array addObject:item.name];
|
||
}
|
||
NSString *trackName = [array componentsJoinedByString:@","];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_quick_entry_show eventAttributes:@{@"gameName" : trackName}];
|
||
[self.tableView reloadData];
|
||
}
|
||
- (void)onGetLittleGameListFail{
|
||
|
||
}
|
||
///获取个人中心banner
|
||
- (void)onGetPersonalBannerListSuccess:(NSArray<HomeBannerInfoModel *> *)items {
|
||
[self.bannerArray removeAllObjects];
|
||
[self.bannerArray addObjectsFromArray:items];
|
||
NSMutableArray *array = [NSMutableArray array];
|
||
for (HomeBannerInfoModel *item in self.bannerArray) {
|
||
[array addObject:item.bannerId];
|
||
}
|
||
NSString *trackName = [array componentsJoinedByString:@","];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_banner_show eventAttributes:@{@"bannerId" : trackName}];
|
||
[self.tableView reloadData];
|
||
}
|
||
-(void)onGetPersonalBannerListFail{
|
||
|
||
}
|
||
|
||
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
|
||
|
||
|
||
///防止重新注册时,获取到用户信息不全,调用接口时401
|
||
if (!userInfo.isBindPhone && [ClientConfig shareConfig].iosPhoneBind) {
|
||
return;
|
||
}
|
||
if (userInfo.nick == nil || userInfo.avatar == nil ) {
|
||
return;
|
||
}
|
||
self.userInfo = userInfo;
|
||
[self.presenter getClanDetailInfo];
|
||
[self.presenter getUserWalletInfo];
|
||
[self.presenter getPersonItemList];
|
||
[self.presenter getLittleGameList];
|
||
[self.presenter getMineBannerList];
|
||
[self.presenter getNobleInfo];
|
||
|
||
[self checkHaveGiveDiamondsPermission];
|
||
userInfo.idAtt = [self.headView creatNameplateIdLabelAttribute:userInfo];
|
||
[self.headView creatNameplateLevleAttribute:userInfo complete:^(NSMutableAttributedString *textAtt) {
|
||
userInfo.levelAtt = textAtt;
|
||
self.headView.userInfo = userInfo;
|
||
}];
|
||
[self.tableView reloadData];
|
||
|
||
|
||
}
|
||
|
||
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo{
|
||
self.headView.walletInfo = balanceInfo;
|
||
[self.tableView reloadData];
|
||
}
|
||
- (void)getUserWalletInfoFail{
|
||
|
||
}
|
||
///获取VIP信息成功
|
||
- (void)getNobleCenterInfoSuccess:(NobleCenterModel *)model {
|
||
self.headView.nobleInfo = model;
|
||
[Api nobleCenterLevelList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||
if (code == 200){
|
||
NobleCenterModel *model = [NobleCenterModel modelWithDictionary:data.data];
|
||
NobleInfo *vipInfo ;
|
||
for (int index = 0; index < model.vipInfos.count; index++) {
|
||
NobleInfo *tagInfo = [model.vipInfos safeObjectAtIndex1:index];
|
||
|
||
if (model.currLevel > 0){
|
||
if (tagInfo.vipLevel == model.currLevel) {
|
||
vipInfo = tagInfo;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
self.headView.vipInfo = vipInfo;
|
||
}
|
||
[self.tableView reloadData];
|
||
}];
|
||
|
||
}
|
||
-(void)getNobleCenterInfoFail{
|
||
|
||
}
|
||
///获取家族信息成功
|
||
- (void)onGetClanDetailInfoSuccess:(ClanDetailMainInfoModel *)clanInfo {
|
||
self.clanInfo = clanInfo;
|
||
[self.tableView reloadData];
|
||
}
|
||
- (void)onGetClanDetailInfofail{
|
||
|
||
}
|
||
|
||
///匹配游戏房成功
|
||
- (void)quickMatchLittleGameRoomSuccess:(HomeLittleGameRoomModel *)roomInfo mgId:(NSString *)mgId {
|
||
if (roomInfo.isPick && roomInfo.uid.length > 0) {
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_quick_entrysuccess_click eventAttributes:@{@"roomUid" : roomInfo.uid}];
|
||
[XPRoomViewController openRoom:roomInfo.uid viewController:self];
|
||
} else if (roomInfo.needOpenSelfRoom) {
|
||
NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_quick_entrysuccess_click eventAttributes:@{@"roomUid" : roomUid}];
|
||
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||
if (code == 200) {
|
||
RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data];
|
||
if (roomInfo.mgId != [mgId intValue]) {///更新房间游戏类型
|
||
NSMutableDictionary * params = [NSMutableDictionary dictionary];
|
||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
||
[params setObject:ticket forKey:@"ticket"];
|
||
[params setObject:uid forKey:@"uid"];
|
||
[params setObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"];
|
||
if (roomInfo.title.length > 0) {
|
||
[params setObject:roomInfo.title forKey:@"title"];
|
||
}
|
||
if (roomInfo.roomPwd.length > 0) {
|
||
[params setObject:roomInfo.roomPwd forKey:@"roomPwd"];
|
||
} else{
|
||
[params setObject:@"" forKey:@"roomPwd"];
|
||
}
|
||
if (roomInfo.tagId > 0) {
|
||
[params setObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"];
|
||
}
|
||
[params setObject:@(RoomType_MiniGame) forKey:@"type"];
|
||
[params setObject:mgId forKey:@"mgId"];
|
||
[params setObject:@(roomInfo.hasAnimationEffect) forKey:@"hasAnimationEffect"];
|
||
[Api ownerUpdateRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||
if (code == 200) {
|
||
[XPRoomViewController openRoom:[AccountInfoStorage instance].getUid mgId:mgId viewController:self];
|
||
}
|
||
} params:params];
|
||
}
|
||
} else {
|
||
[self showErrorToast:msg];
|
||
}
|
||
} uid:roomUid intoUid:roomUid];
|
||
}
|
||
}
|
||
|
||
///匹配游戏房失败
|
||
- (void)quickMatchLittleGameRoomFail:(NSString *)mgId {
|
||
[XPRoomViewController openRoom:[NSString stringWithFormat:@"%ld", self.userInfo.uid] mgId:mgId viewController:self];
|
||
}
|
||
|
||
|
||
#pragma mark - XPMineHeadItemTableViewCellDelegate
|
||
- (void)xPMineHeadItemTableViewCell:(XPMineHeadItemTableViewCell *)cell didSelectItem:(XPMineFuntionItemModel *)item {
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_function_click eventAttributes:@{@"functionName" : item.centerName}];
|
||
[self pushViewControllerWithType:item.skipType functionItem:item];
|
||
}
|
||
|
||
#pragma mark - XPHomeBannerTableViewCellDelegate
|
||
///点击了某个banner
|
||
- (void)xPHomeBannerTableViewCell:(XPHomeBannerTableViewCell *)view didClickBanner:(HomeBannerInfoModel *)info {
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_banner_click eventAttributes:@{@"bannerId" : info.bannerId}];
|
||
switch (info.skipType) {
|
||
case HomeBannerInfoSkipType_Room:
|
||
{
|
||
if (info.skipUri.length > 0) {
|
||
[XPRoomViewController openRoom:info.skipUri viewController:self];
|
||
}
|
||
}
|
||
break;
|
||
case HomeBannerInfoSkipType_Web:
|
||
{
|
||
XPWebViewController *vc = [[XPWebViewController alloc]init];
|
||
vc.url = info.skipUri;
|
||
[self.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
#pragma mark - XPMineGameTableViewCellDelegate
|
||
///选择了某个游戏
|
||
- (void)xPMineGameTableViewCell:(XPMineGameTableViewCell *)cell didSelectItem:(LittleGameInfoModel *)item {
|
||
[self.presenter quickMatchLittleGameWithMgId:item.mgId];
|
||
}
|
||
|
||
#pragma mark - NSNotification
|
||
- (void)onVisitorUnReadCountUpdate:(NSNotification *)noti {
|
||
XPMineVisitorUnReadModel *model = (XPMineVisitorUnReadModel *)noti.object;
|
||
self.headView.visitorUnReadCount = model.visitNum;
|
||
}
|
||
#pragma mark - Getters And Setters
|
||
- (UITableView *)tableView {
|
||
if (!_tableView) {
|
||
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||
_tableView.delegate = self;
|
||
_tableView.dataSource = self;
|
||
_tableView.showsVerticalScrollIndicator = NO;
|
||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;;
|
||
[_tableView registerClass:[XPMineTheGuildCell class] forCellReuseIdentifier:NSStringFromClass([XPMineTheGuildCell class])];
|
||
[_tableView registerClass:[XPMinePersonalCenterCell class] forCellReuseIdentifier:NSStringFromClass([XPMinePersonalCenterCell class])];
|
||
[_tableView registerClass:[XPMineListCell class] forCellReuseIdentifier:NSStringFromClass([XPMineListCell class])];
|
||
_tableView.backgroundColor = [UIColor clearColor];
|
||
}
|
||
return _tableView;
|
||
}
|
||
|
||
- (XPMineHeadView *)headView {
|
||
if (!_headView) {
|
||
CGFloat height = (KScreenWidth - 30 - 13) * 0.5 * 60 / 166;
|
||
_headView = [[XPMineHeadView alloc] initWithFrame:CGRectMake(0, 0,KScreenWidth , 146 + height + kStatusBarHeight)];
|
||
_headView.delegate = self;
|
||
}
|
||
return _headView;
|
||
}
|
||
|
||
- (UIView *)bgImageView {
|
||
if (!_bgImageView) {
|
||
_bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_head_bg"]];
|
||
_bgImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||
}
|
||
return _bgImageView;
|
||
}
|
||
|
||
- (NSMutableArray<XPMineFuntionItemModel *> *)functionArray {
|
||
if (!_functionArray) {
|
||
_functionArray = [NSMutableArray array];
|
||
}
|
||
return _functionArray;
|
||
}
|
||
- (NSMutableArray<LittleGameInfoModel *> *)littleGameArray {
|
||
if (!_littleGameArray) {
|
||
_littleGameArray = [NSMutableArray array];
|
||
}
|
||
return _littleGameArray;
|
||
}
|
||
|
||
- (NSMutableArray<HomeBannerInfoModel *> *)bannerArray {
|
||
if (!_bannerArray) {
|
||
_bannerArray = [NSMutableArray array];
|
||
}
|
||
return _bannerArray;
|
||
}
|
||
|
||
-(UserInfoModel *)userInfo{
|
||
if(!_userInfo){
|
||
_userInfo = [UserInfoModel new];
|
||
_userInfo.uid = [[AccountInfoStorage instance].getUid integerValue];
|
||
}
|
||
return _userInfo;
|
||
}
|
||
@end
|