CommodityCell1.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // CommodityCell1.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/3/3.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "CommodityCell1.h"
  9. @implementation CommodityCell1
  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. infoarr = [NSArray array];
  23. [self createUI];
  24. }
  25. return self;
  26. }
  27. -(void)createUI{
  28. if (!sliderView) {
  29. sliderView = [[sliderCollectionView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 375)];
  30. [self.contentView addSubview:sliderView];
  31. }
  32. statusLb = [[UILabel alloc]init];
  33. statusLb.frame = CGRectMake(_window_width-70, 15, 60, 26);
  34. statusLb.backgroundColor = RGBA(0, 0, 0, 0.37);
  35. statusLb.textColor = [UIColor whiteColor];
  36. statusLb.font = [UIFont systemFontOfSize:12];
  37. statusLb.layer.cornerRadius = 13;
  38. statusLb.layer.masksToBounds = YES;
  39. statusLb.text = YZMsg(@"已下架");
  40. statusLb.textAlignment = NSTextAlignmentCenter;
  41. statusLb.hidden = YES;
  42. [self.contentView addSubview:statusLb];
  43. priceLb = [[UILabel alloc]init];
  44. priceLb.frame = CGRectMake(15, sliderView.bottom+10, 80, 30);
  45. priceLb.font = [UIFont boldSystemFontOfSize:20];
  46. priceLb.textColor = Pink_Cor;
  47. priceLb.text = @"¥199.00";
  48. [self.contentView addSubview:priceLb];
  49. commissionLb = [[UILabel alloc]init];
  50. commissionLb.frame = CGRectMake(priceLb.right+5, sliderView.bottom+10, self.width-30, 30);
  51. commissionLb.font = [UIFont systemFontOfSize:16];
  52. commissionLb.textColor = Pink_Cor;
  53. commissionLb.hidden = YES;
  54. [self.contentView addSubview:commissionLb];
  55. nameLb = [[UILabel alloc]init];
  56. nameLb.frame = CGRectMake(15, priceLb.bottom+10, self.width-30, 20);
  57. nameLb.font = [UIFont systemFontOfSize:16];
  58. nameLb.textColor = [UIColor blackColor];
  59. nameLb.text = @"北京烤鸭";
  60. [self.contentView addSubview:nameLb];
  61. infoarr = @[YZMsg(@"运费:"),YZMsg(@"已售"),YZMsg(@"地点")];
  62. for (int i = 0; i < infoarr.count; i ++) {
  63. UILabel *lb = [[UILabel alloc]init];
  64. lb.frame = CGRectMake(15+i *(_window_width-26)/3, nameLb.bottom+10, (_window_width-26)/3, 20);
  65. lb.text = infoarr[i];
  66. lb.font = [UIFont systemFontOfSize:14];
  67. lb.textColor = [UIColor grayColor];
  68. lb.adjustsFontSizeToFitWidth = YES;
  69. [self addSubview:lb];
  70. if (i == 0) {
  71. freightLb = lb;
  72. }else if (i == 1) {
  73. lb.textAlignment = NSTextAlignmentCenter;
  74. countLb = lb;
  75. }else if (i == 2){
  76. lb.textAlignment = NSTextAlignmentRight;
  77. addressLb = lb;
  78. }
  79. }
  80. }
  81. #pragma mark ============轮播图点击=============
  82. -(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
  83. }
  84. -(void)setModel:(CommodityDetailModel *)model
  85. {
  86. _model = model;
  87. if ([model.goods_status isEqual:@"-1"]) {
  88. statusLb.hidden = NO;
  89. }
  90. NSMutableArray *muaaa = [NSMutableArray array];
  91. BOOL isVideo;
  92. if (_model.video_url_format.length > 6) {
  93. [muaaa addObject:_model.video_url_format];
  94. isVideo = YES;
  95. }else{
  96. isVideo = NO;
  97. }
  98. [muaaa addObjectsFromArray:_model.thumbs_format];
  99. if(muaaa.count > 0){
  100. [sliderView reload:muaaa andIsvideo:isVideo];
  101. }
  102. sliderView.backScroll.showsHorizontalScrollIndicator = NO;
  103. [sliderView resumeGoodsVideo];
  104. // _cycleScroll.imageURLStringsGroup = model.pictures_format;
  105. priceLb.text = [NSString stringWithFormat:@"%@%@",YZMsg(@"¥"), model.price] ;
  106. if ([model.is_sale_platform isEqual:@"1"]) {
  107. commissionLb.hidden = NO;
  108. commissionLb.text = [NSString stringWithFormat:YZMsg(@"佣 ¥%@"), model.commission];
  109. }
  110. nameLb.text = model.name;
  111. freightLb.text = [NSString stringWithFormat:YZMsg(@"运费:%@元"), model.postage];
  112. countLb.text = [NSString stringWithFormat:YZMsg(@"已售%@件"),model.sale_nums];
  113. addressLb.text = model.address_format;
  114. }
  115. @end