// // RQVipBuyNewView.m // jiaPei // // Created by 张嵘 on 2022/10/21. // Copyright © 2022 JCZ. All rights reserved. // #import "RQVipBuyNewView.h" @implementation RQVipBuyNewView + (instancetype)vipBuyNewView { return [super rq_viewFromXib]; } - (void)awakeFromNib { [super awakeFromNib]; self.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.16].CGColor; self.priceBtn.titleLabel.textAlignment = NSTextAlignmentLeft; } - (void)setTypeModel:(RQTypeModel *)typeModel { if (RQObjectIsNil(typeModel)) { [self.priceBtn setTitleNormal:@" 暂无可用VIP套餐"]; } else { NSString *nowPriceStr; NSString *oldPriceStr; if (RQStringIsNotEmpty(typeModel.dictValue) && [typeModel.dictValue containsString:@","]) { nowPriceStr = [typeModel.dictValue componentsSeparatedByString:@","].firstObject; if ([typeModel.dictValue componentsSeparatedByString:@","].count >= 2) { oldPriceStr = [typeModel.dictValue componentsSeparatedByString:@","][1]; } else { oldPriceStr = @""; } } else { nowPriceStr = typeModel.dictValue; oldPriceStr = typeModel.dictValue; } if ([oldPriceStr isEqualToString:nowPriceStr]) { NSString *price = [NSString stringWithFormat:@" ¥%@/1年",nowPriceStr]; [self.priceBtn setTitleNormal:price]; } else { NSString *year = [NSString stringWithFormat:[typeModel.dictLabel isEqualToString:@"理论实操计时"]? @"/长期" : @"/1年"]; NSString *price = [NSString stringWithFormat:@" ¥%@%@ ¥%@",nowPriceStr,year,oldPriceStr]; NSString *oldPrice = [NSString stringWithFormat:@"¥%@",oldPriceStr]; NSMutableAttributedString *nowPriceAttrStr = [[NSMutableAttributedString alloc] initWithString:price]; [nowPriceAttrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:22] range:[price rangeOfString:year]]; [nowPriceAttrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:[price rangeOfString:oldPrice]]; [nowPriceAttrStr addAttribute:NSStrikethroughStyleAttributeName value:@(1) range:[price rangeOfString:oldPrice]]; [nowPriceAttrStr addAttribute:NSBaselineOffsetAttributeName value:@(NSUnderlineStyleSingle) range:[price rangeOfString:oldPrice]]; [nowPriceAttrStr addAttribute:NSForegroundColorAttributeName value:UIColor.whiteColor range:[price rangeOfString:oldPrice]]; [self.priceBtn setAttributedTitle:nowPriceAttrStr forState:UIControlStateNormal]; } } [self layoutIfNeeded]; } - (IBAction)userAgreeBtnAction:(id)sender { _userAgreeBtn.selected = !_userAgreeBtn.selected; } - (IBAction)userAgreementBtnAction:(id)sender { NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://ys.zzxcx.net/jsjp-sf.html"]]; RQWebViewModel *viewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey : request,RQViewModelWebViewTypeKey:@(RQWebViewType_VIP)}]; RQWebViewViewController *viewController = [[RQWebViewViewController alloc] initWithViewModel:viewModel]; RQBaseNavigationController *nav = [[RQBaseNavigationController alloc] initWithRootViewController:viewController]; [RQControllerHelper.currentViewController presentViewController:nav animated:YES completion:^{ }]; // [RQ_APPDELEGATE.services presentViewModel:viewModel animated:YES completion:^{ // // }]; } @end