123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- //
- // CashCouponCell.m
- // FirstLink
- //
- // Created by ascii on 15/6/19.
- // Copyright (c) 2015年 FirstLink. All rights reserved.
- //
- #import "FKCouponTableViewCell.h"
- #import "FLStringHelper.h"
- @interface FKCouponTableViewCell ()
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, strong) UIView *topBanner;
- @property (nonatomic, strong) UIView *leftDotView;
- @property (nonatomic, strong) UIView *rightDotView;
- @property (nonatomic, strong) UIImageView *separateLine;
- @property (nonatomic, strong) UIImageView *bottomSpotLine;
- @property (nonatomic, strong) UILabel *couponNameLabel;
- @property (nonatomic, strong) UILabel *couponDetailLabel;
- @property (nonatomic, strong) UILabel *couponRuleLabel;
- @property (nonatomic, strong) UILabel *couponDateLabel;
- @property (nonatomic, strong) UIImageView *invalidBgView;
- @property (nonatomic, strong) UIImageView *expireImageView;
- @end
- @implementation FKCouponTableViewCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.contentView.backgroundColor = UIColorFromRGB(0xf4f4f4);
- [self addAllSubViews];
- }
- return self;
- }
- #pragma mark -
- - (void)configCellWith:(FKCouponItem *)item serveTime:(NSString *)serveTime{
- if ([item getCouponType] != FKCouponTypeAcitivityCard) {
- self.couponNameLabel.text = [NSString stringWithFormat:@"¥%@", [FLStringHelper convertFenToYuan:item.amount]];
- self.couponDetailLabel.text = item.typeDesc;
- self.couponRuleLabel.text = item.desc;
- self.couponDateLabel.text = item.timeDesc;
- }
- // config style
- if ([item.status isEqualToString:@"1"] && [item.useMark isEqualToString:@"1"]) {
- self.topBanner.backgroundColor = UIColorFromRGB(0xff624a);
- self.couponNameLabel.textColor = UIColorFromRGB(0xff624a);
- self.couponDetailLabel.textColor = UIColorFromRGB(0x333333);
- self.couponRuleLabel.textColor = UIColorFromRGB(0x666666);
- self.couponDateLabel.textColor = UIColorFromRGB(0x666666);
-
- NSDateComponents* dateComonents = [FLStringHelper convertToComponentsFormateFromString:item.expiryDate baseTime:serveTime];
- if (dateComonents && dateComonents.day <= 2) {
- self.expireImageView.hidden = NO;
- } else {
- self.expireImageView.hidden = YES;
- }
- } else {
- self.topBanner.backgroundColor = UIColorFromRGB(0xcccccc);
- self.couponNameLabel.textColor = UIColorFromRGB(0x999999);
- self.couponDetailLabel.textColor = UIColorFromRGB(0x999999);
- self.couponRuleLabel.textColor = UIColorFromRGB(0xcccccc);
- self.couponDateLabel.textColor = UIColorFromRGB(0xcccccc);
-
- self.expireImageView.hidden = YES;
- }
-
-
- }
- - (void)addAllSubViews {
- [self.contentView addSubview:self.bgView];
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(10);
- make.right.bottom.equalTo(self.contentView).with.offset(-10);
- make.top.equalTo(self.contentView);
- }];
-
- [self.bgView addSubview:self.topBanner];
- [self.topBanner mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.right.equalTo(self.bgView);
- make.height.mas_equalTo(6);
- }];
-
- [self.bgView addSubview:self.leftDotView];
- [self.leftDotView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(-5);
- make.top.equalTo(self.bgView).offset(75);
- make.size.mas_equalTo(CGSizeMake(10, 10));
- }];
-
- [self.bgView addSubview:self.rightDotView];
- [self.rightDotView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.leftDotView);
- make.right.equalTo(self.bgView).offset(5);
- make.size.mas_equalTo(CGSizeMake(10, 10));
- }];
-
- [self.bgView addSubview:self.separateLine];
- [self.separateLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.leftDotView.mas_right).offset(12);
- make.right.equalTo(self.rightDotView.mas_left).offset(-12);
- make.centerY.equalTo(self.leftDotView);
- make.height.mas_equalTo(1);
- }];
- [self.bgView addSubview:self.couponNameLabel];
- [self.couponNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(16);
- make.top.equalTo(self.bgView).offset(16);
- }];
-
- [self.bgView addSubview:self.couponDetailLabel];
- [self.couponDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.couponNameLabel);
- make.top.equalTo(self.couponNameLabel.mas_bottom).offset(2);
- }];
- [self.bgView addSubview:self.couponRuleLabel];
- [self.couponRuleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(14);
- make.right.equalTo(self.bgView).offset(-14);
- make.top.equalTo(self.separateLine.mas_bottom).offset(6);
- make.height.mas_equalTo(40);
- }];
-
- [self.bgView addSubview:self.couponDateLabel];
- [self.couponDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.couponRuleLabel);
- make.bottom.equalTo(self.bgView).offset(-20);
- }];
-
- [self.bgView addSubview:self.invalidBgView];
- [self.invalidBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.bgView).offset(-15);
- make.top.equalTo(self.bgView).offset(18);
- make.size.mas_equalTo(CGSizeMake(72, 48));
- }];
-
- [self.bgView addSubview:self.bottomSpotLine];
- [self.bottomSpotLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView);
- make.right.equalTo(self.bgView).offset(-6);
- make.bottom.equalTo(self.bgView);
- make.height.mas_equalTo(3.5);
- }];
-
- [self.bgView addSubview:self.expireImageView];
- [self.expireImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.right.equalTo(self.bgView);
- }];
- }
- #pragma mark -
- - (UIView*)bgView {
- if (!_bgView) {
- _bgView = [[UIView alloc] init];
- _bgView.backgroundColor = [UIColor whiteColor];
- }
- return _bgView;
- }
- - (UIView*)topBanner {
- if (!_topBanner) {
- _topBanner = [[UIView alloc] init];
- }
- return _topBanner;
- }
- - (UIView*)leftDotView {
- if (!_leftDotView) {
- _leftDotView = [[UIView alloc] init];
- _leftDotView.backgroundColor = UIColorFromRGB(0xf4f4f4);
- _leftDotView.layer.cornerRadius = 5;
- }
- return _leftDotView;
- }
- - (UIView*)rightDotView {
- if (!_rightDotView) {
- _rightDotView = [[UIView alloc] init];
- _rightDotView.backgroundColor = UIColorFromRGB(0xf4f4f4);
- _rightDotView.layer.cornerRadius = 5;
- }
- return _rightDotView;
- }
- - (UIImageView *)separateLine{
- if (!_separateLine) {
- UIImage *sizedImg = [[UIImage imageNamed:@"point_line_single"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeTile];
- _separateLine = [[UIImageView alloc]initWithImage:sizedImg];
- }
- return _separateLine;
- }
- - (UIImageView *)bottomSpotLine{
- if (!_bottomSpotLine) {
- UIImage *sizedImg = [[UIImage imageNamed:@"bottom_spot_icon"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeTile];
- _bottomSpotLine = [[UIImageView alloc]initWithImage:sizedImg];
- }
- return _bottomSpotLine;
- }
- - (UILabel *)couponNameLabel {
- if (!_couponNameLabel) {
- _couponNameLabel = [[UILabel alloc] init];
- _couponNameLabel.font = [UIFont boldSystemFontOfSize:22];
- }
- return _couponNameLabel;
- }
- - (UILabel *)couponDetailLabel {
- if (!_couponDetailLabel) {
- _couponDetailLabel = [[UILabel alloc] init];
- _couponDetailLabel.font = [UIFont systemFontOfSize:15];
- }
- return _couponDetailLabel;
- }
- - (UILabel *)couponRuleLabel {
- if (!_couponRuleLabel) {
- _couponRuleLabel = [[UILabel alloc] init];
- _couponRuleLabel.font = [UIFont systemFontOfSize:14];
- _couponRuleLabel.numberOfLines = 0;
- }
- return _couponRuleLabel;
- }
- - (UILabel *)couponDateLabel {
- if (!_couponDateLabel) {
- _couponDateLabel = [[UILabel alloc] init];
- _couponDateLabel.font = [UIFont systemFontOfSize:14];
- _couponDateLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _couponDateLabel;
- }
- - (UIImageView *)invalidBgView {
- if (!_invalidBgView) {
- _invalidBgView = [[UIImageView alloc] init];
- _invalidBgView.image = [UIImage imageNamed:@"CouponInvalidIcon"];
- }
- return _invalidBgView;
- }
- -(UIImageView *)expireImageView {
- if (!_expireImageView) {
- UIImage *expireImage = [UIImage imageNamed:@"will_expire"];
- _expireImageView = [[UIImageView alloc] initWithImage:expireImage];
- _expireImageView.hidden = YES;
- }
- return _expireImageView;
- }
- #pragma mark -
- + (CGFloat)height {
- return (80 + 6 + 42 + 6 + 35 + 6);
- }
- @end
|