YOUPAILZGameListVC.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // YOUPAILZGameListVC.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/4/26.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZGameListVC.h"
  9. #import "YOUPAILZGameListCell.h"
  10. #import "YOUPAILZGameModel.h"
  11. #import "YOUPAILZGameCertificationVC.h"
  12. #import "UIScrollView+LZRefresh.h"
  13. #import "YOUPAILZSetterGamePriceVC.h"
  14. #import "LZAlertWindow.h"
  15. #import "UIViewController+TFPresent.h"
  16. @interface YOUPAILZGameListVC ()<UITableViewDataSource,UITableViewDelegate>
  17. @property (nonatomic, weak)UITableView *youpaiptableView;
  18. @property (nonatomic, assign)NSInteger youpaippage;
  19. @property (nonatomic, strong)NSMutableArray <YOUPAILZGameModel *>*youpaipdataSource;
  20. @end
  21. @implementation YOUPAILZGameListVC
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.title = @"游戏认证";
  25. [self youpaifsetupUI];
  26. [self.youpaiptableView.mj_header beginRefreshing];
  27. }
  28. - (void)youpaifsetupUI{
  29. UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  30. tableView.dataSource = self;
  31. tableView.delegate = self;
  32. tableView.rowHeight = ScaleSize(242.0f) + 20.0f;
  33. tableView.estimatedRowHeight = ScaleSize(242.0f) + 20.0f;
  34. tableView.estimatedSectionHeaderHeight = 0.0f;
  35. tableView.estimatedSectionFooterHeight = 0.0f;
  36. tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  37. [self.view addSubview:tableView];
  38. self.youpaiptableView = tableView;
  39. [tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  40. make.left.bottom.right.offset(0.0f);
  41. make.top.offset(NavBarHeight);
  42. }];
  43. __weak typeof(self) weakSelf = self;
  44. [tableView setRefreshHeaderWithBlock:^{
  45. [weakSelf youpaifrequestGameList:kRefreshHeader];
  46. }];
  47. }
  48. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  49. return self.youpaipdataSource.count;
  50. }
  51. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  52. NSString *cellID = @"GameListCell";
  53. YOUPAILZGameListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  54. if (cell == nil) {
  55. cell = [[YOUPAILZGameListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  56. }
  57. [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row]];
  58. __weak typeof(self) weakSelf = self;
  59. [cell setSetterPriceBtnClickBlock:^(YOUPAILZGameModel * _Nonnull model) {
  60. YOUPAILZSetterGamePriceVC *vc = [[YOUPAILZSetterGamePriceVC alloc] init];
  61. vc.youpaipgameModel = model;
  62. [weakSelf.navigationController pushViewController:vc animated:YES];
  63. }];
  64. return cell;
  65. }
  66. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  67. return 60.0f;
  68. }
  69. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  70. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 60.0f)];
  71. UILabel *titleL = [[UILabel alloc] initWithFrame:CGRectMake(ScaleSize(16.0f), 0, KScreenWidth - ScaleSize(16.0f) * 2.0f, 60.0f)];
  72. titleL.text = @"选择技能";
  73. titleL.font = LCFont14;
  74. titleL.textColor = HexColorFromRGB(0x999999);
  75. [bgV addSubview:titleL];
  76. return bgV;
  77. }
  78. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  79. if (self.youpaipdataSource[indexPath.row].youpaipapplying == 1) {
  80. [ZCHUDHelper showTitle:@"正在审核中..."];
  81. return;
  82. }else if (self.youpaipdataSource[indexPath.row].youpaipapplying == 2){
  83. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"否" handler:^(LZAlertAction *action) {
  84. }];
  85. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  86. LZAlertAction *confirmAction = [LZAlertAction actionWithTitle:@"是" handler:^(LZAlertAction *action) {
  87. [self youpaifgoGameCertificationVCWithIndex:indexPath.row];
  88. }];
  89. confirmAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  90. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"" content:@"你已经通过了该游戏认证,需要重新提交认证吗?" action:@[cancelAction,confirmAction]];
  91. alert.isTouchDismiss = YES;
  92. [self TFPresentVC:alert completion:^{}];
  93. }else{
  94. [self youpaifgoGameCertificationVCWithIndex:indexPath.row];
  95. }
  96. }
  97. - (void)youpaifgoGameCertificationVCWithIndex:(NSInteger)index{
  98. YOUPAILZGameCertificationVC *vc = [[YOUPAILZGameCertificationVC alloc] init];
  99. vc.youpaipgameModel = self.youpaipdataSource[index];
  100. vc.youpaipindex = 0;
  101. [self.navigationController pushViewController:vc animated:YES];
  102. }
  103. /// 获取预约列表数据
  104. - (void)youpaifrequestGameList:(kRefreshStatus)status{
  105. if (status == kRefreshFooter) {
  106. self.youpaippage ++;
  107. }else{
  108. self.youpaippage = 1;
  109. }
  110. [LCHttpHelper requestWithURLString:GameList parameters:@{@"page":@(self.youpaippage)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  111. [self.youpaiptableView endRefreshing:kRefreshAll];
  112. NSDictionary* dict = (NSDictionary*)responseObject;
  113. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  114. if (code == 0) {//成功
  115. if (status != kRefreshFooter) {
  116. [self.youpaipdataSource removeAllObjects];
  117. }
  118. NSDictionary *data = [dict objectForKey:@"data"];
  119. NSArray <YOUPAILZGameModel *>*list = [YOUPAILZGameModel mj_objectArrayWithKeyValuesArray:[data objectForKey:@"list"]];
  120. [self.youpaipdataSource addObjectsFromArray:list];
  121. [self.youpaiptableView reloadData];
  122. NSInteger totalPage = [[data objectForKey:@"total_page"] integerValue];
  123. [self youpaifrefreshFooterWithHidden:self.youpaippage >= totalPage];
  124. }
  125. } failure:^(NSError *error) {
  126. [self.youpaiptableView endRefreshing:kRefreshAll];
  127. }];
  128. }
  129. /// 设置加载更多
  130. - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
  131. __weak typeof(self) weakSelf = self;
  132. [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
  133. [weakSelf youpaifrequestGameList:kRefreshFooter];
  134. }];
  135. }
  136. - (NSMutableArray<YOUPAILZGameModel *> *)youpaipdataSource{
  137. if (_youpaipdataSource == nil) {
  138. _youpaipdataSource = [NSMutableArray array];
  139. }
  140. return _youpaipdataSource;
  141. }
  142. @end