Geen omschrijving

FKPriceWarnListCell.m 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // FKPriceWarnListCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/5/27.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKPriceWarnListCell.h"
  9. @implementation FKPriceWarnListCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  11. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  12. [self addAllSubviews];
  13. self.contentView.backgroundColor = [UIColor whiteColor];
  14. self.selectionStyle = UITableViewCellSelectionStyleNone;
  15. }
  16. return self;
  17. }
  18. - (void)addAllSubviews{
  19. [self.contentView addSubview:self.proImgView];
  20. [self.contentView addSubview:self.titleLabel];
  21. [self.contentView addSubview:self.currentPriceLabel];
  22. [self.contentView addSubview:self.originPriceLabel];
  23. [self.contentView addSubview:self.cutLine];
  24. [self.contentView addSubview:self.bookPirceLabel];
  25. [self.contentView addSubview:self.bookPirceBtn];
  26. [self.proImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.left.equalTo(self.contentView).offset(5);
  28. make.centerY.equalTo(self.contentView);
  29. make.width.height.mas_equalTo([self get_imageMargin]);
  30. }];
  31. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.equalTo(self.proImgView.mas_right).offset(10);
  33. make.top.equalTo(self.contentView).offset(20);
  34. make.right.equalTo(self.contentView).offset(- 15);
  35. }];
  36. [self.currentPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.equalTo(self.titleLabel);
  38. make.bottom.equalTo(self.contentView).offset(- 21);
  39. }];
  40. [self.originPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.equalTo(self.currentPriceLabel.mas_right).offset(2);
  42. make.baseline.equalTo(self.currentPriceLabel.mas_baseline);
  43. make.right.mas_lessThanOrEqualTo(self.bookPirceBtn.mas_left);
  44. }];
  45. [self.cutLine mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.center.equalTo(self.originPriceLabel);
  47. make.width.mas_equalTo(self.originPriceLabel);
  48. make.height.mas_equalTo(0.5);
  49. }];
  50. [self.bookPirceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.right.equalTo(self.contentView).offset(- 15);
  52. make.centerY.equalTo(self.currentPriceLabel);
  53. make.width.equalTo(self.bookPirceLabel).offset(10);
  54. make.height.mas_equalTo(23);
  55. }];
  56. [self.bookPirceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.center.equalTo(self.bookPirceBtn);
  58. }];
  59. }
  60. - (CGFloat)get_imageMargin{
  61. return 95.0f;
  62. }
  63. - (void)configWithRemindItem:(FKRemindProductItem *)remindItem{
  64. if (remindItem){
  65. [self.proImgView setImageWithURL:remindItem.picUrl cdnWidth:[self get_imageMargin]];
  66. self.titleLabel.text = remindItem.title;
  67. self.currentPriceLabel.text = [FLStringHelper convertFenToRMBmoneyString:remindItem.price];
  68. self.originPriceLabel.text = nil;
  69. if ([FLStringHelper isValidString:remindItem.originPrice]){
  70. self.originPriceLabel.text = [FLStringHelper convertFenToRMBmoneyString:remindItem.originPrice];
  71. }
  72. self.bookPirceLabel.text = [NSString stringWithFormat:@"订阅价%@", [FLStringHelper convertFenToRMBmoneyString:remindItem.expectPrice]];
  73. }
  74. }
  75. #pragma mark - property
  76. - (UIImageView *)proImgView{
  77. if (_proImgView == nil) {
  78. _proImgView = [[UIImageView alloc]init];
  79. _proImgView.contentMode = UIViewContentModeScaleAspectFit;
  80. }
  81. return _proImgView;
  82. }
  83. - (UILabel *)titleLabel{
  84. if (_titleLabel == nil) {
  85. _titleLabel = [[UILabel alloc]init];
  86. _titleLabel.font = [UIFont systemFontOfSize:14];
  87. _titleLabel.textColor = UIColorFromRGB(0x333333);
  88. _titleLabel.numberOfLines = 2;
  89. }
  90. return _titleLabel;
  91. }
  92. - (UILabel *)currentPriceLabel{
  93. if (_currentPriceLabel == nil) {
  94. _currentPriceLabel = [[UILabel alloc]init];
  95. _currentPriceLabel.textColor = UIColorFromRGB(0x333333);
  96. _currentPriceLabel.font = [UIFont boldSystemFontOfSize:15];
  97. }
  98. return _currentPriceLabel;
  99. }
  100. - (UILabel *)originPriceLabel{
  101. if (_originPriceLabel == nil) {
  102. _originPriceLabel = [[UILabel alloc]init];
  103. _originPriceLabel.font = [UIFont boldSystemFontOfSize:9];
  104. _originPriceLabel.textColor = UIColorFromRGB(0x666666);
  105. _originPriceLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  106. }
  107. return _originPriceLabel;
  108. }
  109. - (UIButton *)bookPirceBtn{
  110. if (_bookPirceBtn == nil) {
  111. _bookPirceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  112. _bookPirceBtn.layer.cornerRadius = 3;
  113. _bookPirceBtn.layer.borderColor = UIColorFromRGB(0xcccccc).CGColor;
  114. _bookPirceBtn.layer.borderWidth = 0.5f;
  115. }
  116. return _bookPirceBtn;
  117. }
  118. - (UILabel *)bookPirceLabel{
  119. if (_bookPirceLabel == nil) {
  120. _bookPirceLabel = [[UILabel alloc]init];
  121. _bookPirceLabel.font = [UIFont systemFontOfSize:11];
  122. _bookPirceLabel.textColor = UIColorFromRGB(0x666666);
  123. _bookPirceLabel.backgroundColor = [UIColor whiteColor];
  124. [_bookPirceLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  125. }
  126. return _bookPirceLabel;
  127. }
  128. - (UIView *)cutLine{
  129. if (_cutLine == nil) {
  130. _cutLine = [[UIView alloc]init];
  131. _cutLine.backgroundColor = UIColorFromRGB(0x666666);
  132. }
  133. return _cutLine;
  134. }
  135. @end