YOUPAILZVipFooterView.m 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. //
  2. // YOUPAILZVipFooterView.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/8/23.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZVipFooterView.h"
  9. @interface YOUPAILZVipFooterView ()
  10. @property (nonatomic,weak)UILabel *youpaipmoneyL;
  11. @property (nonatomic,weak)UILabel *youpaipoldMoneyL;
  12. @property (nonatomic,weak)UILabel *youpaiprebateL;
  13. @property (nonatomic,weak)UIButton *youpaipconfimBtn;
  14. @property (nonatomic,weak)UIView *youpaipbgV;
  15. @property (nonatomic,weak)UILabel *youpaipdisablePayL;
  16. @property (nonatomic,weak)UIView *youpaipbgV1;
  17. @property (nonatomic,weak)UILabel *youpaipdetailsL;
  18. @property (nonatomic,weak)UIButton *youpaipconfimBtn1;
  19. @end
  20. @implementation YOUPAILZVipFooterView
  21. - (instancetype)init{
  22. if (self = [super init]) {
  23. [self youpaifinitUI];
  24. }
  25. return self;
  26. }
  27. - (void)youpaifinitUI{
  28. UIView *bgV = [[UIView alloc] init];
  29. bgV.hidden = YES;
  30. [self addSubview:bgV];
  31. self.youpaipbgV = bgV;
  32. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.top.bottom.right.offset(0.0f);
  34. }];
  35. UILabel *disablePayL = [[UILabel alloc] init];
  36. disablePayL.text = @"不可购买比当前低级的贵族";
  37. disablePayL.font = LCFont(15.0f);
  38. disablePayL.textColor = HexColorFromRGB(0x75170A);
  39. disablePayL.hidden = YES;
  40. [self addSubview:disablePayL];
  41. self.youpaipdisablePayL = disablePayL;
  42. [disablePayL mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.top.equalTo(27.0f);
  44. make.centerX.equalTo(self);
  45. }];
  46. UILabel *moneyL = [[UILabel alloc] init];
  47. moneyL.font = LCBoldFont(18.0f);
  48. moneyL.textColor = HexColorFromRGB(0x75170A);
  49. [bgV addSubview:moneyL];
  50. self.youpaipmoneyL = moneyL;
  51. [moneyL mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.offset(15.0f);
  53. make.top.offset(16.0f);
  54. }];
  55. UILabel *oldMoneyL = [[UILabel alloc] init];
  56. oldMoneyL.textColor = HexColorFromRGB(0xA85D3C);
  57. oldMoneyL.font = LCFont12;
  58. [bgV addSubview:oldMoneyL];
  59. self.youpaipoldMoneyL = oldMoneyL;
  60. [oldMoneyL mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.equalTo(moneyL.mas_right).offset(4.0f);
  62. make.centerY.equalTo(moneyL.mas_centerY);
  63. }];
  64. UIView *deleteLine = [[UIView alloc] init];
  65. deleteLine.backgroundColor = HexColorFromRGB(0xA85D3C);
  66. [bgV addSubview:deleteLine];
  67. [deleteLine mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(oldMoneyL.mas_left).offset(0.0f);
  69. make.right.equalTo(oldMoneyL.mas_right).offset(0.0f);
  70. make.centerY.equalTo(oldMoneyL.mas_centerY);
  71. make.height.offset(0.5f);
  72. }];
  73. UILabel *rebateL = [[UILabel alloc] init];
  74. rebateL.font = LCFont(12.0f);
  75. rebateL.textColor = HexColorFromRGB(0x75170A);
  76. [bgV addSubview:rebateL];
  77. self.youpaiprebateL = rebateL;
  78. [rebateL mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.left.offset(15.0f);
  80. make.top.equalTo(moneyL.mas_bottom).offset(8.0f);
  81. }];
  82. UIButton *confimBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  83. confimBtn.backgroundColor = HexColorFromRGB(0x2A2935);
  84. confimBtn.layer.cornerRadius = 24.0f;
  85. confimBtn.clipsToBounds = YES;
  86. [confimBtn setTitleColor:HexColorFromRGB(0xFDCC88) forState:UIControlStateNormal];
  87. confimBtn.titleLabel.font = LCFont(17.0f);
  88. [confimBtn addTarget:self action:@selector(youpaifconfimBtnClick) forControlEvents:UIControlEventTouchUpInside];
  89. [bgV addSubview:confimBtn];
  90. self.youpaipconfimBtn = confimBtn;
  91. [confimBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.top.offset(11.0f);
  93. make.right.offset(-14.0f);
  94. make.size.mas_offset(CGSizeMake(128.0f, 48.0f));
  95. }];
  96. UIView *bgV1 = [[UIView alloc] init];
  97. bgV1.hidden = YES;
  98. [self addSubview:bgV1];
  99. self.youpaipbgV1 = bgV1;
  100. [bgV1 mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.left.top.bottom.right.offset(0.0f);
  102. }];
  103. UILabel *detailsL = [[UILabel alloc] init];
  104. detailsL.font = LCBoldFont(16.0f);
  105. detailsL.textColor = HexColorFromRGB(0x75170A);
  106. [bgV1 addSubview:detailsL];
  107. self.youpaipdetailsL = detailsL;
  108. [detailsL mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.left.offset(15.0f);
  110. make.top.offset(27.0f);
  111. }];
  112. UIButton *confimBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
  113. confimBtn1.backgroundColor = HexColorFromRGB(0x2A2935);
  114. confimBtn1.layer.cornerRadius = 24.0f;
  115. confimBtn1.clipsToBounds = YES;
  116. [confimBtn1 setTitleColor:HexColorFromRGB(0xFDCC88) forState:UIControlStateNormal];
  117. confimBtn1.titleLabel.font = LCFont(17.0f);
  118. [confimBtn1 addTarget:self action:@selector(youpaifconfimBtnClick) forControlEvents:UIControlEventTouchUpInside];
  119. [bgV1 addSubview:confimBtn1];
  120. self.youpaipconfimBtn1 = confimBtn1;
  121. [confimBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
  122. make.top.offset(11.0f);
  123. make.right.offset(-14.0f);
  124. make.size.mas_offset(CGSizeMake(128.0f, 48.0f));
  125. }];
  126. }
  127. - (void)youpaifreloadWithModel:(YOUPAILZVipInfoModel *)model{
  128. if ([model.youpaippay_info.youpaipstatus isEqual:@"forbid"]) {
  129. self.youpaipbgV.hidden = YES;
  130. self.youpaipbgV1.hidden = YES;
  131. self.youpaipdisablePayL.hidden = NO;
  132. }else if ([model.youpaippay_info.youpaipstatus isEqual:@"activity"] || model.is_start == 2) {//活动
  133. self.youpaipbgV.hidden = YES;
  134. self.youpaipbgV1.hidden = NO;
  135. self.youpaipdisablePayL.hidden = YES;
  136. if (model.is_start == 2) {
  137. model.youpaippay_info.youpaipbtn = @"参与活动开通";
  138. }
  139. [self.youpaipconfimBtn1 setTitle:model.youpaippay_info.youpaipbtn forState:UIControlStateNormal];
  140. NSString *nameText = @"开通即享30天";
  141. NSRange rebateRange = NSMakeRange(nameText.length,model.youpaipnoble.youpaipname.length);
  142. nameText = [NSString stringWithFormat:@"%@%@特权",nameText,model.youpaipnoble.youpaipname];
  143. NSMutableAttributedString *nameAttrStr = [[NSMutableAttributedString alloc] initWithString:nameText];
  144. [nameAttrStr addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0xFF4848) range:rebateRange];
  145. self.youpaipdetailsL.attributedText = nameAttrStr.copy;
  146. }
  147. else{
  148. self.youpaipbgV.hidden = NO;
  149. self.youpaipbgV1.hidden = YES;
  150. self.youpaipdisablePayL.hidden = YES;
  151. [self.youpaipconfimBtn setTitle:model.youpaippay_info.youpaipbtn forState:UIControlStateNormal];
  152. NSString *moneyText = [NSString stringWithFormat:@"%@",model.youpaippay_info.youpaipprice];
  153. NSRange priceRange = NSMakeRange(0, moneyText.length);
  154. moneyText = [NSString stringWithFormat:@"%@元/",moneyText];
  155. NSRange expireDateRange = NSMakeRange(moneyText.length, model.youpaippay_info.youpaipexpire_date.length);
  156. moneyText = [NSString stringWithFormat:@"%@%@天",moneyText,model.youpaippay_info.youpaipexpire_date];
  157. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:moneyText];
  158. [attrStr addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0xFF4848) range:priceRange];
  159. [attrStr addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0xFF4848) range:expireDateRange];
  160. self.youpaipmoneyL.attributedText = attrStr;
  161. if (model.youpaippay_info.youpaipold_price.length != 0) {
  162. self.youpaipoldMoneyL.text = [NSString stringWithFormat:@"(原价%@元)",model.youpaippay_info.youpaipold_price];
  163. }
  164. NSString *rebateText = @"开通后立即返还";
  165. NSRange rebateRange = NSMakeRange(rebateText.length, model.youpaippay_info.youpaipreturn_coin.length);
  166. rebateText = [NSString stringWithFormat:@"%@%@钻石",rebateText,model.youpaippay_info.youpaipreturn_coin];
  167. NSMutableAttributedString *rebateAttrStr = [[NSMutableAttributedString alloc] initWithString:rebateText];
  168. [rebateAttrStr addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0xFF4848) range:rebateRange];
  169. self.youpaiprebateL.attributedText = rebateAttrStr.copy;
  170. }
  171. }
  172. - (void)youpaifconfimBtnClick{
  173. if (self.payBlock != nil) {
  174. self.payBlock();
  175. }
  176. }
  177. @end