JXPaiHangBangVc.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. //
  2. // JXPaiHangBangVc.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/5/19.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXPaiHangBangVc.h"
  9. #import "XMGXianShiMshaView.h"
  10. #import "JXPhangBangCell.h"
  11. #import "JXPaiHangBangTopView.h"
  12. #import "MJRefresh.h"
  13. @interface JXPaiHangBangVc ()<UITableViewDelegate,UITableViewDataSource,XMGXianshiMSTCellDelegate>
  14. @property (nonatomic,strong) UITableView *tableView;
  15. @property (nonatomic,strong) NSMutableArray *dataArr;
  16. @property (nonatomic,strong) NSMutableArray *dataArr2;
  17. @property (nonatomic,strong) MJRefreshHeaderView *header;
  18. @end
  19. @implementation JXPaiHangBangVc
  20. - (void)viewWillAppear:(BOOL)animated{
  21. [self.navigationController setNavigationBarHidden:NO animated:NO];
  22. }
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. self.navigationItem.title=@"今日排行榜";
  26. _dataArr=[NSMutableArray array];
  27. [self defineNavBar:@"今日排行榜" andRinghtBtnImg:@""];
  28. NSArray *dictArr=@[@{@"text":@"盈利榜",@"image":@"组1",@"subtile":@"宸荨樱桃",@"contet":@"盈利奖金:700000"},
  29. @{@"text":@"充值榜",@"image":@"组1",@"subtile":@"宸荨樱桃",@"contet":@"总充值:1000000"},
  30. @{@"text":@"打码榜",@"image":@"组1",@"subtile":@"宸荨樱桃",@"contet":@"总打码:2000000"}];
  31. _dataArr2=[StatusesModel mj_objectArrayWithKeyValuesArray:dictArr];
  32. /*
  33. UIImageView *backIMG=[[UIImageView alloc] init];
  34. backIMG.image=[UIImage imageNamed:@"paihangbangicon"];
  35. backIMG.frame=CGRectMake(0, 0, JX_SCREEN_WIDTH, 208);
  36. [self.view addSubview:backIMG];
  37. XMGXianShiMshaView *centerView=[[XMGXianShiMshaView alloc]init];
  38. centerView.frame=CGRectMake(0, 0, JX_SCREEN_WIDTH-0, 178);
  39. centerView.layer.cornerRadius=6;
  40. centerView.layer.masksToBounds=YES;
  41. centerView.delegate=self;
  42. centerView.dataArr=_dataArr2;
  43. [backIMG addSubview:centerView];
  44. */
  45. JXPaiHangBangTopView *topView=[JXPaiHangBangTopView XIBJXPaiHangBangTopView];
  46. topView.frame=CGRectMake(0, JX_SCREEN_TOP,JX_SCREEN_WIDTH, 246);
  47. topView.jxpaiHangBangTopViewBlockBtn = ^(UIButton *sender) {
  48. NSString *typeStr=[NSString stringWithFormat:@"%zd",sender.tag];
  49. long time = (long)[[NSDate date] timeIntervalSince1970];
  50. time = (time *1000 + g_server.timeDifference);
  51. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  52. [SVProgressHUD show];
  53. [g_server getMyPaihangBang:salt andType:typeStr andToView:self];
  54. };
  55. [self.view addSubview:topView];
  56. UIButton *topBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 30)];
  57. topBtn.titleLabel.font=[UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
  58. [topBtn setTitle:@"下拉刷新" forState:UIControlStateNormal];
  59. [topBtn setImage:[UIImage imageNamed:@"xialapaih"] forState:UIControlStateNormal];
  60. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(topView.frame), JX_SCREEN_WIDTH-0, JX_SCREEN_HEIGHT-CGRectGetMaxY(topView.frame))];
  61. _tableView.delegate = self;
  62. _tableView.dataSource = self;
  63. _tableView.showsVerticalScrollIndicator = NO;
  64. _tableView.showsHorizontalScrollIndicator = NO;
  65. _tableView.backgroundColor = kRGBColor(181, 27, 35);
  66. self.view.backgroundColor = kRGBColor(181, 27, 35);
  67. //_tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  68. _tableView.contentInset=UIEdgeInsetsMake(0, 0, 70, 0);
  69. [self.view addSubview:_tableView];
  70. _tableView.tableFooterView=[UIView new];
  71. _tableView.tableHeaderView=topBtn;
  72. topBtn.autoresizingMask=UIViewAutoresizingNone;
  73. //加载数据
  74. [self loadData];
  75. _header = [MJRefreshHeaderView header];
  76. _header.pullShowStr=@"数据每日更新一次";
  77. _header.scrollView = _tableView;
  78. __weak typeof(self) weakSelf = self;
  79. _header.beginRefreshingBlock = ^(MJRefreshBaseView *refreshView) {
  80. // 进入刷新状态就会回调这个Block
  81. [weakSelf loadData];
  82. };
  83. _header.endStateChangeBlock = ^(MJRefreshBaseView *refreshView) {
  84. // 刷新完毕就会回调这个Block
  85. //
  86. };
  87. _header.refreshStateChangeBlock = ^(MJRefreshBaseView *refreshView, MJRefreshState state) {
  88. // 控件的刷新状态切换了就会调用这个block
  89. switch (state) {
  90. case MJRefreshStateNormal:
  91. //
  92. break;
  93. case MJRefreshStatePulling:
  94. //
  95. {
  96. }
  97. break;
  98. case MJRefreshStateRefreshing:
  99. // //@"%@----切换到:正在刷新状态", refreshView.class);
  100. break;
  101. default:
  102. break;
  103. }
  104. };
  105. }
  106. /**
  107. * 加载数据
  108. */
  109. - (void)loadData{
  110. long time = (long)[[NSDate date] timeIntervalSince1970];
  111. time = (time *1000 + g_server.timeDifference);
  112. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  113. [SVProgressHUD show];
  114. [g_server getMyPaihangBang:salt andType:@"1" andToView:self];
  115. }
  116. #pragma mark --- 请求成功
  117. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  118. [SVProgressHUD dismiss];
  119. [_header endRefreshing];
  120. if([aDownload.action isEqualToString:act_usertopPHBall])
  121. {
  122. NSLog(@"acccc2%@",array1);
  123. _dataArr=[JXMyModel mj_objectArrayWithKeyValuesArray:array1];
  124. if (_dataArr.count>=1) {
  125. [_dataArr removeObjectAtIndex:0];
  126. }
  127. [_tableView reloadData];
  128. }
  129. }
  130. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  131. [SVProgressHUD dismiss];
  132. [_header endRefreshing];
  133. NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
  134. if([errorCode isEqualToString:@"权限验证失败"])
  135. {
  136. if ([aDownload.action isEqualToString:act_GetBalanceRedTimes])
  137. {
  138. }
  139. }
  140. return 1;
  141. }
  142. #pragma mark -- UICollectionViewDataSource
  143. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  144. return 64;
  145. }
  146. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  147. return _dataArr.count;
  148. }
  149. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  150. JXPhangBangCell *cell=[JXPhangBangCell cellWithTableView:tableView];
  151. JXMyModel *model=_dataArr[indexPath.row];
  152. [cell createStatuModl:model andIndexPath:indexPath.row+1];
  153. return cell;
  154. }
  155. @end