两折卖----返利app-----返利圈

LZMGoodDetailView.m 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. //
  2. // LZMGoodDetailView.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/25.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LZMGoodDetailView.h"
  9. #import "LZMGoodDetailModel.h"
  10. #import "LZMGotoDetailView.h"
  11. #import "UIView+SDAutoLayout.h"
  12. #import "CCCopyLabel.h"
  13. @interface LZMGoodDetailView ()
  14. @property (nonatomic, strong) CCCopyLabel *goodTitleLabel;
  15. @property (nonatomic, strong) UILabel *priceLabel;
  16. @property (nonatomic, strong) UIImageView *discountImageView;
  17. @property (nonatomic, strong) UILabel *discountPriceLabel;
  18. @property (nonatomic, strong) UILabel *freePostLabel;
  19. @property (nonatomic, strong) UILabel *volumeLabel;
  20. @property (nonatomic, strong) UILabel *quanType;
  21. @property (nonatomic, strong) UILabel *quanNum;
  22. @property (nonatomic, strong) UILabel *commissionPrice;
  23. @end
  24. @implementation LZMGoodDetailView
  25. - (instancetype)initWithFrame:(CGRect)frame {
  26. self = [super initWithFrame:frame];
  27. if (self) {
  28. self.backgroundColor = [UIColor whiteColor];
  29. [self initSubviews];
  30. }
  31. return self;
  32. }
  33. - (void)setGoodModel:(LZMGoodDetailModel *)goodModel {
  34. _goodModel = goodModel;
  35. NSString *quanType = [goodModel.is_coupon boolValue]?@"券":@"折";
  36. self.quanType.text = quanType;
  37. NSString *quanNum = [goodModel.is_coupon boolValue]?[NSString stringWithFormat:@"%@元",goodModel.coupon_price]:[NSString stringWithFormat:@"%@折",goodModel.coupon_price];
  38. self.quanNum.text = quanNum;
  39. self.discountImageView.hidden = ![goodModel.is_coupon boolValue];
  40. //标题
  41. NSTextAttachment *textAttach = [[NSTextAttachment alloc]init];
  42. UIImage *img;
  43. if ([goodModel.shop_type isEqualToString:@"1"]) {
  44. img= [UIImage imageNamed:@"tm_shop"];
  45. }else if([goodModel.shop_type isEqualToString:@"0"]){
  46. // img= [UIImage imageNamed:@"share_title_tb"];
  47. }
  48. if (img) {
  49. textAttach.image = img;
  50. textAttach.bounds = CGRectMake(0, -4, img.size.width, img.size.height);
  51. }
  52. NSMutableAttributedString *attri;
  53. if ([goodModel.shop_type isEqualToString:@"1"]) {
  54. attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@",goodModel.title]];
  55. }else {
  56. attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",goodModel.title]];
  57. }
  58. NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:textAttach];
  59. [attri insertAttributedString:string atIndex:0];
  60. NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  61. [paragraphStyle setLineSpacing:8];
  62. [attri addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [string length])];
  63. self.goodTitleLabel.textStr = goodModel.title;
  64. self.goodTitleLabel.attributedText = attri;
  65. NSString *priceText = [NSString stringWithFormat:@"原价 ¥%.2f", [goodModel.price floatValue]];
  66. NSMutableAttributedString *attritu = [[NSMutableAttributedString alloc]initWithString:priceText];
  67. [attritu addAttributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle) } range:NSMakeRange(3, priceText.length-3)];
  68. self.priceLabel.attributedText = attritu;
  69. NSString *dis_price = [goodModel.is_coupon boolValue] ? [NSString stringWithFormat:@"券后 ¥%.2f", [goodModel.discount_price floatValue]]:[NSString stringWithFormat:@"折后 ¥%.2f", [goodModel.discount_price floatValue]];
  70. NSMutableAttributedString *dispriceAttr = [[NSMutableAttributedString alloc]initWithString:dis_price];
  71. [dispriceAttr addAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:13]} range:NSMakeRange(0, 3)];
  72. self.discountPriceLabel.attributedText = dispriceAttr;
  73. self.volumeLabel.text = [NSString stringWithFormat:@"月销 %@", goodModel.volume];
  74. self.freePostLabel.text = [goodModel.freeShipping isEqual:@1] ? @"包邮" : [NSString stringWithFormat:@"邮费 %@", goodModel.postage];
  75. }
  76. - (void)initSubviews {
  77. [self addSubview:self.goodTitleLabel];
  78. [self addSubview:self.priceLabel];
  79. [self addSubview:self.discountImageView];
  80. [self addSubview:self.discountPriceLabel];
  81. [self addSubview:self.volumeLabel];
  82. [self addSubview:self.commissionPrice];
  83. [self.discountImageView addSubview:self.quanType];
  84. [self.discountImageView addSubview:self.quanNum];
  85. [self makeSubviewsConstraints];
  86. }
  87. - (void)makeSubviewsConstraints {
  88. [self.discountPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.left.mas_equalTo(FITSIZE(10));
  90. make.top.mas_equalTo(Fitsize(15));
  91. }];
  92. [self.discountImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.left.mas_equalTo(self.discountPriceLabel.mas_right).mas_offset(10);
  94. make.centerY.mas_equalTo(self.discountPriceLabel.mas_centerY);
  95. make.width.mas_equalTo(64);
  96. make.height.mas_equalTo(14);
  97. }];
  98. [self.quanType mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.top.left.bottom.mas_equalTo(0);
  100. make.width.mas_equalTo(20);
  101. }];
  102. [self.quanNum mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.left.mas_equalTo(20);
  104. make.top.bottom.right.mas_equalTo(0);
  105. }];
  106. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.left.equalTo(self.discountPriceLabel);
  108. make.top.equalTo(self.discountPriceLabel.mas_bottom).offset(FITSIZE(15));
  109. }];
  110. [self.goodTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(FITSIZE(10));
  112. make.left.equalTo(self.discountPriceLabel);
  113. make.right.equalTo(self).offset(-FITSIZE(10));
  114. }];
  115. [self.volumeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.right.equalTo(self).offset(-FITSIZE(20));
  117. make.centerY.mas_equalTo(self.priceLabel.mas_centerY);
  118. }];
  119. [self.commissionPrice mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.right.mas_equalTo(self.volumeLabel.mas_right);
  121. make.bottom.mas_equalTo(self.discountPriceLabel.mas_bottom);
  122. }];
  123. }
  124. - (void)couponTapAction:(UIGestureRecognizer *)sender {
  125. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailViewTapCoupon)]) {
  126. [self.delegate yh_GoodDetailViewTapCoupon];
  127. }
  128. }
  129. - (void)shopTapAction:(UIGestureRecognizer *)sender {
  130. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailViewTapShop)]) {
  131. [self.delegate yh_GoodDetailViewTapShop];
  132. }
  133. }
  134. #pragma mark - lazy
  135. - (CCCopyLabel *)goodTitleLabel {
  136. if (!_goodTitleLabel) {
  137. _goodTitleLabel = [[CCCopyLabel alloc] init];
  138. _goodTitleLabel.backgroundColor = [UIColor clearColor];
  139. _goodTitleLabel.textColor = [UIColor YHColorWithHex:0x222222];
  140. _goodTitleLabel.font = [UIFont systemFontOfSize:FITSIZE(14)];
  141. _goodTitleLabel.numberOfLines = 2;
  142. // _goodTitleLabel.hidden=YES;
  143. }
  144. return _goodTitleLabel;
  145. }
  146. - (UILabel *)priceLabel {
  147. if (!_priceLabel) {
  148. _priceLabel = [[UILabel alloc] init];
  149. _priceLabel.backgroundColor = [UIColor clearColor];
  150. _priceLabel.textColor = [UIColor YHColorWithHex:0x999999];
  151. _priceLabel.font = [UIFont systemFontOfSize:FITSIZE(13)];
  152. }
  153. return _priceLabel;
  154. }
  155. - (UIImageView *)discountImageView {
  156. if (!_discountImageView) {
  157. _discountImageView = [[UIImageView alloc] init];
  158. _discountImageView.backgroundColor = [UIColor clearColor];
  159. _discountImageView.image = [UIImage imageNamed:@"quan_bg"];
  160. }
  161. return _discountImageView;
  162. }
  163. - (UILabel *)discountPriceLabel {
  164. if (!_discountPriceLabel) {
  165. _discountPriceLabel = [[UILabel alloc] init];
  166. _discountPriceLabel.backgroundColor = [UIColor clearColor];
  167. _discountPriceLabel.textColor = [UIColor baseColor];
  168. _discountPriceLabel.font = [UIFont systemFontOfSize:FITSIZE(22)];
  169. }
  170. return _discountPriceLabel;
  171. }
  172. - (UILabel *)freePostLabel {
  173. if (!_freePostLabel) {
  174. _freePostLabel = [[UILabel alloc] init];
  175. _freePostLabel.backgroundColor = [UIColor clearColor];
  176. _freePostLabel.textColor = [UIColor YHColorWithHex:0x999999];
  177. _freePostLabel.font = [UIFont systemFontOfSize:FITSIZE(11)];
  178. }
  179. return _freePostLabel;
  180. }
  181. - (UILabel *)volumeLabel {
  182. if (!_volumeLabel) {
  183. _volumeLabel = [[UILabel alloc] init];
  184. _volumeLabel.backgroundColor = [UIColor clearColor];
  185. _volumeLabel.textColor = [UIColor YHColorWithHex:0x999999];
  186. _volumeLabel.font = [UIFont systemFontOfSize:FITSIZE(11)];
  187. }
  188. return _volumeLabel;
  189. }
  190. - (UILabel *)quanType {
  191. if (!_quanType) {
  192. _quanType = [[UILabel alloc] init];
  193. _quanType.textColor = [UIColor whiteColor];
  194. _quanType.font = [UIFont boldSystemFontOfSize:10];
  195. _quanType.textAlignment = NSTextAlignmentCenter;
  196. }
  197. return _quanType;
  198. }
  199. - (UILabel *)quanNum {
  200. if (!_quanNum) {
  201. _quanNum = [[UILabel alloc] init];
  202. _quanNum.textColor = [UIColor whiteColor];
  203. _quanNum.font = [UIFont boldSystemFontOfSize:10];
  204. _quanNum.textAlignment = NSTextAlignmentCenter;
  205. }
  206. return _quanNum;
  207. }
  208. - (UILabel *)commissionPrice {
  209. if (!_commissionPrice) {
  210. _commissionPrice = [[UILabel alloc] init];
  211. _commissionPrice.textColor = [UIColor homeRedColor];
  212. _commissionPrice.font = [UIFont systemFontOfSize:Fitsize(14)];
  213. _commissionPrice.textAlignment = NSTextAlignmentRight;
  214. _commissionPrice.hidden = YES;
  215. }
  216. return _commissionPrice;
  217. }
  218. -(void)as9VQ6kvLcb:(UIActivity*) as9VQ6kvLcb aZFQtmOwgGl:(UIScreen*) aZFQtmOwgGl aLVe8cCp:(UIInputView*) aLVe8cCp aXKkF:(UIBarButtonItem*) aXKkF aJTdFC2V:(UIImageView*) aJTdFC2V aOBL5ex6v:(UIRegion*) aOBL5ex6v av2aiRr3c:(UICollectionView*) av2aiRr3c aRTn9eChZw:(UIEdgeInsets*) aRTn9eChZw a71MsrhC:(UIApplication*) a71MsrhC {
  219. NSLog(@"onPpL8UrIHAvadCZBlOc");
  220. NSLog(@"fYTpDzKAQSN7r1UlH9wv");
  221. NSLog(@"yViZqcu0QJ5ThnrkKa6OM4NdxltwCvL");
  222. NSLog(@"I637uwCLdZNM");
  223. NSLog(@"CfUAvNz9tPT6EGIu8R0FYeMr2jomL");
  224. NSLog(@"nZdGlLzBeQ5D7H0M6CJbTA3Km");
  225. NSLog(@"kUNK7Qxrj3zi5pIZtdODGolL1gqJCE");
  226. NSLog(@"KCQuwWVncmptxgLa");
  227. NSLog(@"WGmvQIYPKLFeub7dDRcnVfNMxaCi");
  228. NSLog(@"WEtVACSlnh1UdbxeQmrTfjk");
  229. NSLog(@"OWtlcPxF6K3i8aZ7SAVYBfXeNwJnzmLR9qbC");
  230. NSLog(@"uvmT0kiP7w8sbonMlI5LSa");
  231. NSLog(@"Yjm7Wsu6JKO5AZneQplXgvx");
  232. NSLog(@"Gp8LwH4FCfqWk6YN1IlSZT9aKJiPd");
  233. NSLog(@"uz0MWdbs1oagIm73i5nxtUTGKpALOw");
  234. NSLog(@"EhPCKpDwNz4fW6GblLRJaVMSOjZAuydeT79i");
  235. NSLog(@"nZ0hgKMd7Gi");
  236. NSLog(@"RlmevBSGgnPfNtJMAT94auZQKyb7q3Vk2");
  237. NSLog(@"FaseBS7rX12NLK6Qhd9nMEUiTtIWjmHpD");
  238. }
  239. -(void)a4gyL:(UIBarButtonItem*) a4gyL aDq3M:(UIBarButtonItem*) aDq3M aSWHfQ7:(UISearchBar*) aSWHfQ7 axqUg:(UIActivity*) axqUg aUvSBT6:(UIBarButtonItem*) aUvSBT6 a2Cc6krA8P:(UIDocument*) a2Cc6krA8P aZEM1qs:(UIApplication*) aZEM1qs anTQ4:(UIImageView*) anTQ4 aR8iBtQrWuH:(UIEdgeInsets*) aR8iBtQrWuH {
  240. NSLog(@"sCkz6NHcBdeuIf5yMJtP");
  241. NSLog(@"q2lGSQCiV9w0PeNgIYUAOE");
  242. NSLog(@"mCR68h3DL2I4W7JQa");
  243. NSLog(@"Q0KHJ5NCtZByMR8fGULDS4eljAFbdPr");
  244. NSLog(@"UDGQqcNeukZlAEKo");
  245. NSLog(@"MvmceL5wKPyG7Vbt4kXOI");
  246. NSLog(@"Q9XUzbpMlsfVw1TmFi06I2PGuB");
  247. NSLog(@"07J6CVUnxXMdNTKbyFsvkA");
  248. NSLog(@"nwb239XVMeTZOrd");
  249. NSLog(@"DSCLkTNO1GcHaut6");
  250. NSLog(@"KWJU5v0Gdu2ia1xntZFRlLojMCspDgqbS");
  251. NSLog(@"ShIiEPLsDAvg1y2wBnXdKeT8VCHc3z");
  252. NSLog(@"nhp5RHcEsjw");
  253. NSLog(@"Md4E1r5UizOnSHPK2");
  254. NSLog(@"eZ0QV9btchXLzM6kRGyDd8BuvYlr5");
  255. }
  256. -(void)aIjOnq6WJA:(UIDevice*) aIjOnq6WJA aw0zyVuvHGq:(UIEdgeInsets*) aw0zyVuvHGq aUlps:(UISwitch*) aUlps a8X6Aabkd5:(UIKeyCommand*) a8X6Aabkd5 aW3UdxYoFul:(UIRegion*) aW3UdxYoFul a4Czg:(UIControl*) a4Czg ajVNEDAMSX:(UIControlEvents*) ajVNEDAMSX aGlYF:(UIRegion*) aGlYF {
  257. NSLog(@"KBPwhb06TyWnv1MVr97fLkmH2");
  258. NSLog(@"gZXcPSw9ChOFqKD1b7YT8vBMj5LmuGUfJrERod");
  259. NSLog(@"SqMR4l8tkKpGX1");
  260. NSLog(@"N64MxnskWQ5Jufpe0hXFGizYdaTOw");
  261. NSLog(@"MaHb2j5J8QI0pGwcySoAqfDWt3FZuR7Tk");
  262. NSLog(@"mkpFvRoJjQhqC4ug");
  263. NSLog(@"hCG350m9TSeFVwxcIy2g1r8dYRa");
  264. NSLog(@"wUkYxvO5a2f");
  265. NSLog(@"SxPZN941LTWyiK8r7tX5HsfQD6M");
  266. NSLog(@"IxaljCFGTbtgerwZ7yWvNdM");
  267. NSLog(@"MbDPZ3fHS1Ta4RQ69Ympc5orAxiOXU");
  268. NSLog(@"TNLMvSqEgF");
  269. NSLog(@"37HU2GK6jwecS0iBg84hlNdY");
  270. NSLog(@"hIctMRTVZrx34A0oW1g6");
  271. }
  272. @end