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

HSQCommunityCell.m 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. //
  2. // HSQCommunityCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/16.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "HSQCommunityCell.h"
  9. #import "UIView+SDAutoLayout.h"
  10. #import "HSQCommunityDetailModel.h"
  11. #import "CCCopyLabel.h"
  12. @interface HSQCommunityCell ()
  13. @property (nonatomic, strong) UIImageView *iconView;
  14. @property (nonatomic, strong) UIImageView *goodImgV;
  15. @property (nonatomic, strong) UILabel *userName;
  16. @property (nonatomic, strong)UILabel *goodNamelabel;
  17. @property (nonatomic, strong)UILabel *pricelabel;
  18. @property (nonatomic, strong)UILabel *commissionLabel;
  19. @property (nonatomic, strong)UILabel *vouchersLabel;
  20. @property (nonatomic, strong)UIButton *shareBtn;
  21. @property(nonatomic,strong)UILabel *backtiellabel;
  22. @property (nonatomic, strong) UILabel *timeLabel;
  23. @property (nonatomic, strong) CCCopyLabel *contentLabel;
  24. @property (nonatomic, strong) UIView *bottomLine;
  25. @property (nonatomic, strong) UIButton *oneTouchShareButton;
  26. @property(nonatomic,strong)UIView *backV;
  27. @end
  28. @implementation HSQCommunityCell
  29. + (instancetype)cellWithTableView:(UITableView *)tableView {
  30. static NSString *cellID = nil;
  31. cellID = NSStringFromClass([self class]);
  32. HSQCommunityCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  33. if (!cell) {
  34. cell = [[HSQCommunityCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  35. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  36. }
  37. return cell;
  38. }
  39. - (void)awakeFromNib {
  40. [super awakeFromNib];
  41. // Initialization code
  42. }
  43. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  44. [super setSelected:selected animated:animated];
  45. // Configure the view for the selected state
  46. }
  47. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  48. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  49. if (self) {
  50. [self initSubViews];
  51. }
  52. return self;
  53. }
  54. - (void)initSubViews {
  55. [self.contentView addSubview:self.iconView];
  56. [self.contentView addSubview:self.userName];
  57. [self.contentView addSubview:self.goodImgV];
  58. [self.contentView addSubview:self.goodNamelabel];
  59. [self.contentView addSubview:self.pricelabel];
  60. [self.contentView addSubview:self.commissionLabel];
  61. [self.contentView addSubview:self.shareBtn];
  62. [self.contentView addSubview:self.vouchersLabel];
  63. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.left.mas_equalTo(10);
  65. make.top.mas_equalTo(14);
  66. make.width.height.mas_equalTo(19);
  67. }];
  68. [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.top.mas_equalTo(14);
  70. make.left.mas_equalTo(self.iconView.mas_right).mas_offset(10);
  71. }];
  72. [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.mas_equalTo(FITSIZE(10));
  74. make.top.mas_equalTo(FITSIZE(40));
  75. make.width.height.mas_equalTo(FITSIZE(100));
  76. }];
  77. [self.goodNamelabel mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.top.mas_equalTo(FITSIZE(40));
  79. make.left.mas_equalTo(self.goodImgV.mas_right).mas_offset(10);
  80. make.width.mas_equalTo(FITSIZE(229));
  81. make.height.mas_equalTo(FITSIZE(40));
  82. }];
  83. [self.pricelabel mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.top.mas_equalTo(FITSIZE(87));
  85. make.left.mas_equalTo(self.goodImgV.mas_right).mas_offset(10);
  86. }];
  87. [self.commissionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.top.mas_equalTo(FITSIZE(87));
  89. make.right.mas_equalTo(FITSIZE(-20));
  90. }];
  91. [self.vouchersLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.left.mas_equalTo(self.goodImgV.mas_right).mas_offset(10);
  93. make.top.mas_equalTo(FITSIZE(119));
  94. make.width.mas_equalTo(FITSIZE(68));
  95. make.height.mas_equalTo(FITSIZE(20));
  96. }];
  97. [self.shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.top.mas_equalTo(FITSIZE(119));
  99. make.right.mas_equalTo(FITSIZE(-10));
  100. }];
  101. _backV =[[UIView alloc]initWithFrame:CGRectMake(FITSIZE(10), FITSIZE(155), FITSIZE(338), FITSIZE(98))];
  102. _backV.backgroundColor=[UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1.0];
  103. [self.contentView addSubview:_backV];
  104. [_backV addSubview:self.backtiellabel];
  105. [self.backtiellabel mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.mas_equalTo(FITSIZE(4));
  107. make.right.mas_equalTo(FITSIZE(-4));
  108. make.top.mas_equalTo(FITSIZE(5));
  109. }];
  110. UIButton *copyBtn =[[UIButton alloc]initWithFrame:CGRectMake(FITSIZE(270), FITSIZE(71), FITSIZE(58), FITSIZE(20))];
  111. copyBtn.layer.cornerRadius=4;
  112. copyBtn.layer.borderColor=[UIColor YHColorWithHex:0xF4150D].CGColor;
  113. copyBtn.layer.borderWidth=0.5;
  114. copyBtn.layer.masksToBounds=YES;
  115. [copyBtn setTitle:@"复制素材" forState:UIControlStateNormal];
  116. [copyBtn setTitleColor:[UIColor YHColorWithHex:0xF4150D] forState:UIControlStateNormal];
  117. copyBtn.titleLabel.font=[UIFont systemFontOfSize:FITSIZE(11)];
  118. [_backV addSubview:copyBtn];
  119. [copyBtn addTarget:self action:@selector(copyClickBtn) forControlEvents:UIControlEventTouchUpInside];
  120. }
  121. -(void)copyClickBtn
  122. {
  123. if (self.model.texts.length > 0) {
  124. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  125. // pasteboard.string =[NSString stringWithFormat:@"%@\n--------\n【在售价】%@元\n【券后价】%@元\n--------\n复制这条信息¥%@¥\n打开【手机淘宝】即可查看",self.model.title,self.model.originalPrice,self.model.ticketAfterPrice,self.model.infoStr];
  126. pasteboard.string=self.model.texts;
  127. [SVProgressHUD showSuccessWithStatus:@"复制成功"];
  128. }else {
  129. [SVProgressHUD showErrorWithStatus:@"复制失败"];
  130. }
  131. [MobClick event:FaddishNormalCopyContent];
  132. }
  133. - (void)setModel:(HSQCommunityDetailModel *)model {
  134. _model = model;
  135. // 时间分享
  136. self.userName.text = model.shop_title;//店铺名称
  137. if (model.shop_type.integerValue == 1) {//天猫
  138. self.iconView.image =[UIImage imageNamed:@"tm_shop"];
  139. }else{
  140. self.iconView.image =[UIImage imageNamed:@"taobao_shop"];
  141. }
  142. if (model.img &&![@"" isEqualToString:model.img] && model.img.length>5) {
  143. [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil];
  144. }else{
  145. [self.goodImgV setImage:[UIImage imageNamed:@"login"]];
  146. }
  147. self.goodNamelabel.text=model.title;
  148. NSString *discount_price = [NSString stringWithFormat:@"券后¥%.2f",[model.discount_price floatValue]];
  149. NSMutableAttributedString *disAttr = [[NSMutableAttributedString alloc] initWithString:discount_price];
  150. [disAttr yy_setFont:[UIFont systemFontOfSize:13] range:NSMakeRange(0, 2)];
  151. [disAttr yy_setFont:[UIFont systemFontOfSize:15] range:NSMakeRange(3, discount_price.length-3)];
  152. disAttr.yy_color = [UIColor YHColorWithHex:0x333333];
  153. self.pricelabel.attributedText=disAttr;
  154. if (model.commission_price.length !=0) {
  155. self.commissionLabel.text=[NSString stringWithFormat:@"预估佣金:¥%@",model.commission_price];
  156. }
  157. self.vouchersLabel.text=[NSString stringWithFormat:@"券¥%@",model.coupon_price];
  158. if (model.texts.length == 0) {
  159. _backV.hidden=YES;
  160. }else{
  161. _backV.hidden=NO;
  162. //行间距
  163. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:model.texts];
  164. NSRange range = [model.texts rangeOfString:model.texts];
  165. [attr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x333333] range:range];
  166. NSMutableParagraphStyle * mParagraphStyle = [[NSMutableParagraphStyle alloc] init];
  167. mParagraphStyle.lineSpacing = 5;
  168. [attr addAttribute:NSParagraphStyleAttributeName value:mParagraphStyle range:range];
  169. self.backtiellabel.attributedText = attr;
  170. }
  171. }
  172. #pragma mark -事件
  173. -(void)oneTouchShareAction{
  174. if (self.delegate && [self.delegate respondsToSelector:@selector(oneTouchShareWithModel:)]) {
  175. [self.delegate oneTouchShareWithModel:self.model];
  176. }
  177. }
  178. - (void)shareAction {
  179. if (self.shareClick) {
  180. self.shareClick();
  181. }
  182. }
  183. #pragma mark ---- layzer ----
  184. - (UIImageView *)iconView {
  185. if (!_iconView) {
  186. _iconView = [[UIImageView alloc] init];
  187. _iconView.backgroundColor = [UIColor yhGrayColor];
  188. }
  189. return _iconView;
  190. }
  191. - (UILabel *)userName {
  192. if (!_userName) {
  193. _userName = [[UILabel alloc] init];
  194. _userName.textColor = [UIColor YHColorWithHex:0x333333];
  195. _userName.font = [UIFont systemFontOfSize:15];
  196. }
  197. return _userName;
  198. }
  199. - (UILabel *)timeLabel {
  200. if (!_timeLabel) {
  201. _timeLabel = [[UILabel alloc] init];
  202. _timeLabel.font = [UIFont systemFontOfSize:12];
  203. _timeLabel.textColor = [UIColor YHColorWithHex:0x999999];
  204. _timeLabel.text=@"a";
  205. }
  206. return _timeLabel;
  207. }
  208. - (UILabel *)contentLabel {
  209. if (!_contentLabel) {
  210. _contentLabel = [[CCCopyLabel alloc] init];
  211. _contentLabel.textColor = [UIColor YHColorWithHex:0x555555];
  212. _contentLabel.font = [UIFont systemFontOfSize:16];
  213. _contentLabel.numberOfLines = 0;
  214. }
  215. return _contentLabel;
  216. }
  217. - (PhotoContainerView *)picContainerView {
  218. if (!_picContainerView) {
  219. _picContainerView = [PhotoContainerView new];
  220. }
  221. return _picContainerView;
  222. }
  223. - (UIView *)bottomLine {
  224. if (!_bottomLine) {
  225. _bottomLine = [[UIView alloc] init];
  226. _bottomLine.backgroundColor = [UIColor yhGrayColor];
  227. }
  228. return _bottomLine;
  229. }
  230. -(UIButton *)oneTouchShareButton{
  231. if (!_oneTouchShareButton) {
  232. _oneTouchShareButton=[UIButton buttonWithType:UIButtonTypeCustom];
  233. [_oneTouchShareButton setImage:[UIImage imageNamed:@"right_share"] forState:UIControlStateNormal];
  234. [_oneTouchShareButton addTarget:self action:@selector(oneTouchShareAction) forControlEvents:UIControlEventTouchUpInside];
  235. }
  236. return _oneTouchShareButton;
  237. }
  238. -(UIImageView *)goodImgV
  239. {
  240. if (!_goodImgV) {
  241. _goodImgV =[[UIImageView alloc]init];
  242. _goodImgV.backgroundColor = [UIColor yhGrayColor];
  243. }
  244. return _goodImgV;
  245. }
  246. -(UILabel *)pricelabel
  247. {
  248. if (!_pricelabel) {
  249. _pricelabel =[[UILabel alloc]init];
  250. _pricelabel.textColor=[UIColor YHColorWithHex:0x333333];
  251. _pricelabel.font=[UIFont systemFontOfSize:FITSIZE(14)];
  252. }
  253. return _pricelabel;
  254. }
  255. -(UILabel *)goodNamelabel
  256. {
  257. if (!_goodNamelabel) {
  258. _goodNamelabel =[[UILabel alloc]init];
  259. _goodNamelabel.numberOfLines=0;
  260. _goodNamelabel.textColor=[UIColor YHColorWithHex:0x333333];
  261. _goodNamelabel.font=[UIFont systemFontOfSize:FITSIZE(14)];
  262. }
  263. return _goodNamelabel;
  264. }
  265. -(UILabel *)commissionLabel
  266. {
  267. if (!_commissionLabel) {
  268. _commissionLabel =[[UILabel alloc]init];
  269. _commissionLabel.textColor=[UIColor YHColorWithHex:0xF5122A];
  270. _commissionLabel.font=[UIFont systemFontOfSize:FITSIZE(13)];
  271. _commissionLabel.textAlignment=NSTextAlignmentRight;
  272. }
  273. return _commissionLabel;
  274. }
  275. -(UILabel *)vouchersLabel
  276. {
  277. if (!_vouchersLabel) {
  278. _vouchersLabel =[[UILabel alloc]init];
  279. _vouchersLabel.textColor=[UIColor YHColorWithHex:0xF4150D];
  280. _vouchersLabel.font=[UIFont systemFontOfSize:FITSIZE(12)];
  281. _vouchersLabel.layer.borderColor=[UIColor YHColorWithHex:0xF4150D].CGColor;
  282. _vouchersLabel.layer.borderWidth=0.4;
  283. _vouchersLabel.layer.masksToBounds=YES;
  284. _vouchersLabel.textAlignment=NSTextAlignmentCenter;
  285. }
  286. return _vouchersLabel;
  287. }
  288. - (UIButton *)shareBtn {
  289. if (!_shareBtn) {
  290. _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  291. [_shareBtn setImage:[UIImage imageNamed:@"comm_share"] forState:UIControlStateNormal];
  292. [_shareBtn addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside];
  293. }
  294. return _shareBtn;
  295. }
  296. -(UILabel *)backtiellabel
  297. {
  298. if (!_backtiellabel) {
  299. _backtiellabel =[[UILabel alloc]init];
  300. _backtiellabel.textColor=[UIColor YHColorWithHex:0x262626];
  301. _backtiellabel.font=[UIFont systemFontOfSize:FITSIZE(13)];
  302. _backtiellabel.numberOfLines=3;
  303. }
  304. return _backtiellabel;
  305. }
  306. @end