BGReportController.m 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. //
  2. // BGReportController.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 2017/3/20.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "BGReportController.h"
  9. #import "NetHttpsManager.h"
  10. #import "reportModel.h"
  11. #import "BGReportView.h"
  12. #import "MGReportCommentController.h"
  13. @interface BGReportController ()<UITableViewDelegate,UITableViewDataSource,reportDeleGate>
  14. {
  15. NSMutableArray *_dataArray;
  16. NSUInteger _paymentTag; //举报的类型
  17. NSString *_reportId;
  18. UILabel *_reportlabel; //举报原因
  19. UIButton *_reportBtn; //举报的btn
  20. UIView *_headView; //tableView头部的view
  21. BGReportView *_FWReportiew;
  22. }
  23. @end
  24. @implementation BGReportController
  25. - (void)viewDidLoad
  26. {
  27. [super viewDidLoad];
  28. [self.navigationController setNavigationBarHidden:NO animated:NO];
  29. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:NO];
  30. _paymentTag = -1;
  31. _dataArray = [[NSMutableArray alloc]init];
  32. _reportlabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW/2-120,5 ,240,30)];
  33. _reportlabel.backgroundColor = kBackGroundColor;
  34. _reportlabel.text = ASLocalizedString(@"举报原因");
  35. _reportlabel.textAlignment = NSTextAlignmentCenter;
  36. _reportlabel.textColor = kAppGrayColor1;
  37. _reportBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  38. [_reportBtn setTitle:ASLocalizedString(@"举报")forState:UIControlStateNormal];
  39. [_reportBtn setTitleColor:kAppGrayColor1 forState:UIControlStateNormal];
  40. _reportBtn.frame = CGRectMake(0, kScreenH-50 - kTopHeight - MG_BOTTOM_MARGIN - kRealValue(44),kScreenW, 50);
  41. _reportBtn.backgroundColor = kBackGroundColor;
  42. [_reportBtn addTarget:self action:@selector(reportClick) forControlEvents:UIControlEventTouchUpInside];
  43. self.reportTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-64-50)];
  44. self.reportTableView.dataSource = self;
  45. self.reportTableView.delegate = self;
  46. self.reportTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  47. [BGMJRefreshManager refresh:self.reportTableView target:self headerRereshAction:@selector(loadData) footerRereshAction:nil];
  48. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(comeBack) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  49. if (self.reportType == 1)
  50. {
  51. self.navigationItem.title = ASLocalizedString(@"举报小视频");
  52. }else if (self.reportType == 2)
  53. {
  54. self.navigationItem.title = ASLocalizedString(@"举报小视频");
  55. }else if (self.reportType == 3)
  56. {
  57. self.navigationItem.title = ASLocalizedString(@"评论举报");
  58. }
  59. [self.view addSubview:self.reportTableView];
  60. [self.view addSubview:_reportBtn];
  61. [self loadData];
  62. }
  63. - (void)loadData
  64. {
  65. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  66. [parmDict setObject:@"app" forKey:@"ctl"];
  67. [parmDict setObject:@"tipoff_type" forKey:@"act"];
  68. [parmDict setObject:@"xr" forKey:@"itype"];
  69. FWWeakify(self)
  70. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  71. {
  72. FWStrongify(self)
  73. if ([responseJson toInt:@"status"] == 1)
  74. {
  75. [_dataArray removeAllObjects];
  76. NSArray *array = [responseJson objectForKey:@"list"];
  77. if (array.count > 0)
  78. {
  79. for (NSDictionary *dict in array)
  80. {
  81. reportModel *model = [[reportModel alloc]init];
  82. model.ID = [dict toInt:@"id"];
  83. model.name = [dict toString:@"name"];
  84. [_dataArray addObject:model];
  85. }
  86. }
  87. [self.reportTableView reloadData];
  88. }else
  89. {
  90. [[BGHUDHelper sharedInstance] tipMessage:[responseJson toString:@"error"]];
  91. }
  92. [BGMJRefreshManager endRefresh:self.reportTableView];
  93. } FailureBlock:^(NSError *error)
  94. {
  95. FWStrongify(self)
  96. [BGMJRefreshManager endRefresh:self.reportTableView];
  97. }];
  98. }
  99. //返回行数
  100. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  101. {
  102. if (_dataArray.count > 0)
  103. {
  104. return _dataArray.count;
  105. }else
  106. {
  107. return 0;
  108. }
  109. }
  110. //返回单元格
  111. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  112. {
  113. static NSString *CellIdentifier1 = @"CellIdentifier1";
  114. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
  115. if (!cell) {
  116. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1];
  117. cell.selectionStyle = UITableViewCellSelectionStyleGray;
  118. cell.backgroundColor = [UIColor whiteColor];
  119. cell.textLabel.textColor = kGrayTransparentColor5;
  120. }
  121. if (_dataArray.count > 0)
  122. {
  123. reportModel *model = [_dataArray objectAtIndex:indexPath.row];
  124. if (model.name.length > 0)
  125. {
  126. cell.textLabel.text = model.name;
  127. }else
  128. {
  129. cell.textLabel.text = ASLocalizedString(@"其他原因");
  130. }
  131. }
  132. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  133. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
  134. UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"com_radio_selected_2"]];
  135. imageView.tag = indexPath.row;
  136. imageView.userInteractionEnabled = YES;
  137. [imageView addGestureRecognizer:tap];
  138. cell.accessoryView = imageView;
  139. // cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  140. // cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"com_arrow_right_1"]];
  141. if(indexPath.row == _paymentTag)
  142. {
  143. UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"com_radio_selected_2"]];
  144. imageView.tag = indexPath.row;
  145. imageView.userInteractionEnabled = YES;
  146. [imageView addGestureRecognizer:tap];
  147. cell.accessoryView = imageView;
  148. }else
  149. {
  150. UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"com_radio_normal_2"]];
  151. imageView.tag = indexPath.row;
  152. imageView.userInteractionEnabled = YES;
  153. [imageView addGestureRecognizer:tap];
  154. cell.accessoryView = imageView;
  155. }
  156. return cell;
  157. }
  158. - (void)tap:(UITapGestureRecognizer *)sender
  159. {
  160. _paymentTag = sender.view.tag;
  161. reportModel *model = _dataArray[_paymentTag];
  162. _reportId = [NSString stringWithFormat:@"%d",model.ID];
  163. [_reportTableView reloadData];
  164. }
  165. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  166. {
  167. return 50;
  168. }
  169. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  170. {
  171. if (self.reportType == 3) {
  172. reportModel *model = _dataArray[indexPath.row];
  173. model.weibo_id = self.commentID;
  174. MGReportCommentController *vc = [[MGReportCommentController alloc]initWithReportModel:model];
  175. [[AppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
  176. }else{
  177. _paymentTag = indexPath.row;
  178. reportModel *model = _dataArray[indexPath.row];
  179. _reportId = [NSString stringWithFormat:@"%d",model.ID];
  180. [_reportTableView reloadData];
  181. // [self reportClick];
  182. }
  183. }
  184. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  185. {
  186. if (!_headView)
  187. {
  188. _headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 40)];
  189. [_headView addSubview:_reportlabel];
  190. }
  191. return _headView;
  192. }
  193. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  194. {
  195. return 40;
  196. }
  197. #pragma mark 返回
  198. - (void)comeBack
  199. {
  200. [self.navigationController popViewControllerAnimated:YES];
  201. }
  202. - (void)reportClick
  203. {
  204. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  205. [parmDict setObject:@"user" forKey:@"ctl"];
  206. [parmDict setObject:@"tipoff_weibo" forKey:@"act"];
  207. [parmDict setObject:@"xr" forKey:@"itype"];
  208. if (_reportId.length < 1)
  209. {
  210. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请选择举报类型")];
  211. return;
  212. }
  213. [parmDict setObject:_reportId forKey:@"type"];
  214. if (self.to_user_id.length > 0)
  215. {
  216. [parmDict setObject:self.to_user_id forKey:@"to_user_id"];
  217. }
  218. if (self.reportType == 1)
  219. {
  220. if (self.weibo_id.length > 0)
  221. {
  222. [parmDict setObject:self.weibo_id forKey:@"weibo_id"];
  223. }
  224. }
  225. FWWeakify(self)
  226. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  227. {
  228. FWStrongify(self)
  229. if ([responseJson toInt:@"status"] == 1)
  230. {
  231. if (!_FWReportiew)
  232. {
  233. _FWReportiew = [self loadReportVC];
  234. }
  235. _FWReportiew.commentLabel.text = [responseJson toString:@"error"];
  236. }else
  237. {
  238. [[BGHUDHelper sharedInstance] tipMessage:[responseJson toString:@"error"]];
  239. }
  240. } FailureBlock:^(NSError *error)
  241. {
  242. NSLog(@"error==%@",error);
  243. }];
  244. }
  245. - (BGReportView *)loadReportVC
  246. {
  247. _FWReportiew = [[[NSBundle mainBundle] loadNibNamed:@"BGReportView" owner:self options:nil] lastObject];
  248. _FWReportiew.frame = CGRectMake(0, 0, kScreenW, kScreenH);
  249. _FWReportiew.RDeleGate = self;
  250. [[[UIApplication sharedApplication]keyWindow]addSubview:_FWReportiew];
  251. return _FWReportiew;
  252. }
  253. - (void)reportComeBack
  254. {
  255. [_FWReportiew removeFromSuperview];
  256. _FWReportiew = nil;
  257. [self.navigationController popViewControllerAnimated:YES];
  258. }
  259. @end