YOUPAILZChatRoomInviationUpSeatListWindow.m 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // YOUPAILZChatRoomInviationUpSeatListWindow.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/11/5.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomInviationUpSeatListWindow.h"
  9. #import "UIScrollView+LZRefresh.h"
  10. #import "YOUPAILZChatRoomInviationUpSeatCell.h"
  11. @interface YOUPAILZChatRoomInviationUpSeatListWindow ()<UITableViewDataSource,UITableViewDelegate>
  12. @property (nonatomic, weak)UITableView *youpaiptableView;
  13. @property (nonatomic, strong) NSString *youpaipendTime;
  14. @property (nonatomic, strong) NSMutableArray <YOUPAILZChatRoomMemberModel *>*youpaipdataSource;
  15. @end
  16. @implementation YOUPAILZChatRoomInviationUpSeatListWindow
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. self.baseView.hidden = YES;
  20. [self youpaifinitUI];
  21. [self youpaifrequestInviationListWithStatus:kRefreshNormal];
  22. }
  23. - (void)youpaifinitUI{
  24. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 400.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(400.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 youpaifrequestInviationListWithStatus: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 = @"YOUPAILZChatRoomInviationUpSeatCell";
  75. YOUPAILZChatRoomInviationUpSeatCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  76. if (cell == nil) {
  77. cell = [[YOUPAILZChatRoomInviationUpSeatCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  78. }
  79. [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row] index:indexPath.row buttonType:LZChatRoomInviationUpSeatCellButtonTypeWithInviation rankType:LZChatRoomInviationUpSeatCellRankTypeWithDefault contributionName:@"贡献值"];
  80. @weakify(self);
  81. [cell setYoupaipinviationBtnClickBlock:^(YOUPAILZChatRoomMemberModel * _Nonnull model) {
  82. @strongify(self);
  83. [self youpaifinviationUpSeatWithModel:model];
  84. }];
  85. return cell;
  86. }
  87. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  88. return CGFLOAT_MIN;
  89. }
  90. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  91. return CGFLOAT_MIN;
  92. }
  93. /// 邀请上麦
  94. - (void)youpaifinviationUpSeatWithModel:(YOUPAILZChatRoomMemberModel *)model{
  95. [LCHttpHelper requestWithURLString:InviteUpperSeat parameters:@{@"room_id":self.youpaiproomId,@"seat":@(self.youpaipseatId),@"op_uid":model.youpaipid} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  96. } failure:^(NSError *error) {
  97. }];
  98. }
  99. /// 设置加载更多
  100. - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
  101. @weakify(self);
  102. [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
  103. @strongify(self);
  104. [self youpaifrequestInviationListWithStatus:kRefreshFooter];
  105. }];
  106. }
  107. - (void)youpaifrequestInviationListWithStatus:(kRefreshStatus)status{
  108. if (status == kRefreshFooter) {
  109. }else{
  110. self.youpaipendTime = @"0";
  111. }
  112. @weakify(self);
  113. [LCHttpHelper requestWithURLString:GetTalkOnlineUser parameters:@{@"room_id":self.youpaiproomId,@"endtime":self.youpaipendTime} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  114. @strongify(self);
  115. [self.youpaiptableView endRefreshing:kRefreshAll];
  116. NSDictionary* dict = (NSDictionary*)responseObject;
  117. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  118. if (code == 0) {//成功
  119. if (status != kRefreshFooter) {
  120. [self.youpaipdataSource removeAllObjects];
  121. }
  122. NSDictionary *data = [dict objectForKey:@"data"];
  123. NSArray <YOUPAILZChatRoomMemberModel *>*list = [YOUPAILZChatRoomMemberModel mj_objectArrayWithKeyValuesArray:[data objectForKey:@"list"]];
  124. [self.youpaipdataSource addObjectsFromArray:list];
  125. [self.youpaiptableView reloadData];
  126. self.youpaipendTime = [data objectForKey:@"end_time"];
  127. [self youpaifrefreshFooterWithHidden:NO];
  128. }
  129. } failure:^(NSError *error) {
  130. @strongify(self);
  131. [self.youpaiptableView endRefreshing:kRefreshAll];
  132. }];
  133. }
  134. - (NSMutableArray<YOUPAILZChatRoomMemberModel *> *)youpaipdataSource{
  135. if (!_youpaipdataSource) {
  136. _youpaipdataSource = [NSMutableArray array];
  137. }
  138. return _youpaipdataSource;
  139. }
  140. @end