Files
peko-ios/YuMi/Modules/YMMine/View/XPMineViewController.m

800 lines
26 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// 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"
2024-04-03 21:28:30 +08:00
#import "Api+NobleCenter.h"
2023-07-14 18:50:55 +08:00
#import "Api+RoomSetting.h"
#import "AccountInfoStorage.h"
#import "ClientConfig.h"
2024-04-03 21:28:30 +08:00
#import "NobleCenterModel.h"
#import "NobleInfo.h"
2023-07-14 18:50:55 +08:00
///Model
#import "XPMineItemModel.h"
#import "UserInfoModel.h"
#import "XPMineVisitorUnReadModel.h"
#import "ClanDetailInfoModel.h"
#import "HomeBannerInfoModel.h"
#import "XPMineFunctionItemModel.h"
2023-07-14 18:50:55 +08:00
#import "WalletInfoModel.h"
2024-04-03 21:28:30 +08:00
2023-07-14 18:50:55 +08:00
///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"
2024-03-26 14:56:55 +08:00
2023-07-14 18:50:55 +08:00
#import "XPWebViewController.h"
#import "XPRoomViewController.h"
#import "MyDressingViewController.h"
#import "ShoppingMallViewController.h"
2023-07-14 18:50:55 +08:00
#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"
2024-09-04 18:26:30 +08:00
#import "VIPCenterViewController.h"
2023-09-01 14:29:14 +08:00
#import "LittleGameInfoModel.h"
#import "HomeLittleGameRoomModel.h"
#import "XPLittleGameRoomOpenView.h"
2023-11-09 15:26:14 +08:00
#import "PISwitchingEnvironmentVC.h"
2024-07-11 10:06:33 +08:00
#import "XPGameOrdersListViewController.h"
2024-09-04 16:11:11 +08:00
#import "VIPCenterViewController.h"
#import "VipSettingViewController.h"
2024-07-11 10:06:33 +08:00
#import "XPSkillCardPlayerManager.h"
2024-07-11 10:06:33 +08:00
2024-07-17 17:49:33 +08:00
UIKIT_EXTERN NSString *kRequestTicket;
2023-07-14 18:50:55 +08:00
@interface XPMineViewController ()<UITableViewDelegate, UITableViewDataSource, XPMineProtocol, XPMineHeadItemTableViewCellDelegate, XPMineHeadViewDelegate, XPHomeBannerTableViewCellDelegate>
@property (nonatomic,strong) UITableView *tableView;
///
@property (nonatomic, strong) NSMutableArray<XPMineFunctionItemModel *> *functionArray;
2023-07-14 18:50:55 +08:00
///banner
@property (nonatomic, strong) NSMutableArray<HomeBannerInfoModel *> *bannerArray;
///
@property (nonatomic,strong) XPMineHeadView *headView;
///
@property (nonatomic,strong) UserInfoModel *userInfo;
///
2024-05-17 19:11:20 +08:00
@property (nonatomic,strong) ClanDetailMainInfoModel *clanInfo;
2023-07-14 18:50:55 +08:00
///
@property (nonatomic,strong) XPMineItemModel *guildItemModel;
///
@property(nonatomic,assign)BOOL isHavePermission;
///
@property (nonatomic,assign) BOOL isRefreshRoomInfo;
2023-11-02 11:14:35 +08:00
2023-07-14 18:50:55 +08:00
@end
@implementation XPMineViewController
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (XPMinePresent *)createPresenter {
return [[XPMinePresent alloc] init];;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [[ClientConfig shareConfig] bgColor];
[self setupTopTheme];
2023-07-14 18:50:55 +08:00
[self initSubViews];
[self initSubViewConstraints];
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
- (void)setupTopTheme {
__block UIImageView *theme = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kGetScaleWidth(140))];
2024-11-06 17:57:32 +08:00
theme.image = [[ClientConfig shareConfig] navigationAreaBG];
theme.contentMode = UIViewContentModeScaleAspectFill;
[self.view addSubview:theme];
[[NSNotificationCenter defaultCenter] addObserverForName:[ClientConfig shareConfig].reloadNavigationAreaImageKey
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification * _Nonnull notification) {
if ([notification.object isKindOfClass:[UIImage class]]) {
theme.image = (UIImage *)notification.object;
}
}];
}
2023-07-14 18:50:55 +08:00
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
2023-07-19 14:41:04 +08:00
self.isRefreshRoomInfo = NO;
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventUserCenter_recharge_card_show];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventUserCenter_noble_card_show];
2023-07-14 18:50:55 +08:00
if([AccountInfoStorage instance].isRequestTicket == NO) {
[self getDataInfo];
}
2024-04-08 18:55:15 +08:00
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
2024-04-08 18:55:15 +08:00
-(void)getDataInfo{
[self.presenter getUserInfo];
2023-07-14 18:50:55 +08:00
}
2023-07-14 18:50:55 +08:00
#pragma mark-
2024-06-05 17:58:26 +08:00
-(void)checkHaveGiveDiamondsPermission{
2023-07-14 18:50:55 +08:00
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 {
XPMineFunctionItemModel *setItem = [XPMineFunctionItemModel new];
2023-07-14 18:50:55 +08:00
setItem.centerName = YMLocalizedString(@"XPMineSettingViewController0");
setItem.centerPic = @"mineview_set";
setItem.skipType = XPMineItemType_My_Setting;
2023-07-14 18:50:55 +08:00
[self.functionArray addObject:setItem];
[self.view addSubview:self.tableView];
// [self.view addSubview:self.settingButton];
self.tableView.tableHeaderView = self.headView;
if (@available(iOS 15.0, *)) {//iOS1522
self.tableView.sectionHeaderTopPadding = 0;
}
}
2023-10-07 18:42:30 +08:00
2023-07-14 18:50:55 +08:00
- (void)initSubViewConstraints {
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view);
2024-04-11 17:05:27 +08:00
make.leading.trailing.bottom.mas_equalTo(self.view);
2023-07-14 18:50:55 +08:00
}];
}
- (void)pushViewControllerWithType:(NSInteger)type functionItem:(XPMineFunctionItemModel *)item {
2023-11-09 15:26:14 +08:00
2023-11-20 14:25:47 +08:00
if([item.centerName isEqualToString:@"切换环境"]){
2023-11-09 15:26:14 +08:00
PISwitchingEnvironmentVC *vc = [PISwitchingEnvironmentVC new];
[self.navigationController pushViewController:vc animated:YES];
return;
}
2023-07-14 18:50:55 +08:00
switch (type) {
case XPMineItemType_My_Setting:{
2023-07-14 18:50:55 +08:00
[self settingButtonAction];
break;
}
case XPMineItemType_Match_Relevance_Account:
[self pushWebViewWithUrl:item.centerUrl];
2023-07-14 18:50:55 +08:00
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:
2023-07-14 18:50:55 +08:00
{
XPMineUserInfoViewController * infoVC = [[XPMineUserInfoViewController alloc] init];
infoVC.uid = self.userInfo.uid;
[self.navigationController pushViewController:infoVC animated:YES];
}
break;
case XPMineItemType_My_Room:
{
2023-09-01 14:29:14 +08:00
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];
2023-07-14 18:50:55 +08:00
}
break;
case XPMineItemType_Collect_Room://
{
XPMineCollectRoomListViewController *collectVC = [[XPMineCollectRoomListViewController alloc] init];
[self.navigationController pushViewController:collectVC animated:YES];
}
break;
case XPMineItemType_My_DressUp:
2023-07-14 18:50:55 +08:00
{
MyDressingViewController * dressUpVC = [[MyDressingViewController alloc] init];
2023-07-14 18:50:55 +08:00
[self.navigationController pushViewController:dressUpVC animated:YES];
}
break;
case XPMineItemType_DressUp_Market:
{
ShoppingMallViewController *dressUpShopVc = [[ShoppingMallViewController alloc] init];
2023-07-14 18:50:55 +08:00
[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:
{
VIPCenterViewController *vc = [[VIPCenterViewController alloc] initWithRoomUid:-1];
2024-09-04 16:11:11 +08:00
[self.navigationController pushViewController:vc animated:YES];
2023-07-14 18:50:55 +08:00
}
break;
case XPMineItemType_FansTeam: {
XPMineFansTeamViewController *fansTeamVc = [[XPMineFansTeamViewController alloc] init];
[self.navigationController pushViewController:fansTeamVc animated:YES];
}
break;
case XPMineItemType_My_Guild:
{
2024-05-17 19:11:20 +08:00
[self clickHallAction];
2023-07-14 18:50:55 +08:00
}
break;
2024-06-04 15:47:22 +08:00
case XPMineItemType_My_Gift:
{
[self pushGiveDiamondVC];
2024-07-11 10:06:33 +08:00
}
break;
case XPMineItemType_My_Game_Order: {
[self toGameOrdersList];
}
break;
case XPMineItemType_My_Item: {
[self toMineItems];
}
break;
case XPMineItemType_VIP_Switch: {
VipSettingViewController *vc = [[VipSettingViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
2024-06-04 15:47:22 +08:00
}
break;
2023-07-14 18:50:55 +08:00
default:
break;
}
}
- (void)toMineItems {
MyDressingViewController *vc = [[MyDressingViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
2024-07-11 10:06:33 +08:00
- (void)toGameOrdersList {
XPGameOrdersListViewController *vc = [[XPGameOrdersListViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
2023-07-14 18:50:55 +08:00
- (void)pushWebViewWithUrl:(NSString *)url {
XPWebViewController * webVC = [[XPWebViewController alloc] initWithRoomUID:nil];
2023-07-14 18:50:55 +08:00
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 {
switch (section) {
case 0:
return 0;
break;
case 1:
return 0;
break;
case 2:
return self.functionArray.count;
break;
default:
return 0;
break;
}
2023-07-14 18:50:55 +08:00
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
case 0:
return 0; // 44
break;
case 1:
return 0; // self.isHavePermission ? 134 : 99
break;
case 2:
return 60;
break;
default:
return 0;
break;
}
2023-07-14 18:50:55 +08:00
}
- (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])];
2024-06-04 19:39:40 +08:00
cell.isHaveGiveDiamond = NO;
2023-07-14 18:50:55 +08:00
@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];
}
XPMineFunctionItemModel *model = self.functionArray[indexPath.row];
2023-07-14 18:50:55 +08:00
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){
2024-05-17 19:11:20 +08:00
[self clickHallAction];
2023-07-14 18:50:55 +08:00
return;
}
if (indexPath.section != 2)return;
XPMineFunctionItemModel *item = self.functionArray[indexPath.row];
// [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventUserCenter_function_click eventAttributes:@{@"functionName" : item.centerName}];
2023-07-14 18:50:55 +08:00
[self pushViewControllerWithType:item.skipType functionItem:item];
}
2024-05-17 19:11:20 +08:00
///
-(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 alloc] initWithRoomUID:nil];
2024-05-17 19:11:20 +08:00
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];
}
}
2023-07-14 18:50:55 +08:00
///
-(void)pushGiveDiamondVC{
XPMineGiveDiamondVC *giveDiamondVC = [[XPMineGiveDiamondVC alloc]init];
giveDiamondVC.userInfo = self.userInfo;
[self.navigationController pushViewController:giveDiamondVC animated:YES];
}
///
-(void)pushThirdPartyPayVC{
2024-05-29 17:14:02 +08:00
[self pushEarningsRecordVC];
2023-07-14 18:50:55 +08:00
}
2024-05-29 17:14:02 +08:00
///
2023-07-14 18:50:55 +08:00
-(void)pushEarningsRecordVC{
XPIncomeRecordVC *incomeRecordVC = [XPIncomeRecordVC new];
2024-05-17 16:57:28 +08:00
2023-07-14 18:50:55 +08:00
[self.navigationController pushViewController:incomeRecordVC animated:YES];
}
///
-(void)pushMyRoomVC{
if(self.isRefreshRoomInfo == YES)return;
2023-09-01 14:29:14 +08:00
self.isRefreshRoomInfo = YES;
NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid];
@kWeakify(self);
2023-09-01 14:29:14 +08:00
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
2023-09-01 14:29:14 +08:00
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];
2023-07-14 18:50:55 +08:00
}
#pragma mark - XPMineHeadViewDelegate
///
- (void)xPMineHeadView:(XPMineHeadView *)view didClickAvatar:(UserInfoModel *)info {
[self pushViewControllerWithType:XPMineItemType_PersonInfo functionItem:nil];
2023-07-14 18:50:55 +08:00
}
///
- (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)xpMineHeadViewClickAccount {
2023-07-14 18:50:55 +08:00
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_recharge_card_click];
[self pushViewControllerWithType:XPMineItemType_Account functionItem:nil];
}
2024-04-11 15:47:44 +08:00
///VIP
- (void)xPMineHeadViewClickNobleCenter {
2023-07-14 18:50:55 +08:00
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventvipEntranceMeClick];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_noble_card_click];
[self pushViewControllerWithType:XPMineItemType_Noble_Center functionItem:nil];
}
- (void)xPMineHeadViewClickAgency {
[self clickHallAction];
}
2023-07-14 18:50:55 +08:00
#pragma mark - XPMineProtocol
///
- (void)onGetMineFuntionItemSuccess:(NSArray<XPMineFunctionItemModel *> *)items {
[self hideHUD];
2023-07-14 18:50:55 +08:00
[self.functionArray removeAllObjects];
[self.functionArray addObjectsFromArray:items];
2025-01-07 20:07:54 +08:00
for (XPMineFunctionItemModel * _Nonnull obj in self.functionArray) {
2024-06-04 15:47:22 +08:00
if(obj.skipType == XPMineItemType_My_Gift && self.isHavePermission == NO){
[self.functionArray removeObject:obj];
break;
}
}
@kWeakify(self);
[self.functionArray enumerateObjectsUsingBlock:^(XPMineFunctionItemModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
@kStrongify(self);
if (obj.skipType == XPMineItemType_CP) {
2023-07-14 18:50:55 +08:00
[self.functionArray removeObject:obj];
}
2023-11-09 15:26:14 +08:00
if([obj.centerName isEqualToString:@"切换分区"]){
[self.functionArray removeObject:obj];
}
2023-07-14 18:50:55 +08:00
}];
NSMutableArray *array = [NSMutableArray array];
for (XPMineFunctionItemModel *item in self.functionArray) {
2023-07-14 18:50:55 +08:00
[array addObject:item.centerName];
}
NSString *trackName = [array componentsJoinedByString:@","];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventUserCenter_function_show eventAttributes:@{@"functionName" : trackName}];
2023-11-09 15:26:14 +08:00
#ifdef DEBUG
XPMineFunctionItemModel *item = [XPMineFunctionItemModel new];
2023-11-20 14:25:47 +08:00
item.centerName = @"切换环境";
2023-11-09 15:26:14 +08:00
item.centerPic = @"mineview_set";
[self.functionArray addObject:item];
#else
#endif
2023-11-02 11:14:35 +08:00
[self.tableView reloadData];
2023-07-14 18:50:55 +08:00
}
- (void)onGetMineFunctionsItemFail{
[self hideHUD];
2023-07-14 18:50:55 +08:00
}
2023-11-02 11:14:35 +08:00
- (void)onGetLittleGameListFail{
2023-09-01 14:29:14 +08:00
}
2023-07-14 18:50:55 +08:00
///banner
2023-11-02 11:14:35 +08:00
- (void)onGetPersonalBannerListSuccess:(NSArray<HomeBannerInfoModel *> *)items {
2023-07-14 18:50:55 +08:00
[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}];
2023-11-02 11:14:35 +08:00
[self.tableView reloadData];
2023-07-14 18:50:55 +08:00
}
2023-11-02 11:14:35 +08:00
-(void)onGetPersonalBannerListFail{
2023-07-14 18:50:55 +08:00
}
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
[XPSkillCardPlayerManager shareInstance].userInfoModel = userInfo;
///401
[self hideHUD];
if (!userInfo.isBindPhone && [ClientConfig shareConfig].iOSPhoneBind) {
return;
}
if (userInfo.nick == nil || userInfo.avatar == nil ) {
return;
}
self.userInfo = userInfo;
[self checkHaveGiveDiamondsPermission];
[self.tableView reloadData];
[self.headView createNamePlateIdLabelAttribute:userInfo];
self.headView.userInfo = userInfo;
// MARK: checkHaveGiveDiamondsPermission
[self.presenter getPersonItemList];
[self.presenter getClanDetailInfo];
[self.presenter getUserWalletInfo];
[self.presenter getNobleInfo];
2023-07-14 18:50:55 +08:00
}
2023-11-02 11:14:35 +08:00
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo{
2023-07-14 18:50:55 +08:00
self.headView.walletInfo = balanceInfo;
2023-11-02 11:14:35 +08:00
[self.tableView reloadData];
2023-07-14 18:50:55 +08:00
}
2023-11-02 11:14:35 +08:00
- (void)getUserWalletInfoFail{
2023-07-14 18:50:55 +08:00
}
2024-04-11 15:47:44 +08:00
///VIP
2023-11-02 11:14:35 +08:00
- (void)getNobleCenterInfoSuccess:(NobleCenterModel *)model {
2023-07-14 18:50:55 +08:00
self.headView.nobleInfo = model;
@kWeakify(self);
2024-09-12 14:01:12 +08:00
[Api vipCenterLevelList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
2024-04-24 20:08:24 +08:00
if (code == 200){
NobleCenterModel *model = [NobleCenterModel modelWithDictionary:data.data];
NobleInfo *vipInfo ;
for (int index = 0; index < model.vipInfos.count; index++) {
NobleInfo *tagInfo = [model.vipInfos xpSafeObjectAtIndex:index];
if (model.currentLevel > 0){
if (tagInfo.vipLevel == model.currentLevel) {
2024-04-24 20:08:24 +08:00
vipInfo = tagInfo;
break;
}
}
}
self.headView.vipInfo = vipInfo;
}
[self.tableView reloadData];
}];
2023-07-14 18:50:55 +08:00
}
2023-11-02 11:14:35 +08:00
-(void)getNobleCenterInfoFail{
2023-07-14 18:50:55 +08:00
}
2023-07-14 18:50:55 +08:00
///
2024-05-17 19:11:20 +08:00
- (void)onGetClanDetailInfoSuccess:(ClanDetailMainInfoModel *)clanInfo {
2023-07-14 18:50:55 +08:00
self.clanInfo = clanInfo;
self.headView.clanModel = clanInfo;
2023-11-02 11:14:35 +08:00
[self.tableView reloadData];
2023-07-14 18:50:55 +08:00
}
2023-09-01 14:29:14 +08:00
2023-07-14 18:50:55 +08:00
#pragma mark - XPMineHeadItemTableViewCellDelegate
- (void)xPMineHeadItemTableViewCell:(XPMineHeadItemTableViewCell *)cell didSelectItem:(XPMineFunctionItemModel *)item {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventUserCenter_function_click eventAttributes:@{@"functionName" : item.centerName}];
2023-07-14 18:50:55 +08:00
[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}];
2023-07-14 18:50:55 +08:00
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]initWithRoomUID:nil];
2023-07-14 18:50:55 +08:00
vc.url = info.skipUri;
[self.navigationController pushViewController:vc animated:YES];
}
break;
default:
break;
}
}
#pragma mark - NSNotification
- (void)onVisitorUnReadCountUpdate:(NSNotification *)noti {
XPMineVisitorUnReadModel *model = (XPMineVisitorUnReadModel *)noti.object;
self.headView.visitorUnReadCount = model.visitNum;
}
2023-07-14 18:50:55 +08:00
#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 = 120;
2023-07-14 18:50:55 +08:00
_headView = [[XPMineHeadView alloc] initWithFrame:CGRectMake(0, 0,KScreenWidth , 146 + height + kStatusBarHeight)];
_headView.delegate = self;
}
return _headView;
}
- (NSMutableArray<XPMineFunctionItemModel *> *)functionArray {
2023-07-14 18:50:55 +08:00
if (!_functionArray) {
_functionArray = [NSMutableArray array];
}
return _functionArray;
}
- (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