123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- //
- // FKSubmitOrderBottomView.m
- // FirstLink
- //
- // Created by jack on 16/1/19.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKSubmitOrderBottomView.h"
- @implementation FKSubmitOrderBottomView
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
-
- self.backgroundColor = [UIColor whiteColor];
- _enabled = YES;
-
- [self addAllSubviews];
- }
- return self;
- }
- - (void)addAllSubviews{
-
- UIView *topLine = [[UIView alloc]init];
- topLine.backgroundColor = UIColorFromRGB(0xeeeeee);
- [self addSubview:self.priceLabel];
- [self addSubview:self.confirmBtn];
- [self addSubview:topLine];
-
- [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.right.equalTo(self);
- make.height.mas_equalTo(1.0/[UIScreen mainScreen].scale);
- }];
-
- [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.right.bottom.equalTo(self);
- make.width.equalTo(@135);
- }];
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self).offset(15);
- make.right.equalTo(self.confirmBtn.mas_left).offset(- 5);
- make.centerY.equalTo(self);
- }];
-
- }
- - (void)refreshPriceWithAmount:(long)amount totalFee:(CGFloat)totalFee{
- NSString *feeString = [NSString stringWithFormat:@"¥%.2f", totalFee];
- NSString *headStr = [NSString stringWithFormat:@"共%ld件, 合计:", amount];
- NSString *string = [NSString stringWithFormat:@"%@%@", headStr, feeString];
-
- NSMutableAttributedString *attM = [[NSMutableAttributedString alloc]initWithString:string];
- [attM addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xf85a5a) range:NSMakeRange(headStr.length, feeString.length)];
- [attM addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:NSMakeRange(headStr.length, feeString.length)];
-
- self.priceLabel.attributedText = attM;
- }
- - (void)refreshPriceWithAmount:(long)amount totalFee:(CGFloat)totalFee discountFee:(CGFloat)discountFee {
- NSString *feeString = [NSString stringWithFormat:@"¥%.2f", totalFee];
- NSString *headStr = [NSString stringWithFormat:@"共%ld件, 合计:", amount];
- NSString *string = [NSString stringWithFormat:@"%@%@", headStr, feeString];
-
- NSMutableAttributedString *attM = [[NSMutableAttributedString alloc] initWithString:string];
- [attM addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xf85a5a) range:NSMakeRange(headStr.length, feeString.length)];
- [attM addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:NSMakeRange(headStr.length, feeString.length)];
-
- if (discountFee >= 0.001) {
- NSString *discountString = [NSString stringWithFormat:@"\n(已优惠¥%.2f)", discountFee];
- NSMutableAttributedString *discountM = [[NSMutableAttributedString alloc] initWithString:discountString];
- [discountM addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x999999) range:NSMakeRange(0, discountString.length)];
- [discountM addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(0, discountString.length)];
-
- [attM appendAttributedString:discountM];
- NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
- [style setLineSpacing:2];
- [attM addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, attM.length)];
- }
-
- self.priceLabel.attributedText = attM;
- }
- - (void)setEnabled:(BOOL)enabled{
- if (enabled){
- [self.confirmBtn setBackgroundColor:UIColorFromRGB(0xff6362)];
- self.confirmBtn.userInteractionEnabled = YES;
- }else{
- [self.confirmBtn setBackgroundColor:UIColorFromRGB(0xcccccc)];
- self.confirmBtn.userInteractionEnabled = NO;
- }
- }
- #pragma mark - property
- - (UILabel *)priceLabel
- {
- if (_priceLabel == nil) {
- _priceLabel = [[UILabel alloc]init];
- _priceLabel.textColor = UIColorFromRGB(0x333333);
- _priceLabel.font = [UIFont systemFontOfSize:14];
- _priceLabel.numberOfLines = 0;
- }
- return _priceLabel;
- }
- - (UIButton *)confirmBtn
- {
- if (_confirmBtn == nil) {
- _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _confirmBtn.titleLabel.font = [UIFont systemFontOfSize:16];
- [_confirmBtn setTitle:@"提 交" forState:UIControlStateNormal];
- [_confirmBtn setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateNormal];
- [_confirmBtn setBackgroundColor:UIColorFromRGB(0xff6362)];
- }
- return _confirmBtn;
- }
- @end
|