// // LZMGoodDetailView.m // YouHuiProject // // Created by xiaoxi on 2018/1/25. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LZMGoodDetailView.h" #import "LZMGoodDetailModel.h" #import "LZMGotoDetailView.h" #import "UIView+SDAutoLayout.h" #import "CCCopyLabel.h" @interface LZMGoodDetailView () @property (nonatomic, strong) CCCopyLabel *goodTitleLabel; @property (nonatomic, strong) UILabel *priceLabel; @property (nonatomic, strong) UIImageView *discountImageView; @property (nonatomic, strong) UILabel *discountPriceLabel; @property (nonatomic, strong) UILabel *freePostLabel; @property (nonatomic, strong) UILabel *volumeLabel; @property (nonatomic, strong) UILabel *quanType; @property (nonatomic, strong) UILabel *quanNum; @property (nonatomic, strong) UILabel *commissionPrice; @end @implementation LZMGoodDetailView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor whiteColor]; [self initSubviews]; } return self; } - (void)setGoodModel:(LZMGoodDetailModel *)goodModel { _goodModel = goodModel; NSString *quanType = [goodModel.is_coupon boolValue]?@"券":@"折"; self.quanType.text = quanType; NSString *quanNum = [goodModel.is_coupon boolValue]?[NSString stringWithFormat:@"%@元",goodModel.coupon_price]:[NSString stringWithFormat:@"%@折",goodModel.coupon_price]; self.quanNum.text = quanNum; self.discountImageView.hidden = ![goodModel.is_coupon boolValue]; //标题 NSTextAttachment *textAttach = [[NSTextAttachment alloc]init]; UIImage *img; if ([goodModel.shop_type isEqualToString:@"1"]) { img= [UIImage imageNamed:@"tm_shop"]; }else if([goodModel.shop_type isEqualToString:@"0"]){ // img= [UIImage imageNamed:@"share_title_tb"]; } if (img) { textAttach.image = img; textAttach.bounds = CGRectMake(0, -4, img.size.width, img.size.height); } NSMutableAttributedString *attri; if ([goodModel.shop_type isEqualToString:@"1"]) { attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@",goodModel.title]]; }else { attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",goodModel.title]]; } NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:textAttach]; [attri insertAttributedString:string atIndex:0]; NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setLineSpacing:8]; [attri addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [string length])]; self.goodTitleLabel.textStr = goodModel.title; self.goodTitleLabel.attributedText = attri; NSString *priceText = [NSString stringWithFormat:@"原价 ¥%.2f", [goodModel.price floatValue]]; NSMutableAttributedString *attritu = [[NSMutableAttributedString alloc]initWithString:priceText]; [attritu addAttributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle) } range:NSMakeRange(3, priceText.length-3)]; self.priceLabel.attributedText = attritu; NSString *dis_price = [goodModel.is_coupon boolValue] ? [NSString stringWithFormat:@"券后 ¥%.2f", [goodModel.discount_price floatValue]]:[NSString stringWithFormat:@"折后 ¥%.2f", [goodModel.discount_price floatValue]]; NSMutableAttributedString *dispriceAttr = [[NSMutableAttributedString alloc]initWithString:dis_price]; [dispriceAttr addAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:13]} range:NSMakeRange(0, 3)]; self.discountPriceLabel.attributedText = dispriceAttr; self.volumeLabel.text = [NSString stringWithFormat:@"月销 %@", goodModel.volume]; self.freePostLabel.text = [goodModel.freeShipping isEqual:@1] ? @"包邮" : [NSString stringWithFormat:@"邮费 %@", goodModel.postage]; } - (void)initSubviews { [self addSubview:self.goodTitleLabel]; [self addSubview:self.priceLabel]; [self addSubview:self.discountImageView]; [self addSubview:self.discountPriceLabel]; [self addSubview:self.volumeLabel]; [self addSubview:self.commissionPrice]; [self.discountImageView addSubview:self.quanType]; [self.discountImageView addSubview:self.quanNum]; [self makeSubviewsConstraints]; } - (void)makeSubviewsConstraints { [self.discountPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(FITSIZE(10)); make.top.mas_equalTo(Fitsize(15)); }]; [self.discountImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.discountPriceLabel.mas_right).mas_offset(10); make.centerY.mas_equalTo(self.discountPriceLabel.mas_centerY); make.width.mas_equalTo(64); make.height.mas_equalTo(14); }]; [self.quanType mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.bottom.mas_equalTo(0); make.width.mas_equalTo(20); }]; [self.quanNum mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(20); make.top.bottom.right.mas_equalTo(0); }]; [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.discountPriceLabel); make.top.equalTo(self.discountPriceLabel.mas_bottom).offset(FITSIZE(15)); }]; [self.goodTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(FITSIZE(10)); make.left.equalTo(self.discountPriceLabel); make.right.equalTo(self).offset(-FITSIZE(10)); }]; [self.volumeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self).offset(-FITSIZE(20)); make.centerY.mas_equalTo(self.priceLabel.mas_centerY); }]; [self.commissionPrice mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(self.volumeLabel.mas_right); make.bottom.mas_equalTo(self.discountPriceLabel.mas_bottom); }]; } - (void)couponTapAction:(UIGestureRecognizer *)sender { if ([self.delegate respondsToSelector:@selector(yh_GoodDetailViewTapCoupon)]) { [self.delegate yh_GoodDetailViewTapCoupon]; } } - (void)shopTapAction:(UIGestureRecognizer *)sender { if ([self.delegate respondsToSelector:@selector(yh_GoodDetailViewTapShop)]) { [self.delegate yh_GoodDetailViewTapShop]; } } #pragma mark - lazy - (CCCopyLabel *)goodTitleLabel { if (!_goodTitleLabel) { _goodTitleLabel = [[CCCopyLabel alloc] init]; _goodTitleLabel.backgroundColor = [UIColor clearColor]; _goodTitleLabel.textColor = [UIColor YHColorWithHex:0x222222]; _goodTitleLabel.font = [UIFont systemFontOfSize:FITSIZE(14)]; _goodTitleLabel.numberOfLines = 2; // _goodTitleLabel.hidden=YES; } return _goodTitleLabel; } - (UILabel *)priceLabel { if (!_priceLabel) { _priceLabel = [[UILabel alloc] init]; _priceLabel.backgroundColor = [UIColor clearColor]; _priceLabel.textColor = [UIColor YHColorWithHex:0x999999]; _priceLabel.font = [UIFont systemFontOfSize:FITSIZE(13)]; } return _priceLabel; } - (UIImageView *)discountImageView { if (!_discountImageView) { _discountImageView = [[UIImageView alloc] init]; _discountImageView.backgroundColor = [UIColor clearColor]; _discountImageView.image = [UIImage imageNamed:@"quan_bg"]; } return _discountImageView; } - (UILabel *)discountPriceLabel { if (!_discountPriceLabel) { _discountPriceLabel = [[UILabel alloc] init]; _discountPriceLabel.backgroundColor = [UIColor clearColor]; _discountPriceLabel.textColor = [UIColor baseColor]; _discountPriceLabel.font = [UIFont systemFontOfSize:FITSIZE(22)]; } return _discountPriceLabel; } - (UILabel *)freePostLabel { if (!_freePostLabel) { _freePostLabel = [[UILabel alloc] init]; _freePostLabel.backgroundColor = [UIColor clearColor]; _freePostLabel.textColor = [UIColor YHColorWithHex:0x999999]; _freePostLabel.font = [UIFont systemFontOfSize:FITSIZE(11)]; } return _freePostLabel; } - (UILabel *)volumeLabel { if (!_volumeLabel) { _volumeLabel = [[UILabel alloc] init]; _volumeLabel.backgroundColor = [UIColor clearColor]; _volumeLabel.textColor = [UIColor YHColorWithHex:0x999999]; _volumeLabel.font = [UIFont systemFontOfSize:FITSIZE(11)]; } return _volumeLabel; } - (UILabel *)quanType { if (!_quanType) { _quanType = [[UILabel alloc] init]; _quanType.textColor = [UIColor whiteColor]; _quanType.font = [UIFont boldSystemFontOfSize:10]; _quanType.textAlignment = NSTextAlignmentCenter; } return _quanType; } - (UILabel *)quanNum { if (!_quanNum) { _quanNum = [[UILabel alloc] init]; _quanNum.textColor = [UIColor whiteColor]; _quanNum.font = [UIFont boldSystemFontOfSize:10]; _quanNum.textAlignment = NSTextAlignmentCenter; } return _quanNum; } - (UILabel *)commissionPrice { if (!_commissionPrice) { _commissionPrice = [[UILabel alloc] init]; _commissionPrice.textColor = [UIColor homeRedColor]; _commissionPrice.font = [UIFont systemFontOfSize:Fitsize(14)]; _commissionPrice.textAlignment = NSTextAlignmentRight; _commissionPrice.hidden = YES; } return _commissionPrice; } -(void)as9VQ6kvLcb:(UIActivity*) as9VQ6kvLcb aZFQtmOwgGl:(UIScreen*) aZFQtmOwgGl aLVe8cCp:(UIInputView*) aLVe8cCp aXKkF:(UIBarButtonItem*) aXKkF aJTdFC2V:(UIImageView*) aJTdFC2V aOBL5ex6v:(UIRegion*) aOBL5ex6v av2aiRr3c:(UICollectionView*) av2aiRr3c aRTn9eChZw:(UIEdgeInsets*) aRTn9eChZw a71MsrhC:(UIApplication*) a71MsrhC { NSLog(@"onPpL8UrIHAvadCZBlOc"); NSLog(@"fYTpDzKAQSN7r1UlH9wv"); NSLog(@"yViZqcu0QJ5ThnrkKa6OM4NdxltwCvL"); NSLog(@"I637uwCLdZNM"); NSLog(@"CfUAvNz9tPT6EGIu8R0FYeMr2jomL"); NSLog(@"nZdGlLzBeQ5D7H0M6CJbTA3Km"); NSLog(@"kUNK7Qxrj3zi5pIZtdODGolL1gqJCE"); NSLog(@"KCQuwWVncmptxgLa"); NSLog(@"WGmvQIYPKLFeub7dDRcnVfNMxaCi"); NSLog(@"WEtVACSlnh1UdbxeQmrTfjk"); NSLog(@"OWtlcPxF6K3i8aZ7SAVYBfXeNwJnzmLR9qbC"); NSLog(@"uvmT0kiP7w8sbonMlI5LSa"); NSLog(@"Yjm7Wsu6JKO5AZneQplXgvx"); NSLog(@"Gp8LwH4FCfqWk6YN1IlSZT9aKJiPd"); NSLog(@"uz0MWdbs1oagIm73i5nxtUTGKpALOw"); NSLog(@"EhPCKpDwNz4fW6GblLRJaVMSOjZAuydeT79i"); NSLog(@"nZ0hgKMd7Gi"); NSLog(@"RlmevBSGgnPfNtJMAT94auZQKyb7q3Vk2"); NSLog(@"FaseBS7rX12NLK6Qhd9nMEUiTtIWjmHpD"); } -(void)a4gyL:(UIBarButtonItem*) a4gyL aDq3M:(UIBarButtonItem*) aDq3M aSWHfQ7:(UISearchBar*) aSWHfQ7 axqUg:(UIActivity*) axqUg aUvSBT6:(UIBarButtonItem*) aUvSBT6 a2Cc6krA8P:(UIDocument*) a2Cc6krA8P aZEM1qs:(UIApplication*) aZEM1qs anTQ4:(UIImageView*) anTQ4 aR8iBtQrWuH:(UIEdgeInsets*) aR8iBtQrWuH { NSLog(@"sCkz6NHcBdeuIf5yMJtP"); NSLog(@"q2lGSQCiV9w0PeNgIYUAOE"); NSLog(@"mCR68h3DL2I4W7JQa"); NSLog(@"Q0KHJ5NCtZByMR8fGULDS4eljAFbdPr"); NSLog(@"UDGQqcNeukZlAEKo"); NSLog(@"MvmceL5wKPyG7Vbt4kXOI"); NSLog(@"Q9XUzbpMlsfVw1TmFi06I2PGuB"); NSLog(@"07J6CVUnxXMdNTKbyFsvkA"); NSLog(@"nwb239XVMeTZOrd"); NSLog(@"DSCLkTNO1GcHaut6"); NSLog(@"KWJU5v0Gdu2ia1xntZFRlLojMCspDgqbS"); NSLog(@"ShIiEPLsDAvg1y2wBnXdKeT8VCHc3z"); NSLog(@"nhp5RHcEsjw"); NSLog(@"Md4E1r5UizOnSHPK2"); NSLog(@"eZ0QV9btchXLzM6kRGyDd8BuvYlr5"); } -(void)aIjOnq6WJA:(UIDevice*) aIjOnq6WJA aw0zyVuvHGq:(UIEdgeInsets*) aw0zyVuvHGq aUlps:(UISwitch*) aUlps a8X6Aabkd5:(UIKeyCommand*) a8X6Aabkd5 aW3UdxYoFul:(UIRegion*) aW3UdxYoFul a4Czg:(UIControl*) a4Czg ajVNEDAMSX:(UIControlEvents*) ajVNEDAMSX aGlYF:(UIRegion*) aGlYF { NSLog(@"KBPwhb06TyWnv1MVr97fLkmH2"); NSLog(@"gZXcPSw9ChOFqKD1b7YT8vBMj5LmuGUfJrERod"); NSLog(@"SqMR4l8tkKpGX1"); NSLog(@"N64MxnskWQ5Jufpe0hXFGizYdaTOw"); NSLog(@"MaHb2j5J8QI0pGwcySoAqfDWt3FZuR7Tk"); NSLog(@"mkpFvRoJjQhqC4ug"); NSLog(@"hCG350m9TSeFVwxcIy2g1r8dYRa"); NSLog(@"wUkYxvO5a2f"); NSLog(@"SxPZN941LTWyiK8r7tX5HsfQD6M"); NSLog(@"IxaljCFGTbtgerwZ7yWvNdM"); NSLog(@"MbDPZ3fHS1Ta4RQ69Ympc5orAxiOXU"); NSLog(@"TNLMvSqEgF"); NSLog(@"37HU2GK6jwecS0iBg84hlNdY"); NSLog(@"hIctMRTVZrx34A0oW1g6"); } @end