// // LDGoodDetailBottomView.m // YouHuiProject // // Created by xiaoxi on 2018/1/25. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LDGoodDetailBottomView.h" #import "LDGoodDetailModel.h" @interface LDGoodDetailBottomView () @end @implementation LDGoodDetailBottomView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]; [self initSubviews]; } return self; } - (void)initSubviews { [self addSubview:self.buyButton]; [self addSubview:self.commissionButton]; self.commissionButton.frame=CGRectMake(FITSIZE(10), FITSIZE(8), (SCREEN_WIDTH-Fitsize(20))/2, FITSIZE(39)); self.buyButton.frame=CGRectMake((SCREEN_WIDTH-Fitsize(20))/2+FITSIZE(10), FITSIZE(8), (SCREEN_WIDTH-Fitsize(20))/2, FITSIZE(39)); if (![AccountTool isLogin]) {//没有登录的时候 [_commissionButton setTitle:@"直接购买" forState:UIControlStateNormal]; [_buyButton setTitle:@"领红包购买" forState:UIControlStateNormal]; [_buyButton setImage:nil forState:UIControlStateNormal]; [_commissionButton setImage:[UIImage imageNamed:@"quan-2"] forState:UIControlStateNormal]; }else{ [_commissionButton setTitle:@"分享赚钱" forState:UIControlStateNormal]; [_buyButton setTitle:@"购物省钱" forState:UIControlStateNormal]; [_buyButton setImage:[UIImage imageNamed:@"Shape"] forState:UIControlStateNormal]; [_commissionButton setImage:[UIImage imageNamed:@"fenxiang-3"] forState:UIControlStateNormal]; } // 设置圆角 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.buyButton.bounds byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight cornerRadii:CGSizeMake(FITSIZE(19.5), FITSIZE(19.5))]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = self.buyButton.bounds; maskLayer.path = maskPath.CGPath; self.buyButton.layer.mask = maskLayer; // 设置圆角 UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:self.commissionButton.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(FITSIZE(19.5), FITSIZE(19.5))]; CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init]; maskLayer1.frame = self.commissionButton.bounds; maskLayer1.path = maskPath1.CGPath; self.commissionButton.layer.mask = maskLayer1; } - (void)setGoodModel:(LDGoodDetailModel *)goodModel { _goodModel = goodModel; if (![AccountTool isLogin]) {//没有登录的时候 if (goodModel.red_active_status.integerValue == 1) { [_buyButton setTitle:@"领红包购买" forState:UIControlStateNormal]; [_buyButton setImage:[UIImage imageNamed:@"red_detai1"] forState:UIControlStateNormal]; }else{ [_buyButton setTitle:@"返佣金购买" forState:UIControlStateNormal]; [_buyButton setImage:[UIImage imageNamed:@"Shape"] forState:UIControlStateNormal]; } [_commissionButton setTitle:@"直接购买" forState:UIControlStateNormal]; [_commissionButton setImage:[UIImage imageNamed:@"quan-2"] forState:UIControlStateNormal]; }else{ [_commissionButton setTitle:@"分享赚钱" forState:UIControlStateNormal]; [_buyButton setTitle:@"购物省钱" forState:UIControlStateNormal]; [_buyButton setImage:[UIImage imageNamed:@"Shape"] forState:UIControlStateNormal]; [_commissionButton setImage:[UIImage imageNamed:@"fenxiang-3"] forState:UIControlStateNormal]; } //过审 if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) { [_commissionButton setTitle:@"分享" forState:UIControlStateNormal]; [_buyButton setTitle:@"购物省钱" forState:UIControlStateNormal]; } } - (void)buttonAction:(UIButton *)sender { // switch (sender.tag) { case 1: { if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCollectButton)]) { [self.delegate yh_GoodDetailBottomViewClickCollectButton]; } } break; case 2: { if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCommissionButton)]) { [self.delegate yh_GoodDetailBottomViewClickCommissionButton]; } } break; case 3: { if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickBuyButton)]) { [self.delegate yh_GoodDetailBottomViewClickBuyButton]; } } break; default: break; } } #pragma mark - lazy - (UIButton *)buyButton { if (!_buyButton) { _buyButton = [UIButton buttonWithType:UIButtonTypeCustom]; _buyButton.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF7400] toColor:[UIColor YHColorWithHex:0xFF4A00] withWidth:(SCREEN_WIDTH-Fitsize(18))/2]; _buyButton.titleLabel.numberOfLines = 1; _buyButton.titleLabel.textAlignment = NSTextAlignmentCenter; _buyButton.tag = 3; [_buyButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; _buyButton.titleLabel.font = [UIFont boldSystemFontOfSize:14]; [_buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [_buyButton setImage:[UIImage imageNamed:@"Shape"] forState:UIControlStateNormal]; [_buyButton setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(7), FITSIZE(38), FITSIZE(7), (SCREEN_WIDTH-Fitsize(20))/2-FITSIZE(74))]; } return _buyButton; } - (UIButton *)commissionButton { if (!_commissionButton) { _commissionButton = [UIButton buttonWithType:UIButtonTypeCustom]; _commissionButton.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFFCA00] toColor:[UIColor YHColorWithHex:0xFF9802] withWidth:(SCREEN_WIDTH-Fitsize(18))/2]; _commissionButton.titleLabel.textAlignment = NSTextAlignmentCenter; _commissionButton.tag = 2; [_commissionButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; _commissionButton.titleLabel.font = [UIFont boldSystemFontOfSize:14]; [_commissionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [_commissionButton setImage:[UIImage imageNamed:@"fenxiang-3"] forState:UIControlStateNormal]; [_commissionButton setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(10), FITSIZE(43), FITSIZE(9), (SCREEN_WIDTH-Fitsize(20))/2-FITSIZE(67))]; } return _commissionButton; } @end