// // XPMineViewController.m // xplan-ios // // Created by 冯硕 on 2021/9/16. // #import "XPMineViewController.h" ///Third #import #import ///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 "LittleGameInfoModel.h" #import "WalletInfoModel.h" #import "HomeLittleGameRoomModel.h" #import "NobleCenterModel.h" ///P #import "XPMineProtocol.h" #import "XPMinePresent.h" ///View #import "XPMineHeadItemTableViewCell.h" #import "XPMineHeadView.h" #import "XPLittleGameRoomOpenView.h" #import "XPMineGameTableViewCell.h" #import "XPHomeBannerTableViewCell.h" #import "XPMineNewUserRechargeView.h" #import "AnchorLevelView.h" ///VC #import "XPMineSettingViewController.h" #import "XPMineTeenagerViewController.h" #import "XPMineUserInfoViewController.h" #import "XPMineRechargeViewController.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" @interface XPMineViewController () ///顶部背景 @property (nonatomic, strong) UIView *bgImageView; @property (nonatomic,strong) UITableView *tableView; ///个人功能 @property (nonatomic, strong) NSMutableArray *functionArray; ///游戏列表 @property (nonatomic, strong) NSMutableArray *littleGameArray; ///banner列表 @property (nonatomic, strong) NSMutableArray *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.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.left.right.top.mas_equalTo(0); }]; [self.settingButton mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(21, 21)); make.right.mas_equalTo(self.view).offset(-14); make.top.mas_equalTo(self.view).offset(kSafeAreaTopHeight + 29); }]; [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: { XPMineRechargeViewController * rechargeVC = [[XPMineRechargeViewController 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) { 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; 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) { return 172; } else if (indexPath.section == 1) { return 129; } else { return 80; } return 53; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { XPMineHeadItemTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineHeadItemTableViewCell class])]; if (cell == nil) { cell = [[XPMineHeadItemTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineHeadItemTableViewCell class])]; } if (self.functionArray.count) { cell.datasource = self.functionArray; } cell.delegate = self; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } else if (indexPath.section == 1) { XPMineGameTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineGameTableViewCell class])]; if (cell == nil) { cell = [[XPMineGameTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineGameTableViewCell class])]; } if (self.littleGameArray.count) { cell.datasource = self.littleGameArray; } cell.delegate = self; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } else { XPHomeBannerTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])]; if (cell == nil) { cell = [[XPHomeBannerTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: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 16; } - (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)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]; } ///点击了青少年模式 - (void)xPmineHeadViewClickTeenager { [self pushViewControllerWithType:XPMineItemType_Teenager_Mode functionItem:nil]; } - (void)xPMineHeadView:(XPMineHeadView *)view didClickAnchorLevel:(AnchorLevelModel *)info { AnchorLevelView * gradeView = [[AnchorLevelView alloc] init]; gradeView.levelInfo = info; [TTPopup popupView:gradeView style:TTPopupStyleAlert]; } #pragma mark - XPMineProtocol ///获取个人中心功能 - (void)onGetMineFuntionItemSuccess:(NSArray *)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]; } ///获取小游戏列表 - (void)onGetLittleGameListSuccess:(NSArray *)items { [self.littleGameArray removeAllObjects]; [self.littleGameArray addObjectsFromArray:items]; [self.tableView reloadData]; 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}]; } ///获取个人中心banner - (void)onGetPersonalBannerListSuccess:(NSArray *)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.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 - 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 - 新用户充值优惠 - (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:[XPMineGameTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineGameTableViewCell 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) { CGFloat height = (KScreenWidth - 30 - 16) * 0.5 * 64 / 164; _headView = [[XPMineHeadView alloc] initWithFrame:CGRectMake(0, 0,KScreenWidth , 142 +44 + height + kStatusBarHeight)]; _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; } - (UIView *)bgImageView { if (!_bgImageView) { _bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"home_nav_background"]]; _bgImageView.contentMode = UIViewContentModeScaleAspectFill; } return _bgImageView; } - (NSMutableArray *)functionArray { if (!_functionArray) { _functionArray = [NSMutableArray array]; } return _functionArray; } - (NSMutableArray *)littleGameArray { if (!_littleGameArray) { _littleGameArray = [NSMutableArray array]; } return _littleGameArray; } - (NSMutableArray *)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