dkahgld

ZBGoodDetailViewCell.m 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. //
  2. // ZBGoodDetailView.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/3/27.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBGoodDetailViewCell.h"
  9. @implementation ZBGoodDetailViewCell
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self=[super initWithFrame:frame];
  13. if (self) {
  14. self.backgroundColor=[UIColor whiteColor];
  15. [self addSubview:self.imgCycleView];
  16. [self addSubview:self.titleLabel];
  17. [self addSubview:self.priceLabel];
  18. [self addSubview:self.quanImgv];
  19. [self.quanImgv addSubview:self.quanLabel];
  20. [self addSubview:self.saleLabel];
  21. [self addSubview:self.oldPricel];
  22. [self addSubview:self.tipeImgV];
  23. [self addSubview:self.pointbackView];
  24. [self.pointbackView addSubview:self.pointLabel];
  25. [self.imgCycleView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.top.left.right.mas_equalTo(0);
  27. make.height.mas_equalTo(375);
  28. }];
  29. [self.oldPricel mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.left.mas_equalTo(self.priceLabel.mas_left);
  31. make.height.mas_equalTo(16);
  32. make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(5);
  33. }];
  34. [self.saleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.right.mas_equalTo(-10);
  36. make.height.mas_equalTo(16);
  37. make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(5);
  38. }];
  39. [self.tipeImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.width.height.mas_equalTo(19);
  41. make.left.mas_equalTo(10);
  42. make.top.mas_equalTo(self.imgCycleView.mas_bottom).offset(14);
  43. }];
  44. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.mas_equalTo(10);
  46. make.right.mas_equalTo(-10); make.top.mas_equalTo(self.imgCycleView.mas_bottom).offset(14);
  47. }];
  48. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.mas_equalTo(10);
  50. make.height.mas_equalTo(36);
  51. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(8);
  52. }];
  53. [self.quanImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(19);
  55. make.right.mas_equalTo(-10);
  56. make.height.mas_equalTo(16);
  57. make.width.mas_equalTo(65);
  58. }];
  59. [self.quanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.mas_equalTo(24);
  61. make.right.top.mas_equalTo(0);
  62. make.height.mas_equalTo(16);
  63. }];
  64. [self.pointbackView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.mas_equalTo(self.saleLabel.mas_bottom).offset(17);
  66. make.left.mas_equalTo(10);
  67. make.right.mas_equalTo(-10);
  68. }];
  69. //
  70. [self.pointLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.top.mas_equalTo(37);
  72. make.left.mas_equalTo(5);
  73. make.right.mas_equalTo(-5);
  74. }];
  75. }
  76. return self;
  77. }
  78. -(void)setBannerArry:(NSMutableArray *)bannerArry
  79. {
  80. _bannerArry = bannerArry;
  81. if (bannerArry.count>0) {
  82. self.imgCycleView.imageURLStringsGroup=bannerArry;
  83. }
  84. }
  85. -(void)setModel:(ZBGoodModel *)model
  86. {
  87. _model = model;
  88. NSString *str=[NSString stringWithFormat:@" %@",model.title];
  89. NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:str];
  90. NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
  91. [paragraphStyle1 setLineSpacing:8];
  92. [attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [str length])];
  93. [self.titleLabel setAttributedText:attributedString1];
  94. [self.titleLabel sizeToFit];
  95. NSString *timetitle= [NSString stringWithFormat:@"¥%@/利润%@",model.discount_price,model.commission_rate];
  96. NSString *prices =[NSString stringWithFormat:@"¥%@/",model.discount_price];
  97. NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
  98. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x333333] range:NSMakeRange(0,prices.length)];
  99. [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(prices.length,2)]; //设置字体字号和字体类别
  100. [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF7D00] range:NSMakeRange(prices.length,timetitle.length-prices.length)];
  101. self.priceLabel.attributedText=timestr;
  102. //原件
  103. NSString *textStr =[NSString stringWithFormat:@"¥%@",model.price];
  104. //中划线
  105. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  106. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  107. // 赋值
  108. self.oldPricel.attributedText = attribtStr;
  109. //券的价格为0隐藏
  110. if (model.coupon_price.floatValue == 0) {
  111. self.quanImgv.hidden=YES;
  112. }else{
  113. self.quanImgv.hidden=NO;
  114. }
  115. self.quanLabel.text=[NSString stringWithFormat:@"¥%@",model.coupon_price];
  116. if (model.shop_type.integerValue == 1) {
  117. self.tipeImgV.image =[UIImage imageNamed:@"tm_icon"];
  118. }else{
  119. self.tipeImgV.image =[UIImage imageNamed:@"taobao_icon"];
  120. }
  121. self.saleLabel.text=[NSString stringWithFormat:@"月销%@",model.volume];
  122. if (model.goods_point.length>0) {
  123. self.pointbackView.hidden=NO;
  124. self.pointLabel.text=model.goods_point;
  125. [self.pointbackView mas_updateConstraints:^(MASConstraintMaker *make) {
  126. make.bottom.mas_equalTo(self.mas_bottom).offset(-10);
  127. }];
  128. }
  129. }
  130. -(UIView *)pointbackView
  131. {
  132. if (!_pointbackView) {
  133. _pointbackView =[[UIView alloc]init];
  134. _pointbackView.layer.cornerRadius=5;
  135. _pointbackView.layer.masksToBounds=YES;
  136. _pointbackView.backgroundColor=[UIColor YHColorWithHex:0xFEF3E8];
  137. UIImageView *img =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"detail_point"]];
  138. img.frame=CGRectMake(10, 10, 18, 18);
  139. [_pointbackView addSubview:img];
  140. UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(img.right+10, 10, 100, 18)];
  141. label.text=@"卖点:";
  142. label.font=[UIFont boldSystemFontOfSize:13];
  143. label.textColor=[UIColor YHColorWithHex:0x333333];
  144. [_pointbackView addSubview:label];
  145. UIButton *copybtn =[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-80, 10, 50, 16)];
  146. [copybtn setTitle:@"复制" forState:UIControlStateNormal];
  147. copybtn.titleLabel.font=[UIFont systemFontOfSize:10];
  148. [copybtn setTitleColor:[UIColor fontNineColor] forState:UIControlStateNormal];
  149. copybtn.layer.cornerRadius=1;
  150. copybtn.layer.masksToBounds=YES;
  151. copybtn.layer.borderColor=[UIColor fontNineColor].CGColor;
  152. copybtn.layer.borderWidth=0.5;
  153. [_pointbackView addSubview:copybtn];
  154. [copybtn addTarget:self action:@selector(copoyClickBtn) forControlEvents:UIControlEventTouchUpInside];
  155. _pointbackView.hidden=YES;
  156. }
  157. return _pointbackView;
  158. }
  159. -(UILabel *)pointLabel
  160. {
  161. if (!_pointLabel) {
  162. _pointLabel=[[UILabel alloc]init];
  163. _pointLabel.textColor=[UIColor fontsixColor];
  164. _pointLabel.font=[UIFont systemFontOfSize:13];
  165. _pointLabel.numberOfLines=0;
  166. }
  167. return _pointLabel;
  168. }
  169. -(UIImageView *)tipeImgV
  170. {
  171. if (!_tipeImgV) {
  172. _tipeImgV=[[UIImageView alloc]init];
  173. _tipeImgV.layer.cornerRadius=2;
  174. _tipeImgV.layer.masksToBounds=YES;
  175. [_tipeImgV setImage:[UIImage imageNamed:@"tm_icon"]];;
  176. }
  177. return _tipeImgV;
  178. }
  179. -(SDCycleScrollView *)imgCycleView
  180. {
  181. if (!_imgCycleView) {
  182. _imgCycleView=[[SDCycleScrollView alloc]init];
  183. _imgCycleView.backgroundColor=[UIColor lineColor];
  184. }
  185. return _imgCycleView;
  186. }
  187. -(UILabel *)titleLabel
  188. {
  189. if (!_titleLabel) {
  190. _titleLabel =[[UILabel alloc]init];
  191. _titleLabel.textColor=[UIColor YHColorWithHex:0x000000];
  192. _titleLabel.font=[UIFont systemFontOfSize:15];
  193. _titleLabel.text=@" ----标题";
  194. _titleLabel.numberOfLines=2;
  195. }
  196. return _titleLabel;
  197. }
  198. -(UILabel *)priceLabel
  199. {
  200. if (!_priceLabel) {
  201. _priceLabel=[[UILabel alloc]init];
  202. _priceLabel.textColor=[UIColor YHColorWithHex:0xFC6708];
  203. _priceLabel.font=[UIFont systemFontOfSize:25];
  204. _priceLabel.text=@"¥--.--";
  205. }
  206. return _priceLabel;
  207. }
  208. -(UILabel *)oldPricel
  209. {
  210. if (!_oldPricel) {
  211. _oldPricel=[[UILabel alloc]init];
  212. _oldPricel.text=@"¥--";
  213. _oldPricel.font=[UIFont systemFontOfSize:10];
  214. _oldPricel.textColor=[UIColor YHColorWithHex:0xA9A9A9];
  215. }
  216. return _oldPricel;
  217. }
  218. -(UILabel *)saleLabel
  219. {
  220. if (!_saleLabel) {
  221. _saleLabel=[[UILabel alloc]init];
  222. _saleLabel.text=@"月销---";
  223. _saleLabel.font=[UIFont systemFontOfSize:10];
  224. _saleLabel.textColor=[UIColor YHColorWithHex:0xA9A9A9];
  225. }
  226. return _saleLabel;
  227. }
  228. -(UIImageView *)quanImgv
  229. {
  230. if (!_quanImgv) {
  231. _quanImgv =[[UIImageView alloc]init];
  232. [_quanImgv setImage:[UIImage imageNamed:@"quan"]];
  233. _quanImgv.layer.cornerRadius=2;
  234. _quanImgv.layer.masksToBounds=YES;
  235. _quanImgv.hidden=YES;
  236. }
  237. return _quanImgv;
  238. }
  239. -(UILabel *)quanLabel
  240. {
  241. if (!_quanLabel) {
  242. _quanLabel=[[UILabel alloc]init];
  243. _quanLabel.textColor=[UIColor YHColorWithHex:0xFF7D00];
  244. _quanLabel.font=[UIFont systemFontOfSize:10];
  245. _quanLabel.textAlignment=NSTextAlignmentCenter;
  246. _quanLabel.text=@"--元";
  247. }
  248. return _quanLabel;
  249. }
  250. -(void)copoyClickBtn
  251. {
  252. UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
  253. if (self.model.goods_point.length>0) {
  254. pastboard.string = self.model.goods_point;
  255. [MBProgressHUD showMessage:@"复制成功"];
  256. }else {
  257. [MBProgressHUD showMessage:@"复制失败"];
  258. }
  259. }
  260. @end