酷店

KDPDetailGoodInformationView.m 6.5KB

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