ShopGoodsTableViewCell.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // ShopGoodsTableViewCell.m
  3. // UIAuctionShop
  4. //
  5. // Created by 王珂 on 16/9/18.
  6. // Copyright © 2016年 qhy. All rights reserved.
  7. //
  8. #import "ShopGoodsTableViewCell.h"
  9. #import "ShopGoodsModel.h"
  10. #import "ShopGoodsUIView.h"
  11. @interface ShopGoodsTableViewCell()
  12. {
  13. NetHttpsManager *_httpsManager;
  14. }
  15. @property (weak, nonatomic) IBOutlet UIImageView *goodsView;
  16. @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
  17. @property (weak, nonatomic) IBOutlet UILabel *desLabel;
  18. @property (weak, nonatomic) IBOutlet UILabel *priceLabel;
  19. @property (weak, nonatomic) IBOutlet UIButton *toPushButton;
  20. @property (weak, nonatomic) IBOutlet UILabel *lineLabel;
  21. @end
  22. @implementation ShopGoodsTableViewCell
  23. + (instancetype)cellWithTableView:(UITableView *)tableView
  24. {
  25. static NSString *ID = @"ShopGoodsTableViewCell";
  26. ShopGoodsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:ID];
  27. if (cell== nil) {
  28. cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([ShopGoodsTableViewCell class]) owner:nil options:nil] lastObject];;
  29. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  30. }
  31. return cell;
  32. }
  33. - (void)awakeFromNib
  34. {
  35. [super awakeFromNib];
  36. _goodsView.clipsToBounds = YES;
  37. _titleLabel.font = kAppMiddleTextFont;
  38. _titleLabel.textColor = kAppGrayColor1;
  39. _desLabel.textColor = kAppGrayColor3;
  40. _desLabel.hidden = YES;
  41. _desLabel.font = kAppSmallTextFont;
  42. _priceLabel.textColor = kAppGrayColor1;
  43. _priceLabel.font = kAppSmallTextFont;
  44. _toPushButton.layer.cornerRadius = 13;
  45. _toPushButton.layer.masksToBounds = YES;
  46. _toPushButton.backgroundColor = kAppMainColor;
  47. [_toPushButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
  48. [_toPushButton setTitle:ASLocalizedString(@"编辑")forState:UIControlStateNormal];
  49. _toPushButton.titleLabel.font = kAppSmallTextFont;
  50. _lineLabel.backgroundColor = kAppSpaceColor;
  51. }
  52. - (void)setModel:(ShopGoodsModel *)model
  53. {
  54. _model = model;
  55. if (model.type==0)
  56. {
  57. [_toPushButton setTitle:ASLocalizedString(@"推送")forState:UIControlStateNormal];
  58. _toPushButton.hidden = NO;
  59. }
  60. else if (model.type==1)
  61. {
  62. _toPushButton.hidden = YES;
  63. [self.toPushButton setTitle:ASLocalizedString(@"购买")forState:UIControlStateNormal];
  64. }
  65. [_goodsView sd_setImageWithURL:[NSURL URLWithString:model.imgs[0]] placeholderImage:[UIImage imageNamed:@"DefaultImg"]];
  66. _titleLabel.text = model.name;
  67. _priceLabel.text = [NSString stringWithFormat:@"¥ %@",model.price];
  68. // if (model.showDes)
  69. // {
  70. // _desLabel.hidden = NO;
  71. // _desLabel.text = model.descStr;
  72. // }
  73. // else
  74. // {
  75. // _desLabel.hidden = YES;
  76. // }
  77. _desLabel.hidden = NO;
  78. _desLabel.text = model.descStr;
  79. }
  80. - (IBAction)clickButton:(id)sender
  81. {
  82. if (_delegate && [_delegate respondsToSelector:@selector(closeViewWithShopGoodsTableViewCell:)])
  83. {
  84. [_delegate closeViewWithShopGoodsTableViewCell:self];
  85. }
  86. }
  87. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  88. [super setSelected:selected animated:animated];
  89. // Configure the view for the selected state
  90. }
  91. @end