线上所有马甲包模板,与《猎豆》同UI。域名zhuadd

HSQCommunityRightCell.m 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. //
  2. // HSQCommunityRightCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/8/7.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "HSQCommunityRightCell.h"
  9. #import "CPFindIconView.h"
  10. #import "PhoneLoginManager.h"
  11. @interface HSQCommunityRightCell ()
  12. @property (nonatomic, strong) UIImageView *iconView;
  13. @property (nonatomic, strong) UILabel *titleLb;
  14. @property (nonatomic, strong) UILabel *desLabel1;
  15. @property (nonatomic, strong) UILabel *desLabel2;
  16. @property (nonatomic, strong) UILabel *disPrice;
  17. @property (nonatomic, strong) CPFindIconView *icons;
  18. @property (nonatomic, strong) UIButton *shareBtn;
  19. @property (nonatomic, strong) UILabel *commissionLb;
  20. @end
  21. @implementation HSQCommunityRightCell
  22. + (instancetype)cellWithTableView:(UITableView *)tableView {
  23. static NSString *cellID = nil;
  24. cellID = NSStringFromClass([self class]);
  25. HSQCommunityRightCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  26. if (!cell) {
  27. cell = [[HSQCommunityRightCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  28. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  29. }
  30. return cell;
  31. }
  32. - (void)awakeFromNib {
  33. [super awakeFromNib];
  34. // Initialization code
  35. }
  36. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  37. [super setSelected:selected animated:animated];
  38. // Configure the view for the selected state
  39. }
  40. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  41. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  42. if (self) {
  43. self.backgroundColor = [UIColor yhGrayColor];
  44. [self initSubViews];
  45. }
  46. return self;
  47. }
  48. - (void)initSubViews {
  49. UIView *bg = [[UIView alloc] init];
  50. bg.backgroundColor = [UIColor whiteColor];
  51. bg.layer.cornerRadius = Fitsize(5);
  52. [self.contentView addSubview:bg];
  53. [bg mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.mas_equalTo(Fitsize(10));
  55. make.right.mas_equalTo(Fitsize(-10));
  56. make.top.mas_equalTo(Fitsize(5));
  57. make.bottom.mas_equalTo(Fitsize(-5));
  58. }];
  59. [bg addSubview:self.iconView];
  60. [bg addSubview:self.titleLb];
  61. [bg addSubview:self.desLabel1];
  62. [bg addSubview:self.desLabel2];
  63. [bg addSubview:self.disPrice];
  64. [bg addSubview:self.icons];
  65. [bg addSubview:self.shareBtn];
  66. [bg addSubview:self.commissionLb];
  67. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.top.mas_equalTo(Fitsize(10));
  69. make.width.height.mas_equalTo(Fitsize(104));
  70. }];
  71. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.left.mas_equalTo(self.iconView.mas_right).mas_offset(Fitsize(10));
  73. make.top.mas_equalTo(self.iconView.mas_top).mas_offset(Fitsize(5));
  74. make.right.mas_equalTo(Fitsize(-10));
  75. }];
  76. [self.desLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.left.mas_equalTo(self.titleLb);
  78. make.top.mas_equalTo(self.titleLb.mas_bottom).mas_offset(Fitsize(5));
  79. make.right.mas_equalTo(Fitsize(-10));
  80. }];
  81. [self.desLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.left.mas_equalTo(self.titleLb);
  83. make.top.mas_equalTo(self.desLabel1.mas_bottom).mas_offset(Fitsize(5));
  84. make.right.mas_equalTo(Fitsize(-10));
  85. }];
  86. [self.disPrice mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.left.mas_equalTo(self.titleLb);
  88. make.bottom.mas_equalTo(self.iconView.mas_bottom);
  89. }];
  90. [self.icons mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.top.mas_equalTo(self.iconView.mas_bottom).mas_offset(Fitsize(10));
  92. make.left.mas_equalTo(Fitsize(10));
  93. make.right.mas_equalTo(0);
  94. make.height.mas_equalTo(Fitsize(40));
  95. }];
  96. [self.shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.width.mas_equalTo(57);
  98. make.height.mas_equalTo(20);
  99. make.centerY.mas_equalTo(self.icons.mas_centerY);
  100. make.right.mas_equalTo(-10);
  101. }];
  102. [self.commissionLb mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.bottom.mas_equalTo(self.disPrice.mas_bottom);
  104. make.right.mas_equalTo(self.shareBtn.mas_right);
  105. }];
  106. }
  107. - (void)shareAction {
  108. if (self.shareClick) {
  109. self.shareClick();
  110. }
  111. }
  112. - (void)setModel:(HSQCommunityRightModel *)model {
  113. _model = model;
  114. self.titleLb.text = model.title;
  115. self.desLabel1.text = model.desc1;
  116. self.desLabel2.text = model.desc2;
  117. self.commissionLb.text = [NSString stringWithFormat:@"预估佣金:¥%@",model.commission_price];
  118. self.disPrice.text = [NSString stringWithFormat:@"券后¥%.2f",[model.discount_price floatValue]];
  119. [self.iconView sd_setFadeImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil options:0 progress:nil completed:nil];
  120. [self.icons configViewWithIcons:model.headimg upCount:model.share_count];
  121. if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
  122. self.commissionLb.hidden = YES;
  123. }else {
  124. if (model.commission_price.length > 0) {
  125. self.commissionLb.hidden = NO;
  126. }else {
  127. self.commissionLb.hidden = YES;
  128. }
  129. }
  130. }
  131. - (UIImageView *)iconView {
  132. if (!_iconView) {
  133. _iconView = [[UIImageView alloc] init];
  134. _iconView.layer.cornerRadius = Fitsize(5);
  135. _iconView.backgroundColor = [UIColor yhGrayColor];
  136. }
  137. return _iconView;
  138. }
  139. - (UILabel *)titleLb {
  140. if (!_titleLb) {
  141. _titleLb = [[UILabel alloc] init];
  142. _titleLb.font = [UIFont systemFontOfSize:Fitsize(14)];
  143. _titleLb.textColor = [UIColor YHColorWithHex:0x333333];
  144. _titleLb.numberOfLines = 2;
  145. _titleLb.text = @"标题加载中...";
  146. }
  147. return _titleLb;
  148. }
  149. - (UILabel *)desLabel1 {
  150. if (!_desLabel1) {
  151. _desLabel1 = [[UILabel alloc] init];
  152. _desLabel1.font = [UIFont systemFontOfSize:Fitsize(14)];
  153. _desLabel1.textColor = [UIColor YHColorWithHex:0x999999];
  154. }
  155. return _desLabel1;
  156. }
  157. - (UILabel *)desLabel2 {
  158. if (!_desLabel2) {
  159. _desLabel2 = [[UILabel alloc] init];
  160. _desLabel2.font = [UIFont systemFontOfSize:Fitsize(14)];
  161. _desLabel2.textColor = [UIColor YHColorWithHex:0x999999];
  162. }
  163. return _desLabel2;
  164. }
  165. - (UILabel *)disPrice {
  166. if (!_disPrice) {
  167. _disPrice = [[UILabel alloc] init];
  168. _disPrice.font = [UIFont boldSystemFontOfSize:Fitsize(14)];
  169. _disPrice.textColor = [UIColor homeRedColor];
  170. _disPrice.text = @"券后¥--";
  171. }
  172. return _disPrice;
  173. }
  174. - (CPFindIconView *)icons {
  175. if (!_icons) {
  176. _icons = [[CPFindIconView alloc] init];
  177. _icons.backgroundColor = [UIColor whiteColor];
  178. }
  179. return _icons;
  180. }
  181. - (UIButton *)shareBtn {
  182. if (!_shareBtn) {
  183. _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  184. [_shareBtn setImage:[UIImage imageNamed:@"right_share"] forState:UIControlStateNormal];
  185. [_shareBtn addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside];
  186. }
  187. return _shareBtn;
  188. }
  189. - (UILabel *)commissionLb {
  190. if (!_commissionLb) {
  191. _commissionLb = [[UILabel alloc] init];
  192. _commissionLb.textColor = [UIColor homeRedColor];
  193. _commissionLb.font = [UIFont systemFontOfSize:Fitsize(12)];
  194. _commissionLb.textAlignment = NSTextAlignmentRight;
  195. }
  196. return _commissionLb;
  197. }
  198. @end