|
|
@@ -1,271 +0,0 @@
|
|
|
-//
|
|
|
-// BuyVIPViewController.m
|
|
|
-// 隐私保护
|
|
|
-//
|
|
|
-// Created by APPLE on 2023/8/25.
|
|
|
-//
|
|
|
-
|
|
|
-#import "BuyVIPViewController.h"
|
|
|
-#import "BuyVipTopView.h"
|
|
|
-#import "PackageListScrollView.h"
|
|
|
-#import "PayTypeView.h"
|
|
|
-#import "VIPFunctForBuyView.h"
|
|
|
-#import "PhonePackageModel.h"
|
|
|
-#import "PlayResultViewController.h"
|
|
|
-#import "NewPeopleWelfareViewController.h"
|
|
|
-#import "NoEnoughTimeViewController.h"
|
|
|
-#import "UseAccountManage.h"
|
|
|
-#import "CloudPhoneAPI.h"
|
|
|
-#import "PhonePackageModel.h"
|
|
|
-#import "WXApi.h"
|
|
|
-#import "RSATool.h"
|
|
|
-#import "SafeForKey.h"
|
|
|
-
|
|
|
-@interface BuyVIPViewController (){
|
|
|
- BuyVipTopView *buyVipTopView;
|
|
|
- PackageListScrollView *packageListScrollView;
|
|
|
- PayTypeView *payTypeView;
|
|
|
- VIPFunctForBuyView *vipFunctForBuyView;
|
|
|
-
|
|
|
- PhonePackageDataModel *phonePackageDataModel;
|
|
|
-}
|
|
|
-
|
|
|
-@end
|
|
|
-
|
|
|
-@implementation BuyVIPViewController
|
|
|
-
|
|
|
-- (void)viewDidLoad {
|
|
|
- [super viewDidLoad];
|
|
|
- // Do any additional setup after loading the view.
|
|
|
- if (@available(iOS 11.0, *)) { // 兼容低版本ios
|
|
|
- [self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
|
|
- }
|
|
|
-
|
|
|
- [self drawAnyView];
|
|
|
-
|
|
|
- /*请求套餐数据*/
|
|
|
- [[UseAccountManage shareInstance] CommonPostCallBackCode:PostPhonePackageInfoAPI
|
|
|
- Params:[NSDictionary new]
|
|
|
- success:^(id _Nonnull responseObject) {
|
|
|
-
|
|
|
- self->phonePackageDataModel = [[PhonePackageDataModel alloc] initWithDictionary:responseObject error:nil];
|
|
|
-
|
|
|
- if (self->phonePackageDataModel.status.integerValue == 0){
|
|
|
- [self drawPackageVew];
|
|
|
- }
|
|
|
- }
|
|
|
- failure:^(NSError * _Nonnull error) {
|
|
|
- ;
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)drawAnyView{
|
|
|
- [self.view setBackgroundColor:HWF5F7FAColor];
|
|
|
- [[UIApplication sharedApplication] setStatusBarHidden:NO];
|
|
|
- [self.toolBar setHidden:YES];
|
|
|
- [self.navigationBar setHidden:YES];
|
|
|
- [self.navBarBGView setHidden:NO];
|
|
|
- [self.titleLabel setText:NSLocalizedString(@"buy_vip_title",nil)];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)drawPackageVew{
|
|
|
- /*头部视图*/
|
|
|
- buyVipTopView = [[BuyVipTopView alloc] init];
|
|
|
- [self.view addSubview:buyVipTopView];
|
|
|
- [buyVipTopView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(self.navBarBGView.mas_bottom).offset(12.f);
|
|
|
- make.left.mas_equalTo(15);
|
|
|
- make.right.mas_equalTo(-15.f);
|
|
|
- make.height.mas_equalTo(150);
|
|
|
- }];
|
|
|
- [buyVipTopView setImage:[UIImage imageNamed:@"buy_vip_top_bj"]];
|
|
|
-
|
|
|
- NSString *leftStr = NSLocalizedString(@"buy_vip_top_vaildtime",nil);
|
|
|
- NSString *timeStr = phonePackageDataModel.data.exceptTime;
|
|
|
- if (!timeStr || timeStr.length < 1){
|
|
|
- timeStr = NSLocalizedString(@"buy_vip_buy_no_vaildtime",nil);
|
|
|
- }
|
|
|
- [buyVipTopView.vaildTimeLabel setText:[leftStr stringByAppendingString:timeStr]];
|
|
|
-
|
|
|
- /*底部购买按钮*/
|
|
|
- CGFloat w_btn = SCREEN_W - 2*15.f;
|
|
|
- UIButton *buyBtn = [[UIButton alloc] init];
|
|
|
- buyBtn.frame = CGRectMake(0, 0, w_btn, 48.f);
|
|
|
-
|
|
|
- // gradient
|
|
|
- CAGradientLayer *gl = [CAGradientLayer layer];
|
|
|
- gl.frame = CGRectMake(0,0,w_btn,48.f);
|
|
|
- gl.startPoint = CGPointMake(0, 0.5);
|
|
|
- gl.endPoint = CGPointMake(1, 0.5);
|
|
|
- gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
|
|
|
- gl.locations = @[@(0), @(1.0f)];
|
|
|
-
|
|
|
- [buyBtn.layer addSublayer:gl];
|
|
|
- [buyBtn setTitle:NSLocalizedString(@"buy_vip_top_buy_btn",nil) forState:(UIControlStateNormal)];
|
|
|
- [buyBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
|
|
|
- [buyBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
|
|
|
- [buyBtn.layer setCornerRadius:8.f];
|
|
|
- buyBtn.clipsToBounds = YES;
|
|
|
- [self.view addSubview:buyBtn];
|
|
|
- [buyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.bottom.mas_equalTo(-(17.f + AdaptTabHeight));
|
|
|
- make.left.mas_equalTo(15);
|
|
|
- make.right.mas_equalTo(-15.f);
|
|
|
- make.height.mas_equalTo(48);
|
|
|
- }];
|
|
|
- [buyBtn addTarget:self
|
|
|
- action:@selector(buyBtnPressed)
|
|
|
- forControlEvents:(UIControlEventTouchUpInside)];
|
|
|
-
|
|
|
- /*中间可滑动模块*/
|
|
|
- UIScrollView *middleScr = [[UIScrollView alloc] init];
|
|
|
- [middleScr setBackgroundColor:[UIColor clearColor]];
|
|
|
- [middleScr setShowsVerticalScrollIndicator:YES];
|
|
|
- [middleScr setShowsHorizontalScrollIndicator:NO];
|
|
|
- [middleScr setUserInteractionEnabled:YES];
|
|
|
-
|
|
|
- [self.view addSubview:middleScr];
|
|
|
- [middleScr mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.bottom.equalTo(buyBtn.mas_top).offset(-36.f);
|
|
|
- make.left.mas_equalTo(15);
|
|
|
- make.right.mas_equalTo(-15.f);
|
|
|
- make.top.equalTo(buyVipTopView.mas_bottom);
|
|
|
- }];
|
|
|
-
|
|
|
- /*套餐列表*/
|
|
|
- packageListScrollView = [[PackageListScrollView alloc] init];
|
|
|
- [middleScr addSubview:packageListScrollView];
|
|
|
- [packageListScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.height.mas_equalTo(145);
|
|
|
- make.left.mas_equalTo(0);
|
|
|
- make.width.mas_equalTo(SCREEN_W - 2*15.f);
|
|
|
- make.top.mas_equalTo(0);
|
|
|
- }];
|
|
|
- [packageListScrollView setBackgroundColor:[UIColor clearColor]];
|
|
|
- [packageListScrollView setShowsVerticalScrollIndicator:YES];
|
|
|
- [packageListScrollView setShowsHorizontalScrollIndicator:NO];
|
|
|
- [packageListScrollView setUserInteractionEnabled:YES];
|
|
|
- [middleScr.panGestureRecognizer requireGestureRecognizerToFail:packageListScrollView.panGestureRecognizer ];
|
|
|
-
|
|
|
- packageListScrollView.packageModelAry = [[NSMutableArray alloc] initWithArray:phonePackageDataModel.data.menuRuleVOList];
|
|
|
-
|
|
|
- /*支付方式*/
|
|
|
- payTypeView = [[PayTypeView alloc] init];
|
|
|
- [payTypeView setBackgroundColor:[UIColor whiteColor]];
|
|
|
- [payTypeView.layer setCornerRadius:8.f];
|
|
|
- [middleScr addSubview:payTypeView];
|
|
|
- [payTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.height.mas_equalTo(121);
|
|
|
- make.left.mas_equalTo(0);
|
|
|
- make.width.mas_equalTo(SCREEN_W - 2*15.f);
|
|
|
- make.top.equalTo(packageListScrollView.mas_bottom).offset(0);
|
|
|
- }];
|
|
|
-
|
|
|
- /*会员特权*/
|
|
|
- vipFunctForBuyView = [[VIPFunctForBuyView alloc] initWithFunAry:phonePackageDataModel.data.privilegeList];
|
|
|
- [vipFunctForBuyView setBackgroundColor:[UIColor whiteColor]];
|
|
|
- [vipFunctForBuyView.layer setCornerRadius:8.f];
|
|
|
- [middleScr addSubview:vipFunctForBuyView];
|
|
|
-
|
|
|
- /*计算高度*/
|
|
|
-// 全高131
|
|
|
- NSInteger funAryCount = phonePackageDataModel.data.privilegeList.count;
|
|
|
- CGFloat h_vipFunctForBuyView = 131.f;
|
|
|
- if (funAryCount <= 2){
|
|
|
- h_vipFunctForBuyView = 65.f;
|
|
|
- }else if (funAryCount <= 4){
|
|
|
- h_vipFunctForBuyView = 92.f;
|
|
|
- }
|
|
|
-
|
|
|
- [vipFunctForBuyView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.height.mas_equalTo(h_vipFunctForBuyView);
|
|
|
- make.left.mas_equalTo(0);
|
|
|
- make.width.mas_equalTo(SCREEN_W - 2*15.f);
|
|
|
- make.top.equalTo(payTypeView.mas_bottom).offset(16);
|
|
|
- }];
|
|
|
-
|
|
|
- UIView *hidenView = [[UIView alloc] init];
|
|
|
- [hidenView setBackgroundColor:[UIColor clearColor]];
|
|
|
- [middleScr addSubview:hidenView];
|
|
|
- [hidenView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.mas_equalTo(15);
|
|
|
- make.top.equalTo(vipFunctForBuyView.mas_bottom).offset(0);
|
|
|
- make.width.mas_equalTo(SCREEN_W - 2*15.f);
|
|
|
- make.height.mas_equalTo(20);
|
|
|
- make.bottom.equalTo(middleScr.mas_bottom).offset(-10);
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)buyBtnPressed{
|
|
|
- if (payTypeView.selectPayType == 0)/*微信*/{
|
|
|
- if(![WXApi isWXAppInstalled]){
|
|
|
- [[iToast makeText:@"未安装微信,请先安装微信"] show];
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- PhonePackageModel *model = [phonePackageDataModel.data.menuRuleVOList objectAtIndex:packageListScrollView.selectIndex];
|
|
|
- NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
|
|
- [params setObject:@(model.ID) forKey:@"mealId"];
|
|
|
- [params setObject:@(0) forKey:@"mealType"];
|
|
|
- [params setObject:@(0) forKey:@"couponId"];
|
|
|
- [params setObject:@(1) forKey:@"quantity"];
|
|
|
- [params setObject:@(0) forKey:@"userCardId"];
|
|
|
- [params setObject:@"VIP" forKey:@"phoneType"];
|
|
|
- [params setObject:@(0) forKey:@"automaticRenewal"];
|
|
|
-
|
|
|
- if (payTypeView.selectPayType == 0){
|
|
|
- [params setObject:@(2) forKey:@"payType"];
|
|
|
- }else{
|
|
|
- [params setObject:@(1) forKey:@"payType"];
|
|
|
- }
|
|
|
- [params setObject:[NSNumber numberWithFloat:model.actualPrice] forKey:@"totalAmount"];
|
|
|
- [params setObject:@(1) forKey:@"buyType"];
|
|
|
- NSString *jsonStr = [RSATool sortArrWithDictionary:params];
|
|
|
- NSString *signStr = [RSATool RSASignEncrypt:jsonStr key:SignKey];
|
|
|
- signStr = [RSATool deleteNewlineCharactersWithString:signStr];
|
|
|
- [params setObject:signStr forKey:@"sign"];
|
|
|
- [self showNewIndicatorWithCanBack:YES canTouch:NO];
|
|
|
- [[UseAccountManage shareInstance] CommonPostCallBackCode:PostCreateOrderAPI
|
|
|
- Params:params
|
|
|
- success:^(id _Nonnull responseObject) {
|
|
|
- [self removeNewIndicator];
|
|
|
-
|
|
|
- if (CODE == 0){
|
|
|
- NSDictionary *data = [responseObject safeDictionaryForKey:@"data"];
|
|
|
- NSString *orderNum = [data safeStringForKey:@"orderNum"];
|
|
|
- PlayResultViewController *nextVC = [[PlayResultViewController alloc] init];
|
|
|
- nextVC.orderNum = orderNum;
|
|
|
- nextVC.selectPayType = self->payTypeView.selectPayType;
|
|
|
- [self.navigationController pushViewController:nextVC animated:YES];
|
|
|
- }
|
|
|
- }
|
|
|
- failure:^(NSError * _Nonnull error) {
|
|
|
- [self removeNewIndicator];
|
|
|
- }];
|
|
|
-//#define PostCreateOrderAPI @"/api/pay/v1/order/create"/*创建订单*/
|
|
|
-//
|
|
|
-//#define GetPayOrderAPI @"/api/pay/v1/order/closeOrder"/*拉起订单支付*/
|
|
|
-
|
|
|
-// PlayResultViewController *nextVC = [[PlayResultViewController alloc] init];
|
|
|
-// [self.navigationController pushViewController:nextVC animated:YES];
|
|
|
-
|
|
|
-// /*调试UI*/
|
|
|
-// NoEnoughTimeViewController *nextVC = [[NoEnoughTimeViewController alloc] init];
|
|
|
-// nextVC.modalPresentationStyle = UIModalPresentationCustom;
|
|
|
-// [self presentViewController:nextVC animated:YES completion:^{
|
|
|
-// nextVC.view.superview.backgroundColor = [UIColor clearColor];
|
|
|
-// }];
|
|
|
-}
|
|
|
-
|
|
|
-/*
|
|
|
-#pragma mark - Navigation
|
|
|
-
|
|
|
-// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
|
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
|
- // Get the new view controller using [segue destinationViewController].
|
|
|
- // Pass the selected object to the new view controller.
|
|
|
-}
|
|
|
-*/
|
|
|
-
|
|
|
-@end
|