OutsideHeadCell.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // OutsideHeadCell.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/5/27.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "OutsideHeadCell.h"
  9. @implementation OutsideHeadCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  15. [super setSelected:selected animated:animated];
  16. // Configure the view for the selected state
  17. }
  18. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  19. {
  20. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  21. if (self) {
  22. [self createUI];
  23. }
  24. return self;
  25. }
  26. -(void)createUI{
  27. if (!sliderView) {
  28. sliderView = [[sliderCollectionView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 375)];
  29. [self addSubview:sliderView];
  30. }
  31. statusLb = [[UILabel alloc]init];
  32. statusLb.frame = CGRectMake(_window_width-70, 15, 60, 26);
  33. statusLb.backgroundColor = RGBA(0, 0, 0, 0.37);
  34. statusLb.textColor = [UIColor whiteColor];
  35. statusLb.font = [UIFont systemFontOfSize:12];
  36. statusLb.layer.cornerRadius = 13;
  37. statusLb.layer.masksToBounds = YES;
  38. statusLb.text = YZMsg(@"已下架");
  39. statusLb.textAlignment = NSTextAlignmentCenter;
  40. statusLb.hidden = YES;
  41. [self addSubview:statusLb];
  42. priceLb = [[UILabel alloc]init];
  43. // priceLb.frame = CGRectMake(15, sliderView.bottom+10, self.width-30, 30);
  44. priceLb.font = [UIFont boldSystemFontOfSize:20];
  45. priceLb.textColor = Pink_Cor;
  46. priceLb.text = @"¥199.00";
  47. [self addSubview:priceLb];
  48. [priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.equalTo(self).offset(15);
  50. make.top.equalTo(sliderView.mas_bottom).offset(10);
  51. make.height.mas_equalTo(30);
  52. }];
  53. original_priceLb =[[UILabel alloc]init];
  54. // original_priceLb.frame = CGRectMake(priceLb.right+, sliderView.bottom+10, self.width-30, 30);
  55. original_priceLb.font = [UIFont systemFontOfSize:15];
  56. original_priceLb.textColor = [UIColor grayColor];
  57. original_priceLb.text = @"¥199.00";
  58. [self addSubview:original_priceLb];
  59. [original_priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.equalTo(priceLb.mas_right).offset(15);
  61. make.centerY.equalTo(priceLb.mas_centerY);
  62. make.height.mas_equalTo(30);
  63. }];
  64. UILabel *lineLb = [[UILabel alloc]init];
  65. lineLb.backgroundColor = [UIColor grayColor];
  66. [self addSubview:lineLb];
  67. [lineLb mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.right.equalTo(original_priceLb);
  69. make.height.mas_equalTo(1);
  70. make.centerY.equalTo(original_priceLb.mas_centerY);
  71. }];
  72. nameLb = [[UILabel alloc]init];
  73. // nameLb.frame = CGRectMake(15, sliderView.bottom+10+30+10, self.width-30, 40);
  74. nameLb.font = [UIFont boldSystemFontOfSize:16];
  75. nameLb.textColor = [UIColor blackColor];
  76. nameLb.numberOfLines = 0;
  77. nameLb.lineBreakMode = NSLineBreakByWordWrapping;
  78. nameLb.text = @"北京烤鸭";
  79. [self addSubview:nameLb];
  80. [nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.equalTo(priceLb.mas_left);
  82. make.top.equalTo(priceLb.mas_bottom).offset(10);
  83. make.right.equalTo(self).offset(-15);
  84. }];
  85. desLb =[[UILabel alloc]init];
  86. desLb.font = [UIFont systemFontOfSize:15];
  87. desLb.textColor = [UIColor darkGrayColor];
  88. desLb.numberOfLines = 0;
  89. desLb.lineBreakMode = NSLineBreakByWordWrapping;
  90. [self addSubview:desLb];
  91. [desLb mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.left.equalTo(priceLb.mas_left);
  93. make.top.equalTo(nameLb.mas_bottom).offset(10);
  94. make.right.equalTo(self).offset(-15);
  95. }];
  96. }
  97. #pragma mark ============轮播图点击=============
  98. -(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
  99. }
  100. -(void)setModel:(CommodityDetailModel *)model
  101. {
  102. _model = model;
  103. if ([model.goods_status isEqual:@"-1"]) {
  104. statusLb.hidden = NO;
  105. }
  106. NSMutableArray *muaaa = [NSMutableArray array];
  107. BOOL isVideo;
  108. if (_model.video_url_format.length > 6) {
  109. [muaaa addObject:_model.video_url_format];
  110. isVideo = YES;
  111. }else{
  112. isVideo = NO;
  113. }
  114. [muaaa addObjectsFromArray:_model.thumbs_format];
  115. if(muaaa.count > 0){
  116. [sliderView reload:muaaa andIsvideo:isVideo];
  117. }
  118. priceLb.text = [NSString stringWithFormat:@"%@%@",YZMsg(@"¥"), model.present_price] ;
  119. original_priceLb.text =[NSString stringWithFormat:@"%@%@",YZMsg(@"¥"),model.original_price] ;
  120. nameLb.text = model.name;
  121. desLb.text = model.goods_desc;
  122. }
  123. @end