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

802 lines
28 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 "XPMineFuntionItemModel.h"
#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 "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"
2023-09-01 14:29:14 +08:00
#import "LittleGameInfoModel.h"
#import "HomeLittleGameRoomModel.h"
#import "XPLittleGameRoomOpenView.h"
#import "XPMineGameTableViewCell.h"
2023-11-09 15:26:14 +08:00
#import "PISwitchingEnvironmentVC.h"
2023-07-14 18:50:55 +08:00
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) ClanDetailInfoModel *clanInfo;
///
@property (nonatomic,strong) XPMineItemModel *guildItemModel;
///
@property(nonatomic,assign)BOOL isHavePermission;
///
@property (nonatomic,assign) BOOL isRefreshRoomInfo;
2023-11-02 11:14:35 +08:00
2023-09-01 14:29:14 +08:00
///
@property (nonatomic, strong) NSMutableArray<LittleGameInfoModel *> *littleGameArray;
2023-09-12 17:48:18 +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 initSubViews];
[self initSubViewConstraints];
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
2023-07-19 14:41:04 +08:00
self.isRefreshRoomInfo = NO;
2023-07-14 18:50:55 +08:00
[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.presenter getUserInfo];
2024-04-03 21:28:30 +08:00
[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;
}
}];
2023-07-14 18:50:55 +08:00
}
#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];
2023-11-09 15:26:14 +08:00
2023-07-14 18:50:55 +08:00
[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, *)) {//iOS1522
self.tableView.sectionHeaderTopPadding = 0;
}
2023-10-07 18:42:30 +08:00
2023-07-14 18:50:55 +08:00
}
2023-10-07 18:42:30 +08:00
2023-07-14 18:50:55 +08:00
- (void)initSubViewConstraints {
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(0);
}];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view);
make.left.right.bottom.mas_equalTo(self.view);
}];
}
- (void)pushViewControllerWithType:(NSInteger)type functionItem:(XPMineFuntionItemModel *)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_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:
{
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:
{
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:
{
if (self.clanInfo.clan.elderUid.length > 0) {
XPMineClanViewController * clanVC = [[XPMineClanViewController alloc] init];
clanVC.uid = [NSString stringWithFormat:@"%ld", self.userInfo.uid];
[self.navigationController pushViewController:clanVC animated:YES];
} else if(self.clanInfo.hall.hallId.length > 0) {
XPMineGuildViewController * guildVC = [[XPMineGuildViewController alloc] init];
guildVC.ownerUid = self.clanInfo.hall.ownerUid;
guildVC.guildId = self.clanInfo.hall.hallId;
[self.navigationController pushViewController:guildVC animated:YES];
}
}
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){
if( self.clanInfo.clan.elderUid > 0){
XPMineClanViewController * clanVC = [[XPMineClanViewController alloc] init];
clanVC.uid = self.clanInfo.clan.elderUid;
[self.navigationController pushViewController:clanVC animated:YES];
return;
}else {
if(self.clanInfo.hall.ownerUid > 0){
XPMineGuildViewController * hallVC = [[XPMineGuildViewController alloc] init];
hallVC.ownerUid = self.clanInfo.hall.ownerUid;
hallVC.guildId = self.clanInfo.hall.hallId;
[self.navigationController pushViewController:hallVC animated:YES];
return;
}
}
XPMineMainGuildListVC *gulidListVC = [XPMineMainGuildListVC new];
[self.navigationController pushViewController:gulidListVC animated:YES];
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)pushGiveDiamondVC{
XPMineGiveDiamondVC *giveDiamondVC = [[XPMineGiveDiamondVC alloc]init];
giveDiamondVC.userInfo = self.userInfo;
[self.navigationController pushViewController:giveDiamondVC animated:YES];
}
///
-(void)pushThirdPartyPayVC{
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
2023-09-12 17:48:18 +08:00
webVC.type = @"4";
2023-07-14 18:50:55 +08:00
[self.navigationController pushViewController:webVC animated:YES];
}
///
-(void)pushEarningsRecordVC{
XPIncomeRecordVC *incomeRecordVC = [XPIncomeRecordVC new];
incomeRecordVC.clanInfo = self.clanInfo;
incomeRecordVC.userInfo = self.userInfo;
[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];
[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];
2023-07-14 18:50:55 +08:00
}
#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];
}
///
- (void)xPMineHeadViewCliekNobleCenter {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventvipEntranceMeClick];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_noble_card_click];
[self pushViewControllerWithType:XPMineItemType_Noble_Center functionItem:nil];
}
#pragma mark - XPMineProtocol
///
2023-11-02 11:14:35 +08:00
- (void)onGetMineFuntionItemSuccess:(NSArray<XPMineFuntionItemModel *> *)items {
2023-07-14 18:50:55 +08:00
[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];
}
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 (XPMineFuntionItemModel *item in self.functionArray) {
[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
XPMineFuntionItemModel *item = [XPMineFuntionItemModel 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
}
2023-11-02 11:14:35 +08:00
- (void)onGetMineFuntionItemFail{
2023-07-14 18:50:55 +08:00
}
2023-09-01 14:29:14 +08:00
///
2023-11-02 11:14:35 +08:00
- (void)onGetLittleGameListSuccess:(NSArray<LittleGameInfoModel *> *)items {
2023-09-01 14:29:14 +08:00
[self.littleGameArray removeAllObjects];
[self.littleGameArray addObjectsFromArray:items];
2023-11-02 11:14:35 +08:00
2023-09-01 14:29:14 +08:00
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}];
2023-11-02 11:14:35 +08:00
[self.tableView reloadData];
2023-09-01 14:29:14 +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 {
2023-11-02 11:14:35 +08:00
2023-07-14 18:50:55 +08:00
///401
if (!userInfo.isBindPhone && [ClientConfig shareConfig].iosPhoneBind) {
return;
}
if (userInfo.nick == nil || userInfo.avatar == nil ) {
return;
}
2023-11-02 11:14:35 +08:00
self.userInfo = userInfo;
[self.presenter getClanDetailInfo];
[self.presenter getUserWalletInfo];
[self.presenter getPersonItemList];
[self.presenter getLittleGameList];
[self.presenter getMineBannerList];
[self.presenter getNobleInfo];
2023-09-12 17:48:18 +08:00
2023-11-02 11:14:35 +08:00
[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];
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
}
///
2023-11-02 11:14:35 +08:00
- (void)getNobleCenterInfoSuccess:(NobleCenterModel *)model {
2023-07-14 18:50:55 +08:00
self.headView.nobleInfo = model;
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)getNobleCenterInfoFail{
2023-07-14 18:50:55 +08:00
}
///
2023-11-02 11:14:35 +08:00
- (void)onGetClanDetailInfoSuccess:(ClanDetailInfoModel *)clanInfo {
2023-07-14 18:50:55 +08:00
self.clanInfo = clanInfo;
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)onGetClanDetailInfofail{
2023-07-14 18:50:55 +08:00
}
2023-09-12 18:15:48 +08:00
2023-09-01 14:29:14 +08:00
///
- (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];
}
2023-09-12 18:15:48 +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:(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;
}
}
2023-09-01 14:29:14 +08:00
#pragma mark - XPMineGameTableViewCellDelegate
///
- (void)xPMineGameTableViewCell:(XPMineGameTableViewCell *)cell didSelectItem:(LittleGameInfoModel *)item {
[self.presenter quickMatchLittleGameWithMgId:item.mgId];
}
2023-07-14 18:50:55 +08:00
#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;
}
2023-09-01 14:29:14 +08:00
- (NSMutableArray<LittleGameInfoModel *> *)littleGameArray {
if (!_littleGameArray) {
_littleGameArray = [NSMutableArray array];
}
return _littleGameArray;
}
2023-07-14 18:50:55 +08:00
- (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