猎豆优选

LDDetailGuideView.m 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. //
  2. // LDDetailGuideView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/13.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDDetailGuideView.h"
  9. @implementation LDDetailGuideView
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. self.backgroundColor = [UIColor whiteColor];
  14. [self initSubViews];
  15. }
  16. return self;
  17. }
  18. - (void)initSubViews {
  19. self.userInteractionEnabled=YES;
  20. _redView =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(15), FITSIZE(53))];
  21. _redView.backgroundColor=[UIColor colorWithRed:255/255.0 green:244/255.0 blue:223/255.0 alpha:1.0];
  22. _redView.layer.cornerRadius=FITSIZE(5);
  23. _redView.layer.masksToBounds=YES;
  24. UITapGestureRecognizer *redtap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(redtapImageView)];
  25. [_redView addGestureRecognizer:redtap1];
  26. self.redView.userInteractionEnabled=YES;
  27. [self addSubview:_redView];
  28. UIImageView *rediconView =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(10), FITSIZE(16), FITSIZE(18))];
  29. [rediconView setImage:[UIImage imageNamed:@"red_detail"]];
  30. [self.redView addSubview:rediconView];
  31. UILabel *redpriceL =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(30), FITSIZE(10), FITSIZE(200), FITSIZE(18))];
  32. // redpriceL.text=@"xx元红包";
  33. redpriceL.textColor=[UIColor YHColorWithHex:0x99520F];
  34. redpriceL.font=[UIFont systemFontOfSize:FITSIZE(16)];
  35. redpriceL.tag = 9999;
  36. [self.redView addSubview:redpriceL];
  37. UILabel *redtiplabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(32), FITSIZE(130), FITSIZE(14))];
  38. redtiplabel.font=[UIFont systemFontOfSize:FITSIZE(10)];
  39. redtiplabel.textColor=[UIColor YHColorWithHex:0x99520F];
  40. // redtiplabel.text=@"下单可得xx元红包";
  41. redtiplabel.tag=8888;
  42. [self.redView addSubview:redtiplabel];
  43. // UIImageView *rightIcon =[[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-FITSIZE(35), FITSIZE(35), FITSIZE(9), FITSIZE(8))];
  44. // rightIcon.image=[UIImage imageNamed:@"detail_list"];
  45. // [self.redView addSubview:rightIcon];
  46. _leftView =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(15), FITSIZE(53))];
  47. _leftView.backgroundColor=[UIColor colorWithRed:255/255.0 green:244/255.0 blue:223/255.0 alpha:1.0];
  48. _leftView.layer.cornerRadius=FITSIZE(5);
  49. _leftView.layer.masksToBounds=YES;
  50. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView)];
  51. [_leftView addGestureRecognizer:tap];
  52. [self addSubview:_leftView];
  53. UILabel *numlabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(8),FITSIZE(100), FITSIZE(22))];
  54. numlabel.font=[UIFont systemFontOfSize:FITSIZE(16)];
  55. // numlabel.text=@"返¥0.00";
  56. numlabel.tag=2000;
  57. numlabel.textColor=[UIColor YHColorWithHex:0x99520F];
  58. [_leftView addSubview:numlabel];
  59. _leftView.userInteractionEnabled=YES;
  60. UILabel *tiplabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(9), FITSIZE(32), FITSIZE(130), FITSIZE(14))];
  61. tiplabel.font=[UIFont systemFontOfSize:FITSIZE(10)];
  62. tiplabel.textColor=[UIColor YHColorWithHex:0x99520F];
  63. tiplabel.text=@"自购和分享都有佣金";
  64. [_leftView addSubview:tiplabel];
  65. _rightview =[[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2+FITSIZE(5), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53))];
  66. _rightview.image=[UIImage imageNamed:@"quan_short"];
  67. _rightview.layer.cornerRadius=FITSIZE(3);
  68. _rightview.userInteractionEnabled=YES;
  69. _rightview.layer.masksToBounds=YES;
  70. [self addSubview:_rightview];
  71. UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapbuyImageView)];
  72. [_rightview addGestureRecognizer:tap1];
  73. [self addSubview:_leftView];
  74. UILabel *rightpricelabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(14), FITSIZE(8),FITSIZE(100), FITSIZE(22))];
  75. rightpricelabel.font=[UIFont systemFontOfSize:FITSIZE(16)];
  76. rightpricelabel.text=@"券 0.00元";
  77. rightpricelabel.tag=1000;
  78. rightpricelabel.textColor=[UIColor YHColorWithHex:0xF5112A];
  79. [_rightview addSubview:rightpricelabel];
  80. UILabel *timelabel =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(14), FITSIZE(32), FITSIZE(130), FITSIZE(14))];
  81. timelabel.font=[UIFont systemFontOfSize:FITSIZE(10)];
  82. timelabel.textColor=[UIColor YHColorWithHex:0xF5112A];
  83. timelabel.text=@"数量有限 先到先领";
  84. timelabel.tag=1111;
  85. rightpricelabel.textAlignment=NSTextAlignmentLeft;
  86. timelabel.textAlignment=NSTextAlignmentLeft;
  87. [_rightview addSubview:timelabel];
  88. self.leftView.hidden=YES;
  89. self.rightview.hidden=YES;
  90. }
  91. -(void)setModel:(LDGoodDetailModel *)model
  92. {
  93. _model=model;
  94. if (model == nil) {
  95. return;
  96. }
  97. UILabel *pirceLabel =[self.rightview viewWithTag:1000];
  98. UILabel *label =[self.leftView viewWithTag:2000];
  99. pirceLabel.text=[NSString stringWithFormat:@"券 %@元",model.coupon_price];
  100. label.text=[NSString stringWithFormat:@"返 %.2f元",model.commission_price.floatValue];
  101. UILabel *redPriceL =[self.redView viewWithTag:9999];
  102. UILabel *redTipL =[self.redView viewWithTag:8888];
  103. redPriceL.text=[NSString stringWithFormat:@"%ld元红包",(long)model.red_active_money.integerValue];
  104. redTipL.text=[NSString stringWithFormat:@"下单可得%ld元红包",(long)model.red_active_money.integerValue];
  105. if (![AccountTool isLogin]) {//没有登录不显示佣金
  106. self.leftView.hidden=YES;
  107. if (model.red_active_status.integerValue ==1 && [model.is_coupon boolValue]) {
  108. self.rightview.frame=CGRectMake(FITSIZE(9)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  109. self.redView.hidden=NO;
  110. _leftView.hidden=YES;//佣金
  111. self.rightview.hidden=NO;//券
  112. }else if (model.red_active_status.integerValue == 1) {//红包有的时候,灭有佣金、灭有优惠券
  113. self.redView.hidden = NO;
  114. self.rightview.hidden=YES;
  115. }else{//有券的时候 没红包、佣金
  116. self.redView.hidden = YES;
  117. self.rightview.frame=CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  118. self.rightview.hidden=NO;
  119. }
  120. }else{//登录以后
  121. if (model.red_active_status.integerValue == 1 && [model.is_coupon boolValue] && model.commission_price.floatValue>0) {//红包、佣金和优惠券都存在的时候
  122. self.leftView.hidden=NO;
  123. self.rightview.hidden=NO;
  124. self.redView.hidden=NO;
  125. self.rightview.frame=CGRectMake(FITSIZE(9), FITSIZE(61), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  126. self.leftView.frame=CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(15), FITSIZE(53));
  127. }else
  128. {
  129. if (model.red_active_status.integerValue == 0) {//红包不存在的时候
  130. //判断优惠券和佣金存在的时候
  131. if ([model.is_coupon boolValue] && model.commission_price.floatValue>0) {//都存在的时候
  132. _leftView.hidden=NO;
  133. self.redView.hidden=YES;
  134. self.rightview.hidden=NO;
  135. self.leftView.frame=CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  136. self.rightview.frame=CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  137. }else if ([model.is_coupon boolValue] )//只有优惠券的时候
  138. {
  139. self.rightview.frame=CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  140. _leftView.hidden=YES;
  141. self.redView.hidden=YES;
  142. self.rightview.hidden=NO;
  143. }else if (model.commission_price.floatValue>0){//只有佣金的时候
  144. self.leftView.hidden=NO;
  145. self.rightview.hidden=YES;
  146. self.redView.hidden=YES;
  147. self.leftView.frame=CGRectMake(FITSIZE(9), FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  148. }
  149. }else{//红包存在的时候
  150. self.redView.hidden=NO;
  151. if ([model.is_coupon boolValue] && model.commission_price.floatValue>0) {//都存在的时候
  152. _leftView.hidden=NO;
  153. self.rightview.hidden=NO;
  154. self.leftView.frame=CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  155. self.rightview.frame=CGRectMake(FITSIZE(9), FITSIZE(61), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  156. }else if ([model.is_coupon boolValue] )//只有优惠券的时候
  157. {
  158. self.rightview.frame=CGRectMake(FITSIZE(9)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  159. _leftView.hidden=YES;
  160. self.rightview.hidden=NO;
  161. }else if (model.commission_price.floatValue>0){//只有佣金的时候
  162. self.leftView.hidden=NO;
  163. self.rightview.hidden=YES;
  164. self.leftView.frame=CGRectMake(FITSIZE(5)+SCREEN_WIDTH/2, FITSIZE(1), SCREEN_WIDTH/2-FITSIZE(14.5), FITSIZE(53));
  165. }
  166. }
  167. }
  168. }
  169. }
  170. - (void)tapViewAction {
  171. [MobClick event:GoodsDetailVipInfo];
  172. if (self.tapAction) {
  173. self.tapAction();
  174. }
  175. }
  176. //红包h5交互
  177. -(void)redtapImageView
  178. {
  179. if ([self.delegate respondsToSelector:@selector(redClickPage)]) {
  180. [self.delegate redClickPage];
  181. }
  182. }
  183. //跳转
  184. -(void)tapImageView
  185. {
  186. if ([self.delegate respondsToSelector:@selector(commisionClickPage)]) {
  187. [self.delegate commisionClickPage];
  188. }
  189. }
  190. //购买
  191. -(void)tapbuyImageView
  192. {
  193. if ([self.delegate respondsToSelector:@selector(goBuyWithModel:)]) {
  194. [self.delegate goBuyWithModel:_model];
  195. }
  196. }
  197. @end