暫無描述

FKCirDetailLinkCell.m 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // FKCirDetailLinkCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/6/15.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKCirDetailLinkCell.h"
  9. #import "FKCircleDetailViewModel.h"
  10. #define PRO_IMAGE_MARGIN 53
  11. @interface FKCirDetailLinkCell ()
  12. @property (nonatomic, strong) UIView *proCotainerView;
  13. @property (nonatomic, strong) UIImageView *proImgView;
  14. @property (nonatomic, strong) UIImageView *rightArrow;
  15. @property (nonatomic, strong) UILabel *titleLabel;
  16. @property (nonatomic, strong) UILabel *priceLabel;
  17. @property (nonatomic, strong) UILabel *siteLabel;
  18. @end
  19. @implementation FKCirDetailLinkCell
  20. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  21. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  22. [self addAllSubviews];
  23. self.selectionStyle = UITableViewCellSelectionStyleNone;
  24. self.contentView.backgroundColor = [UIColor whiteColor];
  25. }
  26. return self;
  27. }
  28. - (void)addAllSubviews{
  29. [self.contentView addSubview:self.proCotainerView];
  30. [self.proCotainerView addSubview:self.proImgView];
  31. [self.proCotainerView addSubview:self.titleLabel];
  32. [self.proCotainerView addSubview:self.priceLabel];
  33. [self.proCotainerView addSubview:self.siteLabel];
  34. [self.proCotainerView addSubview:self.rightArrow];
  35. [self.proCotainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  36. // make.top.equalTo(self.contentView).offset(10);
  37. make.centerY.equalTo(self.contentView);
  38. make.left.equalTo(self.contentView).offset(15);
  39. make.right.equalTo(self.contentView).offset(- 15);
  40. make.height.mas_equalTo(79);
  41. }];
  42. [self.proImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.equalTo(self.proCotainerView).offset(6);
  44. make.centerY.equalTo(self.proCotainerView);
  45. make.width.height.mas_equalTo(PRO_IMAGE_MARGIN);
  46. }];
  47. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.equalTo(self.proImgView.mas_right).offset(8);
  49. make.right.equalTo(self.proCotainerView).offset(- 15);
  50. make.top.equalTo(self.proImgView);
  51. }];
  52. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.equalTo(self.titleLabel);
  54. make.bottom.equalTo(self.proImgView).offset(- 8);
  55. }];
  56. [self.siteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.equalTo(self.priceLabel.mas_right).offset(18);
  58. make.baseline.equalTo(self.priceLabel);
  59. }];
  60. [self.rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.right.equalTo(self.proCotainerView).offset(- 9);
  62. make.centerY.equalTo(self.proCotainerView);
  63. }];
  64. }
  65. + (CGFloat)cellHeight{
  66. return 89;
  67. }
  68. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  69. if ([viewModel isKindOfClass:[FKCircleDetailViewModel class]]) {
  70. FKCircleDetailViewModel *cirViewModel = (FKCircleDetailViewModel *)viewModel;
  71. FKCirDetailContentItem *contentItem = [cirViewModel.dataItem contentDetailItemForIndex:indexPath.row];
  72. if (contentItem.contentData.productItem){
  73. [self.proImgView setImageWithURL:contentItem.contentData.productItem.firstPicUrl
  74. placeholderImage:nil
  75. width:PRO_IMAGE_MARGIN
  76. height:PRO_IMAGE_MARGIN];
  77. self.titleLabel.text = contentItem.contentData.productItem.name;
  78. self.priceLabel.text = [FLStringHelper convertFenToRMBmoneyString:contentItem.contentData.productItem.price];
  79. self.siteLabel.text = contentItem.contentData.supplyItem.name;
  80. }
  81. }
  82. }
  83. #pragma mark - property
  84. - (UIView *)proCotainerView{
  85. if (_proCotainerView == nil) {
  86. _proCotainerView = [[UIView alloc]init];
  87. _proCotainerView.backgroundColor = UIColorFromRGB(0xf1f1f1);
  88. _proCotainerView.layer.cornerRadius = 2.5;
  89. }
  90. return _proCotainerView;
  91. }
  92. - (UIImageView *)proImgView{
  93. if (_proImgView == nil) {
  94. _proImgView = [[UIImageView alloc]init];
  95. _proImgView.contentMode = UIViewContentModeScaleAspectFit;
  96. }
  97. return _proImgView;
  98. }
  99. - (UIImageView *)rightArrow{
  100. if (_rightArrow == nil) {
  101. _rightArrow = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"rightArrow_more"]];
  102. }
  103. return _rightArrow;
  104. }
  105. - (UILabel *)titleLabel{
  106. if (_titleLabel == nil) {
  107. _titleLabel = [[UILabel alloc]init];
  108. _titleLabel.textColor = UIColorFromRGB(0x262626);
  109. _titleLabel.font = [UIFont systemFontOfSize:14];
  110. }
  111. return _titleLabel;
  112. }
  113. - (UILabel *)priceLabel{
  114. if (_priceLabel == nil) {
  115. _priceLabel = [[UILabel alloc]init];
  116. _priceLabel.textColor = UIColorFromRGB(0xff6362);
  117. _priceLabel.font = [UIFont systemFontOfSize:14];
  118. }
  119. return _priceLabel;
  120. }
  121. - (UILabel *)siteLabel{
  122. if (_siteLabel == nil) {
  123. _siteLabel = [[UILabel alloc]init];
  124. _siteLabel.textColor = UIColorFromRGB(0x9b9b9b);
  125. _siteLabel.font = [UIFont systemFontOfSize:12];
  126. }
  127. return _siteLabel;
  128. }
  129. @end