YBVideoReportVC.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. //
  2. // YBVideoReportVC.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2020/6/20.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "YBVideoReportVC.h"
  9. #import "YBReportCell.h"
  10. @interface YBVideoReportVC ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate>{
  11. NSDictionary *selctDic;
  12. NSInteger selctCount;
  13. MyTextView *jubaoTextView;
  14. CGFloat textHeight;
  15. UILabel *placeLabel;
  16. UILabel *headerLabel;
  17. UIColor *bg_corlor;
  18. NSString *_inputDes;
  19. }
  20. @property(nonatomic,strong)NSMutableArray *dataArr;
  21. @property(nonatomic,strong)UITableView *table;
  22. @end
  23. @implementation YBVideoReportVC
  24. -(void)doReturn{
  25. [[NSNotificationCenter defaultCenter] removeObserver:self];
  26. [self.navigationController popViewControllerAnimated:YES];
  27. [self dismissViewControllerAnimated:YES completion:nil];
  28. }
  29. -(void)viewWillAppear:(BOOL)animated{
  30. [super viewWillAppear:animated];
  31. [self requetData];
  32. [IQKeyboardManager sharedManager].enable = YES;
  33. }
  34. -(void)viewWillDisappear:(BOOL)animated{
  35. [super viewWillDisappear:animated];
  36. [IQKeyboardManager sharedManager].enable = NO;
  37. }
  38. - (void)viewDidLoad {
  39. [super viewDidLoad];
  40. _inputDes = @"";
  41. self.titleL.text = YZMsg(@"举报");
  42. self.dataArr = [NSMutableArray array];
  43. bg_corlor = Normal_Color;
  44. _table = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-ShowDiff) style:UITableViewStyleGrouped];
  45. _table.delegate = self;
  46. _table.dataSource = self;
  47. _table.separatorStyle = UITableViewCellSeparatorStyleNone;
  48. _table.backgroundColor = bg_corlor;
  49. selctCount = 100000;
  50. textHeight = 0.0;
  51. self.view.backgroundColor = bg_corlor;
  52. [self.view addSubview:_table];
  53. }
  54. - (void)requetData{
  55. NSString *url= @"Video.getReportContentlist";
  56. YBWeakSelf;
  57. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  58. if (code == 0) {
  59. weakSelf.dataArr = [NSMutableArray array];
  60. weakSelf.dataArr = [NSMutableArray arrayWithArray:info];
  61. [weakSelf.table reloadData];
  62. }else {
  63. [MBProgressHUD showPop:msg];
  64. }
  65. } Fail:^(id fail) {
  66. }];
  67. }
  68. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  69. if (!headerLabel) {
  70. headerLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, _window_width, 40)];
  71. headerLabel.text = [NSString stringWithFormat:@" %@",YZMsg(@"选择举报理由")];
  72. headerLabel.textColor = Pink_Cor;
  73. headerLabel.font = [UIFont systemFontOfSize:13];
  74. headerLabel.backgroundColor = CellRow_Cor;
  75. }
  76. return headerLabel;
  77. }
  78. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  79. return 40;
  80. }
  81. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  82. UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 80+110)];
  83. view.backgroundColor = bg_corlor;
  84. jubaoTextView = [[MyTextView alloc]initWithFrame:CGRectMake(10, 30, _window_width-20,90)];
  85. jubaoTextView.delegate = self;
  86. jubaoTextView.layer.masksToBounds = YES;
  87. jubaoTextView.layer.cornerRadius = 5.0;
  88. jubaoTextView.font = SYS_Font(13);
  89. jubaoTextView.text = _inputDes;
  90. [view addSubview:jubaoTextView];
  91. jubaoTextView.backgroundColor = CellRow_Cor;
  92. jubaoTextView.textColor = RGB_COLOR(@"#969696", 1);
  93. jubaoTextView.placeholder = YZMsg(@"请填写举报理由");
  94. jubaoTextView.placeholderColor = RGB_COLOR(@"#969696", 1);
  95. UIButton *btn = [UIButton buttonWithType:0];
  96. btn.frame = CGRectMake(20, jubaoTextView.bottom+10, _window_width-40, 40);
  97. btn.layer.masksToBounds = YES;
  98. btn.layer.cornerRadius = 20.0;
  99. [btn setTitleColor:Pink_Cor forState:0];
  100. [btn setTitle:YZMsg(@"提交") forState:0];
  101. [btn addTarget:self action:@selector(dojubao) forControlEvents:UIControlEventTouchUpInside];
  102. [view addSubview:btn];
  103. //20-5-19 只有短视频并且选择了其他选项时才可以输入内容
  104. if ([minstr([selctDic valueForKey:@"id"]) isEqual:@"-1"]) {
  105. jubaoTextView.hidden = NO;
  106. }else{
  107. jubaoTextView.hidden = YES;
  108. }
  109. return view;
  110. }
  111. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  112. return 50;
  113. }
  114. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  115. return 80+110;
  116. }
  117. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  118. return _dataArr.count;
  119. }
  120. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  121. YBReportCell *cell = [tableView dequeueReusableCellWithIdentifier:@"jubaoCell"];
  122. if (!cell) {
  123. cell = [[YBReportCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"jubaoCell"];
  124. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  125. }
  126. cell.isVideo = YES;
  127. cell.leftLabel.text = [_dataArr[indexPath.row] valueForKey:@"name"];
  128. if (indexPath.row == selctCount) {
  129. cell.rightImage.image = [UIImage imageNamed:@"下一步"];
  130. }else{
  131. cell.rightImage.image = [UIImage new];
  132. }
  133. cell.leftLabel.textColor = RGB_COLOR(@"#969696", 1);
  134. cell.cellLineL.backgroundColor = Line_Cor;
  135. cell.backgroundColor = CellRow_Cor;
  136. cell.contentView.backgroundColor = CellRow_Cor;
  137. return cell;
  138. }
  139. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  140. [self hideKeboard];
  141. selctDic = [NSDictionary dictionaryWithDictionary:_dataArr[indexPath.row]];
  142. selctCount = indexPath.row;
  143. _inputDes = jubaoTextView.text;
  144. [_table reloadData];
  145. }
  146. - (void)dojubao{
  147. [self hideKeboard];
  148. if (selctCount == 100000) {
  149. [MBProgressHUD showError:YZMsg(@"选择举报理由")];
  150. return;
  151. }
  152. NSString *content = [NSString stringWithFormat:@"%@",minstr([selctDic valueForKey:@"name"])];
  153. if ([minstr([selctDic valueForKey:@"id"]) isEqual:@"-1"]) {
  154. //其他
  155. content = [NSString stringWithFormat:@"%@ %@",minstr([selctDic valueForKey:@"name"]),jubaoTextView.text];
  156. }
  157. NSString *url = @"Video.report";
  158. NSDictionary *parameterDic = @{
  159. @"uid":[Config getOwnID],
  160. @"videoid":_dongtaiId,
  161. @"token":[Config getOwnToken],
  162. @"content":content,
  163. };
  164. [YBNetworking postWithUrl:url Dic:parameterDic Suc:^(int code, id info, NSString *msg) {
  165. if (code == 0) {
  166. _inputDes = @"";
  167. [MBProgressHUD showError:YZMsg(@"举报成功")];
  168. [UIView animateWithDuration:0.5 animations:^{
  169. [self doReturn];
  170. }];
  171. }else {
  172. [MBProgressHUD showPop:msg];
  173. }
  174. } Fail:^(id fail) {
  175. }];
  176. }
  177. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
  178. if (![text isEqualToString:@""]) {
  179. //placeLabel.hidden = YES;
  180. }
  181. if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
  182. //placeLabel.hidden = NO;
  183. }
  184. return YES;
  185. }
  186. - (void)hideKeboard{
  187. [jubaoTextView resignFirstResponder];
  188. }
  189. - (void)didReceiveMemoryWarning {
  190. [super didReceiveMemoryWarning];
  191. // Dispose of any resources that can be recreated.
  192. }
  193. @end