2025-08-08 10:49:36 +08:00
|
|
|
//
|
|
|
|
|
// QXExpansionViewController.m
|
|
|
|
|
// QXLive
|
|
|
|
|
//
|
|
|
|
|
// Created by 启星 on 2025/5/27.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "QXExpansionViewController.h"
|
|
|
|
|
#import "QXExpansionCell.h"
|
|
|
|
|
#import "UIButton+QX.h"
|
|
|
|
|
#import "QXMenuPopView.h"
|
|
|
|
|
#import "QXDynamicNetwork.h"
|
|
|
|
|
#import "QXUserHomePageViewController.h"
|
|
|
|
|
#import "QXExpansionAppStoreView.h"
|
|
|
|
|
|
|
|
|
|
@interface QXExpansionViewController ()<UITableViewDelegate,UITableViewDataSource,QXMenuPopViewDelegate>
|
|
|
|
|
@property (strong, nonatomic) UILabel *titleLabel;
|
|
|
|
|
@property (strong, nonatomic) UIButton *sortBtn;
|
|
|
|
|
@property (strong, nonatomic) UITableView *tableView;
|
|
|
|
|
@property (strong, nonatomic) NSString *type;
|
|
|
|
|
@property (strong, nonatomic) QXExpansionAppStoreView *appStoreView;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation QXExpansionViewController
|
|
|
|
|
-(UIView *)listView{
|
|
|
|
|
return self.view;
|
|
|
|
|
}
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess) name:noticeUserLogin object:nil];
|
|
|
|
|
}
|
|
|
|
|
- (void)initSubViews{
|
|
|
|
|
self.page = 1;
|
|
|
|
|
self.bgImageHidden = YES;
|
|
|
|
|
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 12, 100, 24)];
|
|
|
|
|
self.titleLabel.font = [UIFont systemFontOfSize:16];
|
2025-10-30 00:45:15 +08:00
|
|
|
self.titleLabel.textColor = RGB16(0xffffff);
|
2025-08-08 10:49:36 +08:00
|
|
|
self.titleLabel.text = QXText(@"扩列交友");
|
|
|
|
|
[self.view addSubview:self.titleLabel];
|
|
|
|
|
|
|
|
|
|
self.sortBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-75-13, 0, 75, 48)];
|
2025-10-30 00:45:15 +08:00
|
|
|
[self.sortBtn setImage:[[UIImage imageNamed:@"arrow_bottom"] imageByTintColor:RGB16(0xffffff)] forState:(UIControlStateNormal)];
|
2025-08-08 10:49:36 +08:00
|
|
|
if ([QXGlobal shareGlobal].loginModel.sex.integerValue == 1) {
|
|
|
|
|
[self.sortBtn setTitle:QXText(@"只看女生") forState:(UIControlStateNormal)];
|
|
|
|
|
self.type = @"2";
|
|
|
|
|
}else{
|
|
|
|
|
[self.sortBtn setTitle:QXText(@"只看男生") forState:(UIControlStateNormal)];
|
|
|
|
|
self.type = @"1";
|
|
|
|
|
}
|
2025-10-30 00:45:15 +08:00
|
|
|
[self.sortBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
|
2025-08-08 10:49:36 +08:00
|
|
|
self.sortBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
|
|
|
[self.sortBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:3];
|
|
|
|
|
[self.sortBtn addTarget:self action:@selector(sortAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
|
|
|
[self.view addSubview:self.sortBtn];
|
|
|
|
|
[self.view addSubview:self.tableView];
|
|
|
|
|
self.appStoreView.hidden = YES;
|
|
|
|
|
[self.view addSubview:self.appStoreView];
|
|
|
|
|
MJWeakSelf
|
|
|
|
|
self.appStoreView.userBlock = ^(QXUserHomeModel * _Nonnull user) {
|
2025-08-11 17:02:47 +08:00
|
|
|
if (!QXGlobal.shareGlobal.isLogin) {
|
|
|
|
|
[[QXGlobal shareGlobal] logOut];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-08-08 10:49:36 +08:00
|
|
|
if (user == nil) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
|
|
|
|
|
vc.user_id = user.user_id;
|
|
|
|
|
[weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
-(void)loginSuccess{
|
|
|
|
|
[self getData];
|
|
|
|
|
}
|
|
|
|
|
- (void)getData{
|
|
|
|
|
MJWeakSelf
|
|
|
|
|
[QXDynamicNetwork expansionListWithPage:self.page type:self.type successBlock:^(NSArray<QXUserHomeModel *> * _Nonnull list, BOOL isAppStore) {
|
|
|
|
|
if (weakSelf.page == 1) {
|
|
|
|
|
[weakSelf.dataArray removeAllObjects];
|
|
|
|
|
}
|
|
|
|
|
if (isAppStore) {
|
|
|
|
|
self.appStoreView.hidden = NO;
|
2025-10-30 00:45:15 +08:00
|
|
|
[self.sortBtn setTitleColor:RGB16(0xFFEB9D) forState:(UIControlStateNormal)];
|
|
|
|
|
[self.sortBtn setImage:[[UIImage imageNamed:@"arrow_bottom"] imageByTintColor:RGB16(0xFFEB9D)] forState:(UIControlStateNormal)];
|
|
|
|
|
self.sortBtn.top = ScaleWidth(71);
|
2025-08-08 10:49:36 +08:00
|
|
|
self.tableView.hidden = YES;
|
|
|
|
|
self.appStoreView.users = list;
|
2025-10-30 00:45:15 +08:00
|
|
|
self.titleLabel.hidden = YES;
|
2025-08-08 10:49:36 +08:00
|
|
|
}else{
|
2025-10-30 00:45:15 +08:00
|
|
|
[self.sortBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
|
|
|
|
|
[self.sortBtn setImage:[[UIImage imageNamed:@"arrow_bottom"] imageByTintColor:RGB16(0xffffff)] forState:(UIControlStateNormal)];
|
|
|
|
|
self.sortBtn.top = 0;
|
2025-08-08 10:49:36 +08:00
|
|
|
self.tableView.hidden = NO;
|
|
|
|
|
self.appStoreView.hidden = YES;
|
2025-10-30 00:45:15 +08:00
|
|
|
self.titleLabel.hidden = NO;
|
2025-08-08 10:49:36 +08:00
|
|
|
}
|
|
|
|
|
[weakSelf.dataArray addObjectsFromArray:list];
|
|
|
|
|
[weakSelf.tableView.mj_header endRefreshing];
|
|
|
|
|
if (list.count == 0) {
|
|
|
|
|
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
|
|
|
|
}else{
|
|
|
|
|
[weakSelf.tableView.mj_footer endRefreshing];
|
|
|
|
|
}
|
|
|
|
|
[self.tableView reloadData];
|
|
|
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
|
[weakSelf.tableView.mj_header endRefreshing];
|
|
|
|
|
[weakSelf.tableView.mj_footer endRefreshing];
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)sortAction{
|
|
|
|
|
QXMenuPopView *menuView = [[QXMenuPopView alloc] initWithPoint:CGPointMake(self.sortBtn.centerX, NavContentHeight+self.sortBtn.bottom-10)];
|
|
|
|
|
menuView.dataArray = @[QXText(@"只看女生"),QXText(@"只看男生"),QXText(@"查看全部")];
|
|
|
|
|
menuView.delegate = self;
|
|
|
|
|
[menuView showInView:KEYWINDOW];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)didSelectedIndex:(NSInteger)index menuTitle:(NSString *)menuTitle{
|
|
|
|
|
QXLOG(@"选择了%@",menuTitle);
|
|
|
|
|
if ([menuTitle isEqualToString:QXText(@"只看女生")]) {
|
|
|
|
|
self.page = 1;
|
|
|
|
|
self.type = @"2";
|
|
|
|
|
[self getData];
|
|
|
|
|
}else if ([menuTitle isEqualToString:QXText(@"只看男生")]) {
|
|
|
|
|
self.page = 1;
|
|
|
|
|
self.type = @"1";
|
|
|
|
|
[self getData];
|
|
|
|
|
}else{
|
|
|
|
|
self.page = 1;
|
|
|
|
|
self.type = @"0";
|
|
|
|
|
[self getData];
|
|
|
|
|
}
|
|
|
|
|
[self.sortBtn setTitle:menuTitle forState:(UIControlStateNormal)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
|
|
return self.dataArray.count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
|
QXExpansionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QXExpansionCell" forIndexPath:indexPath];
|
|
|
|
|
cell.selectionStyle = NO;
|
|
|
|
|
QXUserHomeModel *model = self.dataArray[indexPath.row];
|
|
|
|
|
cell.model = model;
|
|
|
|
|
return cell;
|
|
|
|
|
}
|
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
|
QXUserHomeModel *model = self.dataArray[indexPath.row];
|
|
|
|
|
NSArray *imgArr;
|
|
|
|
|
if (model.home_bgimages.length > 0) {
|
|
|
|
|
imgArr = [model.home_bgimages componentsSeparatedByString:@","];
|
|
|
|
|
}
|
|
|
|
|
// NSArray *
|
|
|
|
|
CGFloat itemH = 94;
|
|
|
|
|
if (imgArr.count == 1) {
|
|
|
|
|
itemH = (SCREEN_WIDTH-15-15-15)/2 + 94;
|
|
|
|
|
}else if(imgArr.count > 1){
|
|
|
|
|
if (imgArr.count > 3) {
|
|
|
|
|
itemH = (SCREEN_WIDTH-16*2-12*2-10*2)/3*2+10+94;
|
|
|
|
|
}else{
|
|
|
|
|
itemH = (SCREEN_WIDTH-16*2-12*2-10*2)/3+94;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
itemH = 94;
|
|
|
|
|
}
|
|
|
|
|
return itemH;
|
|
|
|
|
}
|
|
|
|
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
|
QXUserHomeModel *model = self.dataArray[indexPath.row];
|
|
|
|
|
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
|
|
|
|
|
vc.user_id = model.user_id;
|
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
|
}
|
|
|
|
|
-(UITableView *)tableView{
|
|
|
|
|
if (!_tableView) {
|
|
|
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.titleLabel.bottom+12, SCREEN_WIDTH, self.view.height-TabbarContentHeight-self.titleLabel.bottom-12) style:UITableViewStylePlain];
|
|
|
|
|
self.tableView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
self.tableView.delegate = self;
|
|
|
|
|
self.tableView.dataSource = self;
|
|
|
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
|
|
[self.tableView registerNib:[UINib nibWithNibName:@"QXExpansionCell" bundle:nil] forCellReuseIdentifier:@"QXExpansionCell"];
|
|
|
|
|
self.tableView.estimatedRowHeight = 94;
|
|
|
|
|
MJWeakSelf
|
|
|
|
|
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
|
|
|
|
weakSelf.page = 1;
|
|
|
|
|
[weakSelf getData];
|
|
|
|
|
}];
|
|
|
|
|
_tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
|
|
|
|
|
weakSelf.page++;
|
|
|
|
|
[weakSelf getData];
|
|
|
|
|
}];
|
|
|
|
|
self.tableView.hidden = NO;
|
|
|
|
|
}
|
|
|
|
|
return _tableView;
|
|
|
|
|
}
|
|
|
|
|
-(QXExpansionAppStoreView *)appStoreView{
|
|
|
|
|
if (!_appStoreView) {
|
|
|
|
|
_appStoreView = [[QXExpansionAppStoreView alloc] initWithFrame:self.tableView.bounds];
|
|
|
|
|
}
|
|
|
|
|
return _appStoreView;
|
|
|
|
|
}
|
|
|
|
|
@end
|