// // JXPaiHangBangVc.m // shiku_im // // Created by 123 on 2020/5/19. // Copyright © 2020 Reese. All rights reserved. // #import "JXPaiHangBangVc.h" #import "XMGXianShiMshaView.h" #import "JXPhangBangCell.h" #import "JXPaiHangBangTopView.h" #import "MJRefresh.h" @interface JXPaiHangBangVc () @property (nonatomic,strong) UITableView *tableView; @property (nonatomic,strong) NSMutableArray *dataArr; @property (nonatomic,strong) NSMutableArray *dataArr2; @property (nonatomic,strong) MJRefreshHeaderView *header; @end @implementation JXPaiHangBangVc - (void)viewWillAppear:(BOOL)animated{ [self.navigationController setNavigationBarHidden:NO animated:NO]; } - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title=@"今日排行榜"; _dataArr=[NSMutableArray array]; [self defineNavBar:@"今日排行榜" andRinghtBtnImg:@""]; NSArray *dictArr=@[@{@"text":@"盈利榜",@"image":@"组1",@"subtile":@"宸荨樱桃",@"contet":@"盈利奖金:700000"}, @{@"text":@"充值榜",@"image":@"组1",@"subtile":@"宸荨樱桃",@"contet":@"总充值:1000000"}, @{@"text":@"打码榜",@"image":@"组1",@"subtile":@"宸荨樱桃",@"contet":@"总打码:2000000"}]; _dataArr2=[StatusesModel mj_objectArrayWithKeyValuesArray:dictArr]; /* UIImageView *backIMG=[[UIImageView alloc] init]; backIMG.image=[UIImage imageNamed:@"paihangbangicon"]; backIMG.frame=CGRectMake(0, 0, JX_SCREEN_WIDTH, 208); [self.view addSubview:backIMG]; XMGXianShiMshaView *centerView=[[XMGXianShiMshaView alloc]init]; centerView.frame=CGRectMake(0, 0, JX_SCREEN_WIDTH-0, 178); centerView.layer.cornerRadius=6; centerView.layer.masksToBounds=YES; centerView.delegate=self; centerView.dataArr=_dataArr2; [backIMG addSubview:centerView]; */ JXPaiHangBangTopView *topView=[JXPaiHangBangTopView XIBJXPaiHangBangTopView]; topView.frame=CGRectMake(0, JX_SCREEN_TOP,JX_SCREEN_WIDTH, 246); topView.jxpaiHangBangTopViewBlockBtn = ^(UIButton *sender) { NSString *typeStr=[NSString stringWithFormat:@"%zd",sender.tag]; long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [SVProgressHUD show]; [g_server getMyPaihangBang:salt andType:typeStr andToView:self]; }; [self.view addSubview:topView]; UIButton *topBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 30)]; topBtn.titleLabel.font=[UIFont systemFontOfSize:12 weight:UIFontWeightMedium]; [topBtn setTitle:@"下拉刷新" forState:UIControlStateNormal]; [topBtn setImage:[UIImage imageNamed:@"xialapaih"] forState:UIControlStateNormal]; _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(topView.frame), JX_SCREEN_WIDTH-0, JX_SCREEN_HEIGHT-CGRectGetMaxY(topView.frame))]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.showsVerticalScrollIndicator = NO; _tableView.showsHorizontalScrollIndicator = NO; _tableView.backgroundColor = kRGBColor(181, 27, 35); self.view.backgroundColor = kRGBColor(181, 27, 35); //_tableView.separatorStyle=UITableViewCellSeparatorStyleNone; _tableView.contentInset=UIEdgeInsetsMake(0, 0, 70, 0); [self.view addSubview:_tableView]; _tableView.tableFooterView=[UIView new]; _tableView.tableHeaderView=topBtn; topBtn.autoresizingMask=UIViewAutoresizingNone; //加载数据 [self loadData]; _header = [MJRefreshHeaderView header]; _header.pullShowStr=@"数据每日更新一次"; _header.scrollView = _tableView; __weak typeof(self) weakSelf = self; _header.beginRefreshingBlock = ^(MJRefreshBaseView *refreshView) { // 进入刷新状态就会回调这个Block [weakSelf loadData]; }; _header.endStateChangeBlock = ^(MJRefreshBaseView *refreshView) { // 刷新完毕就会回调这个Block // }; _header.refreshStateChangeBlock = ^(MJRefreshBaseView *refreshView, MJRefreshState state) { // 控件的刷新状态切换了就会调用这个block switch (state) { case MJRefreshStateNormal: // break; case MJRefreshStatePulling: // { } break; case MJRefreshStateRefreshing: // //@"%@----切换到:正在刷新状态", refreshView.class); break; default: break; } }; } /** * 加载数据 */ - (void)loadData{ long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [SVProgressHUD show]; [g_server getMyPaihangBang:salt andType:@"1" andToView:self]; } #pragma mark --- 请求成功 -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{ [SVProgressHUD dismiss]; [_header endRefreshing]; if([aDownload.action isEqualToString:act_usertopPHBall]) { NSLog(@"acccc2%@",array1); _dataArr=[JXMyModel mj_objectArrayWithKeyValuesArray:array1]; if (_dataArr.count>=1) { [_dataArr removeObjectAtIndex:0]; } [_tableView reloadData]; } } -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{ [SVProgressHUD dismiss]; [_header endRefreshing]; NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]; if([errorCode isEqualToString:@"权限验证失败"]) { if ([aDownload.action isEqualToString:act_GetBalanceRedTimes]) { } } return 1; } #pragma mark -- UICollectionViewDataSource - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 64; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return _dataArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ JXPhangBangCell *cell=[JXPhangBangCell cellWithTableView:tableView]; JXMyModel *model=_dataArr[indexPath.row]; [cell createStatuModl:model andIndexPath:indexPath.row+1]; return cell; } @end