dkahgld

ZBOrderDataCell.m 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. //
  2. // ZBOrderDataCell.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/9.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBOrderDataCell.h"
  9. @implementation ZBOrderDataCell
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self=[super initWithFrame:frame];
  13. if (self) {
  14. self.layer.cornerRadius=6;
  15. self.layer.masksToBounds=YES;
  16. self.backgroundColor=[UIColor whiteColor];
  17. [self addSubview:self.goodImgV];
  18. [self addSubview:self.titleLabel];
  19. [self addSubview:self.shopImg];
  20. [self addSubview:self.shopLabel];
  21. [self addSubview:self.priceLabel];
  22. [self addSubview:self.oldPriceL];
  23. [self addSubview:self.quanImgv];
  24. [self.quanImgv addSubview:self.quanLabel];
  25. [self addSubview:self.salesCountL];
  26. [self addSubview:self.makeLabel];
  27. [self addSubview:self.exclusiveLabel];
  28. [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.width.height.mas_equalTo(110);
  30. make.top.left.mas_equalTo(10);
  31. }];
  32. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.mas_equalTo(self.goodImgV.mas_right).offset(9);
  34. make.right.mas_equalTo(-9);
  35. make.top.mas_equalTo(self.goodImgV.mas_top).offset(5);
  36. make.height.mas_equalTo(22);
  37. }];
  38. [self.shopImg mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.width.height.mas_equalTo(14);
  40. make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
  41. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
  42. }];
  43. [self.shopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.mas_equalTo(self.shopImg.mas_right).offset(5);
  45. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(9);
  46. make.height.mas_equalTo(16);
  47. make.right.mas_equalTo(-10);
  48. }];
  49. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.mas_equalTo(self.shopLabel.mas_bottom).offset(7);
  51. make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
  52. make.height.mas_equalTo(22);
  53. }];
  54. [self.exclusiveLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(7);
  56. make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
  57. make.height.mas_equalTo(18);
  58. make.width.mas_equalTo(42);
  59. }];
  60. [self.oldPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.top.mas_equalTo(self.shopLabel.mas_bottom).offset(7);
  62. make.left.mas_equalTo(self.priceLabel.mas_right).offset(10);
  63. make.height.mas_equalTo(22);
  64. }];
  65. [self.quanImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
  67. make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(9);
  68. make.height.mas_equalTo(16);
  69. make.width.mas_equalTo(65);
  70. }];
  71. [self.quanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.left.mas_equalTo(24);
  73. make.right.top.mas_equalTo(0);
  74. make.height.mas_equalTo(16);
  75. }];
  76. [self.salesCountL mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.right.mas_equalTo(-8);
  78. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(9);
  79. make.height.mas_equalTo(16);
  80. }];
  81. [self.makeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.top.mas_equalTo(self.oldPriceL.mas_bottom).offset(3);
  83. make.right.mas_equalTo(-8);
  84. make.height.mas_equalTo(26);
  85. make.width.mas_equalTo(80);
  86. }];
  87. }
  88. return self;
  89. }
  90. -(void)setModel:(ZBGoodModel *)model
  91. {
  92. _model= model;
  93. if (model.selection_tag.length>0) {
  94. self.exclusiveLabel.text=model.selection_tag;
  95. self.exclusiveLabel.hidden=NO;
  96. }else{
  97. self.exclusiveLabel.hidden=YES;
  98. }
  99. [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]];
  100. self.titleLabel.text=model.title;
  101. if (model.shop_type.integerValue == 1) {
  102. self.shopImg.image =[UIImage imageNamed:@"tm_icon"];
  103. }else{
  104. self.shopImg.image =[UIImage imageNamed:@"taobao_icon"];
  105. }
  106. self.shopLabel.text=model.shop_title;
  107. self.salesCountL.text=[NSString stringWithFormat:@"月销%@",model.volume];
  108. self.quanLabel.text=[NSString stringWithFormat:@"%@元",model.coupon_price];
  109. //券的价格为0隐藏
  110. if (model.coupon_price.floatValue == 0) {
  111. self.quanImgv.hidden=YES;
  112. }else{
  113. self.quanImgv.hidden=NO;
  114. }
  115. self.priceLabel.text=[NSString stringWithFormat:@"¥%@",model.discount_price];
  116. //原件
  117. NSString *textStr =[NSString stringWithFormat:@"¥%@",model.price];
  118. //中划线
  119. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  120. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  121. // 赋值
  122. _oldPriceL.attributedText = attribtStr;
  123. NSString *title=[NSString stringWithFormat:@"利润%@",model.commission_rate];
  124. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
  125. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,2)]; //设置字体字号和字体类别
  126. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(2,title.length-2)]; //设置字体字号和字体类别
  127. _makeLabel.attributedText=str;
  128. }
  129. -(UIImageView *)goodImgV
  130. {
  131. if (!_goodImgV) {
  132. _goodImgV=[[UIImageView alloc]init];
  133. _goodImgV.backgroundColor=[UIColor lineColor];
  134. _goodImgV.layer.cornerRadius=4;
  135. _goodImgV.layer.masksToBounds=YES;
  136. }
  137. return _goodImgV;
  138. }
  139. -(UILabel *)titleLabel
  140. {
  141. if (!_titleLabel) {
  142. _titleLabel=[[UILabel alloc]init];
  143. _titleLabel.font=[UIFont systemFontOfSize:15];
  144. _titleLabel.textColor=[UIColor YHColorWithHex:0x333333];
  145. _titleLabel.text=@"---------";
  146. }
  147. return _titleLabel;
  148. }
  149. -(UILabel *)oldPriceL
  150. {
  151. if (!_oldPriceL) {
  152. _oldPriceL=[[UILabel alloc]init];
  153. _oldPriceL.font=[UIFont systemFontOfSize:10];
  154. _oldPriceL.textColor=[UIColor YHColorWithHex:0xBBB9BB];
  155. // _oldPriceL.text=@"99.99";
  156. NSString *textStr =@"¥99.99";
  157. //中划线
  158. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  159. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  160. // 赋值
  161. _oldPriceL.attributedText = attribtStr;
  162. }
  163. return _oldPriceL;
  164. }
  165. -(UILabel *)priceLabel
  166. {
  167. if (!_priceLabel) {
  168. _priceLabel=[[UILabel alloc]init];
  169. _priceLabel.font=[UIFont systemFontOfSize:16];
  170. _priceLabel.textColor=[UIColor YHColorWithHex:0x393939];
  171. _priceLabel.text=@"¥---";
  172. }
  173. return _priceLabel;
  174. }
  175. -(UIImageView *)shopImg
  176. {
  177. if (!_shopImg) {
  178. _shopImg =[[UIImageView alloc]init];
  179. [_shopImg setImage:[UIImage imageNamed:@"tm_icon"]];
  180. _shopImg.layer.cornerRadius=3;
  181. _shopImg.layer.masksToBounds=YES;
  182. }
  183. return _shopImg;
  184. }
  185. -(UILabel *)shopLabel
  186. {
  187. if (!_shopLabel) {
  188. _shopLabel=[[UILabel alloc]init];
  189. _shopLabel.text=@"----";
  190. _shopLabel.textColor=[UIColor YHColorWithHex:0x8D8A8A];
  191. _shopLabel.font=[UIFont systemFontOfSize:11];
  192. }
  193. return _shopLabel;
  194. }
  195. -(UIImageView *)quanImgv
  196. {
  197. if (!_quanImgv) {
  198. _quanImgv =[[UIImageView alloc]init];
  199. [_quanImgv setImage:[UIImage imageNamed:@"quan"]];
  200. _quanImgv.layer.cornerRadius=2;
  201. _quanImgv.layer.masksToBounds=YES;
  202. _quanImgv.hidden=YES;
  203. }
  204. return _quanImgv;
  205. }
  206. -(UILabel *)quanLabel
  207. {
  208. if (!_quanLabel) {
  209. _quanLabel=[[UILabel alloc]init];
  210. _quanLabel.textColor=[UIColor YHColorWithHex:0xFF7D00];
  211. _quanLabel.font=[UIFont systemFontOfSize:10];
  212. _quanLabel.textAlignment=NSTextAlignmentCenter;
  213. _quanLabel.text=@"--元";
  214. }
  215. return _quanLabel;
  216. }
  217. -(UILabel *)salesCountL
  218. {
  219. if (!_salesCountL) {
  220. _salesCountL=[[UILabel alloc]init];
  221. _salesCountL.text=@"月销--";
  222. _salesCountL.textColor=[UIColor YHColorWithHex:0xBBB9BB];
  223. _salesCountL.font=[UIFont systemFontOfSize:10];
  224. }
  225. return _salesCountL;
  226. }
  227. -(UILabel *)makeLabel
  228. {
  229. if (!_makeLabel) {
  230. _makeLabel=[[UILabel alloc]init];
  231. _makeLabel.layer.cornerRadius=13;
  232. _makeLabel.layer.masksToBounds=YES;
  233. _makeLabel.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF8300] toColor:[UIColor YHColorWithHex:0xFF5200] withWidth:80];
  234. _makeLabel.font=[UIFont systemFontOfSize:15];
  235. _makeLabel.textColor=[UIColor whiteColor];
  236. _makeLabel.text=@"赚¥--"; _makeLabel.textAlignment=NSTextAlignmentCenter;
  237. NSString *title=@"赚¥--";
  238. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
  239. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,1)]; //设置字体字号和字体类别
  240. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(1,title.length-1)]; //设置字体字号和字体类别
  241. _makeLabel.attributedText=str;
  242. }
  243. return _makeLabel;
  244. }
  245. -(UILabel *)exclusiveLabel
  246. {
  247. if (!_exclusiveLabel) {
  248. _exclusiveLabel=[[UILabel alloc]init];
  249. _exclusiveLabel.text=@"专属";
  250. _exclusiveLabel.textColor=[UIColor YHColorWithHex:0xFF7D00];
  251. _exclusiveLabel.font=[UIFont systemFontOfSize:10];
  252. _exclusiveLabel.textAlignment=NSTextAlignmentCenter;
  253. _exclusiveLabel.layer.cornerRadius=3;
  254. _exclusiveLabel.hidden=YES;
  255. _exclusiveLabel.layer.masksToBounds=YES;
  256. _exclusiveLabel.layer.borderColor=[UIColor YHColorWithHex:0xFF7D00].CGColor;
  257. _exclusiveLabel.layer.borderWidth=0.5;
  258. }
  259. return _exclusiveLabel;
  260. }
  261. @end