酷店

KDPDetailGoodInformationView.m 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. self.detailTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:[NSString stringWithFormat:@" %@",model.title] linSpacing:5];
  68. if (model.shop_type.integerValue == 1) {
  69. self.shopImgV.image =[UIImage imageNamed:@"tm_icon"];
  70. }else{
  71. self.shopImgV.image =[UIImage imageNamed:@"taobao_icon"];
  72. }
  73. self.volumeL.text=[NSString stringWithFormat:@"月销 %@",model.volume];
  74. NSString *timetitle= [NSString stringWithFormat:@"¥%@/利润%@",model.discount_price,model.commission_rate];
  75. NSString *prices =[NSString stringWithFormat:@"¥%@/",model.discount_price];
  76. NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
  77. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#333333"] range:NSMakeRange(0,prices.length)];
  78. [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(prices.length,2)]; //设置字体字号和字体类别
  79. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:ThemeColor] range:NSMakeRange(prices.length,timetitle.length-prices.length)];
  80. self.priceL.attributedText=timestr;
  81. //原价
  82. NSString *textStr =[NSString stringWithFormat:@"¥%@",model.price];
  83. //中划线
  84. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  85. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  86. self.originalLabel.attributedText=attribtStr;
  87. NSMutableArray *array =[NSMutableArray array];
  88. [array addObject:model.img];
  89. [array addObjectsFromArray:model.small_img];
  90. self.imgView.imageURLStringsGroup=array;
  91. if (model.coupon_price.floatValue>0) {
  92. self.couponImgV.hidden=NO;
  93. self.couponPriceL.text=model.coupon_price;
  94. }else{
  95. self.couponImgV.hidden=YES;
  96. }
  97. UIView *lineV=[self viewWithTag:1000];
  98. if (model.goods_point.length>0) {
  99. lineV.hidden=YES;
  100. }else{
  101. lineV.hidden=NO;
  102. }
  103. }
  104. -(UIImageView *)couponImgV
  105. {
  106. if (!_couponImgV) {
  107. _couponImgV=[[UIImageView alloc]init];
  108. _couponImgV.image=[UIImage imageNamed:@"coupon_icon"];
  109. UILabel *quanL=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 20, 16)];
  110. quanL.text=@"券";
  111. quanL.font=[UIFont systemFontOfSize:12];
  112. quanL.textColor=[UIColor whiteColor];
  113. quanL.textAlignment=NSTextAlignmentCenter;
  114. [_couponImgV addSubview:quanL];
  115. }
  116. return _couponImgV;
  117. }
  118. -(UILabel *)couponPriceL
  119. {
  120. if (!_couponPriceL) {
  121. _couponPriceL=[[UILabel alloc]init];
  122. _couponPriceL.text=@"---";
  123. _couponPriceL.textColor=[UIColor colorWithHexString:ThemeColor];
  124. _couponPriceL.font=[UIFont systemFontOfSize:12];
  125. _couponPriceL.textAlignment=NSTextAlignmentCenter;
  126. }
  127. return _couponPriceL;
  128. }
  129. -(void)exitclickButton
  130. {
  131. if (self.returnBlock) {
  132. self.returnBlock();
  133. }
  134. }
  135. @end