Nessuna descrizione

FKProBCChannelFeeCell.m 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // FKProBCChannelFeeCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 2017/8/21.
  6. // Copyright © 2017年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProBCChannelFeeCell.h"
  9. #import "FKProDetailViewModel.h"
  10. @interface FKProBCChannelFeeCell ()
  11. @property (nonatomic, strong) UIView *topLine;
  12. @property (nonatomic, strong) UILabel *priceTipLabel;
  13. @property (nonatomic, strong) UILabel *priceLabel;
  14. @property (nonatomic, strong) UIImageView *rightArrow;
  15. @end
  16. @implementation FKProBCChannelFeeCell
  17. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  18. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  19. self.selectionStyle = UITableViewCellSelectionStyleNone;
  20. self.contentView.backgroundColor = [UIColor whiteColor];
  21. [self setupViews];
  22. }
  23. return self;
  24. }
  25. + (CGFloat)cellHeight{
  26. return 44.0f;
  27. }
  28. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  29. if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
  30. FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
  31. FKProductInfoItem *productInfoItem = detailModel.dataItem.productInfo;
  32. NSString *productPrice = productInfoItem.price;
  33. if (detailModel.selectBuyItem) {
  34. productPrice = detailModel.selectBuyItem.price;
  35. }
  36. FKProPriceDetailCellType cellType = [detailModel priceDetailCellType];
  37. if (cellType == FKProPriceDetailCellTypeInProgress) {
  38. if (detailModel.selectBuyItem.activityPrice) {
  39. productPrice = detailModel.selectBuyItem.activityPrice;
  40. }
  41. } else {
  42. if ([detailModel.discountItem isVipUserWithDiscount]) {
  43. CGFloat discount = [detailModel.discountItem.discount floatValue];
  44. productPrice = [NSString stringWithFormat:@"%.2lf", [productPrice floatValue] * discount/100.0];
  45. }
  46. }
  47. CGFloat totalPrice = productPrice.floatValue + productInfoItem.internationalPostage.floatValue;
  48. CGFloat taxRate = productInfoItem.taxRate.floatValue/100000.0;
  49. self.priceLabel.text = [NSString stringWithFormat:@"%.2f元", (floor(totalPrice * taxRate)/100.0)];
  50. }
  51. }
  52. #pragma mark - Private Method
  53. - (void)setupViews {
  54. [self.contentView addSubview:self.topLine];
  55. [self.topLine mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.left.right.top.equalTo(self.contentView);
  57. make.height.mas_equalTo(1.0/[UIScreen mainScreen].scale);
  58. }];
  59. [self.contentView addSubview:self.priceTipLabel];
  60. [self.priceTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.equalTo(self.contentView).offset(15);
  62. make.centerY.equalTo(self.contentView);
  63. }];
  64. [self.contentView addSubview:self.priceLabel];
  65. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.equalTo(self.priceTipLabel.mas_right).offset(12);
  67. make.centerY.equalTo(self.contentView);
  68. }];
  69. [self.contentView addSubview:self.rightArrow];
  70. [self.rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.right.equalTo(self.contentView).offset(-15);
  72. make.centerY.equalTo(self.contentView);
  73. }];
  74. }
  75. #pragma mark - Property
  76. - (UIView *)topLine{
  77. if (_topLine == nil) {
  78. _topLine = [[UIView alloc]init];
  79. _topLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
  80. }
  81. return _topLine;
  82. }
  83. - (UILabel *)priceTipLabel {
  84. if (_priceTipLabel == nil) {
  85. _priceTipLabel = [[UILabel alloc]init];
  86. _priceTipLabel.textColor = UIColorFromRGB(0x666666);
  87. _priceTipLabel.font = [UIFont systemFontOfSize:14];
  88. _priceTipLabel.text = @"进口税:";
  89. }
  90. return _priceTipLabel;
  91. }
  92. - (UILabel *)priceLabel {
  93. if (_priceLabel == nil) {
  94. _priceLabel = [[UILabel alloc]init];
  95. _priceLabel.textColor = UIColorFromRGB(0xff6362);
  96. _priceLabel.font = [UIFont systemFontOfSize:14];
  97. _priceLabel.text = @"--";
  98. }
  99. return _priceLabel;
  100. }
  101. - (UIImageView *)rightArrow {
  102. if (_rightArrow == nil) {
  103. _rightArrow = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"more_right_arrow"]];
  104. [_rightArrow setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  105. [_rightArrow setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  106. }
  107. return _rightArrow;
  108. }
  109. @end