| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- //
- // HJMyIntegralExchangeGiftDetailHeaderView.m
- // HappyJob
- //
- // Created by 张晓光 on 2019/9/10.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJMyIntegralExchangeGiftDetailHeaderView.h"
- #import "HJMyIntergralExchangeGiftDetailModel.h"
- @implementation HJMyIntegralExchangeGiftDetailHeaderView
- - (instancetype)initWithFrame:(CGRect)frame {
-
- if (self = [super initWithFrame:frame])
- {
- self.backgroundColor = COLOR_GRAYFA5;
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
-
- [self addSubview:self.bgView];
- [self.bgView addSubview:self.titleLabel];
- [self.bgView addSubview:self.IntegralLabel];
- [self.bgView addSubview:self.conditionsLabel];
- [self.bgView addSubview:self.lineView];
- [self.bgView addSubview:self.inventoryLabel];
- [self.bgView addSubview:self.timeLabel];
-
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.mas_top).offset(10);
- make.left.equalTo(self.mas_left).offset(0);
- make.right.equalTo(self.mas_right).offset(0);
- make.bottom.equalTo(self.mas_bottom).offset(0);
- }];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.bgView.mas_left).offset(15);
- make.top.equalTo(self.bgView.mas_top).offset(15);
- }];
- [self.IntegralLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView.mas_left).offset(15);
- make.top.equalTo(self.titleLabel.mas_bottom).offset(5);
- }];
- [self.conditionsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.bgView.mas_right).offset(-15);
- make.centerY.equalTo(self.IntegralLabel);
- }];
- [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView.mas_left).offset(15);
- make.right.equalTo(self.bgView.mas_right).offset(-15);
- make.top.equalTo(self.IntegralLabel.mas_bottom).offset(20);
- make.height.mas_equalTo(1);
- }];
- [self.inventoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView.mas_left).offset(15);
- make.top.equalTo(self.lineView.mas_bottom).offset(15);
- make.bottom.equalTo(self.bgView.mas_bottom).offset(-15);
- }];
- [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.bgView.mas_right).offset(-15);
- make.centerY.equalTo(self.inventoryLabel);
- }];
-
- }
- - (void)configureHJMyIntegralExchangeGiftDetailHeaderViewDict:(NSDictionary *)dict {
-
- HJMyIntergralExchangeGiftDetailModel *model = [HJMyIntergralExchangeGiftDetailModel yy_modelWithDictionary:dict[@"data"]];
-
- self.titleLabel.text = model.mpCompaignsRewardSettingAPI.rewardName;
-
- if (model.mpCompaignsRewardSettingAPI.money)
- {
- self.IntegralLabel.text = [NSString stringWithFormat:@"%@积分 + %@元",model.mpCompaignsRewardSettingAPI.points,model.mpCompaignsRewardSettingAPI.money];
- }
- else
- {
- self.IntegralLabel.text = [NSString stringWithFormat:@"%@积分",model.mpCompaignsRewardSettingAPI.points];
- }
-
- if (model.mpCompaignsRewardSettingAPI.exchangeNumber)
- {
- self.conditionsLabel.text = [NSString stringWithFormat:@"每人限领%@份",model.mpCompaignsRewardSettingAPI.exchangeNumber];
- }
-
- //库存
- if (model.mpCompaignsRewardSettingAPI.rewardNumber)
- {
- self.inventoryLabel.text = [NSString stringWithFormat:@"库存:%ld 已领:%@",[model.mpCompaignsRewardSettingAPI.rewardNumber integerValue] - [model.mpCompaignsRewardSettingAPI.exchangeRewardNum integerValue],model.mpCompaignsRewardSettingAPI.exchangeRewardNum];
- }
- else
- {
- self.inventoryLabel.text = [NSString stringWithFormat:@"库存:不限 已领:%@",model.mpCompaignsRewardSettingAPI.exchangeRewardNum];
- }
-
- //兑换时间
- self.timeLabel.text = [NSString stringWithFormat:@"兑换时间:%@ - %@",[HJAppService time_timestampToString:[NSString stringWithFormat:@"%ld",(long)[HJAppService timeSwitchTimestamp:model.mpCompaignsRewardSettingAPI.exchangeStartDate]] withType:kTimeStampDateOnlyHorizonLine] ,[HJAppService time_timestampToString:[NSString stringWithFormat:@"%ld",(long)[HJAppService timeSwitchTimestamp:model.mpCompaignsRewardSettingAPI.exchangeEndDate]] withType:kTimeStampDateOnlyHorizonLine]];
-
- if ([self.timeLabel.text isEqualToString:@"兑换时间:1900-01-01 - 2100-01-01"])
- {
- self.timeLabel.text = @"兑换时间:不限";
- }
-
-
- }
- #pragma mark - setter and getter
- - (UIView *)bgView {
-
- if (_bgView == nil)
- {
- _bgView = [[UIView alloc]init];
- _bgView.backgroundColor = [UIColor whiteColor];
- }
- return _bgView;
- }
- - (UILabel *)titleLabel {
-
- if (_titleLabel == nil)
- {
- _titleLabel = [[UILabel alloc]init];
- _titleLabel.font = [UIFont boldSystemFontOfSize:18];
- _titleLabel.textColor = COLOR_BACK3;
- }
- return _titleLabel;
- }
- - (UILabel *)IntegralLabel {
-
- if (_IntegralLabel == nil)
- {
- _IntegralLabel = [[UILabel alloc]init];
- _IntegralLabel.font = [UIFont systemFontOfSize:14];
- _IntegralLabel.textColor = [UIColor colorFromHexString:@"FF7D0B"];
- }
- return _IntegralLabel;
- }
- - (UILabel *)conditionsLabel {
-
- if (_conditionsLabel == nil)
- {
- _conditionsLabel = [[UILabel alloc]init];
- _conditionsLabel.font = [UIFont systemFontOfSize:14];
- _conditionsLabel.textColor = COLOR_GRAY9;
- }
- return _conditionsLabel;
- }
- - (UIView *)lineView {
-
- if (_lineView == nil)
- {
- _lineView = [[UIView alloc]init];
- _lineView.backgroundColor = COLOR_BACKE;
- }
- return _lineView;
- }
- - (UILabel *)inventoryLabel {
-
- if (_inventoryLabel == nil)
- {
- _inventoryLabel = [[UILabel alloc]init];
- _inventoryLabel.font = [UIFont systemFontOfSize:12];
- _inventoryLabel.textColor = COLOR_BACK3;
- }
- return _inventoryLabel;
- }
- - (UILabel *)timeLabel {
-
- if (_timeLabel == nil)
- {
- _timeLabel = [[UILabel alloc]init];
- _timeLabel.font = [UIFont systemFontOfSize:12];
- _timeLabel.textColor = COLOR_BACK3;
- }
- return _timeLabel;
-
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|