// // GoodsDetailSrcView.m // Asteria // // Created by 王猛 on 2023/5/8. // #import "GoodsDetailSrcView.h" #import "WKM_goodsBanner.h" #import "GoodsDetailsPayV.h" #import "GoodsDetailsIntroduceV.h" @interface GoodsDetailSrcView () @property (nonatomic, strong) GoodsInformationM *infoModel; @property (nonatomic, strong) WKM_goodsBanner *goodsBanner; @property (nonatomic, strong) QMUILabel *titleLab; @property (nonatomic, strong) QMUILabel *soldLab; @property (nonatomic, strong) QMUILabel *reviewsLab; @property (nonatomic, strong) QMUILabel *priceLab; @property (nonatomic, strong) QMUILabel *saveLab; @property (nonatomic, strong) QMUILabel *couponLab; @property (nonatomic, strong) QMUILabel *sizeLab; @property (nonatomic, strong) GoodsDetailsPayV *datails_payV; @property (nonatomic, strong) GoodsDetailsIntroduceV *datails_IntroduceV; @end @implementation GoodsDetailSrcView - (void)tt_addsubviewS{ [self addSubview:self.goodsBanner]; [self addSubview:self.titleLab]; [self addSubview:self.soldLab]; [self addSubview:self.reviewsLab]; [self addSubview:self.priceLab]; [self addSubview:self.saveLab]; [self addSubview:self.couponLab]; [self addSubview:self.sizeLab]; [self addSubview:self.datails_payV]; [self addSubview:self.datails_IntroduceV]; [self.goodsBanner mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.mas_equalTo(0); make.width.mas_equalTo(KScreenWidth); make.height.mas_equalTo(KScreenWidth+112+10); }]; [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.width.mas_equalTo(KScreenWidth-20); make.top.equalTo(self.goodsBanner.mas_bottom).offset(20); make.height.mas_equalTo(45); }]; [self.soldLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.height.mas_equalTo(16); make.top.equalTo(self.titleLab.mas_bottom).offset(10); }]; [self.reviewsLab mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.titleLab.mas_right); make.height.mas_equalTo(16); make.top.equalTo(self.titleLab.mas_bottom).offset(10); }]; [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.equalTo(self.reviewsLab.mas_bottom).offset(20); make.height.mas_equalTo(24); }]; [self.saveLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.priceLab.mas_right).offset(10); make.height.mas_equalTo(20); make.centerY.equalTo(self.priceLab); }]; [self.couponLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.equalTo(self.priceLab.mas_bottom).offset(20); make.width.mas_equalTo(KScreenWidth-20); make.height.mas_equalTo(45); }]; [self.sizeLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.equalTo(self.couponLab.mas_bottom).offset(10); make.width.mas_equalTo(KScreenWidth-20); make.height.mas_equalTo(45); }]; [self.datails_payV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.equalTo(self.sizeLab.mas_bottom).offset(10); make.width.mas_equalTo(KScreenWidth-20); make.height.mas_equalTo(78); }]; [self.datails_IntroduceV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.equalTo(self.datails_payV.mas_bottom).offset(10); make.width.mas_equalTo(KScreenWidth-20); make.height.mas_equalTo(120); }]; } - (void)tt_configData:(id)data{ GoodsInformationM *model = (GoodsInformationM *)data; self.infoModel = model; [self.goodsBanner tt_confignewdata:model]; self.titleLab.text =MM_str(model.name); //wm_todo soldLab\ reviewsLab\ coupon 和 size self.soldLab.text = [NSString stringWithFormat:@"SOLD: %@",model.sold] ; NSMutableAttributedString *reviewsStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"REVIEWS:%@",model.review_nums]]; NSRange contentRange = {0,[reviewsStr length]}; [reviewsStr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange]; self.reviewsLab.attributedText = reviewsStr; self.reviewsLab.textAlignment = NSTextAlignmentRight; NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol,model.final_prices]]; [priceAtr addAttribute: NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#0B0B0B"] range:NSMakeRange(0, priceAtr.length)]; [priceAtr addAttribute:NSFontAttributeName value:[UIFont fontWithName:Rob_Bold size:20] range:NSMakeRange(0, priceAtr.length)]; NSString *saveStr = @""; if(model.final_prices == model.price){ self.saveLab.hidden = YES; }else{ self.saveLab.hidden = NO; double savePrice = [model.price doubleValue]-[model.final_prices doubleValue]; saveStr = [NSString stringWithFormat:@"Save %@%.2f",model.currency_symbol,savePrice]; [priceAtr yy_appendString:@" "]; NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",model.price]]; priceAtrSub1.yy_color = [UIColor colorWithHexString:@"#8c8c8c"]; priceAtrSub1.yy_font = [UIFont fontWithName:Rob_Regular size:14]; priceAtrSub1.yy_strikethroughStyle = NSUnderlineStyleSingle; [priceAtr appendAttributedString:priceAtrSub1]; } self.priceLab.attributedText = priceAtr; self.saveLab.text = saveStr; self.datails_payV.titleLab.text = [NSString stringWithFormat:@"Pay in 4 interest-free payments of %@%.2f with",model.currency_symbol,[model.final_prices floatValue]/4]; } #pragma mark - **************** handle **************** -(void)tap_sizeLab{ ///展开size 规格选择的页面 } -(void)handle_couponEvent:(UIButton *)btn{ //wm_todo btn.selected = !btn.selected; } - (WKM_goodsBanner *)goodsBanner { if (!_goodsBanner) { _goodsBanner = [[WKM_goodsBanner alloc] init]; } return _goodsBanner; } - (QMUILabel *)titleLab { if (!_titleLab) { _titleLab = [[QMUILabel alloc] initWithFrame:CGRectZero]; _titleLab.textAlignment = NSTextAlignmentLeft; _titleLab.numberOfLines = 2; _titleLab.textColor = [UIColor colorWithHexString:@"#000000"]; _titleLab.font = [UIFont fontWithName:Rob_Bold size:16]; } return _titleLab; } - (QMUILabel *)soldLab { if (!_soldLab) { _soldLab = [[QMUILabel alloc] initWithFrame:CGRectZero]; _soldLab.textAlignment = NSTextAlignmentLeft; _soldLab.textColor = [UIColor colorWithHexString:@"#666666"]; _soldLab.font = [UIFont systemFontOfSize:12]; } return _soldLab; } - (QMUILabel *)reviewsLab { if (!_reviewsLab) { _reviewsLab = [[QMUILabel alloc] initWithFrame:CGRectZero]; _reviewsLab.textAlignment = NSTextAlignmentRight; _reviewsLab.textColor = [UIColor colorWithHexString:@"#666666"]; _reviewsLab.font = [UIFont fontWithName:Rob_Regular size:12]; // reviewsStr.underlineStyle = NSUnderlineStyleSingle; } return _reviewsLab; } - (QMUILabel *)priceLab { if (!_priceLab) { _priceLab = [[QMUILabel alloc] initWithFrame:CGRectZero]; _priceLab.textAlignment = NSTextAlignmentLeft; _priceLab.textColor = [UIColor blackColor]; _priceLab.font = [UIFont systemFontOfSize:18]; } return _priceLab; } - (QMUILabel *)saveLab { if (!_saveLab) { _saveLab = [[QMUILabel alloc] initWithFrame:CGRectZero]; _saveLab.contentEdgeInsets= UIEdgeInsetsMake(10, 10, 10, 10); _saveLab.backgroundColor = [UIColor colorWithHexString:@"#E0FFF5"]; _saveLab.textAlignment = NSTextAlignmentCenter; _saveLab.textColor = [UIColor colorWithHexString:@"#113632"]; _saveLab.font = [UIFont fontWithName:Rob_Bold size:12]; } return _saveLab; } - (QMUILabel *)couponLab { if (!_couponLab) { _couponLab = [[QMUILabel alloc] initWithFrame:CGRectZero]; _couponLab.mj_size = CGSizeMake(KScreenWidth-20, 45); _couponLab.backgroundColor = [UIColor colorWithHexString:@"#113632"]; _couponLab.textAlignment = NSTextAlignmentLeft; _couponLab.textColor = [UIColor colorWithHexString:@"#FFFFFF"]; _couponLab.font = [UIFont fontWithName:Rob_Bold size:14]; _couponLab.text = @"COUPON"; _couponLab.layer.cornerRadius = 4; _couponLab.clipsToBounds = YES; _couponLab.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0); UIButton *btn = [[UIButton alloc]init]; btn.selected = NO; [btn addTarget:self action:@selector(handle_couponEvent:) forControlEvents:UIControlEventTouchUpInside]; btn.frame = CGRectMake(_couponLab.mj_w-45-10, 0, 45, 45); [btn setImage:[UIImage imageNamed:@"base_add_white"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"base_subtract_white"] forState:UIControlStateSelected]; [_couponLab addSubview:btn]; } return _couponLab; } - (QMUILabel *)sizeLab { if (!_sizeLab) { _sizeLab = [[QMUILabel alloc] initWithFrame:CGRectZero]; _sizeLab.mj_size = CGSizeMake(KScreenWidth-20, 45); _sizeLab.backgroundColor = [UIColor colorWithHexString:@"#113632"]; _sizeLab.textAlignment = NSTextAlignmentLeft; _sizeLab.textColor = [UIColor colorWithHexString:@"#FFFFFF"]; _sizeLab.font = [UIFont fontWithName:Rob_Bold size:14]; _sizeLab.text = @"Size Selection"; _sizeLab.layer.cornerRadius = 4; _sizeLab.clipsToBounds = YES; _sizeLab.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0); UIImageView *imgV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"base_add_white"]]; imgV.frame = CGRectMake(_sizeLab.mj_w-45-10, 0, 45, 45); imgV.userInteractionEnabled = YES; imgV.contentMode = UIViewContentModeCenter; [_sizeLab addSubview:imgV]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap_sizeLab)]; [_sizeLab addGestureRecognizer:tap]; } return _sizeLab; } -(GoodsDetailsPayV *)datails_payV{ if (!_datails_payV) { _datails_payV = [[GoodsDetailsPayV alloc]initWithFrame:CGRectMake(10, 0, KScreenWidth-20, 78)]; _datails_payV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"]; _datails_payV.layer.cornerRadius = 4; _datails_payV.clipsToBounds = YES; } return _datails_payV; } - (GoodsDetailsIntroduceV *)datails_IntroduceV { if (!_datails_IntroduceV) { _datails_IntroduceV = [[GoodsDetailsIntroduceV alloc] initWithFrame:CGRectMake(10, 0, KScreenWidth-20, 120)]; _datails_IntroduceV.backgroundColor = _F5F5F5; _datails_IntroduceV.clipsToBounds = YES; } return _datails_IntroduceV; } @end