Files
featherVoice/QXLive/Mine(音域)/Controller/QXMineViewController.m

413 lines
15 KiB
Mathematica
Raw Normal View History

2025-08-08 10:49:36 +08:00
//
// QXMineViewController.m
// QXLive
//
// Created by on 2025/4/24.
//
#import "QXMineViewController.h"
#import "QXMainHeaderView.h"
#import "QXMineServiceCell.h"
#import "QXSettingViewController.h"
#import "QXPropShopViewController.h"
#import "QXLevelViewController.h"
#import "QXGuildViewController.h"
#import "QXWalletViewController.h"
#import "QXTaskViewController.h"
#import "QXDressViewController.h"
#import "QXBackpackViewController.h"
#import "QXUserInfoEidtViewController.h"
#import "QXUserHomePageViewController.h"
#import "QXBlackListlViewController.h"
#import "QXMyRoomViewController.h"
#import "QXRealNamePopView.h" //
#import "QXRealNameViewController.h"
#import "QXMineNetwork.h"
#import "QXHelpViewController.h"
#import "QXInviteViewController.h"
2025-10-20 09:43:10 +08:00
#import "QXChatViewController.h"
2025-11-03 09:55:25 +08:00
#import "QXWalletRuleView.h"
2025-11-06 13:04:04 +08:00
#import "QXRechargeViewcController.h"
#import "QXGiftWallViewController.h"
2025-11-11 17:19:21 +08:00
#import "QXNobilityViewController.h"
#import "QXHomePageNetwork.h"
2025-11-06 13:04:04 +08:00
#import <WXApi.h>
2025-08-08 10:49:36 +08:00
@interface QXMineViewController ()<UITableViewDelegate,UITableViewDataSource,QXMineServiceCellDelegate,QXMainHeaderViewDelegate>
@property (nonatomic,strong)QXMainHeaderView *tableHeaderView;
@property (nonatomic,strong)UITableView *tableView;
2025-11-06 13:04:04 +08:00
//@property (nonatomic,strong)UIButton *redbagBtn;
//@property (nonatomic,strong)UIButton *serviceBtn;
//@property (nonatomic,strong)UIButton *settingBtn;
2025-08-08 10:49:36 +08:00
@property (nonatomic,strong)QXUserModel *userModel;
2025-11-11 17:19:21 +08:00
@property (nonatomic,strong)NSMutableArray *bannerArry;
2025-08-08 10:49:36 +08:00
@end
@implementation QXMineViewController
- (void)viewDidLoad {
2025-11-06 13:04:04 +08:00
self.isNoChangeBgImage = YES;
2025-08-08 10:49:36 +08:00
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self getUserInfo];
2025-10-30 00:45:15 +08:00
[self.tableView reloadData];
2025-11-06 13:04:04 +08:00
[self.tableHeaderView reloadData];
2025-08-08 10:49:36 +08:00
}
- (void)initSubViews{
2025-11-06 13:04:04 +08:00
[self updateBgImage:@"app_home_bg"];
2025-08-08 10:49:36 +08:00
self.tableView.tableHeaderView = self.tableHeaderView;
[self.view addSubview:self.tableView];
2025-11-06 13:04:04 +08:00
// [self.view addSubview:self.settingBtn];
// [self.view addSubview:self.serviceBtn];
// [self.view addSubview:self.redbagBtn];
// [self.settingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.mas_equalTo(kSafeAreaTop +10);
// make.right.mas_equalTo(-10);
// make.width.height.mas_equalTo(30);
// }];
//
// [self.serviceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.width.height.mas_equalTo(30);
// make.centerY.equalTo(self.settingBtn);
// make.right.equalTo(self.settingBtn.mas_left).offset(-10);
// }];
// [self.redbagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.right.equalTo(self.serviceBtn.mas_left).offset(-10);
// make.centerY.width.height.equalTo(self.settingBtn);
// }];
2025-08-08 10:49:36 +08:00
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(passwordDidChanged) name:noticeChangePassword object:nil];
2025-11-11 17:19:21 +08:00
[self getBanner];
2025-08-08 10:49:36 +08:00
}
-(void)getUserInfo{
MJWeakSelf
[QXMineNetwork getMineInfoSuccessBlock:^(QXUserModel * _Nonnull userModel) {
weakSelf.userModel = userModel;
weakSelf.tableHeaderView.userModel = userModel;
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
2025-11-06 13:04:04 +08:00
[QXMineNetwork getWalletInfoSuccessBlock:^(NSString * _Nonnull coin, NSString * _Nonnull earnings, NSString * _Nonnull title, NSString * _Nonnull url) {
weakSelf.tableHeaderView.coin = coin;
weakSelf.tableHeaderView.earnings = earnings;
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
2025-08-08 10:49:36 +08:00
}
#pragma mark - QXMineServiceCellDelegate
2025-11-06 13:04:04 +08:00
-(void)didClickServiceWithType:(QXMineServiceType)type{
switch (type) {
case QXMineServiceTypeLevel:{
QXLevelViewController *vc = [[QXLevelViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMineServiceTypeDress:{
QXDressViewController *vc = [[QXDressViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMineServiceTypeBackpack:{
QXBackpackViewController *vc = [[QXBackpackViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMineServiceTypeSetting:{
[self gotoSetting];
}
break;
case QXMineServiceTypeHelp:{
[self gotoService];
}
break;
case QXMineServiceTypeInvite:{
[self gotoInvite];
}
break;
case QXMineServiceTypeDayTask:{
QXTaskViewController *vc = [[QXTaskViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMineServiceTypeReport:{
[self gotoService];
}
break;
case QXMineServiceTypeCustomerService:{
WXOpenCustomerServiceReq *req = [[WXOpenCustomerServiceReq alloc] init];
req.corpid = @"ww1de4300858c0b461";
req.url = @"https://work.weixin.qq.com/kfid/kfcb3d23a59c188a0e7";
[WXApi sendReq:req completion:nil];
2025-11-03 09:55:25 +08:00
}
2025-11-06 13:04:04 +08:00
break;
default:
break;
2025-08-08 10:49:36 +08:00
}
}
-(void)didClickOptionType:(QXMainHeaderOptionType)type{
MJWeakSelf
switch (type) {
case QXMainHeaderOptionTypeGotoHome:{
QXLOG(@"跳转个人主页");
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
vc.user_id = [QXGlobal shareGlobal].loginModel.user_id;
// vc.user_id = @"13";
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMainHeaderOptionTypeGotoEdit:{
QXLOG(@"跳转个人编辑");
QXUserInfoEidtViewController *vc = [[QXUserInfoEidtViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
2025-11-06 13:04:04 +08:00
case QXMainHeaderOptionTypeNobility:{
QXLOG(@"跳转贵族");
2025-11-11 17:19:21 +08:00
QXNobilityViewController *vc = [[QXNobilityViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
2025-08-08 10:49:36 +08:00
}
break;
2025-11-06 13:04:04 +08:00
case QXMainHeaderOptionTypeRecharge:{
QXLOG(@"跳转充值");
QXRechargeViewcController *vc = [[QXRechargeViewcController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMainHeaderOptionTypeShop:{
QXLOG(@"跳转商城");
QXPropShopViewController *vc = [[QXPropShopViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMainHeaderOptionTypeGuild:{
QXLOG(@"跳转公会");
QXGuildViewController *vc = [[QXGuildViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMainHeaderOptionTypeFriend:{
QXLOG(@"跳转挚友");
}
break;
case QXMainHeaderOptionTypeGiftWall:{
QXLOG(@"跳转礼物墙");
QXGiftWallViewController *vc = [[QXGiftWallViewController alloc] init];
vc.userId = [QXGlobal shareGlobal].loginModel.user_id;
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMainHeaderOptionTypeWallet:{
QXLOG(@"跳转钱包");
BOOL result = [[NSUserDefaults standardUserDefaults] boolForKey:kWalletRuleHide];
if (result) {
QXWalletViewController * vc = [[QXWalletViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}else{
QXWalletRuleView *ruleView = [[QXWalletRuleView alloc] init];
MJWeakSelf
ruleView.toWalletBlock = ^{
QXWalletViewController*vc = [[QXWalletViewController alloc] init];
[weakSelf.navigationController pushViewController:vc animated:YES];
};
[ruleView showInView:self.view];
}
2025-08-08 10:49:36 +08:00
}
break;
case QXMainHeaderOptionTypeRoom:{
if (![QXGlobal shareGlobal].isRealName) {
QXLOG(@"未实名,弹出实名认证");
QXRealNamePopView *v = [[QXRealNamePopView alloc] init];
v.closeActionBlock = ^{
[[QXGlobal shareGlobal] hideViewBlock:^{}];
};
v.authActionBlock = ^{
[[QXGlobal shareGlobal] hideViewBlock:^{
QXRealNameViewController *vc = [[QXRealNameViewController alloc] init];
[weakSelf.navigationController pushViewController:vc animated:YES];
}];
};
[[QXGlobal shareGlobal] showView:v popType:(PopViewTypePopFromCenter) tapDismiss:NO finishBlock:^{}];
}else{
QXMyRoomViewController *vc = [[QXMyRoomViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
}
break;
case QXMainHeaderOptionTypeFocus:{
QXLOG(@"跳转关注");
QXBlackListlViewController *vc = [[QXBlackListlViewController alloc] init];
vc.type = 2;
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMainHeaderOptionTypeFans:{
QXLOG(@"跳转粉丝");
QXBlackListlViewController *vc = [[QXBlackListlViewController alloc] init];
vc.type = 1;
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXMainHeaderOptionTypeVisitor:{
QXLOG(@"跳转访客");
QXBlackListlViewController *vc = [[QXBlackListlViewController alloc] init];
vc.type = 3;
[self.navigationController pushViewController:vc animated:YES];
}
break;
default:
break;
}
}
#pragma mark - UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
2025-11-06 13:04:04 +08:00
return 2;
2025-08-08 10:49:36 +08:00
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
QXMineServiceCell *cell = [QXMineServiceCell cellWithTableView:tableView];
cell.delegate = self;
2025-11-06 13:04:04 +08:00
if (indexPath.row == 0) {
cell.isMore = NO;
}else{
cell.isMore = YES;
}
2025-08-08 10:49:36 +08:00
return cell;
}
2025-11-06 13:04:04 +08:00
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
return ScaleWidth(110);
}else{
if (QXGlobal.shareGlobal.isOpenRecharge) {
return ScaleWidth(168);
}else{
return ScaleWidth(110);
}
}
}
2025-11-11 17:19:21 +08:00
-(void)getBanner{
MJWeakSelf
[QXHomePageNetwork homeBannerWithType:@"6" successBlock:^(NSArray<QXBanner *> * _Nonnull list) {
weakSelf.tableHeaderView.bannerArray = list;
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
2025-08-08 10:49:36 +08:00
-(void)gotoSetting{
QXSettingViewController *vc = [[QXSettingViewController alloc] init];
2025-11-11 17:19:21 +08:00
vc.haveNobility = self.userModel.is_hide.intValue == 1;
2025-08-08 10:49:36 +08:00
MJWeakSelf
vc.logOutBlock = ^(BOOL isCancel) {
if (isCancel) {
[weakSelf performSelector:@selector(cancelAccount) afterDelay:0.5];
}else{
[weakSelf performSelector:@selector(logout) afterDelay:0.5];
}
};
[self.navigationController pushViewController:vc animated:YES];
}
2025-11-06 13:04:04 +08:00
-(void)gotoInvite{
2025-08-08 10:49:36 +08:00
QXInviteViewController *vc = [[QXInviteViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
-(void)gotoService{
QXHelpViewController *webvc = [[QXHelpViewController alloc] init];
[self.navigationController pushViewController:webvc animated:YES];
2025-10-20 09:43:10 +08:00
// QXChatViewController *vc = [[QXChatViewController alloc] init];
// TUIChatConversationModel *data = [[TUIChatConversationModel alloc] init];
// data.userID = @"@RBT#u88";
// data.title = @"小秘机器人";
// data.faceUrl = @"http://md.qxmier.com/data/avatar/head_pic.png";
// vc.data = data;
// [self.navigationController pushViewController:vc animated:YES];
2025-08-08 10:49:36 +08:00
}
-(void)passwordDidChanged{
[self performSelector:@selector(logout) afterDelay:0.5];
}
-(void)logout{
[QXMineNetwork logoutSuccessBlock:^(NSDictionary * _Nonnull dict) {
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
[[QXGlobal shareGlobal] logOut];
}
-(void)cancelAccount{
[QXMineNetwork cancelAccountSuccessBlock:^(NSDictionary * _Nonnull dict) {
[[QXGlobal shareGlobal] logOut];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
2025-10-20 09:43:10 +08:00
2025-08-08 10:49:36 +08:00
}
-(QXMainHeaderView *)tableHeaderView{
if (!_tableHeaderView) {
2025-11-06 13:04:04 +08:00
_tableHeaderView = [[QXMainHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0)];
_tableHeaderView.height = _tableHeaderView.getHeight;
2025-08-08 10:49:36 +08:00
_tableHeaderView.delegate = self;
}
return _tableHeaderView;
}
-(UITableView *)tableView{
if (!_tableView) {
2025-11-06 13:04:04 +08:00
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-TabbarContentHeight) style:UITableViewStylePlain];
2025-08-08 10:49:36 +08:00
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
return _tableView;
}
2025-11-11 17:19:21 +08:00
-(NSMutableArray *)bannerArry{
if (!_bannerArry) {
_bannerArry = [NSMutableArray array];
}
return _bannerArry;
}
2025-11-06 13:04:04 +08:00
//-(UIButton *)settingBtn{
// if (!_settingBtn) {
// _settingBtn = [[UIButton alloc] init];
// [_settingBtn setImage:[UIImage imageNamed:@"mine_setting"] forState:UIControlStateNormal];
// [_settingBtn setImage:[UIImage imageNamed:@"mine_setting"] forState:UIControlStateHighlighted];
// [_settingBtn addTarget:self action:@selector(gotoSetting) forControlEvents:UIControlEventTouchUpInside];
// }
// return _settingBtn;
//}
//- (UIButton *)redbagBtn {
// if (!_redbagBtn) {
// _redbagBtn = [[UIButton alloc] init];
// [_redbagBtn setImage:[UIImage imageNamed:@"mine_redbag"] forState:UIControlStateNormal];
// [_redbagBtn setImage:[UIImage imageNamed:@"mine_redbag"] forState:UIControlStateHighlighted];
// [_redbagBtn addTarget:self action:@selector(gotoRedbag) forControlEvents:UIControlEventTouchUpInside];
// }
// return _redbagBtn;
//}
//
//- (UIButton *)serviceBtn {
// if (!_serviceBtn) {
// _serviceBtn = [[UIButton alloc] init];
// [_serviceBtn setImage:[UIImage imageNamed:@"mine_service"] forState:UIControlStateNormal];
// [_serviceBtn setImage:[UIImage imageNamed:@"mine_service"] forState:UIControlStateHighlighted];
// [_serviceBtn addTarget:self action:@selector(gotoService) forControlEvents:UIControlEventTouchUpInside];
// }
// return _serviceBtn;
//}
2025-08-08 10:49:36 +08:00
@end