Files
peko-ios/YuMi/Modules/YMMine/View/XPSimpleMineViewController.m
QQQ c6799634e7 移除 A/B 相关代码。
移除 XPMineSimpleUserInfoViewController
2024-05-22 19:05:50 +08:00

492 lines
16 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// YMSimpleMineViewController.m
// YUMI
//
// Created by XY on 2023/2/20.
//
#import "XPSimpleMineViewController.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "TTPopup.h"
#import "YUMIMacroUitls.h"
#import "YUMIHtmlUrl.h"
#import "UIButton+EnlargeTouchArea.h"
#import "StatisticsServiceHelper.h"
#import "YUMIConstant.h"
#import "Api+Room.h"
#import "Api+RoomSetting.h"
#import "AccountInfoStorage.h"
#import "ClientConfig.h"
#import "NSMutableDictionary+Saft.h"
#import "DJDKMIMOMColor.h"
#import "ClientConfig.h"
///Model
#import "XPMineItemModel.h"
#import "UserInfoModel.h"
#import "XPMineVisitorUnReadModel.h"
#import "ClanDetailInfoModel.h"
#import "HomeBannerInfoModel.h"
#import "XPMineFuntionItemModel.h"
#import "WalletInfoModel.h"
///P
#import "XPMineProtocol.h"
#import "XPMinePresent.h"
///View
#import "XPMineHeadItemTableViewCell.h"
#import "XPSimpleMineHeaderView.h"
#import "XPHomeBannerTableViewCell.h"
#import "XPMineNewUserRechargeView.h"
#import "XPMineItemTableViewCell.h"
///VC
#import "XPMineSettingViewController.h"
#import "XPMineUserInfoViewController.h"
#import "XPIAPRechargeViewController.h"
#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 "XPMineFeedbackViewController.h"
#import "XPIAPRechargeViewController.h"
@interface XPSimpleMineViewController ()<UITableViewDelegate, UITableViewDataSource, XPHomeBannerTableViewCellDelegate, XPMineProtocol, XPSimpleMineHeaderViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) XPSimpleMineHeaderView *headerView;
///用户信息
@property (nonatomic,strong) UserInfoModel *userInfo;
///家族信息
@property (nonatomic,strong) ClanDetailInfoModel *clanInfo;
///我的公会
@property (nonatomic,strong) XPMineItemModel *guildItemModel;
///banner列表
@property (nonatomic, strong) NSMutableArray<HomeBannerInfoModel *> *bannerArray;
@property (nonatomic, strong) NSArray<XPMineItemModel *> *sectionArray0;
@property (nonatomic, strong) NSArray<XPMineItemModel *> *sectionArray1;
@end
@implementation XPSimpleMineViewController
- (XPMinePresent *)createPresenter {
return [[XPMinePresent alloc] init];;
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self createUI];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.presenter getUserInfo];
}
- (void)createUI {
self.tableView.tableHeaderView = self.headerView;
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
}
- (void)openMyRoom {
NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid];
[XPRoomViewController openRoom:roomUid viewController:self];
}
#pragma mark - XPSimpleMineHeaderViewDelegate
- (void)headerViewBtnActionType:(XPMineItemType)itemType {
switch (itemType) {
case XPMineItemType_Match_Relevance_Account:
break;
case XPMineItemType_Foot_Print:
{
XPMineFootPrintViewController *vc = [[XPMineFootPrintViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case XPMineItemType_Account:
{
XPIAPRechargeViewController *rechargeVC = [[XPIAPRechargeViewController alloc] init];
rechargeVC.type = @"4";
[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:
{
[self openMyRoom];
}
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_Visitor:
{
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];
}else{
[self showErrorToast:YMLocalizedString(@"XPSimpleMineViewController0")];
}
}
break;
case -1: { // 我的等级
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.url = URLWithType(kUserLevelURL);
[self.navigationController pushViewController:webVC animated:YES];
}
break;
case -2: { // 意见反馈
XPMineFeedbackViewController * feedbackVC = [[XPMineFeedbackViewController alloc] init];
[self.navigationController pushViewController:feedbackVC animated:YES];
}
break;
case -3: { // 设置
XPMineSettingViewController * settingVC = [[XPMineSettingViewController alloc] init];
settingVC.userInfo = self.userInfo;
[self.navigationController pushViewController:settingVC animated:YES];
}
break;
default:
break;
}
}
#pragma mark - XPMineProtocol
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
///防止重新注册时获取到用户信息不全调用接口时401
if (!userInfo.isBindPhone && [ClientConfig shareConfig].iosPhoneBind) {
return;
}
if (userInfo.nick == nil || userInfo.avatar == nil) {
return;
}
self.userInfo = userInfo;
self.headerView.userInfo = userInfo;
[self.tableView reloadData];
[self.presenter getMineBannerList];
[self.presenter getClanDetailInfo];
[self.tableView reloadData];
}
///获取家族信息成功
- (void)onGetClanDetailInfoSuccess:(ClanDetailInfoModel *)clanInfo {
self.clanInfo = clanInfo;
[self.tableView reloadData];
}
- (void)onGetClanDetailInfofail {
}
///获取个人中心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)onGetPersonalBannerListFail {
}
#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 - TableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if (self.userInfo) {
return 3;
}
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return 0;
}else if (section == 1) {
return self.sectionArray1.count;
}else if (section == 2) {
return 1;
}
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
return 64;
} else if (indexPath.section == 1) {
return 64;
} else {
return 80;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (section == 0) {
return 0.01;
}
return 13;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return UIView.new;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return UIView.new;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
XPMineItemTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineItemTableViewCell class])];
XPMineItemModel *itemModel = self.sectionArray0[indexPath.row];
cell.itemModel = itemModel;
if (indexPath.row == 0) {
[cell setCornerTop:YES bottom:NO];
}else if (indexPath.row == self.sectionArray0.count -1) {
[cell setCornerTop:NO bottom:YES];
}else{
[cell setCornerTop:NO bottom:NO];
}
return cell;
}else if (indexPath.section == 1) {
XPMineItemTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineItemTableViewCell class])];
XPMineItemModel *itemModel = self.sectionArray1[indexPath.row];
cell.itemModel = itemModel;
if (indexPath.row == 0) {
[cell setCornerTop:YES bottom:NO];
}else if (indexPath.row == self.sectionArray1.count -1) {
[cell setCornerTop:NO bottom:YES];
}else{
[cell setCornerTop:NO bottom:NO];
}
return cell;
}else if (indexPath.section == 2) {
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;
}
return UITableViewCell.new;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
XPMineItemModel *item = self.sectionArray0[indexPath.row];
[self headerViewBtnActionType:item.type];
}else if (indexPath.section == 1) {
XPMineItemModel *item = self.sectionArray1[indexPath.row];
[self headerViewBtnActionType:item.type];
}
}
#pragma mark - 懒加载
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1];
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[_tableView registerClass:[XPMineItemTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineItemTableViewCell class])];
[_tableView registerClass:[XPHomeBannerTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])];
}
return _tableView;
}
- (XPSimpleMineHeaderView *)headerView {
if (!_headerView) {
_headerView = [[XPSimpleMineHeaderView alloc] init];
_headerView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 313);
_headerView.delegate = self;
}
return _headerView;
}
- (NSArray<XPMineItemModel *> *)sectionArray0 {
if (!_sectionArray0) {
XPMineItemModel *model0 = [[XPMineItemModel alloc] init];
model0.itemImageName = @"mine_union";
model0.itemName = YMLocalizedString(@"XPSimpleMineViewController1");
model0.type = XPMineItemType_My_Guild;
XPMineItemModel *model1 = [[XPMineItemModel alloc] init];
model1.itemImageName = @"mine_dress";
model1.itemName = YMLocalizedString(@"XPSimpleMineViewController2");
model1.type = XPMineItemType_DressUp_Market;
XPMineItemModel *model2 = [[XPMineItemModel alloc] init];
model2.itemImageName = @"mine_fans";
model2.itemName = YMLocalizedString(@"XPSimpleMineViewController3");
model2.type = XPMineItemType_FansTeam;
_sectionArray0 = @[model0, model1, model2];
}
return _sectionArray0;
}
- (NSArray<XPMineItemModel *> *)sectionArray1 {
if (!_sectionArray1) {
XPMineItemModel *model1 = [[XPMineItemModel alloc] init];
model1.itemImageName = @"mine_feedback";
model1.itemName = YMLocalizedString(@"XPSimpleMineViewController5");
model1.type = -2;
XPMineItemModel *model2 = [[XPMineItemModel alloc] init];
model2.itemImageName = @"mine_setting";
model2.itemName = YMLocalizedString(@"XPSimpleMineViewController6");
model2.type = -3;
_sectionArray1 = @[ model1, model2];
}
return _sectionArray1;
}
- (NSMutableArray<HomeBannerInfoModel *> *)bannerArray {
if (!_bannerArray) {
_bannerArray = [NSMutableArray array];
}
return _bannerArray;
}
@end