No Description

FKSubmitOrderBottomView.m 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // FKSubmitOrderBottomView.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/1/19.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKSubmitOrderBottomView.h"
  9. @implementation FKSubmitOrderBottomView
  10. - (instancetype)initWithFrame:(CGRect)frame{
  11. if (self = [super initWithFrame:frame]) {
  12. self.backgroundColor = [UIColor whiteColor];
  13. _enabled = YES;
  14. [self addAllSubviews];
  15. }
  16. return self;
  17. }
  18. - (void)addAllSubviews{
  19. UIView *topLine = [[UIView alloc]init];
  20. topLine.backgroundColor = UIColorFromRGB(0xeeeeee);
  21. [self addSubview:self.priceLabel];
  22. [self addSubview:self.confirmBtn];
  23. [self addSubview:topLine];
  24. [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.left.top.right.equalTo(self);
  26. make.height.mas_equalTo(1.0/[UIScreen mainScreen].scale);
  27. }];
  28. [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.top.right.bottom.equalTo(self);
  30. make.width.equalTo(@135);
  31. }];
  32. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.equalTo(self).offset(15);
  34. make.right.equalTo(self.confirmBtn.mas_left).offset(- 5);
  35. make.centerY.equalTo(self);
  36. }];
  37. }
  38. - (void)refreshPriceWithAmount:(long)amount totalFee:(CGFloat)totalFee{
  39. NSString *feeString = [NSString stringWithFormat:@"¥%.2f", totalFee];
  40. NSString *headStr = [NSString stringWithFormat:@"共%ld件, 合计:", amount];
  41. NSString *string = [NSString stringWithFormat:@"%@%@", headStr, feeString];
  42. NSMutableAttributedString *attM = [[NSMutableAttributedString alloc]initWithString:string];
  43. [attM addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xf85a5a) range:NSMakeRange(headStr.length, feeString.length)];
  44. [attM addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:NSMakeRange(headStr.length, feeString.length)];
  45. self.priceLabel.attributedText = attM;
  46. }
  47. - (void)refreshPriceWithAmount:(long)amount totalFee:(CGFloat)totalFee discountFee:(CGFloat)discountFee {
  48. NSString *feeString = [NSString stringWithFormat:@"¥%.2f", totalFee];
  49. NSString *headStr = [NSString stringWithFormat:@"共%ld件, 合计:", amount];
  50. NSString *string = [NSString stringWithFormat:@"%@%@", headStr, feeString];
  51. NSMutableAttributedString *attM = [[NSMutableAttributedString alloc] initWithString:string];
  52. [attM addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xf85a5a) range:NSMakeRange(headStr.length, feeString.length)];
  53. [attM addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:NSMakeRange(headStr.length, feeString.length)];
  54. if (discountFee >= 0.001) {
  55. NSString *discountString = [NSString stringWithFormat:@"\n(已优惠¥%.2f)", discountFee];
  56. NSMutableAttributedString *discountM = [[NSMutableAttributedString alloc] initWithString:discountString];
  57. [discountM addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x999999) range:NSMakeRange(0, discountString.length)];
  58. [discountM addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(0, discountString.length)];
  59. [attM appendAttributedString:discountM];
  60. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
  61. [style setLineSpacing:2];
  62. [attM addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, attM.length)];
  63. }
  64. self.priceLabel.attributedText = attM;
  65. }
  66. - (void)setEnabled:(BOOL)enabled{
  67. if (enabled){
  68. [self.confirmBtn setBackgroundColor:UIColorFromRGB(0xff6362)];
  69. self.confirmBtn.userInteractionEnabled = YES;
  70. }else{
  71. [self.confirmBtn setBackgroundColor:UIColorFromRGB(0xcccccc)];
  72. self.confirmBtn.userInteractionEnabled = NO;
  73. }
  74. }
  75. #pragma mark - property
  76. - (UILabel *)priceLabel
  77. {
  78. if (_priceLabel == nil) {
  79. _priceLabel = [[UILabel alloc]init];
  80. _priceLabel.textColor = UIColorFromRGB(0x333333);
  81. _priceLabel.font = [UIFont systemFontOfSize:14];
  82. _priceLabel.numberOfLines = 0;
  83. }
  84. return _priceLabel;
  85. }
  86. - (UIButton *)confirmBtn
  87. {
  88. if (_confirmBtn == nil) {
  89. _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  90. _confirmBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  91. [_confirmBtn setTitle:@"提 交" forState:UIControlStateNormal];
  92. [_confirmBtn setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateNormal];
  93. [_confirmBtn setBackgroundColor:UIColorFromRGB(0xff6362)];
  94. }
  95. return _confirmBtn;
  96. }
  97. @end