// // 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" #import "QXChatViewController.h" #import "QXWalletRuleView.h" #import "QXRechargeViewcController.h" #import "QXGiftWallViewController.h" #import @interface QXMineViewController () @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 { self.isNoChangeBgImage = YES; [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]; [self.tableView reloadData]; [self.tableHeaderView reloadData]; } - (void)initSubViews{ [self updateBgImage:@"app_home_bg"]; 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) { }]; [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) { }]; } #pragma mark - QXMineServiceCellDelegate -(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]; } break; default: break; } } -(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 QXMainHeaderOptionTypeNobility:{ QXLOG(@"跳转贵族"); } break; 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]; } } 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 2; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ QXMineServiceCell *cell = [QXMineServiceCell cellWithTableView:tableView]; cell.delegate = self; if (indexPath.row == 0) { cell.isMore = NO; }else{ cell.isMore = YES; } return cell; } -(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); } } } -(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)gotoInvite{ QXInviteViewController *vc = [[QXInviteViewController alloc] init]; [self.navigationController pushViewController:vc animated:YES]; } -(void)gotoService{ QXHelpViewController *webvc = [[QXHelpViewController alloc] init]; [self.navigationController pushViewController:webvc animated:YES]; // 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]; } -(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, 0)]; _tableHeaderView.height = _tableHeaderView.getHeight; _tableHeaderView.delegate = self; } return _tableHeaderView; } -(UITableView *)tableView{ if (!_tableView) { self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-TabbarContentHeight) style:UITableViewStylePlain]; self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; } 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