773 lines
29 KiB
Objective-C
773 lines
29 KiB
Objective-C
//
|
||
// XPMineViewController.m
|
||
// xplan-ios
|
||
//
|
||
// Created by 冯硕 on 2021/9/16.
|
||
//
|
||
|
||
#import "XPMineViewController.h"
|
||
///Third
|
||
#import <Masonry/Masonry.h>
|
||
#import <IQKeyboardManager.h>
|
||
#import <QYSDK_NIM/QYSDK.h>
|
||
#import <NIMSDK/NIMSDK.h>
|
||
///Tool
|
||
#import "TTPopup.h"
|
||
#import "XPMacro.h"
|
||
#import "XPHtmlUrl.h"
|
||
#import "UIButton+EnlargeTouchArea.h"
|
||
#import "StatisticsServiceHelper.h"
|
||
#import "XPConstant.h"
|
||
#import "Api+Room.h"
|
||
#import "Api+RoomSetting.h"
|
||
#import "AccountInfoStorage.h"
|
||
#import "ClientConfig.h"
|
||
#import "NSMutableDictionary+Saft.h"
|
||
///Model
|
||
#import "XPMineItemModel.h"
|
||
#import "UserInfoModel.h"
|
||
#import "XPMineVisitorUnReadModel.h"
|
||
#import "ClanDetailInfoModel.h"
|
||
#import "HomeBannerInfoModel.h"
|
||
#import "XPMineFuntionItemModel.h"
|
||
#import "WalletInfoModel.h"
|
||
#import "HomeLittleGameRoomModel.h"
|
||
#import "NobleCenterModel.h"
|
||
#import "XPMineMoreItemModel.h"
|
||
///P
|
||
#import "XPMineProtocol.h"
|
||
#import "XPMinePresent.h"
|
||
///View
|
||
#import "XPMineHeadItemTableViewCell.h"
|
||
#import "XPMineHeadView.h"
|
||
#import "XPLittleGameRoomOpenView.h"
|
||
#import "XPMineMoreTableViewCell.h"
|
||
#import "XPHomeBannerTableViewCell.h"
|
||
#import "XPMineNewUserRechargeView.h"
|
||
#import "AnchorLevelView.h"
|
||
///VC
|
||
#import "XPMineSettingViewController.h"
|
||
#import "XPMineTeenagerViewController.h"
|
||
#import "XPMineUserInfoViewController.h"
|
||
#import "XPMineNewRechargeViewController.h"
|
||
#import "XPWebViewController.h"
|
||
#import "XPRoomViewController.h"
|
||
#import "XPMineDressUpViewController.h"
|
||
#import "XPDressUpShopViewController.h"
|
||
#import "XPMineFansViewController.h"
|
||
#import "XPMineAttentionViewController.h"
|
||
#import "XPNobleCenterViewController.h"
|
||
#import "XPMatchManageViewController.h"
|
||
#import "XPSkillCardViewController.h"
|
||
#import "XPMineVisitorViewController.h"
|
||
#import "XPMineFansTeamViewController.h"
|
||
#import "XPMineClanViewController.h"
|
||
#import "XPMineGuildViewController.h"
|
||
#import "XPMineFootPrintViewController.h"
|
||
#import "XPMineCollectRoomListViewController.h"
|
||
#import "XPNewUserRechargeViewController.h"
|
||
#import "XPMineGameOrderVC.h"
|
||
#import "SessionViewController.h"
|
||
|
||
@interface XPMineViewController ()<UITableViewDelegate, UITableViewDataSource, XPMineProtocol, XPMineHeadItemTableViewCellDelegate, XPMineHeadViewDelegate, XPMineMoreTableViewCellDelegate, XPHomeBannerTableViewCellDelegate>
|
||
|
||
@property (nonatomic,strong) UITableView *tableView;
|
||
///个人功能
|
||
@property (nonatomic, strong) NSMutableArray<XPMineFuntionItemModel *> *functionArray;
|
||
///更多列表
|
||
@property (nonatomic, strong) NSArray<XPMineMoreItemModel *> *moreItemArray;
|
||
///banner列表
|
||
@property (nonatomic, strong) NSMutableArray<HomeBannerInfoModel *> *bannerArray;
|
||
///头部
|
||
@property (nonatomic,strong) XPMineHeadView *headView;
|
||
///设置
|
||
@property (nonatomic,strong) UIButton *settingButton;
|
||
///用户信息
|
||
@property (nonatomic,strong) UserInfoModel *userInfo;
|
||
///家族信息
|
||
@property (nonatomic,strong) ClanDetailInfoModel *clanInfo;
|
||
///我的公会
|
||
@property (nonatomic,strong) XPMineItemModel *guildItemModel;
|
||
///新用户充值优惠入口
|
||
@property (nonatomic, strong) XPMineNewUserRechargeView *userRechargeView;
|
||
///主播评级
|
||
@property (nonatomic,strong) AnchorLevelModel *anchorGradeInfo;
|
||
|
||
@end
|
||
|
||
@implementation XPMineViewController
|
||
|
||
|
||
- (void)dealloc {
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||
}
|
||
|
||
- (BOOL)isHiddenNavBar {
|
||
return YES;
|
||
}
|
||
|
||
- (XPMinePresent *)createPresenter {
|
||
return [[XPMinePresent alloc] init];;
|
||
}
|
||
|
||
- (instancetype)init {
|
||
if (self = [super init]) {
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onVisitorUnReadCountUpdate:) name:kVisitorUnReadCountNotificationKey object:nil];
|
||
}
|
||
return self;
|
||
}
|
||
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
[self initSubViews];
|
||
[self initSubViewConstraints];
|
||
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||
}
|
||
|
||
- (void)viewWillAppear:(BOOL)animated {
|
||
[super viewWillAppear:animated];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_recharge_card_show];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_noble_card_show];
|
||
}
|
||
|
||
- (void)viewDidAppear:(BOOL)animated {
|
||
[super viewDidAppear:animated];
|
||
[self.presenter getUserInfo];
|
||
}
|
||
|
||
#pragma mark - Response
|
||
- (void)settingButtonAction:(UIButton *)sender {
|
||
XPMineSettingViewController * settingVC = [[XPMineSettingViewController alloc] init];
|
||
settingVC.userInfo = self.userInfo;
|
||
[self.navigationController pushViewController:settingVC animated:YES];
|
||
}
|
||
|
||
#pragma mark - Private Method
|
||
- (void)initSubViews {
|
||
[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.settingButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.size.mas_equalTo(CGSizeMake(24, 24));
|
||
make.right.mas_equalTo(self.view).offset(-15);
|
||
make.top.mas_equalTo(self.view).offset(kStatusBarHeight + 12);
|
||
}];
|
||
|
||
[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 {
|
||
switch (type) {
|
||
case XPMineItemType_Match_Manage: {
|
||
XPMatchManageViewController *vc = [[XPMatchManageViewController alloc] init];
|
||
[self.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
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_Teenager_Mode:
|
||
{
|
||
XPMineTeenagerViewController * vc = [[XPMineTeenagerViewController alloc] init];
|
||
vc.userInfo = self.userInfo;
|
||
[self.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_Account:
|
||
{
|
||
XPMineNewRechargeViewController * rechargeVC = [[XPMineNewRechargeViewController alloc] init];
|
||
[self.navigationController pushViewController:rechargeVC animated:YES];
|
||
}
|
||
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) {
|
||
if(self.userInfo.isCertified == NO && [ClientConfig shareConfig].configInfo.certificationType > 0){
|
||
[self showRealNameAuthenticationTipsAlertView:@"为了营造更安全的网络环境\n在 开通个人房间前\n需要先进行实名认证" isShowRoom:YES];
|
||
return;
|
||
}
|
||
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];
|
||
[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_Noble_Center:
|
||
{
|
||
XPNobleCenterViewController *nobleCenterVC = [[XPNobleCenterViewController alloc] init];
|
||
[self.navigationController pushViewController:nobleCenterVC animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_Skill_Card:
|
||
{
|
||
XPSkillCardViewController *skillCardVC = [[XPSkillCardViewController alloc] init];
|
||
skillCardVC.uid = self.userInfo.uid;
|
||
[self.navigationController pushViewController:skillCardVC animated:YES];
|
||
}
|
||
break;
|
||
case XPMineItemType_Visitor:
|
||
{
|
||
self.headView.visitorUnReadCount = 0;
|
||
XPMineVisitorViewController *visitorVC = [[XPMineVisitorViewController alloc] init];
|
||
[self.navigationController pushViewController:visitorVC 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;
|
||
case XPMineItemType_Game_Order:
|
||
{
|
||
XPMineGameOrderVC* orderVC = [[XPMineGameOrderVC alloc]init];
|
||
[self.navigationController pushViewController:orderVC 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 {
|
||
if (self.userInfo.parentMode) {
|
||
return 0;
|
||
} else {
|
||
return 3;
|
||
}
|
||
}
|
||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||
return 1;
|
||
}
|
||
|
||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
if (indexPath.section == 0) {
|
||
int page;
|
||
if (self.functionArray.count % 4 == 0) {
|
||
page = (int)self.functionArray.count / 4;
|
||
} else {
|
||
page = (int)self.functionArray.count / 4 + 1;
|
||
}
|
||
if (page > 2) {
|
||
page = 2;
|
||
}
|
||
CGFloat itemHeight = 60;
|
||
CGFloat mineLineSpace = 10;
|
||
CGFloat cellTop = 60;
|
||
if (page == 2) {
|
||
cellTop = 60;
|
||
}
|
||
return (itemHeight * page + mineLineSpace * (page -1) + cellTop);
|
||
} else if (indexPath.section == 1) {
|
||
return 48*self.moreItemArray.count+40;
|
||
} else {
|
||
CGFloat width = KScreenWidth-15*2;
|
||
CGFloat height = 80.0/345.0*width;
|
||
return height+10;
|
||
}
|
||
return 53;
|
||
}
|
||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
if (indexPath.section == 0) {
|
||
XPMineHeadItemTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineHeadItemTableViewCell class])];
|
||
if (self.functionArray.count) {
|
||
cell.datasource = self.functionArray;
|
||
}
|
||
cell.delegate = self;
|
||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
return cell;
|
||
} else if (indexPath.section == 1) {
|
||
XPMineMoreTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineMoreTableViewCell class])];
|
||
cell.dataArray = self.moreItemArray;
|
||
cell.delegate = self;
|
||
return cell;
|
||
} else {
|
||
XPHomeBannerTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])];
|
||
cell.isMineViewBanner = YES;
|
||
if (self.bannerArray.count) {
|
||
cell.bannerList = self.bannerArray;
|
||
}
|
||
cell.delegate = self;
|
||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
return cell;
|
||
}
|
||
}
|
||
|
||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
||
return 12;
|
||
}
|
||
|
||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
||
UIView * view = [[UIView alloc] init];
|
||
view.backgroundColor = [UIColor clearColor];
|
||
return view;
|
||
}
|
||
|
||
#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)xpMineHeadViewClickVisitor {
|
||
|
||
|
||
[self pushViewControllerWithType:XPMineItemType_Visitor functionItem:nil];
|
||
}
|
||
|
||
///点击了足迹
|
||
- (void)xpMineHeadViewClickFootprint {
|
||
[self pushViewControllerWithType:XPMineItemType_Foot_Print functionItem:nil];
|
||
}
|
||
|
||
/// 点击了我的等级
|
||
- (void)xPMineHeadViewClickMyGrade {
|
||
|
||
NSString *appVersion = [YYUtility appVersion];
|
||
appVersion = [appVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
|
||
NSString *url = [NSString stringWithFormat:@"%@?appVersionCode=%@",URLWithType(kUserLevelURL),appVersion];
|
||
[self pushWebViewWIthUrl:url];
|
||
}
|
||
|
||
/// 点击了我的房间
|
||
- (void)xPMineHeadViewClickMyRoom {
|
||
[self pushViewControllerWithType:XPMineItemType_My_Room functionItem:nil];
|
||
}
|
||
|
||
///点击了账户中心
|
||
- (void)xpMineHeadViewClickWallet {
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_recharge_card_click];
|
||
[self pushViewControllerWithType:XPMineItemType_Account functionItem:nil];
|
||
}
|
||
|
||
///点击了贵族中心
|
||
- (void)xPMineHeadViewClickNoble {
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventvipEntranceMeClick];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_noble_card_click];
|
||
[self pushViewControllerWithType:XPMineItemType_Noble_Center functionItem:nil];
|
||
}
|
||
|
||
///点击了青少年模式
|
||
- (void)xPmineHeadViewClickTeenager {
|
||
[self pushViewControllerWithType:XPMineItemType_Teenager_Mode functionItem:nil];
|
||
}
|
||
|
||
- (void)xPMineHeadView:(XPMineHeadView *)view didClickAnchorLevel:(AnchorLevelModel *)info {
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventRoom_grade_profit_pop_click];
|
||
@kWeakify(self);
|
||
[self.presenter getAnchorGradeInfoCompletion:^(AnchorLevelModel * _Nonnull info) {
|
||
@kStrongify(self);
|
||
self.headView.anchorLevelInfo = info;
|
||
AnchorLevelView * gradeView = [[AnchorLevelView alloc] init];
|
||
gradeView.levelInfo = info;
|
||
TTPopupService * config = [[TTPopupService alloc] init];
|
||
config.contentView = gradeView;
|
||
@kWeakify(gradeView);
|
||
config.didFinishDismissHandler = ^(BOOL isDismissOnBackgroundTouch) {
|
||
@kStrongify(gradeView);
|
||
[gradeView stopCountDown];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventRoom_grade_profit_close_click];
|
||
};
|
||
[TTPopup popupWithConfig:config];
|
||
}];
|
||
}
|
||
|
||
#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) {
|
||
[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}];
|
||
[self.tableView reloadData];
|
||
}
|
||
|
||
///获取个人中心banner
|
||
- (void)onGetPersonalBannerListSuccess:(NSArray<HomeBannerInfoModel *> *)items {
|
||
[self.bannerArray removeAllObjects];
|
||
[self.bannerArray addObjectsFromArray:items];
|
||
[self.tableView reloadData];
|
||
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}];
|
||
}
|
||
|
||
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
|
||
///防止重新注册时,获取到用户信息不全,调用接口时401
|
||
if (!userInfo.isBindPhone && [ClientConfig shareConfig].iosPhoneBind) {
|
||
return;
|
||
}
|
||
if (userInfo.nick == nil || userInfo.avatar == nil) {
|
||
return;
|
||
}
|
||
self.userInfo = userInfo;
|
||
self.headView.userInfo = userInfo;
|
||
[self.tableView reloadData];
|
||
if (userInfo.parentMode) {
|
||
if (self.userRechargeView.superview) {
|
||
[self.userRechargeView removeFromSuperview];
|
||
self.userRechargeView = nil;
|
||
}
|
||
return;
|
||
}
|
||
[self.presenter getClanDetailInfo];
|
||
// [self.presenter getUserWalletInfo];
|
||
[self.presenter getPersonItemList];
|
||
// [self.presenter getLittleGameList];
|
||
[self.presenter getMineBannerList];
|
||
// [self.presenter getNobleInfo];
|
||
if (userInfo.showLimitCharge) {//新用户充值优惠
|
||
if (!self.userRechargeView.superview) {
|
||
[self.view addSubview:self.userRechargeView];
|
||
[self.userRechargeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(0);
|
||
make.top.mas_equalTo(kNavigationHeight + 80);
|
||
make.size.mas_equalTo(CGSizeMake(74, 88));
|
||
}];
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventUsercenterNugiftPopShow];
|
||
}
|
||
self.userRechargeView.endTime = userInfo.limitChargeEndTime;
|
||
} else {
|
||
[self.userRechargeView removeFromSuperview];
|
||
self.userRechargeView = nil;
|
||
}
|
||
}
|
||
|
||
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo {
|
||
self.headView.walletInfo = balanceInfo;
|
||
}
|
||
|
||
///获取贵族信息成功
|
||
- (void)getNobleCenterInfoSuccess:(NobleCenterModel *)model {
|
||
self.headView.nobleInfo = model;
|
||
}
|
||
|
||
///获取家族信息成功
|
||
- (void)onGetClanDetailInfoSuccess:(ClanDetailInfoModel *)clanInfo {
|
||
self.clanInfo = clanInfo;
|
||
// if (self.clanInfo.hall.hallId > 0 && self.clanInfo.hall.ownerUid.integerValue != [AccountInfoStorage instance].getUid.integerValue && !clanInfo.clan.userIsElder) {
|
||
// [self.presenter getAnchorGradeInfo];
|
||
// }
|
||
}
|
||
|
||
///匹配游戏房成功
|
||
- (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 safeSetObject:ticket forKey:@"ticket"];
|
||
[params safeSetObject:uid forKey:@"uid"];
|
||
[params safeSetObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"];
|
||
if (roomInfo.title.length > 0) {
|
||
[params safeSetObject:roomInfo.title forKey:@"title"];
|
||
}
|
||
if (roomInfo.roomPwd.length > 0) {
|
||
[params safeSetObject:roomInfo.roomPwd forKey:@"roomPwd"];
|
||
} else{
|
||
[params safeSetObject:@"" forKey:@"roomPwd"];
|
||
}
|
||
if (roomInfo.tagId > 0) {
|
||
[params safeSetObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"];
|
||
}
|
||
[params safeSetObject:@(RoomType_MiniGame) forKey:@"type"];
|
||
[params safeSetObject:mgId forKey:@"mgId"];
|
||
[params safeSetObject:@(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];
|
||
}
|
||
|
||
- (void)getAnchorGradeInfoSuccess:(AnchorLevelModel *)info {
|
||
self.anchorGradeInfo = info;
|
||
self.headView.anchorLevelInfo = info;
|
||
}
|
||
|
||
#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 - XPMineMoreTableViewCellDelegate
|
||
|
||
- (void)mineMoreTableViewCellClick:(XPMineMoreItemModel *)itemModel {
|
||
switch (itemModel.itemType) {
|
||
case XPMineItemType_Identity: {
|
||
[self pushWebViewWIthUrl:URLWithType(kIdentityURL)];
|
||
}
|
||
break;
|
||
case XPMineItemType_Teenager_Mode: {
|
||
[self pushViewControllerWithType:XPMineItemType_Teenager_Mode functionItem:nil];
|
||
}
|
||
break;
|
||
case XPMineItemType_Customer_Center: {
|
||
NIMSession *session = [NIMSession session:@"200014" type:NIMSessionTypeP2P];
|
||
SessionViewController *sessionVC = [[SessionViewController alloc] initWithSession:session];
|
||
[self.navigationController pushViewController:sessionVC animated:YES];
|
||
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
#pragma mark - NSNotification
|
||
- (void)onVisitorUnReadCountUpdate:(NSNotification *)noti {
|
||
XPMineVisitorUnReadModel *model = (XPMineVisitorUnReadModel *)noti.object;
|
||
self.headView.visitorUnReadCount = model.visitNum;
|
||
}
|
||
|
||
#pragma mark - 新用户充值优惠
|
||
- (void)onNewUserRechargeTap:(UITapGestureRecognizer *)ges {
|
||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventUsercenterNugiftPopClick];
|
||
XPNewUserRechargeViewController *vc = [[XPNewUserRechargeViewController alloc] initWithNavigation:self.navigationController];
|
||
[self.navigationController presentViewController:vc animated:YES completion:nil];
|
||
}
|
||
|
||
#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:[XPMineMoreTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineMoreTableViewCell class])];
|
||
[_tableView registerClass:[XPMineHeadItemTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineHeadItemTableViewCell class])];
|
||
[_tableView registerClass:[XPHomeBannerTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])];
|
||
_tableView.backgroundColor = [UIColor clearColor];
|
||
}
|
||
return _tableView;
|
||
}
|
||
|
||
- (XPMineHeadView *)headView {
|
||
if (!_headView) {
|
||
_headView = [[XPMineHeadView alloc] init];
|
||
_headView.delegate = self;
|
||
}
|
||
return _headView;
|
||
}
|
||
|
||
- (UIButton *)settingButton {
|
||
if (!_settingButton) {
|
||
_settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
[_settingButton setImage:[UIImage imageNamed:@"mine_nav_setting"] forState:UIControlStateNormal];
|
||
[_settingButton setImage:[UIImage imageNamed:@"mine_nav_setting"] forState:UIControlStateSelected];
|
||
[_settingButton addTarget:self action:@selector(settingButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
[_settingButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
|
||
}
|
||
return _settingButton;
|
||
}
|
||
|
||
|
||
- (NSMutableArray<XPMineFuntionItemModel *> *)functionArray {
|
||
if (!_functionArray) {
|
||
_functionArray = [NSMutableArray array];
|
||
}
|
||
return _functionArray;
|
||
}
|
||
|
||
- (NSArray<XPMineMoreItemModel *> *)moreItemArray {
|
||
if (!_moreItemArray) {
|
||
XPMineMoreItemModel *model1 = [[XPMineMoreItemModel alloc] init];
|
||
model1.icon = @"mine_realname_auth";
|
||
model1.title = @"实名认证";
|
||
model1.itemType = XPMineItemType_Identity;
|
||
|
||
XPMineMoreItemModel *model2 = [[XPMineMoreItemModel alloc] init];
|
||
model2.icon = @"mine_teenager_mode";
|
||
model2.title = @"青少年模式";
|
||
model2.itemType = XPMineItemType_Teenager_Mode;
|
||
|
||
XPMineMoreItemModel *model3 = [[XPMineMoreItemModel alloc] init];
|
||
model3.icon = @"mine_customer_center";
|
||
model3.title = @"客服中心";
|
||
model3.itemType = XPMineItemType_Customer_Center;
|
||
|
||
_moreItemArray = @[model1, model2, model3];
|
||
}
|
||
return _moreItemArray;
|
||
}
|
||
|
||
- (NSMutableArray<HomeBannerInfoModel *> *)bannerArray {
|
||
if (!_bannerArray) {
|
||
_bannerArray = [NSMutableArray array];
|
||
}
|
||
return _bannerArray;
|
||
}
|
||
|
||
- (XPMineNewUserRechargeView *)userRechargeView {
|
||
if (!_userRechargeView) {
|
||
_userRechargeView = [[XPMineNewUserRechargeView alloc] init];
|
||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onNewUserRechargeTap:)];
|
||
[_userRechargeView addGestureRecognizer:tap];
|
||
}
|
||
return _userRechargeView;
|
||
}
|
||
|
||
@end
|