酷店

KDPDetailGoodInformationView.m 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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, 42)];
  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 addSubview:self.profitsLabel];
  50. CGFloat heishgt=self.detailTitleL.bottom+5;
  51. [self.profitsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.mas_equalTo(heishgt);
  53. make.right.mas_equalTo(-10);
  54. make.height.mas_equalTo(28);
  55. }];
  56. self.profitsLabel.text=@"利润 --%";
  57. self.profitsLabel.textColor=[UIColor whiteColor];
  58. self.profitsLabel.font=[UIFont systemFontOfSize:16];
  59. self.profitsLabel.backgroundColor=[UIColor gradientOneColor:[UIColor colorWithHexString:@"#FF235F"] toColor:[UIColor colorWithHexString:@"#FF7676"] Width:150];
  60. self.profitsLabel.layer.cornerRadius=6;
  61. self.profitsLabel.layer.masksToBounds=YES;
  62. self.profitsLabel.textAlignment=NSTextAlignmentCenter;
  63. //原件
  64. NSString *textStr =@"¥---";
  65. //中划线
  66. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  67. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  68. self.originalLabel.attributedText=attribtStr;
  69. self.volumeL=[[UILabel alloc]initWithFrame:CGRectMake(self.detailTitleL.left, self.detailTitleL.bottom+10, 60, 16)];
  70. self.volumeL.textAlignment=NSTextAlignmentLeft;
  71. self.volumeL.text=@"月销:--";
  72. self.volumeL.textColor=[UIColor colorWithHexString:@"#a9a9a9"];
  73. self.volumeL.font=[UIFont systemFontOfSize:10];
  74. [self addSubview:self.volumeL];
  75. [backV addSubview:self.couponImgV];
  76. [self.couponImgV addSubview:self.couponPriceL];
  77. self.couponImgV.frame=CGRectMake(backV.width-70, 17, 60, 16);
  78. self.couponPriceL.frame=CGRectMake(20, 0, 40, 16);
  79. UIView *lineV=[[UIView alloc]init];
  80. lineV.tag=1000;
  81. lineV.backgroundColor=[UIColor colorWithHexString:LineColor];
  82. [self addSubview:lineV];
  83. [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.left.mas_equalTo(0);
  85. make.right.mas_equalTo(0);
  86. make.top.mas_equalTo(self.mas_bottom).offset(-5);
  87. make.height.mas_equalTo(5);
  88. }];
  89. }
  90. return self;
  91. }
  92. -(void)setModel:(KDPGoodsModel *)model
  93. {
  94. _model=model;
  95. if (model.title.length<=0) {
  96. return;
  97. }
  98. self.detailTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:[NSString stringWithFormat:@"%@",model.title] linSpacing:5];
  99. self.volumeL.text=[NSString stringWithFormat:@"月销 %@",model.volume];
  100. NSString *timetitle= [NSString stringWithFormat:@" 利润 %@ ",model.commission_rate];
  101. NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
  102. [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,4)]; //设置字体
  103. self.profitsLabel.attributedText=timestr;
  104. self.priceL.text=[NSString stringWithFormat:@"¥%@",model.discount_price];
  105. //原价
  106. NSString *textStr =[NSString stringWithFormat:@"¥%@",model.price];
  107. //中划线
  108. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  109. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  110. self.originalLabel.attributedText=attribtStr;
  111. NSMutableArray *array =[NSMutableArray array];
  112. [array addObject:model.img];
  113. [array addObjectsFromArray:model.small_img];
  114. self.imgView.imageURLStringsGroup=array;
  115. if (model.coupon_price.floatValue>0) {
  116. self.couponImgV.hidden=NO;
  117. self.couponPriceL.text=model.coupon_price;
  118. }else{
  119. self.couponImgV.hidden=YES;
  120. }
  121. UIView *lineV=[self viewWithTag:1000];
  122. if (model.goods_point.length>0) {
  123. lineV.hidden=YES;
  124. }else{
  125. lineV.hidden=NO;
  126. }
  127. }
  128. -(UIImageView *)couponImgV
  129. {
  130. if (!_couponImgV) {
  131. _couponImgV=[[UIImageView alloc]init];
  132. _couponImgV.image=[UIImage imageNamed:@"coupon_icon"];
  133. UILabel *quanL=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 20, 16)];
  134. quanL.text=@"券";
  135. quanL.font=[UIFont systemFontOfSize:12];
  136. quanL.textColor=[UIColor whiteColor];
  137. quanL.textAlignment=NSTextAlignmentCenter;
  138. [_couponImgV addSubview:quanL];
  139. }
  140. return _couponImgV;
  141. }
  142. -(UILabel *)couponPriceL
  143. {
  144. if (!_couponPriceL) {
  145. _couponPriceL=[[UILabel alloc]init];
  146. _couponPriceL.text=@"---";
  147. _couponPriceL.textColor=[UIColor colorWithHexString:ThemeColor];
  148. _couponPriceL.font=[UIFont systemFontOfSize:12];
  149. _couponPriceL.textAlignment=NSTextAlignmentCenter;
  150. }
  151. return _couponPriceL;
  152. }
  153. -(void)exitclickButton
  154. {
  155. if (self.returnBlock) {
  156. self.returnBlock();
  157. }
  158. }
  159. @end