// // KDPDetailGoodInformationView.m // KuDianProject // // Created by 学丽 on 2019/7/9. // Copyright © 2019 KDP. All rights reserved. // #import "KDPDetailGoodInformationView.h" @implementation KDPDetailGoodInformationView -(instancetype)initWithFrame:(CGRect)frame { self=[super initWithFrame:frame]; if (self) { self.imgView=[[SDCycleScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 355+KDStatusHeight)]; self.imgView.backgroundColor=[UIColor colorWithHexString:LineColor]; [self addSubview:self.imgView]; self.shopImgV=[[UIImageView alloc]initWithFrame:CGRectMake(10, self.imgView.bottom+14, 20, 20)]; self.shopImgV.image=[UIImage imageNamed:@"taobao_icon"]; [self addSubview:self.shopImgV]; self.detailTitleL=[[UILabel alloc]initWithFrame:CGRectMake(10, self.imgView.bottom+14, SCREEN_WIDTH-20, 45)]; self.detailTitleL.numberOfLines=0; self.detailTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:@" -------" linSpacing:4]; self.detailTitleL.textColor=[UIColor blackColor]; self.detailTitleL.font=[UIFont systemFontOfSize:15]; [self addSubview:self.detailTitleL]; self.priceL=[[UILabel alloc]initWithFrame:CGRectMake(10, self.detailTitleL.bottom+8, 300, 36)]; self.priceL.textColor=[UIColor blackColor]; self.priceL.font=[UIFont boldSystemFontOfSize:25]; self.priceL.text=@"¥--"; [self addSubview:self.priceL]; self.originalLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, self.priceL.bottom+5, 100, 14)]; self.originalLabel.textColor=[UIColor colorWithHexString:@"#A9A9A9"]; self.originalLabel.font=[UIFont systemFontOfSize:10]; [self addSubview:self.originalLabel]; //原件 NSString *textStr =@"¥---"; //中划线 NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic]; self.originalLabel.attributedText=attribtStr; self.volumeL=[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-150, self.originalLabel.top, 140, 14)]; self.volumeL.textAlignment=NSTextAlignmentRight; self.volumeL.text=@"月销:--"; self.volumeL.textColor=[UIColor colorWithHexString:@"#a9a9a9"]; self.volumeL.font=[UIFont systemFontOfSize:10]; [self addSubview:self.volumeL]; [self addSubview:self.couponImgV]; [self.couponImgV addSubview:self.couponPriceL]; self.couponImgV.frame=CGRectMake(SCREEN_WIDTH-70, self.priceL.top, 60, 16); self.couponPriceL.frame=CGRectMake(20, 0, 40, 16); UIView *lineV=[[UIView alloc]init]; lineV.tag=1000; lineV.backgroundColor=[UIColor colorWithHexString:LineColor]; [self addSubview:lineV]; [lineV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.top.mas_equalTo(self.mas_bottom).offset(-5); make.height.mas_equalTo(5); }]; } return self; } -(void)setModel:(KDPGoodsModel *)model { _model=model; self.detailTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:[NSString stringWithFormat:@" %@",model.title] linSpacing:5]; if (model.shop_type.integerValue == 1) { self.shopImgV.image =[UIImage imageNamed:@"tm_icon"]; }else{ self.shopImgV.image =[UIImage imageNamed:@"taobao_icon"]; } self.volumeL.text=[NSString stringWithFormat:@"月销 %@",model.volume]; NSString *timetitle= [NSString stringWithFormat:@"¥%@/利润%@",model.discount_price,model.commission_rate]; NSString *prices =[NSString stringWithFormat:@"¥%@/",model.discount_price]; NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle]; [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#333333"] range:NSMakeRange(0,prices.length)]; [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(prices.length,2)]; //设置字体字号和字体类别 [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:ThemeColor] range:NSMakeRange(prices.length,timetitle.length-prices.length)]; self.priceL.attributedText=timestr; //原价 NSString *textStr =[NSString stringWithFormat:@"¥%@",model.price]; //中划线 NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic]; self.originalLabel.attributedText=attribtStr; NSMutableArray *array =[NSMutableArray array]; [array addObject:model.img]; [array addObjectsFromArray:model.small_img]; self.imgView.imageURLStringsGroup=array; if (model.coupon_price.floatValue>0) { self.couponImgV.hidden=NO; self.couponPriceL.text=model.coupon_price; }else{ self.couponImgV.hidden=YES; } UIView *lineV=[self viewWithTag:1000]; if (model.goods_point.length>0) { lineV.hidden=YES; }else{ lineV.hidden=NO; } } -(UIImageView *)couponImgV { if (!_couponImgV) { _couponImgV=[[UIImageView alloc]init]; _couponImgV.image=[UIImage imageNamed:@"coupon_icon"]; UILabel *quanL=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 20, 16)]; quanL.text=@"券"; quanL.font=[UIFont systemFontOfSize:12]; quanL.textColor=[UIColor whiteColor]; quanL.textAlignment=NSTextAlignmentCenter; [_couponImgV addSubview:quanL]; } return _couponImgV; } -(UILabel *)couponPriceL { if (!_couponPriceL) { _couponPriceL=[[UILabel alloc]init]; _couponPriceL.text=@"---"; _couponPriceL.textColor=[UIColor colorWithHexString:ThemeColor]; _couponPriceL.font=[UIFont systemFontOfSize:12]; _couponPriceL.textAlignment=NSTextAlignmentCenter; } return _couponPriceL; } -(void)exitclickButton { if (self.returnBlock) { self.returnBlock(); } } @end