YOUPAIHROperationRecordVC.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // YOUPAIHROperationRecordVC.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/11/8.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHROperationRecordVC.h"
  9. #import "YOUPAIHROperationRecordCell.h"
  10. #import "UIScrollView+LZRefresh.h"
  11. #import "YOUPAIHROperationRecordModel.h"
  12. @interface YOUPAIHROperationRecordVC ()<UITableViewDelegate,UITableViewDataSource>
  13. @property(nonatomic,strong)UITableView *youpaiptableView;
  14. @property (nonatomic, assign) NSInteger youpaippage;
  15. @property (nonatomic, strong) NSMutableArray *youpaipdataSource;
  16. @end
  17. @implementation YOUPAIHROperationRecordVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.title = @"操作记录";
  21. [self youpaiptableView];
  22. @weakify(self);
  23. [self.youpaiptableView setRefreshHeaderWithBlock:^{
  24. @strongify(self);
  25. [self youpaifrequestRankListWithStatus:kRefreshHeader];
  26. }];
  27. [self.youpaiptableView.mj_header beginRefreshing];
  28. }
  29. /// 设置加载更多
  30. - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
  31. @weakify(self);
  32. [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
  33. @strongify(self);
  34. [self youpaifrequestRankListWithStatus:kRefreshFooter];
  35. }];
  36. }
  37. - (void)youpaifrequestRankListWithStatus:(kRefreshStatus)status{
  38. if (status == kRefreshFooter) {
  39. self.youpaippage ++;
  40. }else{
  41. self.youpaippage = 1;
  42. }
  43. @weakify(self);
  44. [LCHttpHelper requestWithURLString:ChatRoom_operationLog parameters:@{@"page":@(self.youpaippage),@"room_id":@(self.youpaiproom_id)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  45. @strongify(self);
  46. [self.youpaiptableView endRefreshing:kRefreshAll];
  47. NSDictionary* dict = (NSDictionary*)responseObject;
  48. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  49. if (code == 0) {//成功
  50. if (status != kRefreshFooter) {
  51. [self.youpaipdataSource removeAllObjects];
  52. }
  53. NSDictionary *data = [dict objectForKey:@"data"];
  54. NSArray <YOUPAIHROperationRecordModel *>*list = [YOUPAIHROperationRecordModel mj_objectArrayWithKeyValuesArray:[data objectForKey:@"list"]];
  55. [self.youpaipdataSource addObjectsFromArray:list];
  56. [self.youpaiptableView reloadData];
  57. NSInteger totalPage = [data[@"total_page"] integerValue];
  58. [self youpaifrefreshFooterWithHidden:self.youpaippage >= totalPage];
  59. if (self.youpaipdataSource.count != 0) {
  60. [self.youpaiptableView lz_hideEmptyView];
  61. }else{
  62. [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"];
  63. }
  64. }
  65. } failure:^(NSError *error) {
  66. @strongify(self);
  67. [self.youpaiptableView endRefreshing:kRefreshAll];
  68. }];
  69. }
  70. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  71. return 68;
  72. }
  73. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  74. return self.youpaipdataSource.count;
  75. }
  76. -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  77. YOUPAIHROperationRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HROperationRecordID" forIndexPath:indexPath];;
  78. if (cell == nil) {
  79. cell = [[YOUPAIHROperationRecordCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"HROperationRecordID"];
  80. }
  81. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  82. cell.backgroundColor = LCBkgColor;
  83. YOUPAIHROperationRecordModel *model = self.youpaipdataSource[indexPath.row];
  84. cell.youpaipmodel = model;
  85. return cell;
  86. }
  87. -(UITableView *)youpaiptableView
  88. {
  89. if (_youpaiptableView == nil) {
  90. _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
  91. [self.view addSubview:_youpaiptableView];
  92. [_youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.top.mas_equalTo(NavBarHeight);
  94. make.left.mas_equalTo(0);
  95. make.right.mas_equalTo(0);
  96. make.bottom.mas_equalTo(-SafeHeight);
  97. }];
  98. _youpaiptableView.delegate = self;
  99. _youpaiptableView.dataSource = self;
  100. _youpaiptableView.backgroundColor = [UIColor clearColor];
  101. _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  102. _youpaiptableView.showsVerticalScrollIndicator = NO;
  103. _youpaiptableView.showsHorizontalScrollIndicator = NO;
  104. if (@available(iOS 15.0, *)) {
  105. _youpaiptableView.sectionHeaderTopPadding = 0;
  106. }
  107. [_youpaiptableView registerClass:[YOUPAIHROperationRecordCell class] forCellReuseIdentifier:@"HROperationRecordID"];
  108. }
  109. return _youpaiptableView;
  110. }
  111. -(NSMutableArray *)youpaipdataSource{
  112. if (_youpaipdataSource == nil) {
  113. _youpaipdataSource = [NSMutableArray new];
  114. }
  115. return _youpaipdataSource;
  116. }
  117. @end