YOUPAILZChatRoomBlockListWindow.m 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //
  2. // YOUPAILZChatRoomBlockListWindow.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/11/10.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomBlockListWindow.h"
  9. #import "YOUPAILZChatRoomBlockCell.h"
  10. @interface YOUPAILZChatRoomBlockListWindow ()<UITableViewDelegate,UITableViewDataSource>
  11. @property (nonatomic, weak)UITableView *youpaiptableView;
  12. @property (nonatomic, weak)UIButton *youpaipconfirmBtn;
  13. @property (nonatomic, strong) NSMutableArray <YOUPAILZChatRoomBlockModel *>*youpaipdataSource;
  14. @end
  15. @implementation YOUPAILZChatRoomBlockListWindow
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.baseView.hidden = YES;
  19. [self youpaifinitUI];
  20. [self youpaifrequestList];
  21. }
  22. - (void)youpaifinitUI{
  23. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 375.0f + SafeHeight)];
  24. bgV.backgroundColor = HexColorFromRGB(0x2A2935);
  25. [self.view addSubview:bgV];
  26. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.left.right.bottom.offset(0.0f);
  28. make.height.offset(375.0f + SafeHeight);
  29. }];
  30. [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
  31. UIView *navV = [[UIView alloc] init];
  32. [bgV addSubview:navV];
  33. [navV mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.right.top.offset(0.0f);
  35. make.height.offset(49.0f);
  36. }];
  37. UIButton *youpaipcloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  38. [youpaipcloseBtn setImage:[UIImage imageNamed:@"vqu_images_nav_return_white"] forState:UIControlStateNormal];
  39. [youpaipcloseBtn setImage:[UIImage imageNamed:@"vqu_images_nav_return_white"] forState:UIControlStateHighlighted];
  40. [youpaipcloseBtn addTarget:self action:@selector(youpaifcloseBtnClick) forControlEvents:UIControlEventTouchUpInside];
  41. [navV addSubview:youpaipcloseBtn];
  42. [youpaipcloseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.offset(4.0f);
  44. make.centerY.equalTo(navV);
  45. make.size.mas_offset(CGSizeMake(44.0f, 44.0f));
  46. }];
  47. UILabel *titleL = [[UILabel alloc] init];
  48. titleL.text = self.youpaiptitleStr;
  49. titleL.textColor = [UIColor whiteColor];
  50. titleL.font = LCBoldFont(17.0f);
  51. [navV addSubview:titleL];
  52. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.center.equalTo(navV);
  54. }];
  55. UIButton *youpaipconfirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  56. [youpaipconfirmBtn addTarget:self action:@selector(youpaifconfirmBtnClick) forControlEvents:UIControlEventTouchUpInside];
  57. [youpaipconfirmBtn setTitle:self.youpaipbtnTitle forState:0];
  58. [youpaipconfirmBtn setTitleColor:HexColorFromRGB(0x9F9DA5) forState:UIControlStateNormal];
  59. [youpaipconfirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
  60. youpaipconfirmBtn.titleLabel.font = LCFont(16);
  61. [youpaipconfirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 80.0f, 48.0f) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  62. [youpaipconfirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 80.0f, 48.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateSelected];
  63. youpaipconfirmBtn.layer.cornerRadius = 24.0f;
  64. youpaipconfirmBtn.clipsToBounds = YES;
  65. youpaipconfirmBtn.userInteractionEnabled = NO;
  66. [bgV addSubview:youpaipconfirmBtn];
  67. self.youpaipconfirmBtn = youpaipconfirmBtn;
  68. [youpaipconfirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.left.offset(40.0f);
  70. make.right.offset(-40.0f);
  71. make.bottom.offset(-SafeHeight-10.0f);
  72. make.height.offset(48.0f);
  73. }];
  74. UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  75. tableView.delegate = self;
  76. tableView.dataSource = self;
  77. tableView.rowHeight = 68.0f;
  78. tableView.estimatedRowHeight = 68.0f;
  79. tableView.estimatedSectionHeaderHeight = 0.0f;
  80. tableView.estimatedSectionFooterHeight = 0.0f;
  81. tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  82. tableView.backgroundColor = [UIColor clearColor];
  83. tableView.showsVerticalScrollIndicator = NO;
  84. [self.view addSubview:tableView];
  85. self.youpaiptableView = tableView;
  86. [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.left.right.offset(0.0f);
  88. make.bottom.equalTo(youpaipconfirmBtn.mas_top).offset(-10.0f);
  89. make.top.equalTo(navV.mas_bottom).offset(0.0f);
  90. }];
  91. }
  92. - (void)youpaifcloseBtnClick{
  93. [self dismissViewControllerAnimated:YES completion:^{}];
  94. }
  95. - (void)youpaifconfirmBtnClick{
  96. NSMutableString *userIdStr = [NSMutableString string];
  97. for (YOUPAILZChatRoomBlockModel *model in self.youpaipdataSource) {
  98. if (model.youpaipisSelected) {
  99. [userIdStr appendFormat:@"%@,",model.youpaipid];
  100. }
  101. }
  102. @weakify(self);
  103. [LCHttpHelper requestWithURLString:ForbidUser parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"time":@"0",@"type":self.youpaiptype,@"op_uid":userIdStr.copy} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  104. @strongify(self);
  105. NSDictionary* dict = (NSDictionary*)responseObject;
  106. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  107. if (code==0) {//成功
  108. [ZCHUDHelper showTitle:@"操作成功"];
  109. for (NSInteger i = 0; i < self.youpaipdataSource.count; i ++) {
  110. YOUPAILZChatRoomBlockModel *model = self.youpaipdataSource[i];
  111. if (model.youpaipisSelected) {
  112. [self.youpaipdataSource removeObject:model];
  113. i --;
  114. }
  115. }
  116. [self.youpaiptableView reloadData];
  117. [self youpaifreloadConfirmBtnStyle];
  118. }
  119. } failure:^(NSError *error) {
  120. }];
  121. }
  122. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  123. return self.youpaipdataSource.count;
  124. }
  125. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  126. NSString *cellID = @"YOUPAILZChatRoomBlockCell";
  127. YOUPAILZChatRoomBlockCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  128. if (cell == nil) {
  129. cell = [[YOUPAILZChatRoomBlockCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  130. }
  131. [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row]];
  132. return cell;
  133. }
  134. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  135. return CGFLOAT_MIN;
  136. }
  137. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  138. return CGFLOAT_MIN;
  139. }
  140. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  141. self.youpaipdataSource[indexPath.row].youpaipisSelected = !self.youpaipdataSource[indexPath.row].youpaipisSelected;
  142. [self.youpaiptableView reloadData];
  143. [self youpaifreloadConfirmBtnStyle];
  144. }
  145. - (void)youpaifreloadConfirmBtnStyle{
  146. BOOL isSelected = NO;
  147. for (YOUPAILZChatRoomBlockModel *model in self.youpaipdataSource) {
  148. if (model.youpaipisSelected) {
  149. isSelected = YES;
  150. break;
  151. }
  152. }
  153. self.youpaipconfirmBtn.selected = isSelected;
  154. self.youpaipconfirmBtn.userInteractionEnabled = isSelected;
  155. }
  156. - (void)youpaifrequestList{
  157. @weakify(self);
  158. [LCHttpHelper requestWithURLString:GetForbidUserList parameters:@{@"type":self.youpaiptype,@"room_id":self.youpaipchatroomModel.youpaiproom_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  159. @strongify(self);
  160. NSDictionary* dict = (NSDictionary*)responseObject;
  161. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  162. if (code == 0) {//成功
  163. self.youpaipdataSource = [YOUPAILZChatRoomBlockModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]];
  164. [self.youpaiptableView reloadData];
  165. }
  166. } failure:^(NSError *error) {
  167. }];
  168. }
  169. @end