| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- //
- // BogoInviteDetailSubViewController.m
- // UniversalApp
- //
- // Created by Mac on 2021/6/10.
- // Copyright © 2021 voidcat. All rights reserved.
- //
- #import "BogoInviteDetailSubViewController.h"
- #import "BogoInviteListCell.h"
- #import "BogoInviteResponseModel.h"
- #import "BogoNetworkKit.h"
- @interface BogoInviteDetailSubViewController ()<UITableViewDelegate,UITableViewDataSource>
- @property(nonatomic, strong) UITableView *tableView;
- @property(nonatomic, strong) NSMutableArray *dataArray;
- @property(nonatomic, assign) NSInteger page;
- @end
- @implementation BogoInviteDetailSubViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.view);
- }];
- [self headerRefresh];
- }
- - (void)headerRefresh{
- self.page = 1;
- [self requestData];
- }
- - (void)footerRefresh{
- self.page ++;
- [self requestData];
- }
- - (void)requestData{
- // /mapi/index.php?ctl=invite_vue&act=invite_info_new&uid=2
- [[BogoNetwork shareInstance] POSTV4:@"" param:@{@"ctl":@"invite_vue",@"act":@"invite_info_new",@"page":@(self.page),@"type":@(self.type)} success:^(id _Nonnull result) {
- if (self.page == 1) {
- [self.dataArray removeAllObjects];
- }
- NSString *money = [NSString stringWithFormat:@"%@",result[@"data"]];
- [[NSNotificationCenter defaultCenter] postNotificationName:@"upldateTopViewMoney" object:money];
- NSArray *list = result[@"lists"];
- for (NSDictionary *dict in list) {
- BogoInviteResponseModelLists *model = [BogoInviteResponseModelLists mj_objectWithKeyValues:dict];
- [self.dataArray addObject:model];
- }
- [self.tableView reloadData];
- [self.tableView.mj_header endRefreshing];
- if (list.count < 20) {
- [self.tableView.mj_footer endRefreshingWithNoMoreData];
- }else{
- [self.tableView.mj_footer endRefreshing];
- }
- } failure:^(NSString * _Nonnull error) {
- [[BGHUDHelper sharedInstance] tipMessage:error];
- [self.tableView.mj_header endRefreshing];
- [self.tableView.mj_footer endRefreshing];
- }];
- }
- #pragma mark - UITableViewDelegate,UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.dataArray.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- BogoInviteListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BogoInviteListCell" forIndexPath:indexPath];
- if (indexPath.row < self.dataArray.count) {
- cell.model = self.dataArray[indexPath.row];
- }
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 54;
- }
- - (UITableView *)tableView{
- if (!_tableView) {
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 120) style:UITableViewStylePlain];
- _tableView.backgroundColor = kWhiteColor;
- _tableView.delegate = self;
- _tableView.dataSource = self;
- [_tableView registerNib:[UINib nibWithNibName:@"BogoInviteListCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"BogoInviteListCell"];
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
- _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
- }
- return _tableView;
- }
- - (NSMutableArray *)dataArray{
- if (!_dataArray) {
- _dataArray = [NSMutableArray array];
- }
- return _dataArray;
- }
- @end
|