123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- //
- // ZBGoodDetailView.m
- // ZBProject
- //
- // Created by 学丽 on 2019/3/27.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ZBGoodDetailViewCell.h"
- @implementation ZBGoodDetailViewCell
- -(instancetype)initWithFrame:(CGRect)frame
- {
- self=[super initWithFrame:frame];
- if (self) {
- self.backgroundColor=[UIColor whiteColor];
-
- [self addSubview:self.imgCycleView];
- [self addSubview:self.titleLabel];
- [self addSubview:self.priceLabel];
- [self addSubview:self.quanImgv];
- [self.quanImgv addSubview:self.quanLabel];
-
- [self addSubview:self.saleLabel];
- [self addSubview:self.oldPricel];
- [self addSubview:self.tipeImgV];
- [self addSubview:self.pointbackView];
- [self.pointbackView addSubview:self.pointLabel];
- [self.imgCycleView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.mas_equalTo(0);
- make.height.mas_equalTo(375);
-
-
- }];
-
-
-
-
- [self.oldPricel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.priceLabel.mas_left);
- make.height.mas_equalTo(16);
- make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(5);
- }];
-
- [self.saleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(16);
- make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(5);
- }];
- [self.tipeImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(19);
- make.left.mas_equalTo(10);
- make.top.mas_equalTo(self.imgCycleView.mas_bottom).offset(14);
- }];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10); make.top.mas_equalTo(self.imgCycleView.mas_bottom).offset(14);
- }];
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.height.mas_equalTo(36);
- make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(8);
- }];
-
-
- [self.quanImgv mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(19);
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(16);
- make.width.mas_equalTo(65);
- }];
- [self.quanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(24);
- make.right.top.mas_equalTo(0);
- make.height.mas_equalTo(16);
- }];
- [self.pointbackView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.saleLabel.mas_bottom).offset(17);
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10);
-
- }];
- //
- [self.pointLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(37);
- make.left.mas_equalTo(5);
- make.right.mas_equalTo(-5);
- }];
-
- }
-
- return self;
- }
- -(void)setBannerArry:(NSMutableArray *)bannerArry
- {
- _bannerArry = bannerArry;
- if (bannerArry.count>0) {
- self.imgCycleView.imageURLStringsGroup=bannerArry;
- }
- }
- -(void)setModel:(ZBGoodModel *)model
- {
- _model = model;
- NSString *str=[NSString stringWithFormat:@" %@",model.title];
- NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:str];
- NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle1 setLineSpacing:8];
- [attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [str length])];
- [self.titleLabel setAttributedText:attributedString1];
- [self.titleLabel sizeToFit];
-
-
-
-
- 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 YHColorWithHex:0x333333] range:NSMakeRange(0,prices.length)];
- [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(prices.length,2)]; //设置字体字号和字体类别
- [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF7D00] range:NSMakeRange(prices.length,timetitle.length-prices.length)];
- self.priceLabel.attributedText=timestr;
-
-
-
-
- //原件
- NSString *textStr =[NSString stringWithFormat:@"¥%@",model.price];
-
- //中划线
- NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
- NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
- // 赋值
- self.oldPricel.attributedText = attribtStr;
- //券的价格为0隐藏
- if (model.coupon_price.floatValue == 0) {
- self.quanImgv.hidden=YES;
- }else{
- self.quanImgv.hidden=NO;
- }
- self.quanLabel.text=[NSString stringWithFormat:@"¥%@",model.coupon_price];
- if (model.shop_type.integerValue == 1) {
- self.tipeImgV.image =[UIImage imageNamed:@"tm_icon"];
- }else{
- self.tipeImgV.image =[UIImage imageNamed:@"taobao_icon"];
-
- }
- self.saleLabel.text=[NSString stringWithFormat:@"月销%@",model.volume];
-
- if (model.goods_point.length>0) {
- self.pointbackView.hidden=NO;
- self.pointLabel.text=model.goods_point;
- [self.pointbackView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(self.mas_bottom).offset(-10);
- }];
- }
-
-
- }
- -(UIView *)pointbackView
- {
- if (!_pointbackView) {
- _pointbackView =[[UIView alloc]init];
- _pointbackView.layer.cornerRadius=5;
- _pointbackView.layer.masksToBounds=YES;
- _pointbackView.backgroundColor=[UIColor YHColorWithHex:0xFEF3E8];
-
- UIImageView *img =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"detail_point"]];
- img.frame=CGRectMake(10, 10, 18, 18);
- [_pointbackView addSubview:img];
-
- UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(img.right+10, 10, 100, 18)];
- label.text=@"卖点:";
- label.font=[UIFont boldSystemFontOfSize:13];
- label.textColor=[UIColor YHColorWithHex:0x333333];
- [_pointbackView addSubview:label];
-
- UIButton *copybtn =[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-80, 10, 50, 16)];
- [copybtn setTitle:@"复制" forState:UIControlStateNormal];
- copybtn.titleLabel.font=[UIFont systemFontOfSize:10];
- [copybtn setTitleColor:[UIColor fontNineColor] forState:UIControlStateNormal];
- copybtn.layer.cornerRadius=1;
- copybtn.layer.masksToBounds=YES;
- copybtn.layer.borderColor=[UIColor fontNineColor].CGColor;
- copybtn.layer.borderWidth=0.5;
- [_pointbackView addSubview:copybtn];
- [copybtn addTarget:self action:@selector(copoyClickBtn) forControlEvents:UIControlEventTouchUpInside];
- _pointbackView.hidden=YES;
- }
- return _pointbackView;
- }
- -(UILabel *)pointLabel
- {
- if (!_pointLabel) {
- _pointLabel=[[UILabel alloc]init];
- _pointLabel.textColor=[UIColor fontsixColor];
- _pointLabel.font=[UIFont systemFontOfSize:13];
-
- _pointLabel.numberOfLines=0;
- }
- return _pointLabel;
- }
- -(UIImageView *)tipeImgV
- {
- if (!_tipeImgV) {
- _tipeImgV=[[UIImageView alloc]init];
- _tipeImgV.layer.cornerRadius=2;
- _tipeImgV.layer.masksToBounds=YES;
- [_tipeImgV setImage:[UIImage imageNamed:@"tm_icon"]];;
- }
- return _tipeImgV;
- }
- -(SDCycleScrollView *)imgCycleView
- {
- if (!_imgCycleView) {
- _imgCycleView=[[SDCycleScrollView alloc]init];
-
- _imgCycleView.backgroundColor=[UIColor lineColor];
-
- }
- return _imgCycleView;
- }
- -(UILabel *)titleLabel
- {
- if (!_titleLabel) {
- _titleLabel =[[UILabel alloc]init];
- _titleLabel.textColor=[UIColor YHColorWithHex:0x000000];
- _titleLabel.font=[UIFont systemFontOfSize:15];
- _titleLabel.text=@" ----标题";
- _titleLabel.numberOfLines=2;
- }
- return _titleLabel;
- }
- -(UILabel *)priceLabel
- {
- if (!_priceLabel) {
- _priceLabel=[[UILabel alloc]init];
- _priceLabel.textColor=[UIColor YHColorWithHex:0xFC6708];
- _priceLabel.font=[UIFont systemFontOfSize:25];
- _priceLabel.text=@"¥--.--";
- }
- return _priceLabel;
-
- }
- -(UILabel *)oldPricel
- {
- if (!_oldPricel) {
- _oldPricel=[[UILabel alloc]init];
- _oldPricel.text=@"¥--";
- _oldPricel.font=[UIFont systemFontOfSize:10];
- _oldPricel.textColor=[UIColor YHColorWithHex:0xA9A9A9];
-
- }
- return _oldPricel;
- }
- -(UILabel *)saleLabel
- {
- if (!_saleLabel) {
- _saleLabel=[[UILabel alloc]init];
- _saleLabel.text=@"月销---";
- _saleLabel.font=[UIFont systemFontOfSize:10];
- _saleLabel.textColor=[UIColor YHColorWithHex:0xA9A9A9];
-
- }
- return _saleLabel;
- }
- -(UIImageView *)quanImgv
- {
- if (!_quanImgv) {
- _quanImgv =[[UIImageView alloc]init];
- [_quanImgv setImage:[UIImage imageNamed:@"quan"]];
- _quanImgv.layer.cornerRadius=2;
- _quanImgv.layer.masksToBounds=YES;
- _quanImgv.hidden=YES;
- }
- return _quanImgv;
- }
- -(UILabel *)quanLabel
- {
- if (!_quanLabel) {
- _quanLabel=[[UILabel alloc]init];
- _quanLabel.textColor=[UIColor YHColorWithHex:0xFF7D00];
- _quanLabel.font=[UIFont systemFontOfSize:10];
- _quanLabel.textAlignment=NSTextAlignmentCenter;
- _quanLabel.text=@"--元";
- }
- return _quanLabel;
- }
- -(void)copoyClickBtn
- {
- UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
- if (self.model.goods_point.length>0) {
- pastboard.string = self.model.goods_point;
- [MBProgressHUD showMessage:@"复制成功"];
-
- }else {
- [MBProgressHUD showMessage:@"复制失败"];
- }
- }
- @end
|