YOUPAILZChatRoomReportWindow.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. //
  2. // YOUPAILZChatRoomReportWindow.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/11/11.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomReportWindow.h"
  9. #import "YOUPAILZChatRoomReportTypeCell.h"
  10. #import "YOUPAILZTextView.h"
  11. #import "IQKeyboardManager.h"
  12. @interface YOUPAILZChatRoomReportWindow ()<UICollectionViewDelegate,UICollectionViewDataSource>
  13. @property (nonatomic,weak)UICollectionView *youpaipcollectionView;
  14. @property (nonatomic,weak)YOUPAILZTextView *youpaipdescTextView;
  15. @property (nonatomic,weak)UIButton *youpaipsubmitBtn;
  16. @property (nonatomic,strong)NSArray <YOUPAILZChatRoomReportTypeModel *>*youpaipdataSource;
  17. @property (nonatomic,strong)YOUPAILZChatRoomReportTypeModel *youpaipselectedModel;
  18. @end
  19. @implementation YOUPAILZChatRoomReportWindow
  20. - (void)viewWillAppear:(BOOL)animated {
  21. [super viewWillAppear:animated];
  22. [[IQKeyboardManager sharedManager] setEnable:YES];
  23. }
  24. - (void)viewWillDisappear:(BOOL)animated {
  25. [super viewWillDisappear:animated];
  26. [[IQKeyboardManager sharedManager] setEnable:NO];
  27. }
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. self.baseView.hidden = YES;
  31. [IQKeyboardManager sharedManager].enableAutoToolbar = NO; // 控制是否显示键盘上的工具条
  32. [IQKeyboardManager sharedManager].keyboardDistanceFromTextField = NavBarHeight; //
  33. [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
  34. [self youpaifinitUI];
  35. [self youpaifrequestReportTypeList];
  36. }
  37. - (void)youpaifinitUI{
  38. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 551.0f + SafeHeight)];
  39. bgV.backgroundColor = HexColorFromRGB(0x2A2935);
  40. [self.view addSubview:bgV];
  41. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.left.right.bottom.offset(0.0f);
  43. make.height.offset(551.0f + SafeHeight);
  44. }];
  45. [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
  46. UIView *navV = [[UIView alloc] init];
  47. [bgV addSubview:navV];
  48. [navV mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.right.top.offset(0.0f);
  50. make.height.offset(49.0f);
  51. }];
  52. UIButton *youpaipcloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  53. [youpaipcloseBtn setImage:[UIImage imageNamed:@"vqu_images_nav_return_white"] forState:UIControlStateNormal];
  54. [youpaipcloseBtn setImage:[UIImage imageNamed:@"vqu_images_nav_return_white"] forState:UIControlStateHighlighted];
  55. [youpaipcloseBtn addTarget:self action:@selector(youpaifcloseBtnClick) forControlEvents:UIControlEventTouchUpInside];
  56. [navV addSubview:youpaipcloseBtn];
  57. [youpaipcloseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.offset(4.0f);
  59. make.centerY.equalTo(navV);
  60. make.size.mas_offset(CGSizeMake(44.0f, 44.0f));
  61. }];
  62. UILabel *titleL = [[UILabel alloc] init];
  63. titleL.text = @"举报";
  64. titleL.textColor = [UIColor whiteColor];
  65. titleL.font = LCBoldFont(17.0f);
  66. [navV addSubview:titleL];
  67. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.center.equalTo(navV);
  69. }];
  70. UILabel *typeL = [[UILabel alloc] init];
  71. typeL.font = LCFont(12.0f);
  72. typeL.textColor = HexColorFromRGB(0x9F9DA5);
  73. typeL.text = @"举报类型";
  74. [bgV addSubview:typeL];
  75. [typeL mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.offset(14.0f);
  77. make.top.equalTo(navV.mas_bottom).offset(10.0f);
  78. make.height.offset(17.0f);
  79. }];
  80. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  81. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  82. flowLayout.minimumLineSpacing = 14.0f;
  83. flowLayout.minimumInteritemSpacing = 14.0f;
  84. flowLayout.sectionInset = UIEdgeInsetsMake(0.0f, 14.0f, 14.0f, 14.0f);
  85. flowLayout.itemSize = CGSizeMake(((KScreenWidth - 14.0f) / 3.0f) - 14.0f, 40.0f);
  86. UICollectionView *youpaipcollectonView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
  87. youpaipcollectonView.delegate = self;
  88. youpaipcollectonView.dataSource = self;
  89. youpaipcollectonView.showsVerticalScrollIndicator = NO;
  90. youpaipcollectonView.showsHorizontalScrollIndicator = NO;
  91. youpaipcollectonView.backgroundColor = [UIColor clearColor];
  92. youpaipcollectonView.clipsToBounds = NO;
  93. [youpaipcollectonView registerClass:YOUPAILZChatRoomReportTypeCell.class forCellWithReuseIdentifier:NSStringFromClass(YOUPAILZChatRoomReportTypeCell.class)];
  94. [bgV addSubview:youpaipcollectonView];
  95. self.youpaipcollectionView = youpaipcollectonView;
  96. [youpaipcollectonView mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.top.equalTo(navV.mas_bottom).offset(37.0f);
  98. make.left.right.offset(0.0f);
  99. make.height.offset(108.0f);
  100. }];
  101. UILabel *descL = [[UILabel alloc] init];
  102. descL.font = LCFont(12.0f);
  103. descL.textColor = HexColorFromRGB(0x9F9DA5);
  104. descL.text = @"举报理由";
  105. [bgV addSubview:descL];
  106. [descL mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.left.offset(14.0f);
  108. make.top.equalTo(youpaipcollectonView.mas_bottom).offset(10.0f);
  109. make.height.offset(17.0f);
  110. }];
  111. YOUPAILZTextView *youpaipdescTextView = [[YOUPAILZTextView alloc] initWithMaxCount:200.0f];
  112. youpaipdescTextView.youpaiptextViewPadding = UIEdgeInsetsMake(15.0f, 12.0f, 16.0f, 12.0f);
  113. youpaipdescTextView.youpaiptextLengthDefaultColor = HexColorFromRGB(0x6C6B70);
  114. youpaipdescTextView.youpaiptextLengthHigtColor = ZYPinkColor;
  115. youpaipdescTextView.youpaiptextLengthFont = LCFont(14.0f);
  116. youpaipdescTextView.youpaiptextLengthRight = 14.0f;
  117. youpaipdescTextView.youpaiptextLengthBottom = 14.0f;
  118. youpaipdescTextView.youpaiptextView.placeholderFont = LCFont(14.0f);
  119. youpaipdescTextView.youpaiptextView.placeholderTextColor = HexColorFromRGB(0x908E96);
  120. youpaipdescTextView.youpaiptextView.placeholderText = @"请描述举报原因~";
  121. youpaipdescTextView.youpaiptextView.textColor = [UIColor whiteColor];
  122. youpaipdescTextView.youpaiptextView.font = LCFont(14.0f);
  123. youpaipdescTextView.backgroundColor = HexColorFromRGB(0x4F4B5B);
  124. youpaipdescTextView.layer.cornerRadius = 5.0f;
  125. youpaipdescTextView.clipsToBounds = YES;
  126. youpaipdescTextView.tintColor = ZYPinkColor;
  127. [bgV addSubview:youpaipdescTextView];
  128. self.youpaipdescTextView = youpaipdescTextView;
  129. [youpaipdescTextView mas_makeConstraints:^(MASConstraintMaker *make) {
  130. make.left.offset(14.0f);
  131. make.top.equalTo(descL.mas_bottom).offset(10.0f);
  132. make.size.mas_offset(CGSizeMake(KScreenWidth - 28.0f, 220.0f));
  133. }];
  134. UIButton *youpaipsubmitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  135. [youpaipsubmitBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 80.0f, 48.0f) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight] forState:UIControlStateSelected];
  136. [youpaipsubmitBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 80.0f, 48.0f) FromColors:@[HexColorFromRGB(0x4F4B5B),HexColorFromRGB(0x4F4B5B)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  137. [youpaipsubmitBtn setTitle:@"提交" forState:UIControlStateNormal];
  138. [youpaipsubmitBtn setTitleColor:HexColorFromRGB(0x9F9DA5) forState:UIControlStateNormal];
  139. [youpaipsubmitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
  140. youpaipsubmitBtn.titleLabel.font = LCFont(16.0f);
  141. youpaipsubmitBtn.layer.cornerRadius = 24.0f;
  142. youpaipsubmitBtn.clipsToBounds = YES;
  143. [youpaipsubmitBtn addTarget:self action:@selector(youpaifsubmitBtnClick) forControlEvents:UIControlEventTouchUpInside];
  144. [bgV addSubview:youpaipsubmitBtn];
  145. self.youpaipsubmitBtn = youpaipsubmitBtn;
  146. [youpaipsubmitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.left.offset(40.0f);
  148. make.top.equalTo(youpaipdescTextView.mas_bottom).offset(20.0f);
  149. make.size.mas_offset(CGSizeMake(KScreenWidth - 80.0f, 48.0f));
  150. }];
  151. }
  152. - (void)youpaifcloseBtnClick{
  153. [self dismissViewControllerAnimated:YES completion:^{}];
  154. }
  155. - (void)youpaifsubmitBtnClick{
  156. @weakify(self);
  157. [LCHttpHelper requestWithURLString:ChatRoomReport parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"type_id":self.youpaipselectedModel.youpaipid,@"content":self.youpaipdescTextView.youpaiptextView.text} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  158. @strongify(self);
  159. NSDictionary* dict = (NSDictionary*)responseObject;
  160. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  161. if (code==0) {//成功
  162. [ZCHUDHelper showTitle:@"举报成功"];
  163. [self dismissViewControllerAnimated:YES completion:^{}];
  164. }
  165. } failure:^(NSError *error) {
  166. }];
  167. }
  168. #pragma mark - UICollectionViewDataSource
  169. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  170. return self.youpaipdataSource.count;
  171. }
  172. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  173. YOUPAILZChatRoomReportTypeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(YOUPAILZChatRoomReportTypeCell.class) forIndexPath:indexPath];
  174. [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.item]];
  175. return cell;
  176. }
  177. #pragma mark - UICollectionViewDelegate
  178. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  179. self.youpaipselectedModel.youpaipisSelected = NO;
  180. self.youpaipselectedModel = self.youpaipdataSource[indexPath.item];
  181. self.youpaipselectedModel.youpaipisSelected = YES;
  182. [self.youpaipcollectionView reloadData];
  183. [self youpaifhideKeyboard];
  184. }
  185. - (void)youpaifrequestReportTypeList{
  186. @weakify(self);
  187. [LCHttpHelper requestWithURLString:GetReportType parameters:@{} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  188. @strongify(self);
  189. NSDictionary* dict = (NSDictionary*)responseObject;
  190. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  191. if (code == 0) {//成功
  192. self.youpaipdataSource = [YOUPAILZChatRoomReportTypeModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"] objectForKey:@"list"]];
  193. [self.youpaipcollectionView reloadData];
  194. }
  195. } failure:^(NSError *error) {
  196. }];
  197. }
  198. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  199. UITouch* touch = [touches anyObject];
  200. UIView* view = [touch view];
  201. if (view != self.youpaipdescTextView) {
  202. [self youpaifhideKeyboard];
  203. }
  204. }
  205. - (void)youpaifhideKeyboard{
  206. dispatch_async(dispatch_get_main_queue(), ^{
  207. [self.view endEditing:YES];
  208. });
  209. if (self.youpaipselectedModel != nil) {
  210. self.youpaipsubmitBtn.selected = YES;
  211. self.youpaipsubmitBtn.userInteractionEnabled = YES;
  212. }else{
  213. self.youpaipsubmitBtn.selected = NO;
  214. self.youpaipsubmitBtn.userInteractionEnabled = NO;
  215. }
  216. }
  217. @end