YBLiveReportVC.m 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. //
  2. // YBLiveReportVC.m
  3. // YBVideo
  4. //
  5. // Created by Boom on 2017/7/14.
  6. // Copyright © 2017年 cat. All rights reserved.
  7. //
  8. #import "YBLiveReportVC.h"
  9. #import "YBReportCell.h"
  10. @interface YBLiveReportVC ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate>{
  11. NSDictionary *selctDic;
  12. NSInteger selctCount;
  13. UITextView *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 YBLiveReportVC
  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. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
  34. }
  35. -(void)viewWillDisappear:(BOOL)animated{
  36. [super viewWillDisappear:animated];
  37. [IQKeyboardManager sharedManager].enable = NO;
  38. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
  39. }
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. _inputDes = @"";
  43. self.titleL.text = YZMsg(@"举报");
  44. self.subNavi.backgroundColor = UIColor.whiteColor;
  45. [self.leftBtn setImage:[UIImage imageNamed:@"pubBlack_back"] forState:0];
  46. self.titleL.textColor = RGB_COLOR(@"#323232", 1);
  47. self.dataArr = [NSMutableArray array];
  48. bg_corlor = RGB_COLOR(@"#f4f5f6", 1);
  49. _table = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-ShowDiff) style:UITableViewStyleGrouped];
  50. _table.delegate = self;
  51. _table.dataSource = self;
  52. _table.separatorStyle = UITableViewCellSeparatorStyleNone;
  53. _table.backgroundColor = bg_corlor;
  54. selctCount = 100000;
  55. textHeight = 0.0;
  56. self.view.backgroundColor = bg_corlor;
  57. [self.view addSubview:_table];
  58. }
  59. - (void)requetData{
  60. NSString *url = @"Live.getReportClass";
  61. YBWeakSelf;
  62. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  63. if (code == 0) {
  64. weakSelf.dataArr = [NSMutableArray array];
  65. weakSelf.dataArr = [NSMutableArray arrayWithArray:info];
  66. [weakSelf.table reloadData];
  67. }else {
  68. [MBProgressHUD showPop:msg];
  69. }
  70. } Fail:^(id fail) {
  71. }];
  72. }
  73. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  74. if (!headerLabel) {
  75. headerLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, _window_width, 40)];
  76. headerLabel.text = [NSString stringWithFormat:@" %@",YZMsg(@"选择举报理由")];
  77. headerLabel.textColor = RGB_COLOR(@"#959697", 1);
  78. headerLabel.font = [UIFont systemFontOfSize:13];
  79. headerLabel.backgroundColor = RGB_COLOR(@"#f4f5f6", 1);
  80. if (!_isLive) {
  81. headerLabel.backgroundColor = CellRow_Cor;
  82. }
  83. }
  84. return headerLabel;
  85. }
  86. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  87. return 40;
  88. }
  89. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  90. UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 80+110)];
  91. view.backgroundColor = bg_corlor;//_table.backgroundColor;
  92. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, _window_width-20, 30)];
  93. label.textColor = RGB_COLOR(@"#959697", 1);
  94. label.text = YZMsg(@"更多详细信息请在说明框中描述(选填)");
  95. label.font = [UIFont systemFontOfSize:13];
  96. [view addSubview:label];
  97. jubaoTextView = [[UITextView alloc]initWithFrame:CGRectMake(10, label.bottom, _window_width-20,90)];
  98. jubaoTextView.delegate = self;
  99. jubaoTextView.layer.masksToBounds = YES;
  100. jubaoTextView.layer.cornerRadius = 5.0;
  101. jubaoTextView.font = SYS_Font(13);
  102. jubaoTextView.textColor = RGB_COLOR(@"#333333", 1);//RGB_COLOR(@"#333333", 1);
  103. jubaoTextView.backgroundColor = [UIColor whiteColor];
  104. jubaoTextView.text = _inputDes;
  105. [view addSubview:jubaoTextView];
  106. placeLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 120, 15)];
  107. placeLabel.font = SYS_Font(12);
  108. placeLabel.textColor = RGB_COLOR(@"#999999", 1);
  109. if (!_isLive) {
  110. jubaoTextView.backgroundColor = CellRow_Cor;
  111. placeLabel.textColor = RGB_COLOR(@"#969696", 1);
  112. jubaoTextView.textColor = RGB_COLOR(@"#969696", 1);
  113. }
  114. //placeLabel.text = @"输入举报理由";
  115. [jubaoTextView addSubview:placeLabel];
  116. UIButton *btn = [UIButton buttonWithType:0];
  117. btn.frame = CGRectMake(20, jubaoTextView.bottom+10, _window_width-40, 40);
  118. btn.layer.masksToBounds = YES;
  119. btn.layer.cornerRadius = 20.0;
  120. [btn setBackgroundColor:Pink_Cor];
  121. [btn setTitle:YZMsg(@"提交") forState:0];
  122. [btn addTarget:self action:@selector(dojubao) forControlEvents:UIControlEventTouchUpInside];
  123. [view addSubview:btn];
  124. return view;
  125. }
  126. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  127. return 50;
  128. }
  129. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  130. return 80+110;
  131. }
  132. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  133. return _dataArr.count;
  134. }
  135. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  136. YBReportCell *cell = [tableView dequeueReusableCellWithIdentifier:@"jubaoCell"];
  137. if (!cell) {
  138. cell = [[YBReportCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"jubaoCell"];
  139. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  140. }
  141. cell.leftLabel.text = [_dataArr[indexPath.row] valueForKey:@"title"];
  142. if (indexPath.row == selctCount) {
  143. cell.rightImage.image = [UIImage imageNamed:@"profit_sel"];
  144. }else{
  145. cell.rightImage.image = [UIImage imageNamed:@"profit_nor"];
  146. }
  147. return cell;
  148. }
  149. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  150. [self hideKeboard];
  151. selctDic = [NSDictionary dictionaryWithDictionary:_dataArr[indexPath.row]];
  152. selctCount = indexPath.row;
  153. _inputDes = jubaoTextView.text;
  154. [_table reloadData];
  155. }
  156. - (void)dojubao{
  157. [self hideKeboard];
  158. if (selctCount == 100000) {
  159. [MBProgressHUD showError:YZMsg(@"选择举报理由")];
  160. return;
  161. }
  162. NSString *content = [NSString stringWithFormat:@"%@ %@",minstr([selctDic valueForKey:@"title"]),jubaoTextView.text];
  163. NSString *url = @"Live.setReport";
  164. NSDictionary *parameterDic = @{
  165. @"uid":[Config getOwnID],
  166. @"touid":_dongtaiId,
  167. @"token":[Config getOwnToken],
  168. @"content":content,
  169. };
  170. [YBNetworking postWithUrl:url Dic:parameterDic Suc:^(int code, id info, NSString *msg) {
  171. if (code == 0) {
  172. _inputDes = @"";
  173. [MBProgressHUD showError:YZMsg(@"举报成功")];
  174. [UIView animateWithDuration:0.5 animations:^{
  175. [self doReturn];
  176. }];
  177. }else {
  178. [MBProgressHUD showPop:msg];
  179. }
  180. } Fail:^(id fail) {
  181. }];
  182. }
  183. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
  184. {
  185. if (![text isEqualToString:@""]) {
  186. placeLabel.hidden = YES;
  187. }
  188. if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
  189. placeLabel.hidden = NO;
  190. }
  191. return YES;
  192. }
  193. - (void)hideKeboard{
  194. [jubaoTextView resignFirstResponder];
  195. }
  196. /*
  197. #pragma mark -- 获取键盘高度
  198. - (void)keyboardWillShow:(NSNotification *)aNotification
  199. {
  200. //获取键盘的高度
  201. NSDictionary *userInfo = [aNotification userInfo];
  202. NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
  203. CGRect keyboardRect = [aValue CGRectValue];
  204. // CGFloat height = keyboardRect.origin.y;
  205. [UIView animateWithDuration:0.3 animations:^{
  206. self.view.frame = CGRectMake(0.0f, -keyboardRect.size.height, _window_width, _window_height);
  207. }];
  208. }
  209. - (void)keyboardWillHide:(NSNotification *)aNotification
  210. {
  211. [UIView animateWithDuration:0.3 animations:^{
  212. self.view.frame =CGRectMake(0, 0, _window_width, _window_height);
  213. }];
  214. }
  215. -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
  216. [jubaoTextView resignFirstResponder];
  217. }
  218. */
  219. - (void)didReceiveMemoryWarning {
  220. [super didReceiveMemoryWarning];
  221. // Dispose of any resources that can be recreated.
  222. }
  223. @end