YOUPAILZChatRoomSeatInlineWindow.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //
  2. // YOUPAILZChatRoomSeatInlineWindow.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/11/6.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomSeatInlineWindow.h"
  9. #import "UIScrollView+LZRefresh.h"
  10. #import "YOUPAILZChatRoomSeatInlineCell.h"
  11. @interface YOUPAILZChatRoomSeatInlineWindow ()<UITableViewDataSource,UITableViewDelegate>
  12. @property (nonatomic, weak)UITableView *youpaiptableView;
  13. @property (nonatomic, assign) NSInteger youpaippage;
  14. @property (nonatomic, strong) NSMutableArray <YOUPAILZChatRoomMemberModel *>*youpaipdataSource;
  15. @end
  16. @implementation YOUPAILZChatRoomSeatInlineWindow
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. self.baseView.hidden = YES;
  20. [self youpaifinitUI];
  21. [self youpaifrequestSeatInlineListWithStatus:kRefreshNormal];
  22. }
  23. - (void)youpaifinitUI{
  24. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 230.0f + SafeHeight)];
  25. bgV.backgroundColor = HexColorFromRGB(0x2A2935);
  26. [self.view addSubview:bgV];
  27. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.left.right.bottom.offset(0.0f);
  29. make.height.offset(230.0f + SafeHeight);
  30. }];
  31. [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
  32. UIView *navV = [[UIView alloc] init];
  33. [bgV addSubview:navV];
  34. [navV mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.left.right.top.offset(0.0f);
  36. make.height.offset(43.0f);
  37. }];
  38. [navV addLineWithColor:[[UIColor whiteColor] colorWithAlphaComponent:0.07f] lineRect:CGRectMake(0, 42.5f, KScreenWidth, 0.5f)];
  39. UILabel *titleL = [[UILabel alloc] init];
  40. titleL.text = @"排麦中";
  41. titleL.textColor = [UIColor whiteColor];
  42. titleL.font = LCBoldFont(16.0f);
  43. [navV addSubview:titleL];
  44. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.center.equalTo(navV);
  46. }];
  47. UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  48. tableView.delegate = self;
  49. tableView.dataSource = self;
  50. tableView.rowHeight = 60.0f;
  51. tableView.estimatedRowHeight = 60.0f;
  52. tableView.estimatedSectionHeaderHeight = 0.0f;
  53. tableView.estimatedSectionFooterHeight = 0.0f;
  54. tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  55. tableView.backgroundColor = [UIColor clearColor];
  56. tableView.showsVerticalScrollIndicator = NO;
  57. [self.view addSubview:tableView];
  58. self.youpaiptableView = tableView;
  59. @weakify(self);
  60. [tableView setRefreshHeaderWithBlock:^{
  61. @strongify(self);
  62. [self youpaifrequestSeatInlineListWithStatus:kRefreshHeader];
  63. }];
  64. [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.right.offset(0.0f);
  66. make.bottom.offset(-SafeHeight);
  67. make.top.equalTo(navV.mas_bottom).offset(0.0f);
  68. }];
  69. }
  70. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  71. return self.youpaipdataSource.count;
  72. }
  73. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  74. NSString *cellID = @"YOUPAILZChatRoomSeatInlineCell";
  75. YOUPAILZChatRoomSeatInlineCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  76. if (cell == nil) {
  77. cell = [[YOUPAILZChatRoomSeatInlineCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  78. }
  79. [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row]];
  80. return cell;
  81. }
  82. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  83. return CGFLOAT_MIN;
  84. }
  85. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  86. return CGFLOAT_MIN;
  87. }
  88. /// 设置加载更多
  89. - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
  90. @weakify(self);
  91. [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
  92. @strongify(self);
  93. [self youpaifrequestSeatInlineListWithStatus:kRefreshFooter];
  94. }];
  95. }
  96. - (void)youpaifrequestSeatInlineListWithStatus:(kRefreshStatus)status{
  97. if (status == kRefreshFooter) {
  98. self.youpaippage ++;
  99. }else{
  100. self.youpaippage = 1;
  101. }
  102. @weakify(self);
  103. [LCHttpHelper requestWithURLString:ApplyList parameters:@{@"page":@(self.youpaippage),@"room_id":self.youpaiproomId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  104. @strongify(self);
  105. [self.youpaiptableView endRefreshing:kRefreshAll];
  106. NSDictionary* dict = (NSDictionary*)responseObject;
  107. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  108. if (code == 0) {//成功
  109. if (status != kRefreshFooter) {
  110. [self.youpaipdataSource removeAllObjects];
  111. }
  112. NSDictionary *data = [dict objectForKey:@"data"];
  113. NSArray <YOUPAILZChatRoomMemberModel *>*list = [YOUPAILZChatRoomMemberModel mj_objectArrayWithKeyValuesArray:[data objectForKey:@"list"]];
  114. [self.youpaipdataSource addObjectsFromArray:list];
  115. [self.youpaiptableView reloadData];
  116. NSInteger totalPage = [[data objectForKey:@"total_page"] integerValue];
  117. [self youpaifrefreshFooterWithHidden:self.youpaippage >= totalPage];
  118. }
  119. } failure:^(NSError *error) {
  120. @strongify(self);
  121. [self.youpaiptableView endRefreshing:kRefreshAll];
  122. }];
  123. }
  124. - (NSMutableArray<YOUPAILZChatRoomMemberModel *> *)youpaipdataSource{
  125. if (!_youpaipdataSource) {
  126. _youpaipdataSource = [NSMutableArray array];
  127. }
  128. return _youpaipdataSource;
  129. }
  130. @end