酷店

KDPDetailGoodInformationView.m 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // KDPDetailGoodInformationView.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPDetailGoodInformationView.h"
  9. @implementation KDPDetailGoodInformationView
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self=[super initWithFrame:frame];
  13. if (self) {
  14. self.imgView=[[SDCycleScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 395+KDStatusHeight)];
  15. self.imgView.backgroundColor=[UIColor colorWithHexString:LineColor];
  16. [self addSubview:self.imgView];
  17. UIView*backV=[[UIView alloc]initWithFrame:CGRectMake(0, self.imgView.height-50, SCREEN_WIDTH, 50)];
  18. backV.backgroundColor=[UIColor colorWithHexString:@"#444444"];
  19. [self addSubview:backV];
  20. // self.shopImgV=[[UIImageView alloc]initWithFrame:CGRectMake(10, self.imgView.bottom+14, 20, 20)];
  21. // self.shopImgV.image=[UIImage imageNamed:@"taobao_icon"];
  22. // [self addSubview:self.shopImgV];
  23. self.detailTitleL=[[UILabel alloc]initWithFrame:CGRectMake(10, self.imgView.bottom+14, SCREEN_WIDTH-20, 45)];
  24. self.detailTitleL.numberOfLines=0;
  25. self.detailTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:@" -------" linSpacing:4];
  26. self.detailTitleL.textColor=[UIColor blackColor];
  27. self.detailTitleL.font=[UIFont systemFontOfSize:15];
  28. [self addSubview:self.detailTitleL];
  29. self.priceL=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 300, 50)];
  30. self.priceL.textColor=[UIColor whiteColor];
  31. self.priceL.font=[UIFont boldSystemFontOfSize:25];
  32. self.priceL.text=@"¥--";
  33. [backV addSubview:self.priceL];
  34. [self.priceL mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.height.mas_equalTo(50);
  36. make.left.mas_equalTo(10);
  37. make.top.mas_equalTo(0);
  38. }];
  39. self.originalLabel=[[UILabel alloc]initWithFrame:CGRectMake(self.priceL.right+10, 0, 100, 50)];
  40. self.originalLabel.textColor=[UIColor whiteColor];
  41. self.originalLabel.font=[UIFont systemFontOfSize:10];
  42. [backV addSubview:self.originalLabel];
  43. [self.originalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.mas_equalTo(self.priceL.mas_right).offset(5);
  45. make.height.mas_equalTo(45);
  46. make.top.mas_equalTo(5);
  47. }];
  48. self.profitsLabel=[[UILabel alloc]initWithFrame:CGRectMake(backV.width-88, 11, 78, 28)];
  49. self.profitsLabel.text=@"利润 --%";
  50. self.profitsLabel.textColor=[UIColor whiteColor];
  51. self.profitsLabel.font=[UIFont systemFontOfSize:16];
  52. self.profitsLabel.backgroundColor=[UIColor gradientOneColor:[UIColor colorWithHexString:@"#FF235F"] toColor:[UIColor colorWithHexString:@"#FF7676"] Width:78];
  53. self.profitsLabel.layer.cornerRadius=6;
  54. self.profitsLabel.layer.masksToBounds=YES;
  55. self.profitsLabel.textAlignment=NSTextAlignmentCenter;
  56. [backV addSubview:self.profitsLabel];
  57. //原件
  58. NSString *textStr =@"¥---";
  59. //中划线
  60. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  61. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  62. self.originalLabel.attributedText=attribtStr;
  63. self.volumeL=[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-150, self.detailTitleL.bottom+5, 140, 14)];
  64. self.volumeL.textAlignment=NSTextAlignmentRight;
  65. self.volumeL.text=@"月销:--";
  66. self.volumeL.textColor=[UIColor colorWithHexString:@"#a9a9a9"];
  67. self.volumeL.font=[UIFont systemFontOfSize:10];
  68. [self addSubview:self.volumeL];
  69. [self addSubview:self.couponImgV];
  70. [self.couponImgV addSubview:self.couponPriceL];
  71. self.couponImgV.frame=CGRectMake(self.detailTitleL.left, self.volumeL.top-1, 60, 16);
  72. self.couponPriceL.frame=CGRectMake(20, 0, 40, 16);
  73. UIView *lineV=[[UIView alloc]init];
  74. lineV.tag=1000;
  75. lineV.backgroundColor=[UIColor colorWithHexString:LineColor];
  76. [self addSubview:lineV];
  77. [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.mas_equalTo(0);
  79. make.right.mas_equalTo(0);
  80. make.top.mas_equalTo(self.mas_bottom).offset(-5);
  81. make.height.mas_equalTo(5);
  82. }];
  83. }
  84. return self;
  85. }
  86. -(void)setModel:(KDPGoodsModel *)model
  87. {
  88. _model=model;
  89. if (model.title.length<=0) {
  90. return;
  91. }
  92. self.detailTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:[NSString stringWithFormat:@"%@",model.title] linSpacing:5];
  93. self.volumeL.text=[NSString stringWithFormat:@"月销 %@",model.volume];
  94. NSString *timetitle= [NSString stringWithFormat:@"利润 %@",model.commission_rate];
  95. NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
  96. [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,3)]; //设置字体
  97. self.profitsLabel.attributedText=timestr;
  98. self.priceL.text=[NSString stringWithFormat:@"¥%@",model.discount_price];
  99. //原价
  100. NSString *textStr =[NSString stringWithFormat:@"¥%@",model.price];
  101. //中划线
  102. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  103. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  104. self.originalLabel.attributedText=attribtStr;
  105. NSMutableArray *array =[NSMutableArray array];
  106. [array addObject:model.img];
  107. [array addObjectsFromArray:model.small_img];
  108. self.imgView.imageURLStringsGroup=array;
  109. if (model.coupon_price.floatValue>0) {
  110. self.couponImgV.hidden=NO;
  111. self.couponPriceL.text=model.coupon_price;
  112. }else{
  113. self.couponImgV.hidden=YES;
  114. }
  115. UIView *lineV=[self viewWithTag:1000];
  116. if (model.goods_point.length>0) {
  117. lineV.hidden=YES;
  118. }else{
  119. lineV.hidden=NO;
  120. }
  121. }
  122. -(UIImageView *)couponImgV
  123. {
  124. if (!_couponImgV) {
  125. _couponImgV=[[UIImageView alloc]init];
  126. _couponImgV.image=[UIImage imageNamed:@"coupon_icon"];
  127. UILabel *quanL=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 20, 16)];
  128. quanL.text=@"券";
  129. quanL.font=[UIFont systemFontOfSize:12];
  130. quanL.textColor=[UIColor whiteColor];
  131. quanL.textAlignment=NSTextAlignmentCenter;
  132. [_couponImgV addSubview:quanL];
  133. }
  134. return _couponImgV;
  135. }
  136. -(UILabel *)couponPriceL
  137. {
  138. if (!_couponPriceL) {
  139. _couponPriceL=[[UILabel alloc]init];
  140. _couponPriceL.text=@"---";
  141. _couponPriceL.textColor=[UIColor colorWithHexString:ThemeColor];
  142. _couponPriceL.font=[UIFont systemFontOfSize:12];
  143. _couponPriceL.textAlignment=NSTextAlignmentCenter;
  144. }
  145. return _couponPriceL;
  146. }
  147. -(void)exitclickButton
  148. {
  149. if (self.returnBlock) {
  150. self.returnBlock();
  151. }
  152. }
  153. @end