CNLiveCommuntyResultListViewController.m
9.54 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
//
// CNLiveCommuntyResultListViewController.m
// CNLiveCommunitModule
//
// Created by open on 2022/2/16.
//
#import "CNLiveCommuntyResultListViewController.h"
@interface CNLiveCommuntyResultListViewController ()<DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
@property (nonatomic, strong) CNLiveCommuntyActivityResultDetailModel * detailModel;
@property (nonatomic, copy) NSString * signId;
@property (nonatomic, copy) NSString * orderId;
@property (nonatomic, copy) NSString * handworkId;
@end
@implementation CNLiveCommuntyResultListViewController
- (instancetype)initWithStyle:(UITableViewStyle)style SignId:(NSString *)signId OrderId:(NSString *)orderId handworkId:(nonnull NSString *)handworkId
{
self = [super initWithStyle:style];
if (self) {
_handworkId = handworkId;
_orderId = orderId;
_signId = signId;
}
return self;
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSMutableArray * tempArray = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers];
for (UIViewController * vc in self.navigationController.viewControllers) {
if ([vc isKindOfClass:CNLiveCommuntyResultViewController.class]) {
[tempArray removeObject:vc];
break;
}
if ([vc isKindOfClass:NSClassFromString(@"CNLiveCommuntSignUpViewController")]) {
[tempArray removeObject:vc];
break;
}
}
self.navigationController.viewControllers = tempArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
self.title = @"报名成功";
__weak typeof(self) weakSelf = self;
[CNLiveCommuntViewModel requestWithCommuntyActivityResultDetailMentOrderId:self.orderId SignId:self.signId handworkId:self.handworkId CompleterBlock:^(CNLiveCommuntyActivityResultDetailModel * _Nonnull detailModel) {
weakSelf.detailModel = detailModel;
[weakSelf setupWithBottemView];
[weakSelf.tableView reloadData];
}];
}
-(void)setupWithBottemView
{
if ([self.detailModel.unitPrice isNotBlank] && [self.detailModel.unitPrice floatValue] > 0) {
__weak typeof(self) weakSelf = self;
UIView * bottemView = [[UIView alloc] init];
bottemView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:bottemView];
[bottemView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(weakSelf.view);
make.height.mas_equalTo(50+kVerticalBottomSafeHeight);
}];
NSMutableAttributedString * str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"合计: %.2f元",(self.detailModel.signupVoList.count * [self.detailModel.unitPrice floatValue])]];
[str addAttribute:NSForegroundColorAttributeName value:UIColorHex(#222833) range:[str.string rangeOfString:@"合计: "]];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:[str.string rangeOfString:@"合计: "]];
[str addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:[str.string rangeOfString:@"合计: "]];
[str addAttribute:NSForegroundColorAttributeName value:UIColorHex(#DF0D23) range:[str.string rangeOfString:@"¥"]];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:9] range:[str.string rangeOfString:@"¥"]];
UILabel * priceLabel = [[UILabel alloc] init];
priceLabel.textColor = UIColorHex(#DF0D23);
priceLabel.font = [UIFont boldSystemFontOfSize:16];
priceLabel.attributedText = str;
[bottemView addSubview:priceLabel];
[priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(bottemView.mas_top).offset(7);
make.right.mas_equalTo(bottemView.mas_right).offset(-10);
}];
}
}
- (void)initTableView
{
[super initTableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.emptyDataSetSource = self;
self.tableView.emptyDataSetDelegate = self;
self.tableView.tableFooterView = [[UIView alloc] init];
self.tableView.backgroundColor = UIColorHex(#f9f9f9);
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.frame = CGRectMake(0, kNavigationBarHeight, kScreenWidth, kScreenHeight - kNavigationBarHeight);
self.tableView.contentInset = UIEdgeInsetsMake(kNavigationBarHeight + 10, 0, 60 + kVerticalBottomSafeHeight, 0);
}
-(void)layoutTableView
{
[super layoutTableView];
}
#pragma mark - DZNEmptyDataSetSource Methods
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
return [[NSAttributedString alloc] initWithString:@"暂无报名人员信息" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]}];
}
-(UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
return [CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_content_empty"];
}
- (UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView
{
return [UIColor whiteColor];
}
- (BOOL)emptyDataSetShouldDisplay:(UIScrollView *)scrollView
{
return YES;
}
- (BOOL)emptyDataSetShouldAllowTouch:(UIScrollView *)scrollView
{
return YES;
}
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView
{
return NO;
}
#pragma mark =
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.detailModel.dataArray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.detailModel.dataArray[section] count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary * dic = self.detailModel.dataArray[indexPath.section][indexPath.row];
return [CNLiveCommuntSignUpOrderViewCell setTableView:tableView Dict:dic];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 30;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 50;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 50)];
view.backgroundColor = [UIColor clearColor];
UIView * radiusView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, kScreenWidth - 20, 40)];
radiusView.backgroundColor = [UIColor whiteColor];
radiusView.layer.shadowColor = [UIColor blackColor].CGColor;
radiusView.layer.shadowOffset = CGSizeMake(0, 0);
radiusView.layer.shadowOpacity = 0.3;
radiusView.layer.shadowRadius = 8;
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_WIDTH - 20, 40) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.path = maskPath.CGPath;
radiusView.layer.mask = maskLayer;
[view insertSubview:radiusView belowSubview:view];
UILabel * nameLabel = [[UILabel alloc] init];
nameLabel.textColor = UIColorHex(#333333);
nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
nameLabel.numberOfLines = 1;
nameLabel.font = [UIFont systemFontOfSize:15];
nameLabel.font = [UIFont boldSystemFontOfSize:15];
nameLabel.text = (self.detailModel.dataArray.count - 1 == section) ? @"活动信息" : [NSString stringWithFormat:@"参与人%ld",section+1];
[view addSubview:nameLabel];
[nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(view);
make.left.mas_equalTo(view.mas_left).offset(20);
}];
if (self.detailModel.dataArray.count-1 != section && [self.detailModel.unitPrice isNotBlank] && [self.detailModel.unitPrice integerValue] > 0) {
UILabel * priceLabel = [[UILabel alloc] init];
priceLabel.textColor = UIColorHex(#DF0D23);
priceLabel.font = [UIFont boldSystemFontOfSize:16];
priceLabel.text = [NSString stringWithFormat:@"%@元",self.detailModel.unitPrice];
[view addSubview:priceLabel];
[priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(view);
make.right.mas_equalTo(view.mas_right).offset(-20);
}];
}
return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 10;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
view.backgroundColor = [UIColor clearColor];
UIView * radiusView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, kScreenWidth - 20, 10)];
radiusView.backgroundColor = [UIColor whiteColor];
radiusView.layer.shadowColor = [UIColor blackColor].CGColor;
radiusView.layer.shadowOffset = CGSizeMake(0, 0);
radiusView.layer.shadowOpacity = 0.3;
radiusView.layer.shadowRadius = 10;
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_WIDTH - 20, 10) byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(5, 5)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.path = maskPath.CGPath;
radiusView.layer.mask = maskLayer;
[view insertSubview:radiusView belowSubview:view];
return view;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
@end