|
|
@@ -64,12 +64,17 @@
|
|
|
NSDate *fromeDate = [NSDate fb_dateWithTimeIntervalString:[NSString stringWithFormat:@"%f", self.startTimeInterval]];
|
|
|
NSDate *toDate = [NSDate fb_dateWithTimeIntervalString:model.position.groupEndTime];
|
|
|
NSDateComponents *dateComponents = [NSDate fb_dateComponentsFromDate:fromeDate toDate:toDate];
|
|
|
- NSMutableAttributedString *clockString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"距离结束还有:%02ld天%02ld小时%02ld分%02ld秒", (long)dateComponents.day, (long)dateComponents.hour, (long)dateComponents.minute, (long)dateComponents.second]];
|
|
|
- [clockString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0] range:NSMakeRange(7, 2)];
|
|
|
- [clockString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0] range:NSMakeRange(10, 2)];
|
|
|
- [clockString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0] range:NSMakeRange(14, 2)];
|
|
|
- [clockString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0] range:NSMakeRange(17, 2)];
|
|
|
- self.clockLabel.attributedText = clockString;
|
|
|
+ if (dateComponents.second < 0) {
|
|
|
+ //倒计时秒数出现负数表示活动已结束
|
|
|
+ self.clockLabel.attributedText = [[NSAttributedString alloc] initWithString:@"该活动已结束"];
|
|
|
+ } else {
|
|
|
+ NSMutableAttributedString *clockString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"距离结束还有:%02ld天%02ld小时%02ld分%02ld秒", (long)dateComponents.day, (long)dateComponents.hour, (long)dateComponents.minute, (long)dateComponents.second]];
|
|
|
+ [clockString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0] range:NSMakeRange(7, 2)];
|
|
|
+ [clockString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0] range:NSMakeRange(10, 2)];
|
|
|
+ [clockString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0] range:NSMakeRange(14, 2)];
|
|
|
+ [clockString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0] range:NSMakeRange(17, 2)];
|
|
|
+ self.clockLabel.attributedText = clockString;
|
|
|
+ }
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
@@ -101,11 +106,11 @@
|
|
|
make.centerX.equalTo(self.contentView);
|
|
|
}];
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(self.portraitGroupView.mas_bottom).with.offset(20);
|
|
|
+ make.bottom.equalTo(self.clockLabel.mas_top).with.offset(-12);
|
|
|
make.centerX.equalTo(self.contentView);
|
|
|
}];
|
|
|
[self.clockLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(self.titleLabel.mas_bottom).with.offset(12);
|
|
|
+ make.bottom.equalTo(self.lineH.mas_top).with.offset(-28);
|
|
|
make.centerX.equalTo(self.contentView);
|
|
|
}];
|
|
|
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
@@ -127,11 +132,9 @@
|
|
|
#pragma mark - event response
|
|
|
|
|
|
- (void)okButtonClicked:(UIButton *)sender {
|
|
|
- [self dismissViewControllerAnimated:YES completion:^{
|
|
|
- if ([self.delegate respondsToSelector:@selector(joinPanelDidJoining:)]) {
|
|
|
- [self.delegate joinPanelDidJoining:self];
|
|
|
- }
|
|
|
- }];
|
|
|
+ if ([self.delegate respondsToSelector:@selector(joinPanelDidJoining:)]) {
|
|
|
+ [self.delegate joinPanelDidJoining:self];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)cancelButtonClicked:(UIButton *)sender {
|
|
|
@@ -144,6 +147,45 @@
|
|
|
|
|
|
#pragma mark - getters and setters
|
|
|
|
|
|
+- (void)setGroup:(NSArray *)group {
|
|
|
+ _group = [group copy];
|
|
|
+
|
|
|
+ if ([self.contentView.subviews indexOfObject:self.portraitGroupView] != NSNotFound) {
|
|
|
+ [self.portraitGroupView removeFromSuperview];
|
|
|
+ }
|
|
|
+ id imageURLStringArray = [group valueForKeyPath:@"hpResumeAPI.headImg"];
|
|
|
+ if ([imageURLStringArray isKindOfClass:[NSArray class]]) {
|
|
|
+ self.portraitGroupView = [[HJPortraitGroupView alloc] initWithImages:imageURLStringArray spacing:-20];
|
|
|
+ } else {
|
|
|
+ self.portraitGroupView = [[HJPortraitGroupView alloc] initWithImages:@[]];
|
|
|
+ }
|
|
|
+ [self.contentView addSubview:self.portraitGroupView];
|
|
|
+ [self.portraitGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.contentView).with.offset(30);
|
|
|
+ make.centerX.equalTo(self.contentView);
|
|
|
+ }];
|
|
|
+
|
|
|
+ //满足三个人就可以成团,计算还差几个人成团
|
|
|
+ id name = [group valueForKeyPath:@"hpResumeAPI.realName"];
|
|
|
+ NSUInteger count = 0;
|
|
|
+ if ([group isKindOfClass:[NSArray class]] && [group count] < 3) {
|
|
|
+ count = 3 - [group count];
|
|
|
+ }
|
|
|
+ NSString *leaderName = @"";
|
|
|
+ if ([name isKindOfClass:[NSArray class]]) {
|
|
|
+ leaderName = [name firstObject];
|
|
|
+ }
|
|
|
+ NSMutableAttributedString *leaderAttributedString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ 的拼工", leaderName]];
|
|
|
+ if (count > 0) {
|
|
|
+ NSMutableAttributedString *numStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" 还差 %@ 位伙伴", @(count)]];
|
|
|
+ NSDictionary *numAttributes = @{NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0],
|
|
|
+ NSFontAttributeName: [UIFont boldSystemFontOfSize:11]};
|
|
|
+ [numStr addAttributes:numAttributes range:NSMakeRange(4, 1)];
|
|
|
+ [leaderAttributedString appendAttributedString:numStr];
|
|
|
+ }
|
|
|
+ self.titleLabel.attributedText = leaderAttributedString;
|
|
|
+}
|
|
|
+
|
|
|
- (UIView *)contentView {
|
|
|
if (_contentView == nil) {
|
|
|
_contentView = [[UIView alloc] init];
|
|
|
@@ -172,12 +214,7 @@
|
|
|
|
|
|
- (HJPortraitGroupView *)portraitGroupView {
|
|
|
if (_portraitGroupView == nil) {
|
|
|
- id imageURLStringArray = [self.group valueForKeyPath:@"hpResumeAPI.headImg"];
|
|
|
- if ([imageURLStringArray isKindOfClass:[NSArray class]]) {
|
|
|
- _portraitGroupView = [[HJPortraitGroupView alloc] initWithImages:imageURLStringArray spacing:-20];
|
|
|
- } else {
|
|
|
- _portraitGroupView = [[HJPortraitGroupView alloc] initWithImages:@[]];
|
|
|
- }
|
|
|
+ _portraitGroupView = [[HJPortraitGroupView alloc] initWithImages:@[]];
|
|
|
}
|
|
|
return _portraitGroupView;
|
|
|
}
|
|
|
@@ -187,25 +224,6 @@
|
|
|
_titleLabel = [[UILabel alloc] init];
|
|
|
_titleLabel.font = [UIFont systemFontOfSize:16];
|
|
|
_titleLabel.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
|
|
|
- //满足三个人就可以成团,计算还差几个人成团
|
|
|
- id name = [self.group valueForKeyPath:@"hpResumeAPI.realName"];
|
|
|
- NSUInteger count = 0;
|
|
|
- if ([self.group isKindOfClass:[NSArray class]] && [self.group count] < 3) {
|
|
|
- count = 3 - [self.group count];
|
|
|
- }
|
|
|
- NSString *leaderName = @"";
|
|
|
- if ([name isKindOfClass:[NSArray class]]) {
|
|
|
- leaderName = [name firstObject];
|
|
|
- }
|
|
|
- NSMutableAttributedString *leaderAttributedString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ 的拼工", leaderName]];
|
|
|
- if (count > 0) {
|
|
|
- NSMutableAttributedString *numStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" 还差 %@ 位伙伴", @(count)]];
|
|
|
- NSDictionary *numAttributes = @{NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0],
|
|
|
- NSFontAttributeName: [UIFont boldSystemFontOfSize:11]};
|
|
|
- [numStr addAttributes:numAttributes range:NSMakeRange(4, 1)];
|
|
|
- [leaderAttributedString appendAttributedString:numStr];
|
|
|
- }
|
|
|
- _titleLabel.attributedText = leaderAttributedString;
|
|
|
}
|
|
|
return _titleLabel;
|
|
|
}
|