CNLiveCommuntEvaluaViewController.m
30 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
//
// CNLiveCommuntEvaluaViewController.m
// CNLiveCommunitModule
//
// Created by open on 2022/2/6.
//
#import "CNLiveCommuntEvaluaViewController.h"
@interface CNLiveCommuntEvaluaViewController ()<QMUITextViewDelegate,TZImagePickerControllerDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate>
@property (nonatomic, strong) UIScrollView * mianScrollView;
@property (nonatomic, strong) UIImageView * imageView;
@property (nonatomic, strong) UILabel * nameLabel;
@property (nonatomic, strong) UILabel * dateLabel;
@property (nonatomic, strong) UILabel * lineLabel;
@property (nonatomic, strong) QMUITextView * evaluaView;
@property (nonatomic, strong) MBProgressHUD * progressHud;
@property (nonatomic, strong) UIImageView * imageView01;
@property (nonatomic, strong) UIImageView * imageView02;
@property (nonatomic, strong) UIImageView * imageView03;
@property (nonatomic, strong) UIButton * delectBtn01;
@property (nonatomic, strong) UIButton * delectBtn02;
@property (nonatomic, strong) UIButton * delectBtn03;
@property (nonatomic, strong) UIButton * selectBtn;
@property (nonatomic, strong) UIView * selectView;
@property (nonatomic, strong) UIView * selectCenterView;
@property (nonatomic, strong) UILabel * evaluaDescLabel;
@property (nonatomic, strong) UIButton * submiteBtn;
@property (nonatomic, strong) NSMutableArray *cameraArray;
@property (nonatomic, strong) NSMutableArray *photosArray;
@property (nonatomic, strong) NSMutableArray *assetsPhotoArray;
@property (nonatomic, strong) NSMutableArray *assetsCameraArray;
@property (nonatomic, strong) NSMutableArray * imageArray;
@property (nonatomic, strong) NSMutableArray * assetsArray;
@property (nonatomic, assign) BOOL isAnonymity;
@property (nonatomic, strong) CNLiveCommuntyActivityRecordListModel * recordModel;
@end
@implementation CNLiveCommuntEvaluaViewController
- (instancetype)initWithRecord:(CNLiveCommuntyActivityRecordListModel *)recordModel
{
self = [super init];
if (self) {
_recordModel = recordModel;
}
return self;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
self.title = @"活动评价";
[self.view addSubview:self.mianScrollView];
[self.mianScrollView addSubview:self.imageView];
[self.mianScrollView addSubview:self.nameLabel];
[self.mianScrollView addSubview:self.dateLabel];
[self.mianScrollView addSubview:self.lineLabel];
[self.mianScrollView addSubview:self.evaluaView];
[self.mianScrollView addSubview:self.imageView01];
[self.mianScrollView addSubview:self.imageView02];
[self.mianScrollView addSubview:self.imageView03];
[self.mianScrollView addSubview:self.selectView];
[self.mianScrollView addSubview:self.evaluaDescLabel];
[self.mianScrollView addSubview:self.selectBtn];
[self.selectView addSubview:self.selectCenterView];
self.delectBtn01 = [self setDelectBtn:0];
self.delectBtn02 = [self setDelectBtn:1];
self.delectBtn03 = [self setDelectBtn:2];
[self.imageView01 addSubview:self.delectBtn01];
[self.imageView02 addSubview:self.delectBtn02];
[self.imageView03 addSubview:self.delectBtn03];
self.assetsPhotoArray = [[NSMutableArray alloc] init];
self.assetsCameraArray = [[NSMutableArray alloc] init];
self.cameraArray = [[NSMutableArray alloc] init];
self.photosArray = [[NSMutableArray alloc] init];
self.imageArray = [[NSMutableArray alloc] init];
self.assetsArray = [[NSMutableArray alloc] init];
[self viewWillLayoutSubview];
UIButton * submiteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
submiteBtn.frame = CGRectMake(0, 0, 50, 14);
[submiteBtn setTitle:@"提交" forState:UIControlStateNormal];
[submiteBtn setTitleColor:UIColorWhite forState:UIControlStateNormal];
submiteBtn.backgroundColor = UIColorHex(#CD0302);//UIColorHex(#F2F2F2);
submiteBtn.titleLabel.font = [UIFont systemFontOfSize:12];
submiteBtn.layer.cornerRadius = 3;
submiteBtn.layer.masksToBounds = YES;
[submiteBtn addTarget:self action:@selector(submiteAction:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:submiteBtn];
self.submiteBtn = submiteBtn;
}
-(void)viewWillLayoutSubview
{
__weak typeof(self) weakSelf = self;
[self.mianScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.view).offset(kNavigationBarHeight);
make.left.right.bottom.mas_equalTo(weakSelf.view);
}];
[self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.mas_equalTo(weakSelf.mianScrollView).offset(10);
make.size.mas_equalTo(50);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.imageView).offset(3);
make.left.mas_equalTo(weakSelf.imageView.mas_right).offset(10);
}];
[self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(weakSelf.imageView.mas_bottom).offset(-3);
make.left.mas_equalTo(weakSelf.imageView.mas_right).offset(10);
}];
[self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.mianScrollView).offset(10);
make.right.mas_equalTo(weakSelf.mianScrollView).offset(-10);
make.centerX.mas_equalTo(weakSelf.mianScrollView);
make.top.mas_equalTo(weakSelf.imageView.mas_bottom).offset(10);
make.height.mas_equalTo(0.5);
}];
[self.evaluaView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.mianScrollView).offset(10);
make.right.mas_equalTo(weakSelf.mianScrollView).offset(-10);
make.centerX.mas_equalTo(weakSelf.mianScrollView);
make.top.mas_equalTo(weakSelf.lineLabel.mas_bottom).offset(10);
make.height.mas_equalTo(150);
}];
[self.imageView01 mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.mianScrollView).offset(10);
make.top.mas_equalTo(weakSelf.evaluaView.mas_bottom).offset(10);
make.size.mas_equalTo((kScreenWidth-40)/3);
}];
[self.imageView02 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.evaluaView.mas_bottom).offset(10);
make.left.mas_equalTo(weakSelf.imageView01.mas_right).offset(10);
make.size.mas_equalTo((kScreenWidth-40)/3);
}];
[self.imageView03 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.evaluaView.mas_bottom).offset(10);
make.left.mas_equalTo(weakSelf.imageView02.mas_right).offset(10);
make.size.mas_equalTo((kScreenWidth-40)/3);
}];
[self.selectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.imageView01.mas_bottom).offset(10);
make.left.mas_equalTo(weakSelf.mianScrollView).offset(10);
make.size.mas_equalTo(14);
}];
[self.selectCenterView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.selectView).offset(2);
make.left.mas_equalTo(weakSelf.selectView).offset(2);
make.right.mas_equalTo(weakSelf.selectView).offset(-2);
make.bottom.mas_equalTo(weakSelf.selectView).offset(-2);
}];
[self.evaluaDescLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(weakSelf.selectView);
make.left.mas_equalTo(weakSelf.selectView.mas_right).offset(5);
}];
[self.selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.imageView01.mas_bottom).offset(10);
make.left.mas_equalTo(weakSelf.mianScrollView).offset(10);
make.right.mas_equalTo(weakSelf.mianScrollView).offset(-10);
make.height.mas_equalTo(30);
}];
[self.delectBtn01 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.imageView01.mas_top).offset(5);
make.right.mas_equalTo(weakSelf.imageView01.mas_right).offset(-5);
make.size.mas_equalTo(20);
}];
[self.delectBtn02 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.imageView02.mas_top).offset(5);
make.right.mas_equalTo(weakSelf.imageView02.mas_right).offset(-5);
make.size.mas_equalTo(20);
}];
[self.delectBtn03 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.imageView03.mas_top).offset(5);
make.right.mas_equalTo(weakSelf.imageView03.mas_right).offset(-5);
make.size.mas_equalTo(20);
}];
}
-(void)submiteAction:(UIButton *)button
{
self.evaluaView.text = [self.evaluaView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([self.evaluaView.text isNotBlank]) {
__weak typeof(self) weakSelf = self;
[self.view endEditing:YES];
if (self.imageArray.count == 0) {
[CNLiveCommuntViewModel requestWithCommuntyCommentsInfoWithContentId:self.recordModel.idStr handworkId:self.recordModel.handworkId comment:self.evaluaView.text imgs:@"" isAnonymity:self.isAnonymity CompleterBlock:^{
[QMUITips showSucceed:@"评论成功" inView:weakSelf.view hideAfterDelay:1.5];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf.navigationController popViewControllerAnimated:YES];
});
}];
}else{
__weak typeof(self) weakSelf = self;
[self uploadImageWithCompleterBlock:^(NSString *imageUrl) {
[CNLiveCommuntViewModel requestWithCommuntyCommentsInfoWithContentId:weakSelf.recordModel.idStr handworkId:weakSelf.recordModel.handworkId comment:weakSelf.evaluaView.text imgs:imageUrl isAnonymity:weakSelf.isAnonymity CompleterBlock:^{
[QMUITips showSucceed:@"评论成功" inView:weakSelf.view hideAfterDelay:1.5];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf.navigationController popViewControllerAnimated:YES];
});
}];
}];
}
}else{
[QMUITips showError:@"评论内容不能空" inView:self.view hideAfterDelay:1.5];
}
}
-(void)selectMothodAction:(UIButton *)button
{
self.selectCenterView.hidden = button.selected;
self.isAnonymity = !button.selected;
NSLog(@"%@",self.isAnonymity?@"匿名":@"实名");
button.selected = !button.selected;
}
-(void)delectImageViewAction:(UIButton *)button
{
UIImage * image = ((UIImageView *)button.superview).image;
if ([self.imageArray containsObject:image]) {
[self.assetsArray removeObjectAtIndex:[self.imageArray indexOfObject:image]];
[self.imageArray removeObject:image];
}
[self setReloadFinishPickingPhotos];
}
-(void)selectWithImageViewForIndex:(NSInteger)index
{
if (self.imageArray.count >= index + 1) return;
__weak typeof(self) weakSelf = self;
[self.view endEditing:YES];
[self.view createAlertViewTitleArray:@[@"拍摄",@"从手机相册选择"] subTitleArr:@[@"",@""] textColor:UIColorMake(40, 40, 40) subTitleColor:UIColorMake(152, 152, 152) font:UIFontMake(15) subFont:UIFontMake(12) actionBlock:^(UIButton *button, NSInteger didRow) {
switch (didRow) {
case 0:
{
if (IOS14_SDK_ALLOWED) {
[weakSelf requestCNLiveALAssetsLibraryAuthorizationWithCompletion:^(BOOL isAuth) {
if (isAuth) {
dispatch_async_on_main_queue(^{
[weakSelf takeToXFPhoto:index];
});
}
}];
}else{
[weakSelf takeToXFPhoto:index];
}
}
break;
case 1:
{
[self pushTZImagePickerController:index];
}
break;
default:
break;
}
}];
}
-(void)requestCNLiveALAssetsLibraryAuthorizationWithCompletion:(void(^)(BOOL isAuth))requestAssetsLibraryAuthCompletion
{
PHAuthorizationStatus authStatus = [PHPhotoLibrary authorizationStatus];
if (authStatus != PHAuthorizationStatusAuthorized) {//未授权
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
if (status != PHAuthorizationStatusAuthorized) {//已授权
if (requestAssetsLibraryAuthCompletion) {
requestAssetsLibraryAuthCompletion(NO);
}
} else {
if (requestAssetsLibraryAuthCompletion) {
requestAssetsLibraryAuthCompletion(YES);
}
}
}];
} else {
if (requestAssetsLibraryAuthCompletion) {
requestAssetsLibraryAuthCompletion(YES);
}
}
}
- (void)takeToXFPhoto:(NSInteger)index
{
__weak typeof(self) weakSelf = self;
XFCameraController *cameraController = [[XFCameraController alloc] init];
cameraController.isCanShootVideo = NO;
cameraController.modalPresentationStyle = UIModalPresentationFullScreen;
__weak XFCameraController *weakCameraController = cameraController;
cameraController.takePhotosCompletionBlock = ^(UIImage *image, NSError *error) {
if (!error) {
NSMutableArray *imageIds = [NSMutableArray array];
[weakCameraController dismissViewControllerAnimated:YES completion:^{
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
//写入图片到相册
PHAssetChangeRequest *req = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
//记录本地标识,等待完成后取到相册中的图片对象
[imageIds addObject:req.placeholderForCreatedAsset.localIdentifier];
} completionHandler:^(BOOL success, NSError * _Nullable error) {
if (success) {
PHFetchResult *result = [PHAsset fetchAssetsWithLocalIdentifiers:imageIds options:nil];
[result enumerateObjectsUsingBlock:^(PHAsset * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
dispatch_async_on_main_queue(^{
// [weakSelf.imageArray removeObject:weakSelf.cameraArray.firstObject];
// [weakSelf.assetsArray removeObject:weakSelf.assetsCameraArray.firstObject];
// [weakSelf.assetsCameraArray removeAllObjects];
// [weakSelf.cameraArray removeAllObjects];
// [weakSelf.assetsCameraArray addObject:obj];
// [weakSelf.cameraArray addObject:image];
[weakSelf.imageArray addObjectsFromArray:@[image]];//weakSelf.cameraArray];
[weakSelf.assetsArray addObjectsFromArray:@[obj]];//weakSelf.assetsCameraArray];
[weakSelf setReloadFinishPickingPhotos];
});
}];
}
}];
}];
}
};
[self presentViewController:cameraController animated:YES completion:NULL];
}
- (void)pushTZImagePickerController:(NSInteger)index
{
CNImagePickerController *imagePickerVc = [[CNImagePickerController alloc] initWithMaxImagesCount:3 columnNumber:3 delegate:self pushPhotoPickerVc:YES];
imagePickerVc.modalPresentationStyle = UIModalPresentationFullScreen;
[imagePickerVc configTZImagePicker];//配置
imagePickerVc.isSelectOriginalPhoto = NO;//是否选择原图
// 1.设置目前已经选中的图片数组
imagePickerVc.selectedAssets = self.assetsArray;
imagePickerVc.maxEditVideoTime = 60;//编辑长度
imagePickerVc.maxVideoDuration = 120;//编辑视频最大长度
// 3. Set allow picking video & photo & originalPhoto or not
// 3. 设置是否可以选择视频/图片/原图
imagePickerVc.allowPickingMultipleVideo = NO;
imagePickerVc.allowPickingVideo = NO;
/// 5. Single selection mode, valid when maxImagesCount = 1
/// 5. 单选模式,maxImagesCount为1时才生效
// 设置竖屏下的裁剪尺寸
NSInteger left = 30;
NSInteger widthHeight = KScreenWidth - 2 * left;
NSInteger top = (KScreenHeight - widthHeight) / 2;
imagePickerVc.cropRect = CGRectMake(left, top, widthHeight, widthHeight);
[self presentViewController:imagePickerVc animated:YES completion:NULL];
}
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto
{
[self.imageArray removeAllObjects];
[self.assetsArray removeAllObjects];
[self.imageArray addObjectsFromArray:photos];
[self.assetsArray addObjectsFromArray:assets];
[self setReloadFinishPickingPhotos];
}
-(BOOL)textViewShouldReturn:(QMUITextView *)textView
{
[textView resignFirstResponder];
return YES;
}
//- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
//{
// if (text.length > 0) {
// [self.submiteBtn setTitleColor:UIColorWhite forState:UIControlStateNormal];
// self.submiteBtn.backgroundColor = UIColorHex(#CD0302);
// }else{
// [self.submiteBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
// self.submiteBtn.backgroundColor = UIColorHex(#F2F2F2);
// }
// return YES;
//}
-(void)setReloadFinishPickingPhotos
{
if (self.imageArray.count == 0) {
self.imageView01.hidden = NO;
self.delectBtn01.hidden = YES;
self.imageView01.image = [CNLiveCommuntTools cCommunt_setImageWithName:@"c_communt_edit_add_image"];
self.imageView02.hidden = YES;
self.delectBtn02.hidden = YES;
}
if (self.imageArray.count == 1) {
self.imageView01.hidden = NO;
self.imageView01.image = self.imageArray.firstObject;
self.imageView02.hidden = NO;
self.delectBtn01.hidden = NO;
self.delectBtn02.hidden = YES;
self.imageView02.image = [CNLiveCommuntTools cCommunt_setImageWithName:@"c_communt_edit_add_image"];
self.imageView03.hidden = YES;
self.delectBtn03.hidden = YES;
}
if (self.imageArray.count == 2) {
self.imageView01.hidden = NO;
self.imageView01.image = self.imageArray.firstObject;
self.imageView02.hidden = NO;
self.imageView02.image = self.imageArray.lastObject;
self.delectBtn01.hidden = NO;
self.delectBtn02.hidden = NO;
self.imageView03.hidden = NO;
self.delectBtn03.hidden = YES;
self.imageView03.image = [CNLiveCommuntTools cCommunt_setImageWithName:@"c_communt_edit_add_image"];
}
if (self.imageArray.count == 3) {
self.delectBtn01.hidden = NO;
self.imageView01.hidden = NO;
self.imageView01.image = self.imageArray.firstObject;
self.delectBtn02.hidden = NO;
self.imageView02.hidden = NO;
self.imageView02.image = [self.imageArray objectAtIndex:1];
self.delectBtn03.hidden = NO;
self.imageView03.hidden = NO;
self.imageView03.image = self.imageArray.lastObject;
}
}
-(UIButton *)setDelectBtn:(NSInteger)index
{
UIButton * delectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
delectBtn.backgroundColor = [UIColor clearColor];
[delectBtn setImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communt_edit_delect_image"] forState:UIControlStateNormal];
delectBtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
delectBtn.hidden = YES;
delectBtn.tag = index + 100;
[delectBtn addTarget:self action:@selector(delectImageViewAction:) forControlEvents:UIControlEventTouchUpInside];
return delectBtn;
}
-(void)uploadImageWithCompleterBlock:(void(^)(NSString * imageUrl))completerBlock
{
__weak typeof(self) weakSelf = self;
NSDictionary *param = @{@"appId":AppId,
@"verb":@"POST",
@"storageType":@"2",
@"bucket":API_BucketName
};
self.progressHud.hidden = NO;
self.progressHud.mode = MBProgressHUDModeIndeterminate;
self.progressHud.bezelView.backgroundColor = [UIColor blackColor];
[CNLiveUploadManager uploadRequestType:CNLiveUploadTypeQN url:CNUploadAuthForApp dic:param imageArray:self.imageArray assetArray:self.assetsArray isOriginal:NO limitType:AppPhototLimitTypeFriendsCircle progress:^(float progress) {
NSLog(@"上传进度测试:%.2f",progress);
weakSelf.progressHud.mode = MBProgressHUDModeDeterminate;
weakSelf.progressHud.label.text = @"上传图片中...";
weakSelf.progressHud.bezelView.color = [UIColor colorWithWhite:0.95f alpha:0.6f];
weakSelf.progressHud.detailsLabel.text = [NSString stringWithFormat:@"%.2f %%",(progress * 100)];
} success:^(NSMutableArray *fileArray) {
NSLog(@"输出结果测试:%@",fileArray);
__block NSMutableString *picString = [[NSMutableString alloc] init];
[fileArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
CNLiveUploadModel *model = fileArray[idx];
if ([model.code isEqualToString:@"200"]) {
[picString appendString:model.imageUrl];
if (fileArray.count != idx + 1) [picString appendString:@","];
}else {
weakSelf.progressHud.hidden = YES;
weakSelf.progressHud = nil;
[QMUITips showError:model.info.error.localizedDescription inView:weakSelf.view hideAfterDelay:1.5f];
}
}];
weakSelf.progressHud.hidden = YES;
weakSelf.progressHud = nil;
if (completerBlock) completerBlock(picString);
} failure:^(NSMutableArray *errorArray, NSError *error) {
weakSelf.progressHud.hidden = YES;
weakSelf.progressHud = nil;
NSLog(@"输出结果测试:%@,错误:%@---%ld",errorArray,error,error.code);
if (error.code == 0) {
[QMUITips showError:@"上传失败" inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:1.5f];
}else {
[QMUITips showWithText:error.localizedDescription inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:1.5];
}
}];
}
#pragma mark =
-(UIScrollView *)mianScrollView
{
if (!_mianScrollView) {
_mianScrollView = [[UIScrollView alloc] init];
_mianScrollView.backgroundColor = [UIColor whiteColor];
_mianScrollView.contentSize = CGSizeMake(kScreenWidth, kScreenHeight);
}
return _mianScrollView;
}
-(UIImageView *)imageView
{
if (!_imageView) {
_imageView = [[UIImageView alloc] init];
_imageView.backgroundColor = [UIColor whiteColor];
_imageView.contentMode = UIViewContentModeScaleToFill;
_imageView.layer.masksToBounds = YES;
_imageView.layer.cornerRadius = 5;
_imageView.image = [UIImage imageWithColor:UIColorHex(#f9f9f9)];
[_imageView sd_setImageWithURL:[NSURL URLWithString:self.recordModel.imgUrl] placeholderImage:[UIImage imageWithColor:UIColorHex(#f9f9f9)]];
}
return _imageView;
}
-(UILabel *)nameLabel
{
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.backgroundColor = [UIColor whiteColor];
_nameLabel.font = [UIFont systemFontOfSize:15];
_nameLabel.textColor = UIColorHex(#333333);
_nameLabel.numberOfLines = 1;
_nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_nameLabel.text = self.recordModel.handworkName;
}
return _nameLabel;
}
-(UILabel *)dateLabel
{
if (!_dateLabel) {
_dateLabel = [[UILabel alloc] init];
_dateLabel.backgroundColor = [UIColor whiteColor];
_dateLabel.font = [UIFont systemFontOfSize:11];
_dateLabel.textColor = UIColorHex(#999999);
_dateLabel.numberOfLines = 1;
_dateLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_dateLabel.text = self.recordModel.createTimeString;
}
return _dateLabel;
}
-(UILabel *)lineLabel
{
if (!_lineLabel) {
_lineLabel = [[UILabel alloc] init];
_lineLabel.backgroundColor = UIColorHex(#E6E6E6);
}
return _lineLabel;
}
-(QMUITextView *)evaluaView
{
if (!_evaluaView) {
_evaluaView = [[QMUITextView alloc] init];
_evaluaView.backgroundColor = UIColorHex(#F9F9F9);
_evaluaView.layer.masksToBounds = YES;
_evaluaView.layer.cornerRadius = 7;
_evaluaView.placeholderColor = UIColorHex(#C8C8C8);
_evaluaView.placeholder = @"说说活动的特色和感受";
_evaluaView.textColor = UIColorHex(#333333);
_evaluaView.font = [UIFont systemFontOfSize:14.0f];
_evaluaView.returnKeyType = UIReturnKeyDone;
_evaluaView.maximumTextLength = 100;
_evaluaView.textContainerInset = UIEdgeInsetsMake(2.5, 2.5, 2.5, 2.5);
_evaluaView.contentInset = UIEdgeInsetsMake(2.5, 2.5, 2.5, 2.5);
_evaluaView.delegate = self;
}
return _evaluaView;
}
-(UIImageView *)imageView01
{
if (!_imageView01) {
_imageView01 = [[UIImageView alloc] init];
_imageView01.backgroundColor = [UIColor whiteColor];
_imageView01.contentMode = UIViewContentModeScaleAspectFill;
_imageView01.image = [CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_evalua_add_image"];
_imageView01.layer.cornerRadius = 6;
_imageView01.layer.masksToBounds = YES;
_imageView01.userInteractionEnabled = YES;
__weak typeof(self) weakSelf = self;
[_imageView01 addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
[weakSelf selectWithImageViewForIndex:0];
}]];
}
return _imageView01;
}
-(UIImageView *)imageView02
{
if (!_imageView02) {
_imageView02 = [[UIImageView alloc] init];
_imageView02.backgroundColor = [UIColor whiteColor];
_imageView02.contentMode = UIViewContentModeScaleAspectFill;
_imageView02.image = [CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_evalua_add_image"];
_imageView02.layer.cornerRadius = 6;
_imageView02.layer.masksToBounds = YES;
_imageView02.hidden = YES;
_imageView02.userInteractionEnabled = YES;
__weak typeof(self) weakSelf = self;
[_imageView02 addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
[weakSelf selectWithImageViewForIndex:1];
}]];
}
return _imageView02;
}
-(UIImageView *)imageView03
{
if (!_imageView03) {
_imageView03 = [[UIImageView alloc] init];
_imageView03.backgroundColor = [UIColor whiteColor];
_imageView03.contentMode = UIViewContentModeScaleAspectFill;
_imageView03.image = [CNLiveCommuntTools cCommunt_setImageWithName:@"c_communty_evalua_add_image"];
_imageView03.layer.cornerRadius = 6;
_imageView03.layer.masksToBounds = YES;
_imageView03.hidden = YES;
_imageView03.userInteractionEnabled = YES;
__weak typeof(self) weakSelf = self;
[_imageView03 addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
[weakSelf selectWithImageViewForIndex:2];
}]];
}
return _imageView03;
}
-(UILabel *)evaluaDescLabel
{
if (!_evaluaDescLabel) {
_evaluaDescLabel = [[UILabel alloc] init];
_evaluaDescLabel.backgroundColor = [UIColor whiteColor];
_evaluaDescLabel.font = [UIFont systemFontOfSize:11];
_evaluaDescLabel.numberOfLines = 1;
_evaluaDescLabel.lineBreakMode = NSLineBreakByTruncatingTail;
NSMutableAttributedString * text01 = [[NSMutableAttributedString alloc] initWithString:@"匿名评价" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSForegroundColorAttributeName:UIColorHex(#333333)}];
NSMutableAttributedString * text02 = [[NSMutableAttributedString alloc] initWithString:@" 您写的评价会以匿名的形式展现" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:11],NSForegroundColorAttributeName:UIColorHex(#999999)}];
[text01 appendAttributedString:text02];
_evaluaDescLabel.attributedText = text01;
}
return _evaluaDescLabel;
}
-(UIView *)selectView
{
if (!_selectView) {
_selectView = [[UIView alloc] init];
_selectView.backgroundColor = [UIColor whiteColor];
_selectView.layer.cornerRadius = 7;
_selectView.layer.masksToBounds = YES;
_selectView.layer.borderColor = UIColorHex(#979797).CGColor;
_selectView.layer.borderWidth = 0.5;
}
return _selectView;
}
-(UIView *)selectCenterView
{
if (!_selectCenterView) {
_selectCenterView = [[UIView alloc] init];
_selectCenterView.backgroundColor = UIColorHex(#CD0302);
_selectCenterView.layer.masksToBounds = YES;
_selectCenterView.layer.cornerRadius = 5;
_selectCenterView.hidden = YES;
}
return _selectCenterView;
}
-(UIButton *)selectBtn
{
if (!_selectBtn) {
_selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_selectBtn.backgroundColor = [UIColor clearColor];
[_selectBtn addTarget:self action:@selector(selectMothodAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _selectBtn;
}
- (MBProgressHUD *)progressHud {
if (!_progressHud) {
_progressHud= [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
_progressHud.mode = MBProgressHUDModeDeterminate;
_progressHud.animationType = MBProgressHUDAnimationZoomIn;
_progressHud.bezelView.backgroundColor = [UIColor blackColor];
}
return _progressHud;
}
@end