首次提交
This commit is contained in:
158
SweetParty/主类/RCMic/Room/Box/手气榜/ShouQiBangVC.m
Executable file
158
SweetParty/主类/RCMic/Room/Box/手气榜/ShouQiBangVC.m
Executable file
@@ -0,0 +1,158 @@
|
||||
//
|
||||
// ShouQiBangVC.m
|
||||
// miliao
|
||||
//
|
||||
// Created by 翟三美 on 2020/6/27.
|
||||
// Copyright © 2020 miliao. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ShouQiBangVC.h"
|
||||
#import <HWPopController/HWPop.h>
|
||||
#import "ShouQiBangCell.h"
|
||||
#import "BJBoxRankModel.h"
|
||||
@interface ShouQiBangVC ()<UITableViewDelegate,UITableViewDataSource>
|
||||
@property(nonatomic, strong) UITableView *tableView;
|
||||
@property(nonatomic, strong) NSMutableArray *dataArray;
|
||||
/*页码*/
|
||||
@property(nonatomic, assign) NSInteger page;
|
||||
|
||||
/*返回*/
|
||||
@property(nonatomic, strong) UIButton *backBtn;
|
||||
@end
|
||||
|
||||
@implementation ShouQiBangVC
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.page = 1;
|
||||
//设置区域
|
||||
self.contentSizeInPop = CGSizeMake(ScreenWidth, ScreenHeight);
|
||||
//表视图
|
||||
[self.view addSubview:self.tableView];
|
||||
self.view.backgroundColor =COLOR16(0xf8f8f8);
|
||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.bottom.equalTo(self.view);
|
||||
make.top.mas_equalTo(162);
|
||||
}];
|
||||
//返回按钮
|
||||
[self.view addSubview:self.backBtn];
|
||||
[self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.view).offset(15);
|
||||
make.top.equalTo(self.view).offset(ZJStatusBarH+10);
|
||||
make.width.mas_equalTo(10);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
__weak __typeof(self)weakSelf = self;
|
||||
[self.backBtn buttonAddTaget:^(UIButton *btn) {
|
||||
[weakSelf.navigationController popViewControllerAnimated:YES];
|
||||
[weakSelf dismissViewControllerAnimated:YES completion:nil];
|
||||
} forControlEvents:UIControlEventTouchUpInside];
|
||||
[self getRecord];
|
||||
|
||||
}
|
||||
//获取推荐动态
|
||||
- (void)getRecord
|
||||
{
|
||||
[self loadDataIsRefresh:YES];
|
||||
[ZJUIUtil refreshWithHeader:self.tableView refresh:^{
|
||||
WEAK_SELF
|
||||
weakSelf.page = 1;
|
||||
[weakSelf loadDataIsRefresh:YES];
|
||||
}];
|
||||
[ZJUIUtil refreshWithFooter:self.tableView refresh:^{
|
||||
WEAK_SELF
|
||||
weakSelf.page ++;
|
||||
[weakSelf loadDataIsRefresh:NO];
|
||||
}];
|
||||
//解决加载更多数据时界面跳动问题
|
||||
self.tableView.estimatedRowHeight = 0;
|
||||
self.tableView.estimatedSectionHeaderHeight = 0;
|
||||
self.tableView.estimatedSectionFooterHeight = 0;
|
||||
}
|
||||
-(void)loadDataIsRefresh:(BOOL)isRefresh
|
||||
{
|
||||
|
||||
if (isRefresh) {
|
||||
[self.dataArray removeAllObjects];
|
||||
}
|
||||
NSString *page = [NSString stringWithFormat:@"%zd",self.page];
|
||||
|
||||
NSDictionary *dict = @{@"page":page};
|
||||
[BJHttpTool getShouQiBangListWithParameters:dict success:^(id response) {
|
||||
NSArray *allArray = [BJBoxRankModel mj_objectArrayWithKeyValuesArray:response[@"data"]];
|
||||
if (allArray.count > 0) {
|
||||
[self.dataArray addObjectsFromArray:allArray];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.page --;
|
||||
}
|
||||
[self.tableView.mj_header endRefreshing];
|
||||
[self.tableView.mj_footer endRefreshing];
|
||||
[self.tableView reloadData];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
[self.tableView.mj_header endRefreshing];
|
||||
[self.tableView.mj_footer endRefreshing];
|
||||
}];
|
||||
}
|
||||
#pragma mark -------------------tableview代理-------------------------
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.dataArray.count;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return 83;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
static NSString *identifier = @"ShouQiBangCell";
|
||||
ShouQiBangCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
|
||||
if (!cell) {
|
||||
cell = [[ShouQiBangCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
|
||||
}
|
||||
cell.model = self.dataArray[indexPath.row];
|
||||
cell.contentView.backgroundColor = kClearColor;
|
||||
cell.backgroundColor = kClearColor;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -------------------懒加载-------------------------
|
||||
- (UITableView *)tableView{
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
// _tableView.contentInset = UIEdgeInsetsMake(0, 10, 0, 10);
|
||||
_tableView.backgroundColor = kWhiteColor;
|
||||
_tableView.showsVerticalScrollIndicator = NO;
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
|
||||
_tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[_tableView registerNib:[UINib nibWithNibName:@"ShouQiBangCell" bundle:nil] forCellReuseIdentifier:@"ShouQiBangCell"];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)dataArray{
|
||||
if (!_dataArray) {
|
||||
_dataArray = [NSMutableArray array];
|
||||
}
|
||||
return _dataArray;
|
||||
}
|
||||
- (UIButton *)backBtn{
|
||||
if (!_backBtn) {
|
||||
_backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_backBtn setImage:ImageNamed(@"l_back") forState:UIControlStateNormal];
|
||||
}
|
||||
return _backBtn;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user