282 lines
10 KiB
Objective-C
282 lines
10 KiB
Objective-C
//
|
|
// 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"
|
|
|
|
@interface QXMineViewController ()<UITableViewDelegate,UITableViewDataSource,QXMineServiceCellDelegate,QXMainHeaderViewDelegate>
|
|
@property (nonatomic,strong)QXMainHeaderView *tableHeaderView;
|
|
@property (nonatomic,strong)UITableView *tableView;
|
|
@property (nonatomic,strong)UIButton *redbagBtn;
|
|
@property (nonatomic,strong)UIButton *serviceBtn;
|
|
@property (nonatomic,strong)UIButton *settingBtn;
|
|
@property (nonatomic,strong)QXUserModel *userModel;
|
|
@end
|
|
|
|
@implementation QXMineViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[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];
|
|
}
|
|
|
|
- (void)initSubViews{
|
|
self.tableView.tableHeaderView = self.tableHeaderView;
|
|
[self.view addSubview:self.tableView];
|
|
[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);
|
|
}];
|
|
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(passwordDidChanged) name:noticeChangePassword object:nil];
|
|
}
|
|
-(void)getUserInfo{
|
|
MJWeakSelf
|
|
[QXMineNetwork getMineInfoSuccessBlock:^(QXUserModel * _Nonnull userModel) {
|
|
weakSelf.userModel = userModel;
|
|
weakSelf.tableHeaderView.userModel = userModel;
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
}
|
|
#pragma mark - QXMineServiceCellDelegate
|
|
-(void)didClickServiceWithBtn:(UIButton *)button title:(NSString *)title{
|
|
UIViewController *vc;
|
|
if ([title isEqualToString:QXText(@"道具商城")]) {
|
|
vc = [[QXPropShopViewController alloc] init];
|
|
}else if([title isEqualToString:QXText(@"段位")]){
|
|
vc = [[QXLevelViewController alloc] init];
|
|
}else if([title isEqualToString:QXText(@"公会中心")]){
|
|
vc = [[QXGuildViewController alloc] init];
|
|
}else if([title isEqualToString:QXText(@"个性装扮")]){
|
|
vc = [[QXDressViewController alloc] init];
|
|
}else if([title isEqualToString:QXText(@"我的背包")]){
|
|
vc = [[QXBackpackViewController alloc] init];
|
|
}else if([title isEqualToString:QXText(@"每日任务")]){
|
|
vc = [[QXTaskViewController alloc] init];
|
|
}else if([title isEqualToString:QXText(@"钱包")]){
|
|
vc = [[QXWalletViewController alloc] init];
|
|
}
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
QXLOG(@"点击了%@",title);
|
|
}
|
|
-(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;
|
|
case QXMainHeaderOptionTypeRealName:{
|
|
QXLOG(@"跳转实名认证");
|
|
}
|
|
break;
|
|
case QXMainHeaderOptionTypeAnchorCenter:{
|
|
QXLOG(@"跳转主播中心");
|
|
}
|
|
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{
|
|
return 1;
|
|
}
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
QXMineServiceCell *cell = [QXMineServiceCell cellWithTableView:tableView];
|
|
cell.delegate = self;
|
|
return cell;
|
|
}
|
|
|
|
|
|
-(void)gotoSetting{
|
|
QXSettingViewController *vc = [[QXSettingViewController alloc] init];
|
|
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];
|
|
}
|
|
-(void)gotoRedbag{
|
|
QXInviteViewController *vc = [[QXInviteViewController alloc] init];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
-(void)gotoService{
|
|
QXHelpViewController *webvc = [[QXHelpViewController alloc] init];
|
|
[self.navigationController pushViewController:webvc animated:YES];
|
|
}
|
|
|
|
|
|
-(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);
|
|
}];
|
|
}
|
|
|
|
-(QXMainHeaderView *)tableHeaderView{
|
|
if (!_tableHeaderView) {
|
|
_tableHeaderView = [[QXMainHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 230+12-67+ScaleWidth(67))];
|
|
_tableHeaderView.delegate = self;
|
|
}
|
|
return _tableHeaderView;
|
|
}
|
|
-(UITableView *)tableView{
|
|
if (!_tableView) {
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-TabbarContentHeight-kSafeAreaTop) style:UITableViewStylePlain];
|
|
self.tableView.backgroundColor = [UIColor clearColor];
|
|
self.tableView.delegate = self;
|
|
self.tableView.dataSource = self;
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
|
self.tableView.rowHeight = 164;
|
|
}
|
|
return _tableView;
|
|
}
|
|
-(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;
|
|
}
|
|
@end
|