123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- //
- // YOUPAILZGameListVC.m
- // VQU
- //
- // Created by CY on 2021/4/26.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZGameListVC.h"
- #import "YOUPAILZGameListCell.h"
- #import "YOUPAILZGameModel.h"
- #import "YOUPAILZGameCertificationVC.h"
- #import "UIScrollView+LZRefresh.h"
- #import "YOUPAILZSetterGamePriceVC.h"
- #import "LZAlertWindow.h"
- #import "UIViewController+TFPresent.h"
- @interface YOUPAILZGameListVC ()<UITableViewDataSource,UITableViewDelegate>
- @property (nonatomic, weak)UITableView *youpaiptableView;
- @property (nonatomic, assign)NSInteger youpaippage;
- @property (nonatomic, strong)NSMutableArray <YOUPAILZGameModel *>*youpaipdataSource;
- @end
- @implementation YOUPAILZGameListVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"游戏认证";
- [self youpaifsetupUI];
- [self.youpaiptableView.mj_header beginRefreshing];
- }
- - (void)youpaifsetupUI{
- UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
- tableView.dataSource = self;
- tableView.delegate = self;
- tableView.rowHeight = ScaleSize(242.0f) + 20.0f;
- tableView.estimatedRowHeight = ScaleSize(242.0f) + 20.0f;
- tableView.estimatedSectionHeaderHeight = 0.0f;
- tableView.estimatedSectionFooterHeight = 0.0f;
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- [self.view addSubview:tableView];
- self.youpaiptableView = tableView;
- [tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.right.offset(0.0f);
- make.top.offset(NavBarHeight);
- }];
-
- __weak typeof(self) weakSelf = self;
- [tableView setRefreshHeaderWithBlock:^{
- [weakSelf youpaifrequestGameList:kRefreshHeader];
- }];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.youpaipdataSource.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- NSString *cellID = @"GameListCell";
- YOUPAILZGameListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
- if (cell == nil) {
- cell = [[YOUPAILZGameListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
- }
- [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row]];
- __weak typeof(self) weakSelf = self;
- [cell setSetterPriceBtnClickBlock:^(YOUPAILZGameModel * _Nonnull model) {
- YOUPAILZSetterGamePriceVC *vc = [[YOUPAILZSetterGamePriceVC alloc] init];
- vc.youpaipgameModel = model;
- [weakSelf.navigationController pushViewController:vc animated:YES];
-
- }];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return 60.0f;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 60.0f)];
- UILabel *titleL = [[UILabel alloc] initWithFrame:CGRectMake(ScaleSize(16.0f), 0, KScreenWidth - ScaleSize(16.0f) * 2.0f, 60.0f)];
- titleL.text = @"选择技能";
- titleL.font = LCFont14;
- titleL.textColor = HexColorFromRGB(0x999999);
- [bgV addSubview:titleL];
- return bgV;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if (self.youpaipdataSource[indexPath.row].youpaipapplying == 1) {
- [ZCHUDHelper showTitle:@"正在审核中..."];
- return;
- }else if (self.youpaipdataSource[indexPath.row].youpaipapplying == 2){
- LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"否" handler:^(LZAlertAction *action) {
-
- }];
- cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
- LZAlertAction *confirmAction = [LZAlertAction actionWithTitle:@"是" handler:^(LZAlertAction *action) {
- [self youpaifgoGameCertificationVCWithIndex:indexPath.row];
- }];
- confirmAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
- LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"" content:@"你已经通过了该游戏认证,需要重新提交认证吗?" action:@[cancelAction,confirmAction]];
- alert.isTouchDismiss = YES;
- [self TFPresentVC:alert completion:^{}];
- }else{
- [self youpaifgoGameCertificationVCWithIndex:indexPath.row];
- }
-
- }
- - (void)youpaifgoGameCertificationVCWithIndex:(NSInteger)index{
- YOUPAILZGameCertificationVC *vc = [[YOUPAILZGameCertificationVC alloc] init];
- vc.youpaipgameModel = self.youpaipdataSource[index];
- vc.youpaipindex = 0;
- [self.navigationController pushViewController:vc animated:YES];
- }
- /// 获取预约列表数据
- - (void)youpaifrequestGameList:(kRefreshStatus)status{
- if (status == kRefreshFooter) {
- self.youpaippage ++;
- }else{
- self.youpaippage = 1;
- }
- [LCHttpHelper requestWithURLString:GameList parameters:@{@"page":@(self.youpaippage)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- [self.youpaiptableView endRefreshing:kRefreshAll];
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- if (status != kRefreshFooter) {
- [self.youpaipdataSource removeAllObjects];
- }
- NSDictionary *data = [dict objectForKey:@"data"];
- NSArray <YOUPAILZGameModel *>*list = [YOUPAILZGameModel mj_objectArrayWithKeyValuesArray:[data objectForKey:@"list"]];
- [self.youpaipdataSource addObjectsFromArray:list];
- [self.youpaiptableView reloadData];
-
- NSInteger totalPage = [[data objectForKey:@"total_page"] integerValue];
- [self youpaifrefreshFooterWithHidden:self.youpaippage >= totalPage];
- }
- } failure:^(NSError *error) {
- [self.youpaiptableView endRefreshing:kRefreshAll];
- }];
- }
- /// 设置加载更多
- - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
- __weak typeof(self) weakSelf = self;
- [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
- [weakSelf youpaifrequestGameList:kRefreshFooter];
- }];
- }
- - (NSMutableArray<YOUPAILZGameModel *> *)youpaipdataSource{
- if (_youpaipdataSource == nil) {
- _youpaipdataSource = [NSMutableArray array];
- }
- return _youpaipdataSource;
- }
- @end
|