MGReportCommentController.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. //
  2. // MGReportCommentController.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2020/1/15.
  6. // Copyright © 2020 xfg. All rights reserved.
  7. //
  8. #import "MGReportCommentController.h"
  9. //#import "BGOssManager.h"
  10. #import "MultipleFileUploads.h"
  11. @interface MGReportCommentController ()<UITextViewDelegate>
  12. @property (nonatomic,strong) MultipleFileUploads * multipleFileUploads;
  13. @property(nonatomic, strong) UIView *firstView;
  14. @property(nonatomic, strong) UIView *secondView;
  15. @property(nonatomic, strong) UIView *centerView;
  16. @property(nonatomic, strong) UILabel *textViewL;
  17. @property(nonatomic, strong) UILabel *placeHolderL;
  18. @property(nonatomic, strong) UITextView *textView;
  19. @property(nonatomic, strong) UIButton *commitBtn;
  20. @property(nonatomic, strong) UIView *successView;
  21. //@property (nonatomic, strong) BGOssManager *ossManager; //oss 类
  22. @end
  23. @implementation MGReportCommentController
  24. -(instancetype)initWithReportModel:(reportModel *)reportModel{
  25. MGReportCommentController *vc = [MGReportCommentController new];
  26. vc.model = reportModel;
  27. return vc;
  28. }
  29. - (void)viewDidLoad {
  30. [super viewDidLoad];
  31. // Do any additional setup after loading the view.
  32. // _ossManager = [[BGOssManager alloc]initWithDelegate:self];
  33. self.navigationController.navigationBar.hidden = NO;
  34. self.navigationItem.title = ASLocalizedString(@"评论举报");
  35. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(comeBack) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  36. [self setUpFirstView];
  37. [self setUpSecondView];
  38. [self setUpThirdView];
  39. [self initPickerView];
  40. self.imageArray = [NSMutableArray array];
  41. [self.pickerCollectionView reloadData];
  42. self.commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  43. [self.commitBtn setTitle:ASLocalizedString(@"提交")forState:UIControlStateNormal];
  44. self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  45. [self.commitBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
  46. [self.commitBtn setBackgroundImage:[UIImage imageNamed:@"mg_sign_bg_ImgView"] forState:UIControlStateNormal];
  47. self.commitBtn.layer.cornerRadius = kRealValue(38 / 2);
  48. self.commitBtn.layer.masksToBounds = YES;
  49. self.commitBtn.frame = CGRectMake(0, kRealValue(380), kRealValue(240), kRealValue(38));
  50. self.commitBtn.centerX = kScreenW / 2;
  51. [self.commitBtn addTarget:self action:@selector(reportClick) forControlEvents:UIControlEventTouchUpInside];
  52. [self.view addSubview:self.commitBtn];
  53. [self clickView];
  54. [self.view addSubview:self.successView];
  55. self.successView.hidden = YES;
  56. }
  57. -(void)setUpFirstView{
  58. UIView *firstView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(44))];
  59. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kRealValue(75), kRealValue(44))];
  60. label.text = ASLocalizedString(@"举报理由");
  61. label.textAlignment = NSTextAlignmentCenter;
  62. label.font = [UIFont systemFontOfSize:14];
  63. label.textColor = [UIColor colorWithHexString:@"#666666"];
  64. UILabel *reportL = [[UILabel alloc]initWithFrame:CGRectMake(label.right, 0, kRealValue(75), kRealValue(44))];
  65. reportL.text = self.model.name;
  66. reportL.textAlignment = NSTextAlignmentLeft;
  67. reportL.font = [UIFont systemFontOfSize:16];
  68. reportL.textColor = kBlackColor;
  69. [firstView addSubview:label];
  70. [firstView addSubview:reportL];
  71. self.firstView = firstView;
  72. [self.view addSubview:firstView];
  73. }
  74. #pragma mark 返回
  75. - (void)comeBack
  76. {
  77. [self.navigationController popViewControllerAnimated:YES];
  78. }
  79. -(void)setUpSecondView{
  80. UIView *firstView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(144))];
  81. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(kRealValue(10), 0, kRealValue(120), kRealValue(44))];
  82. label.text = ASLocalizedString(@"举报描述(选填)");
  83. label.font = [UIFont systemFontOfSize:14];
  84. label.textColor = [UIColor colorWithHexString:@"#666666"];
  85. UILabel *reportL = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - kRealValue(120), 0, kRealValue(120), kRealValue(44))];
  86. reportL.text = @"0/200";
  87. reportL.textAlignment = NSTextAlignmentRight;
  88. reportL.font = [UIFont systemFontOfSize:16];
  89. reportL.textColor = kBlackColor;
  90. _textViewL = reportL;
  91. UILabel *placeHolderL = [[UILabel alloc]initWithFrame:CGRectMake(kRealValue(10), 0, kScreenW / 2, kRealValue(44))];
  92. placeHolderL.text = ASLocalizedString(@"请详细描述您的举报理由");
  93. placeHolderL.font = [UIFont systemFontOfSize:14];
  94. placeHolderL.textColor = [UIColor colorWithHexString:@"#666666"];
  95. _placeHolderL = placeHolderL;
  96. UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(label.left, label.bottom, kScreenW - kRealValue(15 * 2), kRealValue(120))];
  97. textView.font = [UIFont systemFontOfSize:13];
  98. textView.delegate = self;
  99. _textView = textView;
  100. [firstView addSubview:textView];
  101. [textView addSubview:placeHolderL];
  102. [firstView addSubview:label];
  103. [firstView addSubview:reportL];
  104. [self.view addSubview:firstView];
  105. self.secondView = firstView;
  106. self.secondView.top = self.firstView.bottom;
  107. }
  108. -(void)setUpThirdView{
  109. UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, self.secondView.bottom, kScreenW, 163)];
  110. // view.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
  111. [self.view addSubview:view];
  112. self.centerView = view;
  113. }
  114. -(void)clickView{
  115. self.maxCount = 4;
  116. // //选择图片 图片和视频不能共存
  117. // [self addNewImg];
  118. if (self.pickerCollectionView.hidden == YES) {
  119. self.pickerCollectionView.hidden = NO;
  120. }
  121. [self updatePickerViewFrameY:self.secondView.bottom+10];
  122. self.centerView.frame = CGRectMake(0, self.pickerCollectionView.bottom+20, kScreenW, 163);
  123. [self.pickerCollectionView reloadData];
  124. [self changeCollectionViewHeight];
  125. }
  126. -(void)textViewDidBeginEditing:(UITextView *)textView{
  127. self.placeHolderL.hidden = YES;
  128. }
  129. -(void)textViewDidChange:(UITextView *)textView{
  130. self.placeHolderL.hidden = YES;
  131. if (textView.text.length > 199) {
  132. textView.text = [textView.text substringToIndex:199];
  133. }
  134. self.textViewL.text = [NSString stringWithFormat:@"%ld/200",textView.text.length];
  135. }
  136. -(void)textViewDidEndEditing:(UITextView *)textView{
  137. if (textView.text.length < 1) {
  138. self.placeHolderL.hidden = NO;
  139. }
  140. }
  141. - (void)reportClick
  142. {
  143. if (self.arrSelected >0)
  144. {
  145. [[BGHUDHelper sharedInstance]syncLoading:ASLocalizedString(@"正在上传")];
  146. __block typeof(self)blockself =self;
  147. [self PhassetgetBigImageArray:self.arrSelected isSubmit:YES callBack:^(NSArray *ary, bool isImg) {
  148. if (self.arrSelected.count == ary.count)
  149. {
  150. NSMutableArray *smallImageDataArray = [ary copy];
  151. [blockself submitToserverWith:smallImageDataArray isImg:isImg];
  152. }
  153. }];
  154. }
  155. }
  156. #pragma mark - 上传数据到服务器前将图片转data(上传服务器用form表单:未写)
  157. - (void)submitToserverWith:(NSArray * )imgary isImg:(BOOL)isImg{
  158. // [[BGHUDHelper sharedInstance]syncLoading:ASLocalizedString(@"正在上传图片...")];
  159. NSMutableArray<MultipleFileUploadsModel *> *arr = [NSMutableArray array];
  160. for (int i =0 ; i<self.bigImageArray.count; i++) {
  161. MultipleFileUploadsModel *model = [[MultipleFileUploadsModel alloc] init];
  162. model.fileName = [NSString stringWithFormat:@"uploadpng%d.png",i];
  163. model.data =self.bigImageArray[i];
  164. [arr addObject:model];
  165. }
  166. WeakSelf
  167. [self.multipleFileUploads uploadFile:arr done:^(NSArray<NSString *> * _Nonnull urlStrMArray) {
  168. NSLog(@"%@",urlStrMArray);
  169. [[BGHUDHelper sharedInstance]syncStopLoading];
  170. NSString *imgStr = [urlStrMArray componentsJoinedByString:@","];
  171. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  172. [parmDict setObject:@"user" forKey:@"ctl"];
  173. [parmDict setObject:@"tipoff_weibo" forKey:@"act"];
  174. [parmDict setObject:@"xr" forKey:@"itype"];
  175. [parmDict setObject:[NSString stringWithFormat:@"%d",self.model.ID] forKey:@"type"];
  176. [parmDict setObject:imgStr forKey:@"screenshot"];
  177. [parmDict setObject:@"3" forKey:@"report_type"];//视频评论举报
  178. [parmDict setObject:weakSelf.textView.text forKey:@"remark"];
  179. if (self.model.to_userID.length > 0)
  180. {
  181. [parmDict setObject:self.model.to_userID forKey:@"to_user_id"];
  182. }
  183. if (self.model.weibo_id.length > 0)
  184. {
  185. [parmDict setObject:self.model.weibo_id forKey:@"weibo_id"];
  186. }
  187. FWWeakify(self)
  188. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  189. {
  190. FWStrongify(self)
  191. if ([responseJson toInt:@"status"] == 1)
  192. {
  193. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"举报成功")];
  194. self.successView.hidden = NO;
  195. }else
  196. {
  197. [[BGHUDHelper sharedInstance] tipMessage:[responseJson toString:@"error"]];
  198. }
  199. } FailureBlock:^(NSError *error)
  200. {
  201. NSLog(@"error==%@",error);
  202. }];
  203. }];
  204. // __weak __typeof(self)weakSelf = self;
  205. // [_ossManager showUploadOfOssServiceOfDataMarray:self.bigImageArray andSTDynamicSelectType:STDynamicSelectPhoto andComplete:^(BOOL finished, NSMutableArray<NSString *> *urlStrMArray) {
  206. //
  207. // NSLog(@"%@",urlStrMArray);
  208. //
  209. // [[BGHUDHelper sharedInstance]syncStopLoading];
  210. // NSString *imgStr = [urlStrMArray componentsJoinedByString:@","];
  211. // NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  212. // [parmDict setObject:@"user" forKey:@"ctl"];
  213. // [parmDict setObject:@"tipoff_weibo" forKey:@"act"];
  214. // [parmDict setObject:@"xr" forKey:@"itype"];
  215. // [parmDict setObject:[NSString stringWithFormat:@"%d",self.model.ID] forKey:@"type"];
  216. // [parmDict setObject:imgStr forKey:@"screenshot"];
  217. // [parmDict setObject:@"3" forKey:@"report_type"];//视频评论举报
  218. // [parmDict setObject:weakSelf.textView.text forKey:@"remark"];
  219. //
  220. //
  221. //
  222. // if (self.model.to_userID.length > 0)
  223. // {
  224. // [parmDict setObject:self.model.to_userID forKey:@"to_user_id"];
  225. // }
  226. //
  227. // if (self.model.weibo_id.length > 0)
  228. // {
  229. // [parmDict setObject:self.model.weibo_id forKey:@"weibo_id"];
  230. // }
  231. //
  232. // FWWeakify(self)
  233. // [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  234. // {
  235. // FWStrongify(self)
  236. // if ([responseJson toInt:@"status"] == 1)
  237. // {
  238. // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"举报成功")];
  239. // self.successView.hidden = NO;
  240. // }else
  241. // {
  242. // [[BGHUDHelper sharedInstance] tipMessage:[responseJson toString:@"error"]];
  243. // }
  244. //
  245. // } FailureBlock:^(NSError *error)
  246. // {
  247. // NSLog(@"error==%@",error);
  248. // }];
  249. //
  250. // }];
  251. }
  252. -(MultipleFileUploads *)multipleFileUploads
  253. {
  254. if(_multipleFileUploads ==nil)
  255. {
  256. _multipleFileUploads = [[MultipleFileUploads alloc] init];
  257. }
  258. return _multipleFileUploads;
  259. }
  260. -(void)clickComplete:(UIButton *)sender{
  261. [self.navigationController popViewControllerAnimated:YES];
  262. [self.navigationController popViewControllerAnimated:YES];
  263. }
  264. -(UIView *)successView{
  265. if (!_successView) {
  266. _successView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
  267. _successView.backgroundColor = kWhiteColor;
  268. UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, kRealValue(119), kRealValue(56), kRealValue(56))];
  269. [imgView setImage:[UIImage imageNamed:@"mg_report_success"]];
  270. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, imgView.bottom + kRealValue(10), kScreenW / 2, kRealValue(20))];
  271. label.text = ASLocalizedString(@"举报提交成功");
  272. label.textAlignment = NSTextAlignmentCenter;
  273. label.textColor = [UIColor colorWithHexString:@"333333"];
  274. label.font = [UIFont systemFontOfSize:16];
  275. UILabel *subLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, label.bottom + kRealValue(10), kScreenW - kRealValue(20), kRealValue(20))];
  276. subLabel.text = ASLocalizedString(@"我们将在24小时之内进行处理");
  277. subLabel.textAlignment = NSTextAlignmentCenter;
  278. subLabel.textColor = [UIColor colorWithHexString:@"666666"];
  279. subLabel.font = [UIFont systemFontOfSize:14];
  280. UIButton *completeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  281. completeBtn.frame = CGRectMake(0, subLabel.bottom + kRealValue(40), kRealValue(250), kRealValue(32));
  282. [completeBtn setTitle:ASLocalizedString(@"完成")forState:UIControlStateNormal];
  283. [completeBtn setBackgroundImage:[UIImage imageNamed:@"mg_sign_bg_ImgView"] forState:UIControlStateNormal];
  284. completeBtn.layer.cornerRadius = kRealValue(38 / 2);
  285. completeBtn.layer.masksToBounds = YES;
  286. [completeBtn addTarget:self action:@selector(clickComplete:) forControlEvents:UIControlEventTouchUpInside];
  287. imgView.centerX = completeBtn.centerX = subLabel.centerX = label.centerX = kScreenW / 2;
  288. [_successView addSubview:imgView];
  289. [_successView addSubview:label];
  290. [_successView addSubview:subLabel];
  291. [_successView addSubview:completeBtn];
  292. }
  293. return _successView;
  294. }
  295. @end