Files
yinmeng-ios/xplan-ios/Main/Mine/View/XPMineViewController.m

775 lines
29 KiB
Mathematica
Raw Normal View History

2021-09-16 19:30:22 +08:00
//
// XPMineViewController.m
// xplan-ios
//
// Created by on 2021/9/16.
//
#import "XPMineViewController.h"
///Third
#import <Masonry/Masonry.h>
2023-03-09 19:46:22 +08:00
#import <IQKeyboardManager.h>
#import <QYSDK_NIM/QYSDK.h>
2021-09-16 19:30:22 +08:00
///Tool
2022-01-21 19:47:46 +08:00
#import "TTPopup.h"
2021-09-16 19:30:22 +08:00
#import "XPMacro.h"
2021-09-17 19:41:09 +08:00
#import "XPHtmlUrl.h"
#import "UIButton+EnlargeTouchArea.h"
2022-01-11 11:28:04 +08:00
#import "StatisticsServiceHelper.h"
2022-01-26 15:51:19 +08:00
#import "XPConstant.h"
2022-01-21 19:47:46 +08:00
#import "Api+Room.h"
#import "Api+RoomSetting.h"
#import "AccountInfoStorage.h"
2022-07-29 17:09:01 +08:00
#import "ClientConfig.h"
#import "NSMutableDictionary+Saft.h"
2021-09-16 19:30:22 +08:00
///Model
#import "XPMineItemModel.h"
2021-09-23 18:38:33 +08:00
#import "UserInfoModel.h"
2022-01-26 15:51:19 +08:00
#import "XPMineVisitorUnReadModel.h"
2022-04-14 00:35:31 +08:00
#import "ClanDetailInfoModel.h"
2022-07-22 18:48:23 +08:00
#import "HomeBannerInfoModel.h"
#import "XPMineFuntionItemModel.h"
#import "WalletInfoModel.h"
#import "HomeLittleGameRoomModel.h"
2022-07-27 15:11:11 +08:00
#import "NobleCenterModel.h"
2023-03-08 17:28:21 +08:00
#import "XPMineMoreItemModel.h"
2021-09-16 19:30:22 +08:00
///P
#import "XPMineProtocol.h"
#import "XPMinePresent.h"
///View
#import "XPMineHeadItemTableViewCell.h"
2021-09-16 19:30:22 +08:00
#import "XPMineHeadView.h"
2022-01-21 19:47:46 +08:00
#import "XPLittleGameRoomOpenView.h"
2023-03-08 17:28:21 +08:00
#import "XPMineMoreTableViewCell.h"
2022-07-22 18:48:23 +08:00
#import "XPHomeBannerTableViewCell.h"
2022-07-28 15:24:42 +08:00
#import "XPMineNewUserRechargeView.h"
2022-12-13 21:09:48 +08:00
#import "AnchorLevelView.h"
2021-09-17 19:41:09 +08:00
///VC
#import "XPMineSettingViewController.h"
#import "XPMineTeenagerViewController.h"
2021-09-23 18:38:33 +08:00
#import "XPMineUserInfoViewController.h"
2023-03-14 16:35:05 +08:00
#import "XPMineNewRechargeViewController.h"
2021-09-17 19:41:09 +08:00
#import "XPWebViewController.h"
2021-10-14 21:10:04 +08:00
#import "XPRoomViewController.h"
2021-12-16 19:02:31 +08:00
#import "XPMineDressUpViewController.h"
2022-07-29 15:26:33 +08:00
#import "XPDressUpShopViewController.h"
#import "XPMineFansViewController.h"
#import "XPMineAttentionViewController.h"
2021-12-28 17:32:27 +08:00
#import "XPNobleCenterViewController.h"
#import "XPMatchManageViewController.h"
#import "XPSkillCardViewController.h"
2022-01-26 11:51:06 +08:00
#import "XPMineVisitorViewController.h"
2022-04-08 16:16:38 +08:00
#import "XPMineFansTeamViewController.h"
2022-04-06 21:52:38 +08:00
#import "XPMineClanViewController.h"
2022-04-14 00:35:31 +08:00
#import "XPMineGuildViewController.h"
2022-07-26 11:08:01 +08:00
#import "XPMineFootPrintViewController.h"
2022-07-27 15:51:09 +08:00
#import "XPMineCollectRoomListViewController.h"
2022-07-29 18:56:08 +08:00
#import "XPNewUserRechargeViewController.h"
2023-08-24 17:03:32 +08:00
#import "XPMineGameOrderVC.h"
2023-03-08 17:28:21 +08:00
@interface XPMineViewController ()<UITableViewDelegate, UITableViewDataSource, XPMineProtocol, XPMineHeadItemTableViewCellDelegate, XPMineHeadViewDelegate, XPMineMoreTableViewCellDelegate, XPHomeBannerTableViewCellDelegate>
2021-09-16 19:30:22 +08:00
@property (nonatomic,strong) UITableView *tableView;
2022-07-22 18:48:23 +08:00
///
@property (nonatomic, strong) NSMutableArray<XPMineFuntionItemModel *> *functionArray;
2023-03-08 17:28:21 +08:00
///
@property (nonatomic, strong) NSArray<XPMineMoreItemModel *> *moreItemArray;
2022-07-22 18:48:23 +08:00
///banner
@property (nonatomic, strong) NSMutableArray<HomeBannerInfoModel *> *bannerArray;
2021-09-16 19:30:22 +08:00
///
@property (nonatomic,strong) XPMineHeadView *headView;
///
@property (nonatomic,strong) UIButton *settingButton;
2022-04-14 00:35:31 +08:00
///
@property (nonatomic,strong) UserInfoModel *userInfo;
2022-04-14 00:35:31 +08:00
///
@property (nonatomic,strong) ClanDetailInfoModel *clanInfo;
///
@property (nonatomic,strong) XPMineItemModel *guildItemModel;
2022-07-28 15:24:42 +08:00
///
@property (nonatomic, strong) XPMineNewUserRechargeView *userRechargeView;
2022-12-13 21:09:48 +08:00
///
@property (nonatomic,strong) AnchorLevelModel *anchorGradeInfo;
2022-07-28 15:24:42 +08:00
2021-09-16 19:30:22 +08:00
@end
@implementation XPMineViewController
2022-01-26 15:51:19 +08:00
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
2021-09-16 19:30:22 +08:00
- (BOOL)isHiddenNavBar {
return YES;
}
- (XPMinePresent *)createPresenter {
return [[XPMinePresent alloc] init];;
}
2022-01-26 15:51:19 +08:00
- (instancetype)init {
if (self = [super init]) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onVisitorUnReadCountUpdate:) name:kVisitorUnReadCountNotificationKey object:nil];
}
return self;
}
2021-09-16 19:30:22 +08:00
- (void)viewDidLoad {
[super viewDidLoad];
2021-09-16 19:30:22 +08:00
[self initSubViews];
[self initSubViewConstraints];
2022-08-05 13:04:10 +08:00
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
2021-09-16 19:30:22 +08:00
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_recharge_card_show];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_noble_card_show];
2022-07-22 18:48:23 +08:00
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
2022-08-02 17:06:46 +08:00
[self.presenter getUserInfo];
2021-09-16 19:30:22 +08:00
}
#pragma mark - Response
- (void)settingButtonAction:(UIButton *)sender {
2021-09-17 19:41:09 +08:00
XPMineSettingViewController * settingVC = [[XPMineSettingViewController alloc] init];
settingVC.userInfo = self.userInfo;
2021-09-17 19:41:09 +08:00
[self.navigationController pushViewController:settingVC animated:YES];
2021-09-16 19:30:22 +08:00
}
#pragma mark - Private Method
- (void)initSubViews {
[self.view addSubview:self.tableView];
[self.view addSubview:self.settingButton];
self.tableView.tableHeaderView = self.headView;
2022-01-19 16:29:07 +08:00
if (@available(iOS 15.0, *)) {//iOS1522
self.tableView.sectionHeaderTopPadding = 0;
}
2021-09-16 19:30:22 +08:00
}
- (void)initSubViewConstraints {
[self.settingButton mas_makeConstraints:^(MASConstraintMaker *make) {
2023-03-08 17:28:21 +08:00
make.size.mas_equalTo(CGSizeMake(24, 24));
make.right.mas_equalTo(self.view).offset(-15);
2023-03-17 21:46:02 +08:00
make.top.mas_equalTo(self.view).offset(kStatusBarHeight + 12);
2021-09-16 19:30:22 +08:00
}];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view);
make.left.right.bottom.mas_equalTo(self.view);
}];
}
2022-07-22 18:48:23 +08:00
- (void)pushViewControllerWithType:(NSInteger)type functionItem:(XPMineFuntionItemModel *)item {
2021-09-16 19:30:22 +08:00
switch (type) {
case XPMineItemType_Match_Manage: {
XPMatchManageViewController *vc = [[XPMatchManageViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
2021-09-16 19:30:22 +08:00
case XPMineItemType_Match_Relevance_Account:
2022-07-22 18:48:23 +08:00
[self pushWebViewWIthUrl:item.centerUrl];
2021-09-16 19:30:22 +08:00
break;
2022-07-26 11:08:01 +08:00
case XPMineItemType_Foot_Print:
{
XPMineFootPrintViewController *vc = [[XPMineFootPrintViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
2021-09-16 19:30:22 +08:00
case XPMineItemType_Teenager_Mode:
{
XPMineTeenagerViewController * vc = [[XPMineTeenagerViewController alloc] init];
vc.userInfo = self.userInfo;
[self.navigationController pushViewController:vc animated:YES];
}
2021-09-16 19:30:22 +08:00
break;
2021-09-17 19:41:09 +08:00
case XPMineItemType_Account:
2021-09-24 19:17:19 +08:00
{
2023-03-14 16:35:05 +08:00
XPMineNewRechargeViewController * rechargeVC = [[XPMineNewRechargeViewController alloc] init];
2021-10-25 10:22:40 +08:00
[self.navigationController pushViewController:rechargeVC animated:YES];
2021-09-24 19:17:19 +08:00
}
2021-09-17 19:41:09 +08:00
break;
case XPMineItemType_Personinfo:
2021-09-23 18:38:33 +08:00
{
XPMineUserInfoViewController * infoVC = [[XPMineUserInfoViewController alloc] init];
infoVC.uid = self.userInfo.uid;
[self.navigationController pushViewController:infoVC animated:YES];
}
2021-09-16 19:30:22 +08:00
break;
case XPMineItemType_My_Room:
{
NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid];
2023-12-18 18:58:30 +08:00
[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 {
if(code == 10108){
[self showRealNameAuthenticationTipsAlertView];
return;
}
2023-12-18 18:58:30 +08:00
[self showErrorToast:msg];
}
} uid:roomUid intoUid:roomUid];
}
break;
2022-07-27 15:51:09 +08:00
case XPMineItemType_Collect_Room://
{
XPMineCollectRoomListViewController *collectVC = [[XPMineCollectRoomListViewController alloc] init];
[self.navigationController pushViewController:collectVC animated:YES];
}
break;
2021-12-16 19:02:31 +08:00
case XPMineItemType_My_Dressup:
{
XPMineDressUpViewController * dressUpVC = [[XPMineDressUpViewController alloc] init];
[self.navigationController pushViewController:dressUpVC animated:YES];
}
break;
2022-07-29 15:26:33 +08:00
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;
2021-12-28 17:32:27 +08:00
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];
2022-01-26 11:51:06 +08:00
}
break;
case XPMineItemType_Visitor:
{
2022-07-27 11:49:51 +08:00
self.headView.visitorUnReadCount = 0;
2022-01-26 11:51:06 +08:00
XPMineVisitorViewController *visitorVC = [[XPMineVisitorViewController alloc] init];
[self.navigationController pushViewController:visitorVC animated:YES];
2022-04-08 16:16:38 +08:00
}
break;
case XPMineItemType_FansTeam: {
XPMineFansTeamViewController *fansTeamVc = [[XPMineFansTeamViewController alloc] init];
[self.navigationController pushViewController:fansTeamVc animated:YES];
2021-12-28 17:32:27 +08:00
}
break;
2022-04-06 21:52:38 +08:00
case XPMineItemType_My_Guild:
{
2022-04-14 00:35:31 +08:00
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];
}
2022-04-06 21:52:38 +08:00
}
break;
2023-08-25 14:48:58 +08:00
case XPMineItemType_Game_Order:
{
XPMineGameOrderVC* orderVC = [[XPMineGameOrderVC alloc]init];
[self.navigationController pushViewController:orderVC animated:YES];
}
break;
2021-09-16 19:30:22 +08:00
default:
break;
}
}
2021-09-17 19:41:09 +08:00
- (void)pushWebViewWIthUrl:(NSString *)url {
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.url = url;
[self.navigationController pushViewController:webVC animated:YES];
}
2021-09-16 19:30:22 +08:00
#pragma mark - UITableViewDelegate And UITableViewDataSource
2022-07-22 18:48:23 +08:00
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
2022-09-27 15:07:31 +08:00
if (self.userInfo.parentMode) {
return 0;
} else {
return 3;
}
2021-09-16 19:30:22 +08:00
}
2022-07-22 18:48:23 +08:00
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
2021-09-16 19:30:22 +08:00
}
- (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;
2023-03-22 14:03:03 +08:00
CGFloat cellTop = 60;
if (page == 2) {
cellTop = 60;
}
return (itemHeight * page + mineLineSpace * (page -1) + cellTop);
2022-07-22 18:48:23 +08:00
} else if (indexPath.section == 1) {
2023-03-08 17:28:21 +08:00
return 48*self.moreItemArray.count+40;
2022-07-22 18:48:23 +08:00
} else {
2023-03-20 17:15:46 +08:00
CGFloat width = KScreenWidth-15*2;
CGFloat height = 80.0/345.0*width;
return height+10;
2022-07-22 18:48:23 +08:00
}
2021-09-16 19:30:22 +08:00
return 53;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
XPMineHeadItemTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineHeadItemTableViewCell class])];
2022-07-22 18:48:23 +08:00
if (self.functionArray.count) {
cell.datasource = self.functionArray;
}
2021-09-16 19:30:22 +08:00
cell.delegate = self;
2022-07-27 16:33:24 +08:00
cell.selectionStyle = UITableViewCellSelectionStyleNone;
2021-09-16 19:30:22 +08:00
return cell;
2022-07-22 18:48:23 +08:00
} else if (indexPath.section == 1) {
2023-03-08 17:28:21 +08:00
XPMineMoreTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineMoreTableViewCell class])];
cell.dataArray = self.moreItemArray;
2022-07-22 18:48:23 +08:00
cell.delegate = self;
2021-09-16 19:30:22 +08:00
return cell;
2022-07-22 18:48:23 +08:00
} else {
XPHomeBannerTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])];
2022-08-05 13:04:10 +08:00
cell.isMineViewBanner = YES;
2022-07-22 18:48:23 +08:00
if (self.bannerArray.count) {
cell.bannerList = self.bannerArray;
}
cell.delegate = self;
2022-07-27 16:33:24 +08:00
cell.selectionStyle = UITableViewCellSelectionStyleNone;
2022-07-22 18:48:23 +08:00
return cell;
}
2021-09-16 19:30:22 +08:00
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
2023-03-08 17:28:21 +08:00
return 12;
2021-09-16 19:30:22 +08:00
}
- (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 {
2022-07-22 18:48:23 +08:00
[self pushViewControllerWithType:XPMineItemType_Personinfo functionItem:nil];
2021-09-17 19:41:09 +08:00
}
2022-07-22 18:48:23 +08:00
///
- (void)xpMineHeadViewClickFans {
[self pushViewControllerWithType:XPMineItemType_Fans_List functionItem:nil];
2021-09-17 19:41:09 +08:00
}
2022-07-22 18:48:23 +08:00
///
- (void)xpMineHeadViewClickAttention {
[self pushViewControllerWithType:XPMineItemType_Attention_List functionItem:nil];
2021-09-16 19:30:22 +08:00
}
2022-07-22 18:48:23 +08:00
///
- (void)xpMineHeadViewClickSkillCard {
[self pushViewControllerWithType:XPMineItemType_Skill_Card functionItem:nil];
}
2022-07-22 18:48:23 +08:00
///访
- (void)xpMineHeadViewClickVisitor {
2023-08-24 17:03:32 +08:00
2023-08-25 14:48:58 +08:00
[self pushViewControllerWithType:XPMineItemType_Visitor functionItem:nil];
}
2022-07-22 18:48:23 +08:00
///
- (void)xpMineHeadViewClickFootprint {
2022-07-26 11:08:01 +08:00
[self pushViewControllerWithType:XPMineItemType_Foot_Print functionItem:nil];
2022-07-22 18:48:23 +08:00
}
2023-03-08 17:28:21 +08:00
///
- (void)xPMineHeadViewClickMyGrade {
2023-11-07 19:38:07 +08:00
NSString *appVersion = [YYUtility appVersion];
appVersion = [appVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
NSString *url = [NSString stringWithFormat:@"%@?appVersionCode=%@",URLWithType(kUserLevelURL),appVersion];
2023-03-08 17:28:21 +08:00
[self pushWebViewWIthUrl:url];
}
///
- (void)xPMineHeadViewClickMyRoom {
[self pushViewControllerWithType:XPMineItemType_My_Room functionItem:nil];
}
2022-07-22 18:48:23 +08:00
///
2023-03-08 17:28:21 +08:00
- (void)xpMineHeadViewClickWallet {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_recharge_card_click];
2022-07-22 18:48:23 +08:00
[self pushViewControllerWithType:XPMineItemType_Account functionItem:nil];
}
///
2023-03-08 17:28:21 +08:00
- (void)xPMineHeadViewClickNoble {
2022-01-11 11:28:04 +08:00
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventvipEntranceMeClick];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_noble_card_click];
2022-07-22 18:48:23 +08:00
[self pushViewControllerWithType:XPMineItemType_Noble_Center functionItem:nil];
}
2022-09-27 15:07:31 +08:00
///
- (void)xPmineHeadViewClickTeenager {
[self pushViewControllerWithType:XPMineItemType_Teenager_Mode functionItem:nil];
}
2022-12-13 21:09:48 +08:00
- (void)xPMineHeadView:(XPMineHeadView *)view didClickAnchorLevel:(AnchorLevelModel *)info {
2022-12-14 16:28:15 +08:00
[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;
2023-01-04 18:49:02 +08:00
@kWeakify(gradeView);
2022-12-14 16:28:15 +08:00
config.didFinishDismissHandler = ^(BOOL isDismissOnBackgroundTouch) {
2023-01-04 18:49:02 +08:00
@kStrongify(gradeView);
[gradeView stopCountDown];
2022-12-14 16:28:15 +08:00
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventRoom_grade_profit_close_click];
};
[TTPopup popupWithConfig:config];
}];
2022-12-13 21:09:48 +08:00
}
2021-09-16 19:30:22 +08:00
#pragma mark - XPMineProtocol
2022-07-22 18:48:23 +08:00
///
- (void)onGetMineFuntionItemSuccess:(NSArray<XPMineFuntionItemModel *> *)items {
[self.functionArray removeAllObjects];
[self.functionArray addObjectsFromArray:items];
2022-07-25 18:16:45 +08:00
[self.functionArray enumerateObjectsUsingBlock:^(XPMineFuntionItemModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
2022-07-27 15:51:09 +08:00
if (obj.skipType == XPMineItemType_CP) {
2022-07-25 18:16:45 +08:00
[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}];
2022-07-22 18:48:23 +08:00
[self.tableView reloadData];
2021-09-16 19:30:22 +08:00
}
2022-07-22 18:48:23 +08:00
///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}];
2021-09-16 19:30:22 +08:00
}
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
2022-07-29 17:09:01 +08:00
///401
if (!userInfo.isBindPhone && [ClientConfig shareConfig].iosPhoneBind) {
return;
}
if (userInfo.nick == nil || userInfo.avatar == nil) {
return;
}
2022-09-27 15:07:31 +08:00
self.userInfo = userInfo;
self.headView.userInfo = userInfo;
[self.tableView reloadData];
if (userInfo.parentMode) {
if (self.userRechargeView.superview) {
[self.userRechargeView removeFromSuperview];
self.userRechargeView = nil;
}
return;
}
2023-03-22 17:47:11 +08:00
[self.presenter getClanDetailInfo];
2023-03-08 17:28:21 +08:00
// [self.presenter getUserWalletInfo];
2022-07-29 17:09:01 +08:00
[self.presenter getPersonItemList];
2023-03-08 17:28:21 +08:00
// [self.presenter getLittleGameList];
2022-07-29 17:09:01 +08:00
[self.presenter getMineBannerList];
2023-03-08 17:28:21 +08:00
// [self.presenter getNobleInfo];
2022-07-28 15:24:42 +08:00
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];
2022-07-28 15:24:42 +08:00
}
self.userRechargeView.endTime = userInfo.limitChargeEndTime;
} else {
[self.userRechargeView removeFromSuperview];
self.userRechargeView = nil;
}
2021-09-16 19:30:22 +08:00
}
2022-07-22 18:48:23 +08:00
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo {
self.headView.walletInfo = balanceInfo;
}
2022-07-27 15:11:11 +08:00
///
- (void)getNobleCenterInfoSuccess:(NobleCenterModel *)model {
self.headView.nobleInfo = model;
}
2022-07-27 16:25:51 +08:00
///
2022-04-14 00:35:31 +08:00
- (void)onGetClanDetailInfoSuccess:(ClanDetailInfoModel *)clanInfo {
self.clanInfo = clanInfo;
2023-03-22 17:47:11 +08:00
// if (self.clanInfo.hall.hallId > 0 && self.clanInfo.hall.ownerUid.integerValue != [AccountInfoStorage instance].getUid.integerValue && !clanInfo.clan.userIsElder) {
// [self.presenter getAnchorGradeInfo];
// }
2022-07-22 18:48:23 +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 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];
2022-07-22 18:48:23 +08:00
}
}
///
- (void)quickMatchLittleGameRoomFail:(NSString *)mgId {
[XPRoomViewController openRoom:[NSString stringWithFormat:@"%ld", self.userInfo.uid] mgId:mgId viewController:self];
2022-04-14 00:35:31 +08:00
}
2022-12-13 21:09:48 +08:00
- (void)getAnchorGradeInfoSuccess:(AnchorLevelModel *)info {
self.anchorGradeInfo = info;
self.headView.anchorLevelInfo = info;
}
#pragma mark - XPMineHeadItemTableViewCellDelegate
2022-07-22 18:48:23 +08:00
- (void)xPMineHeadItemTableViewCell:(XPMineHeadItemTableViewCell *)cell didSelectItem:(XPMineFuntionItemModel *)item {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventusercenter_function_click eventAttributes:@{@"functionName" : item.centerName}];
2022-07-22 18:48:23 +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}];
2022-07-22 18:48:23 +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]init];
vc.url = info.skipUri;
[self.navigationController pushViewController:vc animated:YES];
}
break;
default:
break;
}
}
2023-03-08 17:28:21 +08:00
#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: {
2023-03-09 19:46:22 +08:00
[QYSDK sharedSDK].customUIConfig.customerHeadImageUrl = self.userInfo.avatar;
QYSource *source = [[QYSource alloc] init];
source.title = @"音萌客服";
source.urlString = @"https://gzhfwlkjyxgs.qiyukf.com/";
[[IQKeyboardManager sharedManager].disabledDistanceHandlingClasses addObject:[QYSessionViewController class]];
QYSessionViewController *sessionViewController = [[QYSDK sharedSDK] sessionViewController];
sessionViewController.sessionTitle = @"音萌客服";
sessionViewController.source = source;
[self.navigationController pushViewController:sessionViewController animated:YES];
2023-03-08 17:28:21 +08:00
}
break;
default:
break;
}
2021-09-16 19:30:22 +08:00
}
2022-01-26 15:51:19 +08:00
#pragma mark - NSNotification
- (void)onVisitorUnReadCountUpdate:(NSNotification *)noti {
XPMineVisitorUnReadModel *model = (XPMineVisitorUnReadModel *)noti.object;
2022-07-27 11:49:51 +08:00
self.headView.visitorUnReadCount = model.visitNum;
2022-01-26 15:51:19 +08:00
}
2022-07-29 18:56:08 +08:00
#pragma mark -
- (void)onNewUserRechargeTap:(UITapGestureRecognizer *)ges {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventUsercenterNugiftPopClick];
2022-07-29 18:56:08 +08:00
XPNewUserRechargeViewController *vc = [[XPNewUserRechargeViewController alloc] initWithNavigation:self.navigationController];
[self.navigationController presentViewController:vc animated:YES completion:nil];
}
2021-09-16 19:30:22 +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;
2023-03-08 17:28:21 +08:00
[_tableView registerClass:[XPMineMoreTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineMoreTableViewCell class])];
[_tableView registerClass:[XPMineHeadItemTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineHeadItemTableViewCell class])];
2022-07-22 18:48:23 +08:00
[_tableView registerClass:[XPHomeBannerTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])];
2021-09-16 19:30:22 +08:00
_tableView.backgroundColor = [UIColor clearColor];
}
return _tableView;
}
- (XPMineHeadView *)headView {
if (!_headView) {
2023-03-08 17:28:21 +08:00
_headView = [[XPMineHeadView alloc] init];
2021-09-16 19:30:22 +08:00
_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];
2021-09-17 19:41:09 +08:00
[_settingButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
2021-09-16 19:30:22 +08:00
}
return _settingButton;
}
2022-07-22 18:48:23 +08:00
- (NSMutableArray<XPMineFuntionItemModel *> *)functionArray {
if (!_functionArray) {
_functionArray = [NSMutableArray array];
2022-01-19 16:29:07 +08:00
}
2022-07-22 18:48:23 +08:00
return _functionArray;
2022-01-19 16:29:07 +08:00
}
2023-03-08 17:28:21 +08:00
- (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];
2022-07-22 18:48:23 +08:00
}
2023-03-08 17:28:21 +08:00
return _moreItemArray;
2022-04-14 00:35:31 +08:00
}
2022-07-22 18:48:23 +08:00
- (NSMutableArray<HomeBannerInfoModel *> *)bannerArray {
if (!_bannerArray) {
_bannerArray = [NSMutableArray array];
}
return _bannerArray;
2022-04-14 00:35:31 +08:00
}
2022-07-28 15:24:42 +08:00
- (XPMineNewUserRechargeView *)userRechargeView {
if (!_userRechargeView) {
_userRechargeView = [[XPMineNewUserRechargeView alloc] init];
2022-07-29 18:56:08 +08:00
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onNewUserRechargeTap:)];
[_userRechargeView addGestureRecognizer:tap];
2022-07-28 15:24:42 +08:00
}
return _userRechargeView;
}
2021-09-16 19:30:22 +08:00
@end