Files
featherVoice/QXLive/Login(登录)/Controlller/QXAccountListViewController.m
2025-08-08 10:49:36 +08:00

91 lines
3.1 KiB
Objective-C

//
// QXAccountListViewController.m
// QXLive
//
// Created by 启星 on 2025/5/19.
//
#import "QXAccountListViewController.h"
#import "QXBlackListCell.h"
#import "QXLoginNetwork.h"
#import "AppDelegate+Login.h"
#import "QXFillUserInfoViewController.h"
@interface QXAccountListViewController ()<UITableViewDelegate,UITableViewDataSource,QXBlackListCellDelegate>
@property (nonatomic,strong)UITableView *tableView;
@end
@implementation QXAccountListViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)setNavgationItems{
[super setNavgationItems];
self.navigationItem.title = QXText(@"选择账号");
}
-(void)initSubViews{
[self.view addSubview:self.tableView];
}
#pragma mark - UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.accountList.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
QXBlackListCell *cell = [QXBlackListCell cellWithTableView:tableView];
cell.cellType = QXBlackListCellTypeLogin;
cell.loginModel = self.accountList[indexPath.row];
cell.delegate = self;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
#pragma mark - QXBlackListCellDelegate
-(void)didClickLoginWithModel:(QXLoginModel *)model{
__block QXLoginModel *loginModel = model;
MJWeakSelf
[QXLoginNetwork loginAccountWithUser_login:model.user_id successBlock:^(id _Nonnull responseObject) {
hideLoadingInView(self.view);
[[QXGlobal shareGlobal] saveLoginData:[loginModel yy_modelToJSONString]];
AppDelegate *delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
[delegate tencentLogin];
if ([loginModel.sex isEqualToString:@"0"]) {
// 没有完善个人信息
QXFillUserInfoViewController *fillVC = [[QXFillUserInfoViewController alloc] init];
[weakSelf.navigationController pushViewController:fillVC animated:YES];
}else{
[weakSelf.navigationController dismissViewControllerAnimated:YES completion:^{
}];
}
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
}
-(UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight) style:(UITableViewStylePlain)];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.rowHeight = 62;
}
return _tableView;
}
@end