12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //
- // FKProActivityNoticeCell.m
- // FirstLink
- //
- // Created by ascii on 2016/11/11.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProActivityForeshowCell.h"
- #import "FKProDetailViewModel.h"
- #import "FLStringHelper.h"
- @implementation FKProActivityForeshowCell
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self addAllSubviews];
- }
- return self;
- }
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath {
- if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
- FKProDetailViewModel *detailModel = (FKProDetailViewModel*)viewModel;
-
- [self.leftIconView sd_setImageWithURL:[NSURL URLWithString:detailModel.dataItem.promotionItem.iconURL]];
- self.titleLabel.text = [self timeStartTipString:detailModel.dataItem.promotionItem.beginTime];
-
- self.countDownView.descLabel.text = @"距开启时间:";
-
- NSTimeInterval serverTime = [FLStringHelper timeIntervalFromString:detailModel.dataItem.serverTime];
- NSTimeInterval beginTime = [FLStringHelper timeIntervalFromString:detailModel.dataItem.promotionItem.beginTime];
- [self.countDownView startWithTimeInterval:(beginTime - serverTime)];
- }
- }
- - (NSString *)timeStartTipString:(NSString *)timeString {
- NSDate *date = [FLStringHelper convertToDateFromString:timeString];
-
- NSCalendarUnit unit = kCFCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute;
- NSDateComponents *componets = [[NSCalendar currentCalendar] components:unit fromDate:date];
- return [NSString stringWithFormat:@"%02ld月%02ld日%02ld:%02ld开启", componets.month, componets.day, componets.hour, componets.minute];
- }
- #pragma mark - Layout
- - (void)addAllSubviews {
- [self.contentView addSubview:self.leftIconView];
- [self.leftIconView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.equalTo(self.contentView);
- make.width.mas_equalTo(60);
- }];
-
- [self.contentView addSubview:self.countDownView];
- [self.countDownView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.top.bottom.equalTo(self.contentView);
- make.width.mas_equalTo([FKProActivityBaseCell countDownViewWidth]);
- }];
-
- [self.contentView addSubview:self.titleLabel];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.leftIconView.mas_right).offset(4);
- make.right.equalTo(self.countDownView.mas_left).offset(-12);
- make.centerY.equalTo(self.contentView);
- }];
- }
- #pragma mark - Property
- @end
|