猎豆优选

LDGoodDetailBottomView.m 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //
  2. // LDGoodDetailBottomView.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/25.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDGoodDetailBottomView.h"
  9. #import "LDGoodDetailModel.h"
  10. @interface LDGoodDetailBottomView ()
  11. @end
  12. @implementation LDGoodDetailBottomView
  13. - (instancetype)initWithFrame:(CGRect)frame {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. self.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
  17. [self initSubviews];
  18. }
  19. return self;
  20. }
  21. - (void)initSubviews {
  22. [self addSubview:self.buyButton];
  23. [self addSubview:self.commissionButton];
  24. self.commissionButton.frame=CGRectMake(FITSIZE(10), FITSIZE(8), (SCREEN_WIDTH-Fitsize(20))/2, FITSIZE(39));
  25. self.buyButton.frame=CGRectMake((SCREEN_WIDTH-Fitsize(20))/2+FITSIZE(10), FITSIZE(8), (SCREEN_WIDTH-Fitsize(20))/2, FITSIZE(39));
  26. if (![AccountTool isLogin]) {//没有登录的时候
  27. [_commissionButton setTitle:@"直接购买" forState:UIControlStateNormal];
  28. [_buyButton setTitle:@"领红包购买" forState:UIControlStateNormal];
  29. [_buyButton setImage:nil forState:UIControlStateNormal];
  30. [_commissionButton setImage:[UIImage imageNamed:@"quan-2"] forState:UIControlStateNormal];
  31. }else{
  32. [_commissionButton setTitle:@"分享赚钱" forState:UIControlStateNormal];
  33. [_buyButton setTitle:@"购物省钱" forState:UIControlStateNormal];
  34. [_buyButton setImage:[UIImage imageNamed:@"Shape"] forState:UIControlStateNormal];
  35. [_commissionButton setImage:[UIImage imageNamed:@"fenxiang-3"] forState:UIControlStateNormal];
  36. }
  37. // 设置圆角
  38. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.buyButton.bounds byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight cornerRadii:CGSizeMake(FITSIZE(19.5), FITSIZE(19.5))];
  39. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  40. maskLayer.frame = self.buyButton.bounds;
  41. maskLayer.path = maskPath.CGPath;
  42. self.buyButton.layer.mask = maskLayer;
  43. // 设置圆角
  44. UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:self.commissionButton.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(FITSIZE(19.5), FITSIZE(19.5))];
  45. CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
  46. maskLayer1.frame = self.commissionButton.bounds;
  47. maskLayer1.path = maskPath1.CGPath;
  48. self.commissionButton.layer.mask = maskLayer1;
  49. }
  50. - (void)setGoodModel:(LDGoodDetailModel *)goodModel {
  51. _goodModel = goodModel;
  52. if (![AccountTool isLogin]) {//没有登录的时候
  53. if (goodModel.red_active_status.integerValue == 1) {
  54. [_buyButton setTitle:@"领红包购买" forState:UIControlStateNormal];
  55. [_buyButton setImage:[UIImage imageNamed:@"red_detai1"] forState:UIControlStateNormal];
  56. }else{
  57. [_buyButton setTitle:@"返佣金购买" forState:UIControlStateNormal];
  58. [_buyButton setImage:[UIImage imageNamed:@"Shape"] forState:UIControlStateNormal];
  59. }
  60. [_commissionButton setTitle:@"直接购买" forState:UIControlStateNormal];
  61. [_commissionButton setImage:[UIImage imageNamed:@"quan-2"] forState:UIControlStateNormal];
  62. }else{
  63. [_commissionButton setTitle:@"分享赚钱" forState:UIControlStateNormal];
  64. [_buyButton setTitle:@"购物省钱" forState:UIControlStateNormal];
  65. [_buyButton setImage:[UIImage imageNamed:@"Shape"] forState:UIControlStateNormal];
  66. [_commissionButton setImage:[UIImage imageNamed:@"fenxiang-3"] forState:UIControlStateNormal];
  67. }
  68. //过审
  69. if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
  70. [_commissionButton setTitle:@"分享" forState:UIControlStateNormal];
  71. [_buyButton setTitle:@"购物省钱" forState:UIControlStateNormal];
  72. }
  73. }
  74. - (void)buttonAction:(UIButton *)sender {
  75. //
  76. switch (sender.tag) {
  77. case 1:
  78. {
  79. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCollectButton)]) {
  80. [self.delegate yh_GoodDetailBottomViewClickCollectButton];
  81. }
  82. }
  83. break;
  84. case 2:
  85. {
  86. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCommissionButton)]) {
  87. [self.delegate yh_GoodDetailBottomViewClickCommissionButton];
  88. }
  89. }
  90. break;
  91. case 3:
  92. {
  93. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickBuyButton)]) {
  94. [self.delegate yh_GoodDetailBottomViewClickBuyButton];
  95. }
  96. }
  97. break;
  98. default:
  99. break;
  100. }
  101. }
  102. #pragma mark - lazy
  103. - (UIButton *)buyButton {
  104. if (!_buyButton) {
  105. _buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
  106. _buyButton.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF7400] toColor:[UIColor YHColorWithHex:0xFF4A00] withWidth:(SCREEN_WIDTH-Fitsize(18))/2];
  107. _buyButton.titleLabel.numberOfLines = 1;
  108. _buyButton.titleLabel.textAlignment = NSTextAlignmentCenter;
  109. _buyButton.tag = 3;
  110. [_buyButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  111. _buyButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  112. [_buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  113. [_buyButton setImage:[UIImage imageNamed:@"Shape"] forState:UIControlStateNormal];
  114. [_buyButton setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(7), FITSIZE(38), FITSIZE(7), (SCREEN_WIDTH-Fitsize(20))/2-FITSIZE(74))];
  115. }
  116. return _buyButton;
  117. }
  118. - (UIButton *)commissionButton {
  119. if (!_commissionButton) {
  120. _commissionButton = [UIButton buttonWithType:UIButtonTypeCustom];
  121. _commissionButton.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFFCA00] toColor:[UIColor YHColorWithHex:0xFF9802] withWidth:(SCREEN_WIDTH-Fitsize(18))/2];
  122. _commissionButton.titleLabel.textAlignment = NSTextAlignmentCenter;
  123. _commissionButton.tag = 2;
  124. [_commissionButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  125. _commissionButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  126. [_commissionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  127. [_commissionButton setImage:[UIImage imageNamed:@"fenxiang-3"] forState:UIControlStateNormal];
  128. [_commissionButton setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(10), FITSIZE(43), FITSIZE(9), (SCREEN_WIDTH-Fitsize(20))/2-FITSIZE(67))];
  129. }
  130. return _commissionButton;
  131. }
  132. @end