123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- //
- // YOUPAIHRCoinDetailVC.m
- // VQU
- //
- // Created by xiaohaoran on 2021/10/19.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAIHRCoinDetailVC.h"
- #import "YOUPAIHRCoinDetailCell.h"
- #import "YOUPAIHRCoinDetailModel.h"
- @interface YOUPAIHRCoinDetailVC ()<UITableViewDelegate,UITableViewDataSource>{
-
- int ispage;
- int nextpage;
- }
- @property(nonatomic,strong)UITableView *youpaiptableView;
- @property(nonatomic,strong)NSMutableArray *youpaipdataArr;//数据源
- @end
- @implementation YOUPAIHRCoinDetailVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"贵族币明细";
- self.view.backgroundColor = LCBkgColor;
- [self youpaiptableView];
- [self youpaifRefreshUI];
- }
- -(void)youpaifRefreshUI{
-
- nextpage = 1;
- self.view.tag = 1;
- @weakify(self);
- self.youpaiptableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- @strongify(self);
- self->nextpage = 1;
-
- [self youpaifgetNobleCoinLog];
-
- }];
-
- // 上拉刷新
- self.youpaiptableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
- @strongify(self);
-
-
-
- if (self->nextpage< self->ispage) {
- self.view.tag = 2;
- self->nextpage = self->nextpage+1;
- [self youpaifgetNobleCoinLog];
- }else
- {
- [self.youpaiptableView.mj_footer endRefreshing];
- [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
- }
-
- }];
-
- [self.youpaiptableView.mj_header beginRefreshing];
-
- }
- #pragma mark UITableViewDelegate&UITableViewDataSource
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- return 75;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return self.youpaipdataArr.count;
- }
- -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAIHRCoinDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HRCoinDetailID"];
- if (cell == nil) {
- cell = [[YOUPAIHRCoinDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"HRCoinDetailID"];
- }
- YOUPAIHRCoinDetailModel *model = self.youpaipdataArr[indexPath.row];
- cell.youpaipmodel = model;
- cell.backgroundColor = LCBkgColor;
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
-
- return cell;
- }
- -(UITableView *)youpaiptableView{
- if (!_youpaiptableView) {
- _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
- [self.view addSubview:_youpaiptableView];
- [_youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.top.mas_equalTo(NavBarHeight);
- make.bottom.mas_equalTo(-SafeHeight);
- make.right.mas_equalTo(0);
- }];
- _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _youpaiptableView.showsVerticalScrollIndicator = NO;
- _youpaiptableView.showsHorizontalScrollIndicator = NO;
- _youpaiptableView.delegate = self;
- _youpaiptableView.dataSource = self;
- _youpaiptableView.backgroundColor = LCBkgColor;
- [_youpaiptableView registerClass:[YOUPAIHRCoinDetailCell class] forCellReuseIdentifier:@"HRCoinDetailID"];
- _youpaiptableView.tableFooterView = [UIView new];
- if (@available(iOS 15.0, *)) {
- _youpaiptableView.sectionHeaderTopPadding = 0;
- }
- }
- return _youpaiptableView;
- }
- #pragma 获取数据
- -(void)youpaifgetNobleCoinLog{
-
-
- [LCHttpHelper requestWithURLString:GetNobleCoinLog parameters:@{@"page":[NSString stringWithFormat:@"%d",nextpage]} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- [self.youpaiptableView.mj_header endRefreshing];
- NSDictionary *dic = dict[@"data"];
- NSMutableArray *arrM = [NSMutableArray new];
- if (self.view.tag == 1) {
-
- NSArray *arr = dic[@"list"];
- if (arr.count<=0) {
- [self.youpaipdataArr removeAllObjects];
- [self.youpaiptableView reloadData];
- return ;
- }
- [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- YOUPAIHRCoinDetailModel *noticModel = [YOUPAIHRCoinDetailModel mj_objectWithKeyValues:obj];
- [self.youpaipdataArr addObject:noticModel];
- [arrM addObject:noticModel];
-
- }];
- if (self->nextpage == 1) {
- self.youpaipdataArr = arrM;
- self->nextpage = [dict[@"data"][@"page"] intValue];
- self->ispage = [dict[@"data"][@"total_page"] intValue];
- [self.youpaiptableView reloadData];
- }
-
- }else{
-
- NSArray *arr = dic[@"list"];
- if (arr.count<=0) {
- return ;
- }
- [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- YOUPAIHRCoinDetailModel *noticModel = [YOUPAIHRCoinDetailModel mj_objectWithKeyValues:obj];
- [self.youpaipdataArr addObject:noticModel];
-
-
- }];
- self->nextpage = [dict[@"data"][@"page"] intValue];
- self->ispage = [dict[@"data"][@"total_page"] intValue];
-
- [self.youpaiptableView reloadData];
- [self.youpaiptableView.mj_header endRefreshing];
- [self.youpaiptableView.mj_footer endRefreshing];
- }
- }
- } failure:^(NSError *error) {
-
- [self.youpaiptableView.mj_header endRefreshing];
- [self.youpaiptableView.mj_footer endRefreshing];
- }];
-
- }
- -(NSMutableArray *)youpaipdataArr{
-
- if (_youpaipdataArr == nil) {
- _youpaipdataArr = [NSMutableArray new];
- }
-
- return _youpaipdataArr;
- }
- @end
|