新UI马甲包

HCGoodDetailBottomView.m 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // HCGoodDetailBottomView.m
  3. // hc
  4. //
  5. // Created by xiaoxi on 2018/1/25.
  6. // Copyright © 2018年 hc. All rights reserved.
  7. //
  8. #import "HCGoodDetailBottomView.h"
  9. #import "HCGoodDetailModel.h"
  10. @interface HCGoodDetailBottomView ()
  11. @end
  12. @implementation HCGoodDetailBottomView
  13. - (instancetype)initWithFrame:(CGRect)frame {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. [self initSubviews];
  17. }
  18. return self;
  19. }
  20. - (void)initSubviews {
  21. [self addSubview:self.collectButton];
  22. [self addSubview:self.buyButton];
  23. // [self addSubview:self.commissionButton];
  24. [self.collectButton mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.left.mas_equalTo(0);
  26. make.top.mas_equalTo(0);
  27. make.width.mas_equalTo(Fitsize(96));
  28. make.bottom.mas_equalTo(0);
  29. }];
  30. // [self.commissionButton mas_makeConstraints:^(MASConstraintMaker *make) {
  31. // make.left.mas_equalTo(self.collectButton.mas_right);
  32. // make.top.bottom.mas_equalTo(0);
  33. // make.width.mas_equalTo((SCREEN_WIDTH-Fitsize(96))/2);
  34. // }];
  35. [self.buyButton mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(self.collectButton.mas_right);
  37. make.top.bottom.mas_equalTo(0);
  38. make.right.mas_equalTo(0);
  39. }];
  40. }
  41. - (void)setGoodModel:(HCGoodDetailModel *)goodModel {
  42. _goodModel = goodModel;
  43. if ([goodModel.is_favorites isEqual:@1]) {
  44. self.collectButton.selected = YES;
  45. }
  46. else {
  47. self.collectButton.selected = NO;
  48. }
  49. [_commissionButton setTitle:@"马上分享" forState:UIControlStateNormal];
  50. _commissionButton.hidden=YES;
  51. [_buyButton setTitle:@"立即购买" forState:UIControlStateNormal];
  52. }
  53. - (void)buttonAction:(UIButton *)sender {
  54. //
  55. switch (sender.tag) {
  56. case 1:
  57. {
  58. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCollectButton)]) {
  59. [self.delegate yh_GoodDetailBottomViewClickCollectButton];
  60. }
  61. }
  62. break;
  63. case 2:
  64. {
  65. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCommissionButton)]) {
  66. [self.delegate yh_GoodDetailBottomViewClickCommissionButton];
  67. }
  68. }
  69. break;
  70. case 3:
  71. {
  72. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickBuyButton)]) {
  73. [self.delegate yh_GoodDetailBottomViewClickBuyButton];
  74. }
  75. }
  76. break;
  77. default:
  78. break;
  79. }
  80. }
  81. #pragma mark - lazy
  82. - (UIButton *)shopButton {
  83. if (!_shopButton) {
  84. _shopButton = [UIButton buttonWithType:UIButtonTypeCustom];
  85. _shopButton.backgroundColor = [UIColor clearColor];
  86. [_shopButton setTitleColor:[UIColor YHColorWithHex:0x444444] forState:UIControlStateNormal];
  87. _shopButton.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(10)];
  88. [_shopButton setTitle:@"店铺" forState:UIControlStateNormal];
  89. [_shopButton setImage:[UIImage imageNamed:@"detail_shop"] forState:UIControlStateNormal];
  90. [_shopButton setButtonStyle:WSLButtonStyleImageTop spacing:5];
  91. _shopButton.tag = 1;
  92. [_shopButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  93. }
  94. return _shopButton;
  95. }
  96. - (UIButton *)collectButton {
  97. if (!_collectButton) {
  98. _collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
  99. _collectButton.backgroundColor = [UIColor clearColor];
  100. [_collectButton setTitleColor:[UIColor YHColorWithHex:0x444444] forState:UIControlStateNormal];
  101. _collectButton.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(10)];
  102. [_collectButton setTitle:@"收藏" forState:UIControlStateNormal];
  103. [_collectButton setImage:[UIImage imageNamed:@"detail_collect"] forState:UIControlStateNormal];
  104. [_collectButton setImage:[UIImage imageNamed:@"detail_collect_selected"] forState:UIControlStateSelected];
  105. [_collectButton setButtonStyle:WSLButtonStyleImageTop spacing:5];
  106. _collectButton.tag = 1;
  107. [_collectButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  108. }
  109. return _collectButton;
  110. }
  111. - (UIButton *)buyButton {
  112. if (!_buyButton) {
  113. _buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
  114. _buyButton.backgroundColor = [UIColor homeRedColor];
  115. _buyButton.titleLabel.numberOfLines = 1;
  116. _buyButton.titleLabel.textAlignment = NSTextAlignmentCenter;
  117. _buyButton.tag = 3;
  118. [_buyButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  119. _buyButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  120. [_buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  121. }
  122. return _buyButton;
  123. }
  124. - (UIButton *)commissionButton {
  125. if (!_commissionButton) {
  126. _commissionButton = [UIButton buttonWithType:UIButtonTypeCustom];
  127. _commissionButton.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFEC800] toColor:[UIColor YHColorWithHex:0xFD9D03] withWidth:(SCREEN_WIDTH-Fitsize(90))/2];
  128. _commissionButton.titleLabel.textAlignment = NSTextAlignmentCenter;
  129. _commissionButton.tag = 2;
  130. [_commissionButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  131. _commissionButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  132. [_commissionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  133. }
  134. return _commissionButton;
  135. }
  136. @end