// // LDDetailGuideView.m // YouHuiProject // // Created by 小花 on 2018/7/13. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LDDetailGuideView.h" @implementation LDDetailGuideView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor whiteColor]; [self initSubViews]; } return self; } - (void)initSubViews { self.userInteractionEnabled=YES; _redView =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(15), FITSIZE(53))]; _redView.backgroundColor=[UIColor colorWithRed:255/255.0 green:244/255.0 blue:223/255.0 alpha:1.0]; _redView.layer.cornerRadius=FITSIZE(5); _redView.layer.masksToBounds=YES; UITapGestureRecognizer *redtap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(redtapImageView)]; [_redView addGestureRecognizer:redtap1]; self.redView.userInteractionEnabled=YES; [self addSubview:_redView]; UIImageView *rediconView =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(10), FITSIZE(16), FITSIZE(18))]; [rediconView setImage:[UIImage imageNamed:@"red_detail"]]; [self.redView addSubview:rediconView]; UILabel *redpriceL =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(30), FITSIZE(10), FITSIZE(200), FITSIZE(18))]; // redpriceL.text=@"xx元红包"; redpriceL.textColor=[UIColor YHColorWithHex:0x99520F]; redpriceL.font=[UIFont systemFontOfSize:FITSIZE(16)]; redpriceL.tag = 9999; [self.redView addSubview:redpriceL]; UILabel *redtiplabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(32), FITSIZE(130), FITSIZE(14))]; redtiplabel.font=[UIFont systemFontOfSize:FITSIZE(10)]; redtiplabel.textColor=[UIColor YHColorWithHex:0x99520F]; // redtiplabel.text=@"下单可得xx元红包"; redtiplabel.tag=8888; [self.redView addSubview:redtiplabel]; // UIImageView *rightIcon =[[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-FITSIZE(35), FITSIZE(35), FITSIZE(9), FITSIZE(8))]; // rightIcon.image=[UIImage imageNamed:@"detail_list"]; // [self.redView addSubview:rightIcon]; _leftView =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(15), FITSIZE(53))]; _leftView.backgroundColor=[UIColor colorWithRed:255/255.0 green:244/255.0 blue:223/255.0 alpha:1.0]; _leftView.layer.cornerRadius=FITSIZE(5); _leftView.layer.masksToBounds=YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView)]; [_leftView addGestureRecognizer:tap]; [self addSubview:_leftView]; UILabel *numlabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(8),FITSIZE(100), FITSIZE(22))]; numlabel.font=[UIFont systemFontOfSize:FITSIZE(16)]; // numlabel.text=@"返¥0.00"; numlabel.tag=2000; numlabel.textColor=[UIColor YHColorWithHex:0x99520F]; [_leftView addSubview:numlabel]; _leftView.userInteractionEnabled=YES; UILabel *tiplabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(32), FITSIZE(130), FITSIZE(14))]; tiplabel.font=[UIFont systemFontOfSize:FITSIZE(10)]; tiplabel.textColor=[UIColor YHColorWithHex:0x99520F]; tiplabel.text=@"自购和分享都有佣金"; [_leftView addSubview:tiplabel]; _rightview =[[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2+FITSIZE(5), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53))]; _rightview.image=[UIImage imageNamed:@"quan_short"]; _rightview.layer.cornerRadius=FITSIZE(3); _rightview.userInteractionEnabled=YES; _rightview.layer.masksToBounds=YES; [self addSubview:_rightview]; UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapbuyImageView)]; [_rightview addGestureRecognizer:tap1]; [self addSubview:_leftView]; UILabel *rightpricelabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(14), FITSIZE(8),FITSIZE(100), FITSIZE(22))]; rightpricelabel.font=[UIFont systemFontOfSize:FITSIZE(16)]; rightpricelabel.text=@"券 0.00元"; rightpricelabel.tag=1000; rightpricelabel.textColor=[UIColor YHColorWithHex:0xF5112A]; [_rightview addSubview:rightpricelabel]; UILabel *timelabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(14), FITSIZE(32), FITSIZE(130), FITSIZE(14))]; timelabel.font=[UIFont systemFontOfSize:FITSIZE(10)]; timelabel.textColor=[UIColor YHColorWithHex:0xF5112A]; timelabel.text=@"数量有限 先到先领"; timelabel.tag=1111; rightpricelabel.textAlignment=NSTextAlignmentLeft; timelabel.textAlignment=NSTextAlignmentLeft; [_rightview addSubview:timelabel]; self.leftView.hidden=YES; self.rightview.hidden=YES; } -(void)setModel:(LDGoodDetailModel *)model { _model=model; if (model == nil) { return; } UILabel *pirceLabel =[self.rightview viewWithTag:1000]; UILabel *label =[self.leftView viewWithTag:2000]; pirceLabel.text=[NSString stringWithFormat:@"券 %@元",model.coupon_price]; label.text=[NSString stringWithFormat:@"返 %.2f元",model.commission_price.floatValue]; UILabel *redPriceL =[self.redView viewWithTag:9999]; UILabel *redTipL =[self.redView viewWithTag:8888]; redPriceL.text=[NSString stringWithFormat:@"%ld元红包",(long)model.red_active_money.integerValue]; redTipL.text=[NSString stringWithFormat:@"下单可得%ld元红包",(long)model.red_active_money.integerValue]; if (![AccountTool isLogin]) {//没有登录不显示佣金 self.leftView.hidden=YES; if (model.red_active_status.integerValue ==1 && [model.is_coupon boolValue]) { self.rightview.frame=CGRectMake(FITSIZE(9)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); self.redView.hidden=NO; _leftView.hidden=YES;//佣金 self.rightview.hidden=NO;//券 }else if (model.red_active_status.integerValue == 1) {//红包有的时候,灭有佣金、灭有优惠券 self.redView.hidden = NO; self.rightview.hidden=YES; }else{//有券的时候 没红包、佣金 self.redView.hidden = YES; self.rightview.frame=CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); self.rightview.hidden=NO; } }else{//登录以后 if (model.red_active_status.integerValue == 1 && [model.is_coupon boolValue] && model.commission_price.floatValue>0) {//红包、佣金和优惠券都存在的时候 self.leftView.hidden=NO; self.rightview.hidden=NO; self.redView.hidden=NO; self.rightview.frame=CGRectMake(FITSIZE(9), FITSIZE(61), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); self.leftView.frame=CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(15), FITSIZE(53)); }else { if (model.red_active_status.integerValue == 0) {//红包不存在的时候 //判断优惠券和佣金存在的时候 if ([model.is_coupon boolValue] && model.commission_price.floatValue>0) {//都存在的时候 _leftView.hidden=NO; self.redView.hidden=YES; self.rightview.hidden=NO; self.leftView.frame=CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); self.rightview.frame=CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); }else if ([model.is_coupon boolValue] )//只有优惠券的时候 { self.rightview.frame=CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); _leftView.hidden=YES; self.redView.hidden=YES; self.rightview.hidden=NO; }else if (model.commission_price.floatValue>0){//只有佣金的时候 self.leftView.hidden=NO; self.rightview.hidden=YES; self.redView.hidden=YES; self.leftView.frame=CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); } }else{//红包存在的时候 self.redView.hidden=NO; if ([model.is_coupon boolValue] && model.commission_price.floatValue>0) {//都存在的时候 _leftView.hidden=NO; self.rightview.hidden=NO; self.leftView.frame=CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); self.rightview.frame=CGRectMake(FITSIZE(9), FITSIZE(61), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); }else if ([model.is_coupon boolValue] )//只有优惠券的时候 { self.rightview.frame=CGRectMake(FITSIZE(9)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); _leftView.hidden=YES; self.rightview.hidden=NO; }else if (model.commission_price.floatValue>0){//只有佣金的时候 self.leftView.hidden=NO; self.rightview.hidden=YES; self.leftView.frame=CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53)); } } } } } - (void)tapViewAction { [MobClick event:GoodsDetailVipInfo]; if (self.tapAction) { self.tapAction(); } } //红包h5交互 -(void)redtapImageView { if ([self.delegate respondsToSelector:@selector(redClickPage)]) { [self.delegate redClickPage]; } } //跳转 -(void)tapImageView { if ([self.delegate respondsToSelector:@selector(commisionClickPage)]) { [self.delegate commisionClickPage]; } } //购买 -(void)tapbuyImageView { if ([self.delegate respondsToSelector:@selector(goBuyWithModel:)]) { [self.delegate goBuyWithModel:_model]; } } @end