YOUPAIHRHorizontalPageCell.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //
  2. // YOUPAIHRHorizontalPageCell.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/11/1.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHRHorizontalPageCell.h"
  9. @implementation YOUPAIHRHorizontalPageCell
  10. -(instancetype)initWithFrame:(CGRect)frame{
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. self.youpaipbgV = [[UIView alloc] init];
  14. [self.contentView addSubview:self.youpaipbgV];
  15. [self.youpaipbgV mas_makeConstraints:^(MASConstraintMaker *make) {
  16. make.top.offset(0.0f);
  17. make.bottom.offset(0.0f);
  18. make.left.offset(6.5f);
  19. make.right.offset(-6.5f);
  20. }];
  21. CGFloat width = 51.0f;
  22. self.youpaipimgView = [[UIImageView alloc] init];
  23. self.youpaipimgView.contentMode = UIViewContentModeScaleAspectFit;
  24. [self.youpaipbgV addSubview:self.youpaipimgView];
  25. [self.youpaipimgView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.centerX.equalTo(self);
  27. make.top.offset(2.0f);
  28. make.size.mas_offset(CGSizeMake(width, width));
  29. }];
  30. self.youpaiptitleL = [[UILabel alloc] init];
  31. self.youpaiptitleL.font = [UIFont systemFontOfSize:12];
  32. self.youpaiptitleL.textColor = HexColorFromRGBA(0xffffff,1.0);
  33. self.youpaiptitleL.textAlignment = NSTextAlignmentCenter;
  34. [self.youpaipbgV addSubview:self.youpaiptitleL];
  35. [self.youpaiptitleL mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.offset(0.0f);
  37. make.right.offset(0.0f);
  38. make.top.equalTo(self.youpaipimgView.mas_bottom);
  39. make.height.offset(15.0f);
  40. }];
  41. self.youpaippriceL = [[UILabel alloc]init];
  42. self.youpaippriceL.font = [UIFont systemFontOfSize:10];
  43. self.youpaippriceL.textColor = HexColorFromRGBA(0xffffff,0.5);
  44. self.youpaippriceL.textAlignment = NSTextAlignmentCenter;
  45. [self.youpaipbgV addSubview:self.youpaippriceL];
  46. [self.youpaippriceL mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.centerX.equalTo(self.mas_centerX).offset(6.0f);
  48. make.top.equalTo(self.youpaiptitleL.mas_bottom).offset(3);
  49. }];
  50. UIImageView *coinImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_user_show_zuanshi"]];
  51. [self.youpaipbgV addSubview:coinImgV];
  52. [coinImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.right.equalTo(self.youpaippriceL.mas_left).offset(-3.0f);
  54. make.centerY.equalTo(self.youpaippriceL);
  55. make.size.mas_offset(CGSizeMake(9, 9));
  56. }];
  57. //角标
  58. self.youpaipbageBtn = [UIButton new];
  59. [self.youpaipbgV addSubview:self.youpaipbageBtn];
  60. [self.youpaipbageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.mas_equalTo(0);
  62. make.top.mas_equalTo(0);
  63. make.size.mas_equalTo(CGSizeMake(24, 15));
  64. }];
  65. [self.youpaipbageBtn setTitle:@"活动" forState:UIControlStateNormal];
  66. [self.youpaipbageBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  67. self.youpaipbageBtn.titleLabel.font = [UIFont systemFontOfSize:9];
  68. self.youpaipbageBtn.layer.cornerRadius = 2.0f;
  69. self.youpaipbageBtn.layer.masksToBounds = YES;
  70. self.youpaipbageBtn.backgroundColor = HexColorFromRGB(0xFF41A4);
  71. self.youpaipbageBtn.hidden = YES;
  72. //个数
  73. self.youpaipcountLabel = [[UILabel alloc]init];
  74. self.youpaipcountLabel.font = [UIFont systemFontOfSize:9];
  75. self.youpaipcountLabel.textColor = HexColorFromRGBA(0xFF41A4,1.0);
  76. [self.youpaipbgV addSubview:self.youpaipcountLabel];
  77. [self.youpaipcountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.mas_equalTo(2);
  79. make.top.mas_equalTo(2);
  80. make.height.offset(15);
  81. // make.size.mas_equalTo(CGSizeMake(40, 15));
  82. }];
  83. self.youpaipbageBtn.layer.zPosition = MAXFLOAT;
  84. }
  85. return self;
  86. }
  87. -(void)setYoupaipmodel:(YOUPAILCGiftModel *)youpaipmodel{
  88. _youpaipmodel = youpaipmodel;
  89. // self.youpaipimgView.image = [LCTools giftImgWithGiftUrlStr:model.img];
  90. //modify by leo 解决主线程卡死问题 20191204
  91. NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,youpaipmodel.youpaipimg];
  92. [self.youpaipimgView sd_setImageWithURL:[NSURL URLWithString:urlStr]];
  93. // self.youpaiptitleL.text = self.model.name;
  94. // self.youpaippriceL.text = [NSString stringWithFormat:@"%zd",self.model.price];
  95. if (youpaipmodel.youpaipnum>0) {
  96. self.youpaipcountLabel.text = [NSString stringWithFormat:@"×%ld",(long)youpaipmodel.youpaipnum];
  97. }
  98. NSString *signStr =[NSString stringWithFormat:@"%@",youpaipmodel.youpaipsign];
  99. if (signStr.length>0) {
  100. self.youpaipbageBtn.hidden = NO;
  101. [self.youpaipbageBtn setTitle:youpaipmodel.youpaipsign forState:UIControlStateNormal];
  102. NSLog(@"签名是:%@",youpaipmodel.youpaipsign);
  103. }else{
  104. self.youpaipbageBtn.hidden = YES;
  105. }
  106. self.youpaiptitleL.text = self.youpaipmodel.youpaipname;
  107. self.youpaippriceL.text = [NSString stringWithFormat:@"%zd",self.youpaipmodel.youpaipprice];
  108. if (youpaipmodel.youpaipselected) {
  109. self.youpaipbgV.layer.borderColor = HexColorFromRGB(0xFF3A00).CGColor;
  110. self.youpaipbgV.layer.borderWidth = 1.0;
  111. self.youpaipbgV.layer.cornerRadius = 8;
  112. }else{
  113. self.youpaipbgV.layer.borderColor = [UIColor clearColor].CGColor;
  114. self.youpaipbgV.layer.borderWidth = 0;
  115. self.youpaipbgV.layer.cornerRadius = 0;
  116. }
  117. }
  118. @end