YBGoodsBriefView.m 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //
  2. // YBGoodsBriefView.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2020/8/31.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "YBGoodsBriefView.h"
  9. #import "YBGoodsInfoVC.h"
  10. #import "OutsideGoodsDetailVC.h"
  11. #import "CommodityDetailVC.h"
  12. @interface YBGoodsBriefView()
  13. @property(nonatomic,strong)UIView *bgView;
  14. @property(nonatomic,strong)UIImageView *thumbIV;
  15. @property(nonatomic,strong)UILabel *titleL;
  16. @property(nonatomic,strong)UILabel *priceL;
  17. @property(nonatomic,strong)UILabel *oldPriceL;
  18. @property(nonatomic,strong)UILabel *oldPLL;
  19. @property(nonatomic,strong)UIButton *infoBtn;
  20. @end
  21. @implementation YBGoodsBriefView
  22. - (instancetype)initWithFrame:(CGRect)frame {
  23. self = [super initWithFrame:frame];
  24. if (self) {
  25. [self addSubview:self.bgView];
  26. }
  27. return self;
  28. }
  29. - (void)setGoodsDic:(NSDictionary *)goodsDic {
  30. _goodsDic = goodsDic;
  31. [_thumbIV sd_setImageWithURL:[NSURL URLWithString:minstr([_goodsDic valueForKey:@"goods_thumb"])]];
  32. _titleL.text = minstr([_goodsDic valueForKey:@"goods_name"]);
  33. _priceL.text = minstr([_goodsDic valueForKey:@"goods_price"]);
  34. _oldPriceL.hidden = _oldPLL.hidden = YES;
  35. // NSString *oldPrice = minstr([_goodsDic valueForKey:@"goods_old_price"]);
  36. // if (![PublicObj checkNull:oldPrice]) {
  37. if ([minstr([_goodsDic valueForKey:@"goods_type"]) isEqual:@"1"]) {
  38. _oldPriceL.hidden = _oldPLL.hidden = NO;
  39. _oldPriceL.text = minstr([_goodsDic valueForKey:@"goods_old_price"]);
  40. }
  41. }
  42. - (UIView *)bgView {
  43. if (!_bgView) {
  44. _bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.width, self.height)];
  45. _bgView.backgroundColor = UIColor.whiteColor;
  46. _bgView.layer.cornerRadius = 5;
  47. _bgView.layer.masksToBounds = YES;
  48. _thumbIV = [[UIImageView alloc]init];
  49. _thumbIV.layer.cornerRadius = 2;
  50. _thumbIV.layer.masksToBounds = YES;
  51. _thumbIV.contentMode = UIViewContentModeScaleAspectFill;
  52. _thumbIV.clipsToBounds = YES;
  53. [_bgView addSubview:_thumbIV];
  54. [_thumbIV mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.left.equalTo(_bgView.mas_left).offset(8);
  56. make.height.mas_equalTo(_bgView.mas_height).offset(-20);
  57. make.centerY.equalTo(_bgView);
  58. make.width.equalTo(_thumbIV.mas_height);
  59. }];
  60. _titleL = [[UILabel alloc]init];
  61. _titleL.font = SYS_Font(12);
  62. _titleL.textColor = RGB_COLOR(@"#323232", 1);
  63. _titleL.numberOfLines = 2;
  64. [_bgView addSubview:_titleL];
  65. [_titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.equalTo(_thumbIV.mas_right).offset(8);
  67. make.top.equalTo(_thumbIV.mas_top).offset(2);
  68. make.right.equalTo(_bgView.mas_right).offset(-8);
  69. }];
  70. _priceL = [[UILabel alloc]init];
  71. _priceL.font = [UIFont boldSystemFontOfSize:13];
  72. _priceL.textColor = Pink_Cor;
  73. [_bgView addSubview:_priceL];
  74. [_priceL mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.left.equalTo(_titleL.mas_left);
  76. make.bottom.equalTo(_thumbIV.mas_bottom).offset(-2);
  77. }];
  78. _oldPriceL = [[UILabel alloc]init];
  79. _oldPriceL.font = SYS_Font(11);
  80. _oldPriceL.textColor = RGB_COLOR(@"#969696", 1);
  81. [_bgView addSubview:_oldPriceL];
  82. [_oldPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.left.equalTo(_priceL.mas_right).offset(10);
  84. make.bottom.equalTo(_priceL.mas_bottom);
  85. }];
  86. _oldPLL = [[UILabel alloc]init];
  87. _oldPLL.backgroundColor = _oldPriceL.textColor;
  88. [_bgView addSubview:_oldPLL];
  89. [_oldPLL mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.width.equalTo(_oldPriceL.mas_width).offset(5);
  91. make.centerY.centerX.equalTo(_oldPriceL);
  92. make.height.equalTo(@1);
  93. }];
  94. _infoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  95. [_infoBtn setTitle:YZMsg(@"去看看") forState:0];
  96. _infoBtn.titleLabel.font = SYS_Font(12);
  97. [_infoBtn setTitleColor:Pink_Cor forState:0];
  98. _infoBtn.layer.borderWidth = 1;
  99. _infoBtn.layer.cornerRadius = 12;
  100. _infoBtn.layer.borderColor = Pink_Cor.CGColor;
  101. _infoBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10);
  102. [_infoBtn addTarget:self action:@selector(clickInfoBtn) forControlEvents:UIControlEventTouchUpInside];
  103. [_bgView addSubview:_infoBtn];
  104. [_infoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.bottom.equalTo(_priceL);
  106. make.height.mas_equalTo(24);
  107. make.right.equalTo(_bgView.mas_right).offset(-10);
  108. }];
  109. }
  110. return _bgView;
  111. }
  112. -(void)clickInfoBtn {
  113. NSLog(@"goods--------:%@",_goodsDic);
  114. [PublicObj checkGoodsExistenceWithID:minstr([_goodsDic valueForKey:@"goodsid"]) Existence:^(int code, NSString *msg) {
  115. if (code ==0) {
  116. if ([minstr([_goodsDic valueForKey:@"goods_type"]) isEqual:@"1"]) {
  117. OutsideGoodsDetailVC *detail = [[OutsideGoodsDetailVC alloc]init];
  118. detail.goodsID = minstr([_goodsDic valueForKey:@"goodsid"]);
  119. detail.liveUid= _touserID;
  120. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:detail animated:YES];
  121. }else{
  122. CommodityDetailVC *detail = [[CommodityDetailVC alloc]init];
  123. detail.goodsID = minstr([_goodsDic valueForKey:@"goodsid"]);
  124. detail.backTags = @"live";
  125. detail.liveUid= _touserID;
  126. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:detail animated:YES];
  127. }
  128. }else{
  129. [MBProgressHUD showError:msg];
  130. }
  131. }];
  132. // YBGoodsInfoVC *infoVC = [[YBGoodsInfoVC alloc]init];
  133. // infoVC.infoType = InfoEnterType_OnSale;
  134. // infoVC.touserID = _touserID;
  135. // infoVC.goodsID = minstr([_goodsDic valueForKey:@"goodsid"]);
  136. // [[YBBaseAppDelegate sharedAppDelegate]pushViewController:infoVC animated:YES];
  137. }
  138. @end