CNBPersonalInfoCell.m
16.1 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
//
// CNBPersonalInfoCell.m
// CNLiveBPersonalVerificationModule
//
// Created by 殷巧娟 on 2020/4/14.
//
#import "CNBPersonalInfoCell.h"
#import "CNLivePerAuthGetImage.h"
#import "CNBPerCertificationSuccessModel.h"
#import "CNBImageZoom.h"
#import <Masonry/Masonry.h>
#import <CNLiveCommonCategory/UIColor+CNLiveExtension.h>
#import <CNLiveBaseKit/CNLiveBaseKit.h>
#import <QMUIKit/QMUIKit.h>
#import <SDWebImage/SDWebImage.h>
#import <MJExtension/MJExtension.h>
#pragma mark - 身份证cell
@interface CNBPersonalInfoCell ()
@property (nonatomic, strong) UILabel *nameLabel; //名字名称
@property (nonatomic, strong) UILabel *cardLabel; //身份证号
@property (nonatomic, strong) UIImageView *photoImageV; //图片
@property (nonatomic, strong) UIImageView *authImageV; //认证图片
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, assign) CGSize imageSize;
@end
@implementation CNBPersonalInfoCell
- (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.nameLabel];
[self.contentView addSubview:self.cardLabel];
[self.contentView addSubview:self.photoImageV];
[self.contentView addSubview:self.authImageV];
[self addMasony];
}
- (void)addMasony {
__weak typeof(self) weakSelf = self;
[_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(11.5);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-150);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(20);
make.height.mas_equalTo(15);
}];
[_cardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(11.5);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-150);
make.top.mas_equalTo(weakSelf.nameLabel.mas_bottom).offset(12);
make.height.mas_equalTo(10);
}];
[_photoImageV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(11.5);
make.top.mas_equalTo(weakSelf.cardLabel.mas_bottom).offset(10);
make.size.mas_equalTo(CGSizeMake(101, 151));
}];
[_authImageV mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(weakSelf.contentView.mas_right).mas_offset(-28);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(26);
make.size.mas_equalTo(CGSizeMake(81, 81));
}];
}
#pragma mark - GetterAndSetter
- (void)setInfoModel:(CNBUserInfoModel *)infoModel {
_infoModel = infoModel;
self.nameLabel.text = [self replaceWithOriginalStr:infoModel.realName startLocation:0 length:infoModel.realName.length - 1];
self.cardLabel.text = [self replaceCardWithOriginalStr:infoModel.idCardNo];
__weak typeof(self) weakSelf = self;
UIImage *placeholder = [UIImage qmui_imageWithColor:[UIColor qmui_colorWithHexString:@"#F9F9F9"] size:CGSizeMake(101, 151) cornerRadius:0];
[_photoImageV sd_setImageWithURL:[NSURL URLWithString:infoModel.icon] placeholderImage:placeholder completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
weakSelf.photoImageV.image = image;
}];
}
#pragma mark - 颜色转成image
- (UIImage *)creatImageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 101.f, 151.f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,[color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
#pragma mark -姓名替换字符串
- (NSString *)replaceWithOriginalStr:(NSString *)originalStr startLocation:(NSInteger)startLocation length:(NSInteger)length {
NSString *newStr = originalStr;
for (int i = 0 ; i < length; i ++ ) {
NSRange range = NSMakeRange(startLocation, 1);
newStr = [newStr stringByReplacingCharactersInRange:range withString:@"*"];
startLocation ++;
}
return newStr;
}
#pragma mark - 身份证替换
- (NSString *)replaceCardWithOriginalStr:(NSString *)originalStr {
NSString *xingStr = @"";
for (int i = 0; i< originalStr.length - 10; i++) {
xingStr = [xingStr stringByAppendingString:@"*"];
}
originalStr = [NSString stringWithFormat:@"%@ %@ %@",
[originalStr substringToIndex:6],xingStr,
[originalStr substringFromIndex:originalStr.length-4]];
return originalStr;
}
#pragma mark -身份证点击放大预览
- (void)tapAction:(UITapGestureRecognizer *)tap {
UIImageView *clickedImageView = (UIImageView *)tap.view;
if (clickedImageView.image && [clickedImageView.image isKindOfClass:[UIImage class]]) {
[CNBImageZoom imageZoomWithImageView:clickedImageView];
}
}
#pragma mark -lazy
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc]init];
_nameLabel.textColor = CNLiveColorWithHexString(@"1A1A1A");
_nameLabel.font = [UIFont systemFontOfSize:16];
_nameLabel.textAlignment = NSTextAlignmentLeft;
_nameLabel.numberOfLines = 0;
_nameLabel.text = @"**哈";
}
return _nameLabel;
}
- (UILabel *)cardLabel {
if (!_cardLabel) {
_cardLabel = [[UILabel alloc]init];
_cardLabel.textColor = CNLiveColorWithHexString(@"9C9C9C");
_cardLabel.font = [UIFont systemFontOfSize:12];
_cardLabel.numberOfLines = 1;
_cardLabel.textAlignment = NSTextAlignmentLeft;
_cardLabel.text = @"1****0";
}
return _cardLabel;
}
- (UIImageView *)photoImageV {
if (!_photoImageV) {
_photoImageV = [[UIImageView alloc]init];
_photoImageV.contentMode = UIViewContentModeScaleAspectFit;
_photoImageV.userInteractionEnabled = YES;
_photoImageV.layer.cornerRadius = 5;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
[_photoImageV addGestureRecognizer:tap];
}
return _photoImageV;
}
- (UIImageView *)authImageV {
if (!_authImageV) {
_authImageV = [[UIImageView alloc]init];
_authImageV.image =[CNLivePerAuthGetImage cnLivePerAuth_getImageName:@"authSuccess" bundle:@"CNLiveBPersonalVerificationModule.bundle/CNLiveBPersonalVerificationModule" targetClass:[self class]];
_authImageV.contentMode = UIViewContentModeScaleAspectFit;
}
return _authImageV;
}
@end
#pragma mark - 机构cell
@interface CNBInstitutionsInfoCell ()
@property (nonatomic, strong) UILabel *institutionsLabel; //圈子
@property (nonatomic, strong) UILabel *institutionsDescLabel;
@end
@implementation CNBInstitutionsInfoCell
- (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.institutionsLabel];
[self.contentView addSubview:self.institutionsDescLabel];
__weak typeof(self) weakSelf = self;
[_institutionsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(12);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(14);
make.height.mas_equalTo(12);
make.width.mas_equalTo(118);
}];
[_institutionsDescLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.institutionsLabel.mas_right).offset(8);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-15);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(14);
make.height.mas_equalTo(12);
}];
}
- (void)setInstitutionModel:(CNBInstitutionModel *)institutionModel {
_institutionModel = institutionModel;
_institutionsDescLabel.text = institutionModel.mainName;
}
#pragma mark -Lazy
- (UILabel *)institutionsLabel {
if (!_institutionsLabel) {
_institutionsLabel = [[UILabel alloc]init];
_institutionsLabel.textColor = CNLiveColorWithHexString(@"333333");
_institutionsLabel.font = [UIFont systemFontOfSize:12.5];
_institutionsLabel.numberOfLines = 1;
_institutionsLabel.text = @"所属机构 (主账号) :";
_institutionsLabel.textAlignment = NSTextAlignmentLeft;
}
return _institutionsLabel;
}
- (UILabel *)institutionsDescLabel {
if (!_institutionsDescLabel) {
_institutionsDescLabel = [[UILabel alloc]init];
_institutionsDescLabel.textColor = CNLiveColorWithHexString(@"B9B9B9");
_institutionsDescLabel.font = [UIFont systemFontOfSize:12.5];
_institutionsDescLabel.numberOfLines = 1;
_institutionsDescLabel.textAlignment = NSTextAlignmentLeft;
_institutionsDescLabel.text = @"北京中投视讯文化传媒股份有限公司";
}
return _institutionsDescLabel;
}
@end
#pragma mark -群组cell
@interface CNBGroupInfoCell ()
@property (nonatomic, strong) UILabel *circleLabel; //圈子
@property (nonatomic, strong) UILabel *circleDescLabel;
@property (nonatomic, strong) UILabel *groupLabel; //群组
@property (nonatomic, strong) UIView *groupDesView;
@property (nonatomic, strong) UIView *middleline; //中间的line
@end
@implementation CNBGroupInfoCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self configUI];
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
return self;
}
#pragma mark - 配置UI
- (void)configUI {
[self.contentView addSubview:self.circleLabel];
[self.contentView addSubview:self.circleDescLabel];
[self.contentView addSubview:self.middleline];
[self.contentView addSubview:self.groupLabel];
[self.contentView addSubview:self.groupDesView];
__weak typeof(self) weakSelf = self;
[_circleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(12);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(14);
make.height.mas_equalTo(12);
make.width.mas_equalTo(118);
}];
[_circleDescLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.circleLabel.mas_right).offset(8);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-15);
make.top.mas_equalTo(weakSelf.contentView.mas_top).offset(14);
make.height.mas_equalTo(12);
}];
[_middleline mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.circleLabel.mas_bottom).offset(14);
make.left.right.mas_equalTo(weakSelf.contentView);
make.height.mas_equalTo(0.5);
}];
[_groupLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo (weakSelf.middleline.mas_bottom).offset(14);
make.left.mas_equalTo(weakSelf.contentView.mas_left).offset(12);
make.width.mas_equalTo(118);
make.height.mas_equalTo(12);
}];
[_groupDesView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf.groupLabel.mas_right);
make.right.mas_equalTo(weakSelf.contentView.mas_right).offset(-15);
make.top.mas_equalTo (weakSelf.middleline.mas_bottom).offset(8.5);
make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom).offset(-10);
}];
}
- (void)setCircleModel:(CNBCirccleModel *)circleModel {
_circleModel = circleModel;
_circleDescLabel.text = CNLiveStringIsEmpty(circleModel.quanziName)? @"" :circleModel.quanziName;
NSMutableArray *groupArray = [NSMutableArray array];
if (circleModel.groupItem && circleModel.groupItem.count > 0) {
[self setTagView:circleModel.groupItem];
}else {
NSArray *noneArray = @[@{@"groupId":@"",@"groupName":@"无"},
];
for (NSDictionary *dic in noneArray) {
CNBGroupModel *model = [CNBGroupModel mj_objectWithKeyValues:dic];
[groupArray addObject:model];
}
// array = groupArray.copy;
[self setTagView:groupArray.copy];
}
// [self setTagView:circleModel.groupItem];
}
#pragma mark -展示标签列表
- (void)setTagView:(NSArray *)array {
CGFloat tagsTotalWidth = 8;
CGFloat tagsTotalHeigh = 0;
CGFloat tagHeight = 0;
[self.groupDesView qmui_removeAllSubviews];
// if (array && array.count > 0) {
for (CNBGroupModel *groupModel in array) {
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(tagsTotalWidth, tagsTotalHeigh, 0, 0)];
label.font = [UIFont systemFontOfSize:12];
label.textAlignment = NSTextAlignmentCenter;
if ([groupModel.groupName isEqualToString:@"无"]) {
label.textColor = CNLiveColorWithHexString(@"B9B9B9");
}else {
label.layer.cornerRadius = 5;
label.layer.borderWidth = 1;
label.layer.borderColor = CNLiveColorWithHexString(@"48A7F9").CGColor;
label.textColor = CNLiveColorWithHexString(@"48A7F9");
}
label.text = groupModel.groupName;
[label sizeToFit];
label.frame = CGRectMake(tagsTotalWidth, tagsTotalHeigh, CGRectGetWidth(label.frame) + 7.5, CGRectGetHeight(label.frame)+7.5);
tagsTotalWidth += CGRectGetWidth(label.frame)+8;
tagHeight = CGRectGetHeight(label.frame);
if (tagsTotalWidth > KScreenWidth - 170) {
tagsTotalHeigh += CGRectGetHeight(label.frame) + 7.5;
tagsTotalWidth = 8;
label.frame = CGRectMake(tagsTotalWidth, tagsTotalHeigh, CGRectGetWidth(label.frame) + 7.5, CGRectGetHeight(label.frame));
tagsTotalWidth += CGRectGetWidth(label.frame)+7.5;
}
[self.groupDesView addSubview:label];
}
tagsTotalHeigh += tagHeight;
[_groupDesView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(tagsTotalHeigh);
}];
}
#pragma mark -Lazy
- (UILabel *)circleLabel {
if (!_circleLabel) {
_circleLabel = [[UILabel alloc]init];
_circleLabel.textColor = CNLiveColorWithHexString(@"333333");
_circleLabel.font = [UIFont systemFontOfSize:12.5];
_circleLabel.numberOfLines = 1;
_circleLabel.text = @"您的圈子 (子账号) :";
_circleLabel.textAlignment = NSTextAlignmentLeft;
}
return _circleLabel;
}
- (UILabel *)circleDescLabel {
if (!_circleDescLabel) {
_circleDescLabel = [[UILabel alloc]init];
_circleDescLabel.textColor = CNLiveColorWithHexString(@"B9B9B9");
_circleDescLabel.font = [UIFont systemFontOfSize:12.5];
_circleDescLabel.numberOfLines = 1;
_circleDescLabel.textAlignment = NSTextAlignmentLeft;
_circleDescLabel.text = @"无";
}
return _circleDescLabel;
}
- (UIView *)middleline {
if (!_middleline) {
_middleline = [[UIView alloc]init];
_middleline.backgroundColor = CNLiveColorWithHexString(@"EDEDED");
}
return _middleline;
}
- (UILabel *)groupLabel {
if (!_groupLabel) {
_groupLabel = [[UILabel alloc]init];
_groupLabel.textColor = CNLiveColorWithHexString(@"333333");
_groupLabel.font = [UIFont systemFontOfSize:13];
_groupLabel.text = @"圈子群组 (子群组) :";
_groupLabel.numberOfLines = 1;
}
return _groupLabel;
}
- (UIView *)groupDesView {
if (!_groupDesView) {
_groupDesView = [[UIView alloc]init];
_groupDesView.backgroundColor = [UIColor whiteColor];
}
return _groupDesView;
}
@end