RQVipBuyNewView.m 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // RQVipBuyNewView.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/10/21.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQVipBuyNewView.h"
  9. @implementation RQVipBuyNewView
  10. + (instancetype)vipBuyNewView {
  11. return [super rq_viewFromXib];
  12. }
  13. - (void)awakeFromNib {
  14. [super awakeFromNib];
  15. self.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.16].CGColor;
  16. self.priceBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
  17. }
  18. - (void)setTypeModel:(RQTypeModel *)typeModel {
  19. if (RQObjectIsNil(typeModel)) {
  20. [self.priceBtn setTitleNormal:@" 暂无可用VIP套餐"];
  21. } else {
  22. NSString *nowPriceStr;
  23. NSString *oldPriceStr;
  24. if (RQStringIsNotEmpty(typeModel.dictValue) && [typeModel.dictValue containsString:@","]) {
  25. nowPriceStr = [typeModel.dictValue componentsSeparatedByString:@","].firstObject;
  26. if ([typeModel.dictValue componentsSeparatedByString:@","].count >= 2) {
  27. oldPriceStr = [typeModel.dictValue componentsSeparatedByString:@","][1];
  28. } else {
  29. oldPriceStr = @"";
  30. }
  31. } else {
  32. nowPriceStr = typeModel.dictValue;
  33. oldPriceStr = typeModel.dictValue;
  34. }
  35. if ([oldPriceStr isEqualToString:nowPriceStr]) {
  36. NSString *price = [NSString stringWithFormat:@" ¥%@/1年",nowPriceStr];
  37. [self.priceBtn setTitleNormal:price];
  38. } else {
  39. NSString *year = [NSString stringWithFormat:[typeModel.dictLabel isEqualToString:@"理论实操计时"]? @"/长期" : @"/1年"];
  40. NSString *price = [NSString stringWithFormat:@" ¥%@%@ ¥%@",nowPriceStr,year,oldPriceStr];
  41. NSString *oldPrice = [NSString stringWithFormat:@"¥%@",oldPriceStr];
  42. NSMutableAttributedString *nowPriceAttrStr = [[NSMutableAttributedString alloc] initWithString:price];
  43. [nowPriceAttrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:22] range:[price rangeOfString:year]];
  44. [nowPriceAttrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:[price rangeOfString:oldPrice]];
  45. [nowPriceAttrStr addAttribute:NSStrikethroughStyleAttributeName value:@(1) range:[price rangeOfString:oldPrice]];
  46. [nowPriceAttrStr addAttribute:NSBaselineOffsetAttributeName value:@(NSUnderlineStyleSingle) range:[price rangeOfString:oldPrice]];
  47. [nowPriceAttrStr addAttribute:NSForegroundColorAttributeName value:UIColor.whiteColor range:[price rangeOfString:oldPrice]];
  48. [self.priceBtn setAttributedTitle:nowPriceAttrStr forState:UIControlStateNormal];
  49. }
  50. }
  51. [self layoutIfNeeded];
  52. }
  53. - (IBAction)userAgreeBtnAction:(id)sender {
  54. _userAgreeBtn.selected = !_userAgreeBtn.selected;
  55. }
  56. - (IBAction)userAgreementBtnAction:(id)sender {
  57. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://ys.zzxcx.net/jsjp-sf.html"]];
  58. RQWebViewModel *viewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey : request,RQViewModelWebViewTypeKey:@(RQWebViewType_VIP)}];
  59. RQWebViewViewController *viewController = [[RQWebViewViewController alloc] initWithViewModel:viewModel];
  60. RQBaseNavigationController *nav = [[RQBaseNavigationController alloc] initWithRootViewController:viewController];
  61. [RQControllerHelper.currentViewController presentViewController:nav animated:YES completion:^{
  62. }];
  63. // [RQ_APPDELEGATE.services presentViewModel:viewModel animated:YES completion:^{
  64. //
  65. // }];
  66. }
  67. @end