ReportViewController.m 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. //
  2. // ForwardViewController.m
  3. // AIIM
  4. //
  5. // Created by qitewei on 2025/5/10.
  6. //
  7. #import "ReportViewController.h"
  8. #import "FriendListCell.h"
  9. #import "FriendNetApi.h"
  10. #import "GroupNetApi.h"
  11. #import "ChatListStore.h"
  12. #import "GWebSocket.h"
  13. #import "UDManager.h"
  14. @interface ReportViewController ()<UITableViewDelegate,UITableViewDataSource>
  15. @property (nonatomic, strong) UIImageView * bgImageView;
  16. @property (nonatomic, strong) UIButton * leftBtn;
  17. @property (nonatomic, strong) UITableView *tableview;
  18. @property (nonatomic, strong) NSMutableArray * textSrray;
  19. @property (nonatomic, strong) NSMutableArray * selSrray;
  20. @end
  21. @implementation ReportViewController
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. _selSrray = [NSMutableArray new];
  25. _textSrray = [NSMutableArray new];
  26. [self configUI];
  27. }
  28. - (void)configUI{
  29. [self setNavigationTitle:NSLocalizedString(@"FriendCtr-toushujb", @"")];
  30. [self setNavigationBarTransparent:YES];
  31. [self setNavigationBarBackgroundColor:UIColor.clearColor];
  32. [self setNavigationTitleColor:UIColor.whiteColor font:SYSBFONT(18)];
  33. [self addBarButtonWithImage:kImageMake(@"fanhui") position:BarButtonItemPositionLeft action:@selector(backToChat)];
  34. [self.view addSubview:self.bgImageView];
  35. [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.right.top.bottom.mas_equalTo(0);
  37. }];
  38. [_textSrray addObject:NSLocalizedString(@"Report-fabubudangnr", @"")];
  39. [_selSrray addObject:@"0"];
  40. [_textSrray addObject:NSLocalizedString(@"Report-cunzaiqzxw", @"")];
  41. [_selSrray addObject:@"0"];
  42. [_textSrray addObject:NSLocalizedString(@"Report-zhanghaobd", @"")];
  43. [_selSrray addObject:@"0"];
  44. [_textSrray addObject:NSLocalizedString(@"Report-fangmaopin", @"")];
  45. [_selSrray addObject:@"0"];
  46. [_textSrray addObject:NSLocalizedString(@"Report-maocongtr", @"")];
  47. [_selSrray addObject:@"0"];
  48. [_textSrray addObject:NSLocalizedString(@"Report-qinquan", @"")];
  49. [_selSrray addObject:@"0"];
  50. [_textSrray addObject:NSLocalizedString(@"Report-qinfanwcnr", @"")];
  51. [_selSrray addObject:@"0"];
  52. [_textSrray addObject:NSLocalizedString(@"Report-qitayuanyin", @"")];
  53. [_selSrray addObject:@"0"];
  54. [self layoutselectitem];
  55. }
  56. #pragma mark lazy
  57. - (UIImageView *)bgImageView{
  58. if (!_bgImageView) {
  59. _bgImageView = [[UIImageView alloc] initWithImage:kImageMake(@"loginBG")];
  60. }
  61. return _bgImageView;
  62. }
  63. - (void)backToChat{
  64. NSLog(@"backToChat");
  65. [self dismissViewControllerAnimated:YES completion:nil];
  66. }
  67. #pragma mark statusBar
  68. - (UIStatusBarStyle)preferredStatusBarStyle{
  69. return UIStatusBarStyleLightContent;
  70. }
  71. -(void)layoutselectitem{
  72. // 标题
  73. UILabel *notelb1 = [[UILabel alloc] init];
  74. notelb1.font = SYSBFONT(18);
  75. notelb1.textColor = UIColor.whiteColor;
  76. notelb1.textAlignment = NSTextAlignmentLeft;
  77. [self.view addSubview:notelb1];
  78. notelb1.text =NSLocalizedString(@"Report-duixiang", @"");
  79. UIButton *tijiaoBT = [UIButton buttonWithType:UIButtonTypeSystem];
  80. [tijiaoBT setTitle:NSLocalizedString(@"app-tijiao", @"") forState:UIControlStateNormal];
  81. [tijiaoBT setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
  82. [tijiaoBT setBackgroundColor:globalColor(GCTypeGreen)];
  83. tijiaoBT.layer.cornerRadius = 5.f;
  84. tijiaoBT.layer.masksToBounds = YES;
  85. [self.view addSubview:tijiaoBT];
  86. [tijiaoBT addTarget:self action:@selector(tijiaojubao) forControlEvents:UIControlEventTouchUpInside];
  87. UIImageView *avatar = [[UIImageView alloc] initWithImage:nil];
  88. [avatar sd_setImageWithURL:[NSURL URLWithString:self.friendAvatar] placeholderImage:[UIImage imageNamed:@"Avatar"]];
  89. [self.view addSubview:avatar];
  90. UILabel *notelb2 = [[UILabel alloc] init];
  91. notelb2.font = SYSBFONT(18);
  92. notelb2.textColor = UIColor.whiteColor;
  93. notelb2.textAlignment = NSTextAlignmentCenter;
  94. [self.view addSubview:notelb2];
  95. notelb2.text = self.friendName?:@"";
  96. UILabel *notelb3 = [[UILabel alloc] init];
  97. notelb3.font = SYSBFONT(18);
  98. notelb3.textColor = globalColor(GCTypeYellow);
  99. notelb3.textAlignment = NSTextAlignmentLeft;
  100. [self.view addSubview:notelb3];
  101. notelb3.text =NSLocalizedString(@"Report-yuanyin", @"");
  102. _tableview = [[UITableView alloc] init];
  103. [self.view addSubview:_tableview];
  104. _tableview.delegate = self;
  105. _tableview.dataSource = self;
  106. _tableview.backgroundColor = [UIColor clearColor];
  107. _tableview.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  108. [_tableview registerClass:UITableViewCell.class forCellReuseIdentifier:@"cell"];
  109. // 标题标签布局
  110. [notelb1 mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.top.equalTo(self.view.mas_top).offset(SCREEN_TOP+48);
  112. make.left.equalTo(self.view.mas_left).offset(40);
  113. make.right.equalTo(self.view.mas_right).offset(-80);
  114. make.height.equalTo(@30);
  115. }];
  116. // notelb1.backgroundColor=[UIColor linkColor];
  117. // 提交按钮布局
  118. [tijiaoBT mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.top.equalTo(self.view.mas_top).offset(SCREEN_TOP+48);
  120. make.right.mas_equalTo(-20);
  121. make.height.equalTo(@34);
  122. make.width.equalTo(@70);
  123. }];
  124. // 头像布局
  125. [avatar mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.top.equalTo(notelb1.mas_bottom).offset(10);
  127. make.left.equalTo(self.view.mas_left).offset(40);
  128. make.width.equalTo(@50);
  129. make.height.equalTo(@50);
  130. }];
  131. // 用户名布局
  132. [notelb2 mas_makeConstraints:^(MASConstraintMaker *make) {
  133. make.top.equalTo(notelb1.mas_bottom).offset(10);
  134. make.left.equalTo(avatar.mas_right).offset(20);
  135. make.height.equalTo(@50);
  136. }];
  137. // 选择提示
  138. [notelb3 mas_makeConstraints:^(MASConstraintMaker *make) {
  139. make.top.equalTo(avatar.mas_bottom).offset(20);
  140. make.left.equalTo(self.view.mas_left).offset(10);
  141. make.right.equalTo(self.view.mas_right).offset(-80);
  142. make.height.equalTo(@30);
  143. }];
  144. [_tableview mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.top.equalTo(notelb3.mas_bottom).offset(5);
  146. make.left.equalTo(self.view.mas_left).offset(0);
  147. make.right.mas_equalTo(0);
  148. make.bottom.equalTo(self.view.mas_bottom).offset(-20);
  149. }];
  150. }
  151. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  152. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  153. // 设置勾选框
  154. // cell.selectionStyle = UITableViewCellSelectionStyleNone;
  155. cell.selectionStyle = UITableViewCellSelectionStyleDefault;
  156. cell.tintColor = [UIColor whiteColor];
  157. cell.textLabel.textColor = globalColor(GCTypeOrangeR);
  158. cell.textLabel.font = SYSBFONT(16);
  159. cell.backgroundColor = [UIColor clearColor];
  160. cell.textLabel.text = _textSrray[indexPath.row];
  161. if([_selSrray[indexPath.row] isEqualToString:@"1"]){
  162. cell.accessoryType = UITableViewCellAccessoryCheckmark;
  163. }
  164. else{
  165. cell.accessoryType = UITableViewCellAccessoryNone;
  166. }
  167. return cell;
  168. }
  169. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  170. return _textSrray.count;
  171. }
  172. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  173. return 1;
  174. }
  175. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  176. return 60;
  177. }
  178. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  179. NSString *mark = _selSrray[indexPath.row];
  180. if([mark isEqualToString:@"0"]){
  181. [_selSrray setObject:@"1" atIndexedSubscript:indexPath.row];
  182. }
  183. else{
  184. [_selSrray setObject:@"0" atIndexedSubscript:indexPath.row];
  185. }
  186. [_tableview reloadData];
  187. }
  188. -(void)tijiaojubao{
  189. NSString *spec=@"";
  190. for (NSString *item in _selSrray) {
  191. if([item isEqualToString:@"1"]){
  192. NSInteger index =[_selSrray indexOfObject:item];
  193. if(spec.length==0){
  194. spec=_textSrray[index];
  195. }
  196. else{
  197. spec= [NSString stringWithFormat:@"%@;%@",spec,_textSrray[index]];
  198. }
  199. }
  200. }
  201. if(spec.length==0){
  202. [MBProgressHUD showWithText:NSLocalizedString(@"Report-yuanyin", @"")];
  203. return;
  204. }
  205. NSDictionary *data=@{
  206. @"jsonStr":[NSString stringWithFormat:@"%@",self.friendMsg],
  207. @"spec":spec,
  208. @"type":@"0"
  209. };
  210. [FriendNetApi reportUser:data succ:^(int code, NSDictionary * res) {
  211. NSLog(@"reportUser res:%@",res);
  212. NSString *coder=res[@"code"];
  213. if (coder.intValue==200) {
  214. [MBProgressHUD showWithText:NSLocalizedString(@"friendCtr-caozuocg", @"")];
  215. }
  216. } fail:^(NSError * _Nonnull error) {
  217. NSLog(@"reportUser:%@",error);
  218. }];
  219. }
  220. @end