省钱达人

DRGoodDetailBottomView.m 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. //
  2. // DRGoodDetailBottomView.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/25.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRGoodDetailBottomView.h"
  9. #import "DRGoodDetailModel.h"
  10. @interface DRGoodDetailBottomView ()
  11. @end
  12. @implementation DRGoodDetailBottomView
  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.commissionButton.mas_right);
  37. make.top.bottom.mas_equalTo(0);
  38. make.right.mas_equalTo(0);
  39. }];
  40. }
  41. - (void)setGoodModel:(DRGoodDetailModel *)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. // NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥%@", goodModel.discount_price] attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:FITSIZE(20)],NSForegroundColorAttributeName:[UIColor whiteColor]}];
  50. // NSAttributedString *att1 = [[NSAttributedString alloc] initWithString:@"去领券¥\n" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:FITSIZE(11)],NSForegroundColorAttributeName:[UIColor whiteColor]}];
  51. // [att appendAttributedString:att1];
  52. // [_buyButton setAttributedTitle:att forState:UIControlStateNormal];
  53. // NSString *isCoup =@"";
  54. //
  55. // if ([self.goodModel.is_coupon integerValue]==1) {
  56. // isCoup=@"领券购";
  57. // }else{
  58. // isCoup=@"优惠购";
  59. // }
  60. // NSString *price=[NSString stringWithFormat:@"%@¥%.2f",isCoup,[goodModel.discount_price floatValue]];
  61. // [_buyButton setTitle:price forState:UIControlStateNormal];
  62. // if ([AccountTool isLogin]&&![@"" isEqualToString:self.goodModel.commission_price]) {
  63. // NSString *price2 = [NSString stringWithFormat:@"立即购买"];
  64. // [_commissionButton setTitle:price2 forState:UIControlStateNormal];
  65. // }else{
  66. // NSString *price2 = [NSString stringWithFormat:@"马上分享"];
  67. // [_commissionButton setTitle:price2 forState:UIControlStateNormal];
  68. // }
  69. [_commissionButton setTitle:@"马上分享" forState:UIControlStateNormal];
  70. [_buyButton setTitle:@"立即购买" forState:UIControlStateNormal];
  71. }
  72. - (void)buttonAction:(UIButton *)sender {
  73. //
  74. switch (sender.tag) {
  75. case 1:
  76. {
  77. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCollectButton)]) {
  78. [self.delegate yh_GoodDetailBottomViewClickCollectButton];
  79. }
  80. }
  81. break;
  82. case 2:
  83. {
  84. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCommissionButton)]) {
  85. [self.delegate yh_GoodDetailBottomViewClickCommissionButton];
  86. }
  87. }
  88. break;
  89. case 3:
  90. {
  91. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickBuyButton)]) {
  92. [self.delegate yh_GoodDetailBottomViewClickBuyButton];
  93. }
  94. }
  95. break;
  96. default:
  97. break;
  98. }
  99. }
  100. #pragma mark - lazy
  101. - (UIButton *)shopButton {
  102. if (!_shopButton) {
  103. _shopButton = [UIButton buttonWithType:UIButtonTypeCustom];
  104. _shopButton.backgroundColor = [UIColor clearColor];
  105. [_shopButton setTitleColor:[UIColor YHColorWithHex:0x444444] forState:UIControlStateNormal];
  106. _shopButton.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(10)];
  107. [_shopButton setTitle:@"店铺" forState:UIControlStateNormal];
  108. [_shopButton setImage:[UIImage imageNamed:@"detail_shop"] forState:UIControlStateNormal];
  109. [_shopButton setButtonStyle:WSLButtonStyleImageTop spacing:5];
  110. _shopButton.tag = 1;
  111. [_shopButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  112. }
  113. return _shopButton;
  114. }
  115. - (UIButton *)collectButton {
  116. if (!_collectButton) {
  117. _collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
  118. _collectButton.backgroundColor = [UIColor clearColor];
  119. [_collectButton setTitleColor:[UIColor YHColorWithHex:0x444444] forState:UIControlStateNormal];
  120. _collectButton.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(10)];
  121. [_collectButton setTitle:@"收藏" forState:UIControlStateNormal];
  122. [_collectButton setImage:[UIImage imageNamed:@"detail_collect"] forState:UIControlStateNormal];
  123. [_collectButton setImage:[UIImage imageNamed:@"detail_collect_selected"] forState:UIControlStateSelected];
  124. [_collectButton setButtonStyle:WSLButtonStyleImageTop spacing:5];
  125. _collectButton.tag = 1;
  126. [_collectButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  127. }
  128. return _collectButton;
  129. }
  130. - (UIButton *)buyButton {
  131. if (!_buyButton) {
  132. _buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
  133. _buyButton.backgroundColor = [UIColor homeRedColor];
  134. _buyButton.titleLabel.numberOfLines = 1;
  135. _buyButton.titleLabel.textAlignment = NSTextAlignmentCenter;
  136. _buyButton.tag = 3;
  137. [_buyButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  138. _buyButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  139. [_buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  140. }
  141. return _buyButton;
  142. }
  143. - (UIButton *)commissionButton {
  144. if (!_commissionButton) {
  145. _commissionButton = [UIButton buttonWithType:UIButtonTypeCustom];
  146. _commissionButton.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFEC800] toColor:[UIColor YHColorWithHex:0xFD9D03] withWidth:(SCREEN_WIDTH-Fitsize(90))/2];
  147. _commissionButton.titleLabel.textAlignment = NSTextAlignmentCenter;
  148. _commissionButton.tag = 2;
  149. [_commissionButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  150. _commissionButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  151. [_commissionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  152. }
  153. return _commissionButton;
  154. }
  155. @end