CNBPersonalVerificationCell.m
27.6 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
//
// CNBPersonalVerificationCell.m
// CNLiveBPersonalVerificationModule
//
// Created by 殷巧娟 on 2020/4/6.
//
#import "CNBPersonalVerificationCell.h"
#import <Masonry/Masonry.h>
#import "CNLivePerAuthGetImage.h"
#import "UIColor+CNLiveExtension.h"
#import "CNLiveBaseKit.h"
#import <QMUIKit/QMUIKit.h>
#import "CNBIdentifierModel.h"
#import "CNBPerAuthShowView.h"
#import "CNBPerAuthTypeRadioView.h"
#import "CNBPerAuthManager.h"
#define CNBAppKeyWindow ([UIApplication sharedApplication].delegate).window
@interface CNBPersonalVerificationCell ()<UITextFieldDelegate>
@property (nonatomic, strong) UIImageView *logoImageV; //是不是必须的标识
@property (nonatomic, strong) UILabel *titleLabel; //标题
@property (nonatomic, strong) CNBPerAuthShowView *institutionsView; //所属机构
@property (nonatomic, strong) NSMutableArray *selectArray;
@end
#pragma mark - 所属机构
@implementation CNBPersonalVerificationCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self configUI];
}
return self;
}
#pragma mark - 配置UI
- (void)configUI {
[self.contentView addSubview:self.logoImageV];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.institutionsView];
[self addMasony];
}
#pragma mark - 添加约束
- (void)addMasony {
__weak typeof(self) weakSelf = self;
[_logoImageV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(10);
make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
make.size.mas_equalTo(CGSizeMake(7, 8));
}];
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.logoImageV.mas_right).offset(4.5);
make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
make.size.mas_equalTo(CGSizeMake(100, 12));
}];
[_institutionsView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.titleLabel.mas_right).offset(8);
make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-16);
make.height.mas_equalTo(28);
}];
}
#pragma mark - Action
- (void)handleGesture:(UITapGestureRecognizer *)tap {
__weak typeof(self) weakSelf = self;
CNBPerAuthTypeRadioView *typeView = [[CNBPerAuthTypeRadioView alloc]initWithSelectType:CNBPerAuthRadioTypeInstitutions spId:@"" type:@"" homepageId:@"" typeModel:self.typeModel];
typeView.selectedCellBlock = ^(CNBTypeModel * _Nonnull typeModel, CNBPerAuthSelectTypeModel * _Nonnull selectModel) {
if (weakSelf.sectionModel.addSection == typeModel.addSection) {
weakSelf.sectionModel.institutionId = selectModel.typeId;
weakSelf.sectionModel.institutionName = selectModel.name;
for (CNBTypeModel * circleModel in weakSelf.sectionModel.typeArray) {
circleModel.circleName = @"";
circleModel.homePageId = @"";
circleModel.groupName = @"";
circleModel.groupArray = @[]; //如果点击切换了机构,就将圈子和群组的数据都清空
}
if ([CNBPerAuthManager shareManager].circleDic && [[[CNBPerAuthManager shareManager].circleDic allKeys]containsObject:[NSString stringWithFormat:@"%ld",typeModel.addSection]]) {
[[CNBPerAuthManager shareManager].circleDic removeObjectForKey:[NSString stringWithFormat:@"%ld",typeModel.addSection]]; //删除存储的圈子信息
}
}
if (weakSelf.typeModel.addSection == typeModel.addSection) { //机构显示
if (weakSelf.typeModel.addRow == typeModel.addRow) {
weakSelf.typeModel.institutionsName = selectModel.name;
weakSelf.typeModel.spId = selectModel.typeId;
if (weakSelf.refreshDataBlock) {
weakSelf.refreshDataBlock();
}
}
}
};
[typeView show];
}
- (void)setSectionModel:(CNBAddSectionModel *)sectionModel {
_sectionModel = sectionModel;
}
- (void)setTypeModel:(CNBTypeModel *)typeModel {
_typeModel = typeModel;
if (CNLiveStringIsEmpty(typeModel.institutionsName)) {
self.institutionsView.showLabel.text = @"请选择您所属的机构";
self.institutionsView.showLabel.textColor = CNLiveColorWithHexString(@"B9B9B9");
}else {
self.institutionsView.showLabel.text = typeModel.institutionsName;
self.institutionsView.showLabel.textColor = CNLiveColorWithHexString(@"333333");
}
}
#pragma mark -lazy
- (UIImageView *)logoImageV {
if (!_logoImageV) {
_logoImageV = [[UIImageView alloc]init];
_logoImageV.image = [CNLivePerAuthGetImage cnLivePerAuth_getImageName:@"bitian" bundle:@"CNLiveBPersonalVerificationModule.bundle/CNLiveBPersonalVerificationModule" targetClass:[self class]];
_logoImageV.contentMode = UIViewContentModeScaleAspectFit;
}
return _logoImageV;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc]init];
_titleLabel.textColor = CNLiveColorWithHexString(@"333333");
_titleLabel.font = [UIFont systemFontOfSize:12];
_titleLabel.textAlignment = NSTextAlignmentLeft;
_titleLabel.numberOfLines = 1;
_titleLabel.text = @"所属机构 (主账号)";
}
return _titleLabel;
}
- (CNBPerAuthShowView *)institutionsView {
if (!_institutionsView) {
_institutionsView = [[CNBPerAuthShowView alloc]init];
_institutionsView.showLabel.text = @"请选择您所属的机构";
_institutionsView.layer.borderWidth = 0.5;
_institutionsView.layer.borderColor = CNLiveColorWithHexString(@"C1C1C1").CGColor;
_institutionsView.layer.cornerRadius = 5;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleGesture:)];
[_institutionsView addGestureRecognizer:tap];
}
return _institutionsView;
}
- (NSMutableArray *)selectArray {
if (!_selectArray) {
_selectArray = [NSMutableArray array];
}
return _selectArray;
}
@end
#pragma mark - 圈子和圈子群组
static const NSInteger CNBCircleTag = 201;
static const NSInteger CNBGroupTag = 202;
@interface CNBCircleGroupCell ()
@property (nonatomic, strong) UILabel *circleLabel; //圈子
@property (nonatomic, strong) CNBPerAuthShowView *circleView;//圈子TF
@property (nonatomic, strong) UILabel *groupLabel; //群组
@property (nonatomic, strong) CNBPerAuthShowView *groupView; //群组TF
@property (nonatomic, strong) UIButton *deleteBtn; //删除
@end
@implementation CNBCircleGroupCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self configUI];
}
return self;
}
#pragma mark - 配置UI
- (void)configUI {
[self.contentView addSubview:self.circleLabel];
[self.contentView addSubview:self.circleView];
[self.contentView addSubview:self.groupLabel];
[self.contentView addSubview:self.groupView];
[self addMasony];
}
- (void)addMasony {
__weak typeof(self) weakSelf = self;
[_circleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset (21.5);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(20);
make.size.mas_equalTo(CGSizeMake(100, 12));
}];
[_circleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.circleLabel.mas_right).offset(8);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-16);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(12);
make.height.mas_equalTo(28);
}];
[_groupLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset (21.5);
make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom).offset(-20);
make.size.mas_equalTo(CGSizeMake(100, 12));
}];
[_groupView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.groupLabel.mas_right).offset(8);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-16);
make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom).offset(-12);
make.height.mas_equalTo(28);
}];
}
#pragma mark - 显示删除按钮
- (void)showDeleteBtn {
__weak typeof(self) weakSelf = self;
[self.contentView addSubview:self.deleteBtn];
self.deleteBtn.hidden = NO;
[_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-15);
make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
make.size.mas_equalTo(CGSizeMake(20, 20));
}];
[_circleView mas_updateConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-43);
}];
[_groupView mas_updateConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-43);
}];
}
#pragma mark - getterAndSetter
- (void)setTypeModel:(CNBTypeModel *)typeModel{
_typeModel = typeModel;
if ([typeModel.showType isEqualToString:@"1"]) {
if ([typeModel.isDelete isEqualToString:@"1"]) {
[self showDeleteBtn];
}else {
[self.deleteBtn removeFromSuperview];
self.deleteBtn.hidden = YES;
}
}
if (CNLiveStringIsEmpty(typeModel.homePageId)) {
self.circleView.showLabel.text = @"无";
self.circleView.showLabel.textColor = CNLiveColorWithHexString(@"B9B9B9");
}else {
self.circleView.showLabel.text = typeModel.circleName;
self.circleView.showLabel.textColor = CNLiveColorWithHexString(@"333333");
}
if (CNLiveStringIsEmpty(typeModel.groupName) || [typeModel.groupName isEqualToString:@"无"]) {
self.groupView.showLabel.text = @"无";
self.groupView.showLabel.textColor = CNLiveColorWithHexString(@"B9B9B9");
}else {
self.groupView.showLabel.text = typeModel.groupName;
self.groupView.showLabel.textColor = CNLiveColorWithHexString(@"333333");
}
}
#pragma mark - Action
- (void)deleteBtnAction {
if (self.circleDeleteBlock) {
self.circleDeleteBlock();
}
}
- (void)handleGesture:(UITapGestureRecognizer *)tap {
__weak typeof(self) weakSelf = self;
if (tap.view.tag == CNBCircleTag) {
if (CNLiveStringIsEmpty(self.spIdStr)) {
[QMUITips showWithText:@"请先选择所属机构" inView:CNBAppKeyWindow hideAfterDelay:1.5];
return;
}
CNBPerAuthTypeRadioView *circleView = [[CNBPerAuthTypeRadioView alloc]initWithSelectType:CNBPerAuthRadioTypeCircle spId:self.spIdStr type:@"" homepageId:@"" typeModel:self.typeModel];
circleView.selectedCellBlock = ^(CNBTypeModel * _Nonnull typeModel, CNBPerAuthSelectTypeModel * _Nonnull selectModel) {
if (weakSelf.typeModel.addSection == typeModel.addSection) {
if (weakSelf.typeModel.addRow == typeModel.addRow) {
weakSelf.typeModel.circleName = selectModel.name;
weakSelf.typeModel.homePageId = selectModel.typeId;
weakSelf.typeModel.type = selectModel.type;
weakSelf.typeModel.groupName = @"";
weakSelf.typeModel.groupArray = @[]; //切换圈子删掉群组信息
if (weakSelf.refreshDataBlock) {
weakSelf.refreshDataBlock();
}
}
}
};
[circleView show];
}else if (tap.view.tag == CNBGroupTag) { //这里是多选 要弹出多选框
if (CNLiveStringIsEmpty(self.spIdStr)) {
[QMUITips showWithText:@"请先选择所属机构" inView:CNBAppKeyWindow hideAfterDelay:1.5];
return;
}
if (CNLiveStringIsEmpty(self.typeModel.homePageId)) {
[QMUITips showWithText:@"请先选择您的圈子" inView:CNBAppKeyWindow hideAfterDelay:1.5];
return;
}
CNBPerAuthTypeRadioView *groupView = [[CNBPerAuthTypeRadioView alloc]initWithSelectType:CNBperAuthRadioTypeMultiGroup spId:@"" type:@"" homepageId:self.typeModel.homePageId typeModel:self.typeModel];
__block NSMutableArray *nameArray = [NSMutableArray array];
groupView.multiSelectBlock = ^(CNBTypeModel * _Nonnull typeMoedl, NSArray * _Nonnull groupArray) {
for (CNBPerAuthSelectTypeModel *groupModel in groupArray) {
[nameArray addObject:groupModel.name];
}
if (weakSelf.typeModel.addSection == typeMoedl.addSection) {
if (weakSelf.typeModel.addRow == typeMoedl.addRow) {
weakSelf.typeModel.groupName = [nameArray componentsJoinedByString:@","];
weakSelf.typeModel.groupArray = groupArray;
if (weakSelf.refreshDataBlock) {
weakSelf.refreshDataBlock();
}
}
}
};
[groupView show];
}
}
#pragma mark - lazy
- (UILabel *)circleLabel {
if (!_circleLabel) {
_circleLabel = [[UILabel alloc]init];
_circleLabel.textColor = CNLiveColorWithHexString(@"333333");
_circleLabel.font = [UIFont systemFontOfSize:12];
_circleLabel.textAlignment = NSTextAlignmentLeft;
_circleLabel.numberOfLines = 1;
_circleLabel.text = @"您的圈子 (子账号)";
}
return _circleLabel;
}
- (CNBPerAuthShowView *)circleView {
if (!_circleView) {
_circleView = [[CNBPerAuthShowView alloc]init];
_circleView.showLabel.text = @"请选择您的圈子";
_circleView.layer.borderWidth = 0.5;
_circleView.layer.borderColor = CNLiveColorWithHexString(@"C1C1C1").CGColor;
_circleView.layer.cornerRadius = 5;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleGesture:)];
_circleView.tag = CNBCircleTag;
[_circleView addGestureRecognizer:tap];
}
return _circleView;
}
- (UILabel *)groupLabel {
if (!_groupLabel) {
_groupLabel = [[UILabel alloc]init];
_groupLabel.textColor = CNLiveColorWithHexString(@"333333");
_groupLabel.font = [UIFont systemFontOfSize:12];
_groupLabel.textAlignment = NSTextAlignmentLeft;
_groupLabel.numberOfLines = 1;
_groupLabel.text = @"圈子群组 (子群组)";
}
return _groupLabel;
}
- (CNBPerAuthShowView *)groupView {
if (!_groupView) {
_groupView= [[CNBPerAuthShowView alloc]init];
_groupView.showLabel.text = @"请选择圈子群组";
_groupView .layer.borderWidth = 0.5;
_groupView .layer.borderColor = CNLiveColorWithHexString(@"C1C1C1").CGColor;
_groupView .layer.cornerRadius = 5;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleGesture:)];
_groupView.tag = CNBGroupTag;
[_groupView addGestureRecognizer:tap];
}
return _groupView;
}
- (UIButton *)deleteBtn {
if (!_deleteBtn) {
_deleteBtn = [[UIButton alloc]init];
[_deleteBtn setImage:[CNLivePerAuthGetImage cnLivePerAuth_getImageName:@"delete-icon" bundle:@"CNLiveBPersonalVerificationModule.bundle/CNLiveBPersonalVerificationModule" targetClass:[self class]] forState:UIControlStateNormal];
[_deleteBtn addTarget:self action:@selector(deleteBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _deleteBtn;
}
@end
#pragma mark - 添加圈子
@interface CNBCircleAddGroupCell ()
@property (nonatomic, strong) UILabel *descLabel;
@property (nonatomic, strong) QMUIButton *addBtn; //添加圈子
@end
@implementation CNBCircleAddGroupCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self configUI];
}
return self;
}
- (void)configUI {
[self.contentView addSubview:self.addBtn];
[self.contentView addSubview:self.descLabel];
__weak typeof(self) weakSelf = self;
[_addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-15);
make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
make.size.mas_equalTo(CGSizeMake(90, 28));
}];
[_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.addBtn.mas_left).offset(-11);
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(20);
make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
make.height.mas_equalTo(12);
}];
}
#pragma mark -Action
- (void)addBtnAction {
if (self.addCircleGroupBlock) {
self.addCircleGroupBlock();
}
}
#pragma mark -lazy
- (UILabel *)descLabel {
if (!_descLabel) {
_descLabel = [[UILabel alloc]init];
_descLabel.textColor = CNLiveColorWithHexString(@"999999");
_descLabel.font = [UIFont systemFontOfSize:11];
_descLabel.numberOfLines = 1;
_descLabel.textAlignment = NSTextAlignmentRight;
_descLabel.text = @"如您有多个圈子,可点击添加";
}
return _descLabel;
}
- (QMUIButton *)addBtn {
if (!_addBtn) {
_addBtn = [[QMUIButton alloc]init];
[_addBtn setImage:[CNLivePerAuthGetImage cnLivePerAuth_getImageName:@"add" bundle:@"CNLiveBPersonalVerificationModule.bundle/CNLiveBPersonalVerificationModule" targetClass:[self class]] forState:UIControlStateNormal];
[_addBtn setTitle:@"添加圈子" forState:UIControlStateNormal];
_addBtn.titleLabel.textColor = CNLiveColorWithHexString(@"48A7F9");
_addBtn.titleLabel.font = [UIFont systemFontOfSize:14];
_addBtn.imagePosition = QMUIButtonImagePositionLeft;
_addBtn.spacingBetweenImageAndTitle = 5;
_addBtn.layer.borderColor = CNLiveColorWithHexString(@"48A7F9").CGColor;
_addBtn.layer.borderWidth = 1;
_addBtn.layer.cornerRadius = 5;
[_addBtn addTarget:self action:@selector(addBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _addBtn;
}
@end
#pragma mark - 相关账号和相关群组
static const NSInteger CNBAccountTag = 203;
static const NSInteger CNBRelateGroupTag = 204;
@interface CNBAccountGroupCell ()
@property (nonatomic, strong) UILabel *accountLabel; //圈子
@property (nonatomic, strong) CNBPerAuthShowView *accountView;//圈子TF
@property (nonatomic, strong) UILabel *relateGroupLabel; //群组
@property (nonatomic, strong) CNBPerAuthShowView *relateGroupView; //群组TF
@property (nonatomic, strong) UIButton *deleteBtn; //删除
@end
@implementation CNBAccountGroupCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self configUI];
}
return self;
}
#pragma mark - 配置UI
- (void)configUI {
[self.contentView addSubview:self.accountLabel];
[self.contentView addSubview:self.accountView];
[self.contentView addSubview:self.relateGroupLabel];
[self.contentView addSubview:self.relateGroupView];
[self addMasony];
}
- (void)addMasony {
__weak typeof(self) weakSelf = self;
[_accountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset (21.5);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(20);
make.size.mas_equalTo(CGSizeMake(100, 12));
}];
[_accountView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.accountLabel.mas_right).offset(8);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-16);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(12);
make.height.mas_equalTo(28);
}];
[_relateGroupLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset (21.5);
make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom).offset(-20);
make.size.mas_equalTo(CGSizeMake(100, 12));
}];
[_relateGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.relateGroupLabel.mas_right).offset(8);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-16);
make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom).offset(-12);
make.height.mas_equalTo(28);
}];
}
#pragma mark - 显示删除按钮
- (void)showDeleteBtn {
__weak typeof(self) weakSelf = self;
[self.contentView addSubview:self.deleteBtn];
self.deleteBtn.hidden = NO;
[_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-15);
make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
make.size.mas_equalTo(CGSizeMake(20, 20));
}];
[_accountView mas_updateConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-43);
}];
[_relateGroupView mas_updateConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-43);
}];
}
#pragma mark - getterAndSetter
- (void)setAccountTypeModel:(CNBTypeModel *)accountTypeModel {
_accountTypeModel = accountTypeModel;
if ([accountTypeModel.showType isEqualToString:@"3"]) {
if ([accountTypeModel.isDelete isEqualToString:@"1"]) {
[self showDeleteBtn];
}else{
[self.deleteBtn removeFromSuperview];
[self.deleteBtn setHidden:YES];
}
}
}
#pragma mark - Action
- (void)deleteBtnAction {
if (self.accountDeleteBlock) {
self.accountDeleteBlock();
}
}
#pragma mark -lazy
- (UILabel *)accountLabel {
if (!_accountLabel) {
_accountLabel = [[UILabel alloc]init];
_accountLabel.textColor = CNLiveColorWithHexString(@"333333");
_accountLabel.font = [UIFont systemFontOfSize:12];
_accountLabel.textAlignment = NSTextAlignmentLeft;
_accountLabel.numberOfLines = 1;
_accountLabel.text = @"相关账号 (子账号)";
}
return _accountLabel;
}
- (CNBPerAuthShowView *)accountView {
if (!_accountView) {
_accountView = [[CNBPerAuthShowView alloc]init];
_accountView.showLabel.text = @"请选择机构子账号";
_accountView.layer.borderWidth = 0.5;
_accountView.layer.borderColor = CNLiveColorWithHexString(@"C1C1C1").CGColor;
_accountView.layer.cornerRadius = 5;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleGesture:)];
tap.view.tag = CNBAccountTag;
[_accountView addGestureRecognizer:tap];
}
return _accountView;
}
- (UILabel *)relateGroupLabel {
if (!_relateGroupLabel) {
_relateGroupLabel = [[UILabel alloc]init];
_relateGroupLabel.textColor = CNLiveColorWithHexString(@"333333");
_relateGroupLabel.font = [UIFont systemFontOfSize:12];
_relateGroupLabel.textAlignment = NSTextAlignmentLeft;
_relateGroupLabel.numberOfLines = 1;
_relateGroupLabel.text = @"相关群组 (子群组)";
}
return _relateGroupLabel;
}
- (CNBPerAuthShowView *)relateGroupView{
if (!_relateGroupView) {
_relateGroupView = [[CNBPerAuthShowView alloc]init];
_relateGroupView.showLabel.text = @"请选择圈子账号群组";
_relateGroupView.layer.borderWidth = 0.5;
_relateGroupView.layer.borderColor = CNLiveColorWithHexString(@"C1C1C1").CGColor;
_relateGroupView.layer.cornerRadius = 5;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleGesture:)];
tap.view.tag = CNBRelateGroupTag;
[_relateGroupView addGestureRecognizer:tap];
}
return _relateGroupView;
}
- (UIButton *)deleteBtn {
if (!_deleteBtn) {
_deleteBtn = [[UIButton alloc]init];
[_deleteBtn setImage:[CNLivePerAuthGetImage cnLivePerAuth_getImageName:@"delete-icon" bundle:@"CNLiveBPersonalVerificationModule.bundle/CNLiveBPersonalVerificationModule" targetClass:[self class]] forState:UIControlStateNormal];
[_deleteBtn addTarget:self action:@selector(deleteBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _deleteBtn;
}
@end
#pragma mark - 添加子账号
@interface CNBAddAccountGroupCell ()
@property (nonatomic, strong) UILabel *descLabel;
@property (nonatomic, strong) QMUIButton *addBtn; //添加子账号
@end
@implementation CNBAddAccountGroupCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self configUI];
}
return self;
}
- (void)configUI {
[self.contentView addSubview:self.addBtn];
[self.contentView addSubview:self.descLabel];
__weak typeof(self) weakSelf = self;
[_addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-15);
make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
make.size.mas_equalTo(CGSizeMake(103, 28));
}];
[_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.addBtn.mas_left).offset(-11);
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(20);
make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
make.height.mas_equalTo(12);
}];
}
#pragma mark -Action
- (void)addBtnAction {
if (self.addAccountGroupBlock) {
self.addAccountGroupBlock();
}
}
#pragma mark -lazy
- (UILabel *)descLabel {
if (!_descLabel) {
_descLabel = [[UILabel alloc]init];
_descLabel.textColor = CNLiveColorWithHexString(@"999999");
_descLabel.font = [UIFont systemFontOfSize:11];
_descLabel.numberOfLines = 1;
_descLabel.textAlignment = NSTextAlignmentRight;
_descLabel.text = @"如您有多个子账号,可点击添加";
}
return _descLabel;
}
- (QMUIButton *)addBtn {
if (!_addBtn) {
_addBtn = [[QMUIButton alloc]init];
[_addBtn setImage:[CNLivePerAuthGetImage cnLivePerAuth_getImageName:@"add" bundle:@"CNLiveBPersonalVerificationModule.bundle/CNLiveBPersonalVerificationModule" targetClass:[self class]] forState:UIControlStateNormal];
[_addBtn setTitle:@"添加子账号" forState:UIControlStateNormal];
_addBtn.titleLabel.textColor = CNLiveColorWithHexString(@"48A7F9");
_addBtn.titleLabel.font = [UIFont systemFontOfSize:14];
_addBtn.imagePosition = QMUIButtonImagePositionLeft;
_addBtn.spacingBetweenImageAndTitle = 5;
_addBtn.layer.borderColor = CNLiveColorWithHexString(@"48A7F9").CGColor;
_addBtn.layer.borderWidth = 1;
_addBtn.layer.cornerRadius = 5;
[_addBtn addTarget:self action:@selector(addBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _addBtn;
}
@end