// // BogoRechargeViewController.m // BuguLive // // Created by 宋晨光 on 2021/4/7. // Copyright © 2021 xfg. All rights reserved. // #import "BogoRechargeViewController.h" #import "BogoRechargeScrollView.h" #import "BogoRechargeRecordController.h"//收支记录 #import "IAPManager.h" @interface BogoRechargeViewController () @property(nonatomic, strong) BogoRechargeScrollView *scrollView; @end @implementation BogoRechargeViewController - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.hidden = YES; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self setUpView]; // self.title =ASLocalizedString( @"充值"); // self.view.backgroundColor = kWhiteColor; self.view.backgroundColor = [UIColor colorWithHexString:@"#F5F5F5"]; UIImageView * navView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationHeight)]; navView.image = [UIImage imageNamed:@"mine_navbg"]; navView.userInteractionEnabled = YES; [self.view addSubview:navView]; UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal]; backBtn.frame = CGRectMake(10, StatusBarHeight, 44, 44); [backBtn addTarget:self action:@selector(backLastVC) forControlEvents:UIControlEventTouchUpInside]; [navView addSubview:backBtn]; UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)]; titleLabel.centerX = SCREEN_WIDTH/2; titleLabel.centerY = backBtn.centerY; titleLabel.text = ASLocalizedString(@"充值"); titleLabel.textColor = UIColor.blackColor; titleLabel.font = [UIFont boldSystemFontOfSize:18]; titleLabel.textAlignment = NSTextAlignmentCenter; [navView addSubview:titleLabel]; UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal]; rightBtn.frame = CGRectMake(SCREEN_WIDTH - 60 - 10, StatusBarHeight, 60, 44); [rightBtn addTarget:self action:@selector(clickRightItem) forControlEvents:UIControlEventTouchUpInside]; [rightBtn setTitle:ASLocalizedString(@"收支记录") forState:UIControlStateNormal]; rightBtn.titleLabel.font = [UIFont systemFontOfSize:12]; [rightBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal]; [navView addSubview:rightBtn]; // UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:ASLocalizedString(@"收支记录") style:UIBarButtonItemStylePlain target:self action:@selector(clickRightItem:)]; // self.navigationItem.rightBarButtonItem = rightItem; // [self.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"333333"],NSFontAttributeName: [UIFont systemFontOfSize:14]} forState:UIControlStateNormal]; // [self.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"333333"],NSFontAttributeName: [UIFont systemFontOfSize:14]} forState:UIControlStateHighlighted]; [self setupBackBtnWithBlock:nil]; } - (void)backLastVC { [self.navigationController popViewControllerAnimated:YES]; } -(void)clickRightItem { BogoRechargeRecordController *vc = [BogoRechargeRecordController new]; [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES]; } -(void)setUpView{ // [self.scrollView addSubview:self.topView]; self.scrollView.contentSize = CGSizeMake(0, kScreenH - SafeAreaBottomHeight - NavigationHeight); [self.view addSubview:self.scrollView]; } #pragma marlk 刷新账户 - (void)reloadAcount { NSMutableDictionary *parmDict = [NSMutableDictionary dictionary]; // if (_is_vip) // { // [parmDict setObject:@"vip_pay" forKey:@"ctl"]; // [parmDict setObject:@"purchase" forKey:@"act"]; // } // else // { [parmDict setObject:@"pay" forKey:@"ctl"]; [parmDict setObject:@"recharge" forKey:@"act"]; // } WeakSelf [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) { NSInteger diamonds = [[responseJson objectForKey:@"diamonds"] integerValue]; [weakSelf.scrollView updateDiamonds:diamonds]; } FailureBlock:^(NSError *error) { }]; } #pragma marlk 支付宝支付 -(void)alipay:(NSString *)payinfo{ // [self alipay:payinfo block:nil]; } - (void)checkProid:(NSString *)pro_id { [[IAPManager sharedManager] buyProduct:pro_id completion:^(BOOL success, NSInteger amount, NSError * _Nullable error) { if (success) { [self.scrollView updateDiamonds:amount]; [self reloadAcount]; } }]; } - (void)getProductInfowithprotectId:(NSString *)proId { } - (void)rechargeScrollView:(BogoRechargeScrollView *)rechargeScrollView didClickCloseBtn:(UIButton *)sender { } //- (void)alipay:(NSString*)payinfo block:(void(^)(SResBase* resb))block //{ // NSString *appScheme = AlipayScheme; // // [[AlipaySDK defaultService] payOrder:payinfo fromScheme:appScheme callback:^(NSDictionary *resultDic) { // // SResBase* retobj = nil; // // if (resultDic) // { // if ( [[resultDic objectForKey:@"resultStatus"] intValue] == 9000 ) // { // retobj = [[SResBase alloc]init]; // retobj.msuccess = YES; // retobj.mmsg = ASLocalizedString(@"支付成功"); // retobj.mcode = 1; // // block(retobj); // [FanweMessage alert:[NSString stringWithFormat:@"%@",retobj.mmsg]]; // // [self reloadAcount]; // } // else // { // retobj = [SResBase infoWithString: [resultDic objectForKey:@"memo" ]]; // [FanweMessage alert:ASLocalizedString(@"支付失败")]; // } // } // else // { // retobj = [SResBase infoWithString: ASLocalizedString(@"支付出现异常")]; // [FanweMessage alert:ASLocalizedString(@"支付异常")]; // } // // }]; //} // 支付结果的通知: - (void)receiveResult:(NSString*)payid result:(BOOL)success message:(NSString*)message { if ( success == YES ) { [self reloadAcount]; [FanweMessage alert:ASLocalizedString(@"支付成功")]; } else { [FanweMessage alert:ASLocalizedString(@"支付失败")]; } } - (void)receiveChannelTypes:(NSArray*)types { // [BGInterface selectChannel:_juBaoModel.withType]; } - (BOOL)shouldAutorotate { return YES; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)dealloc { NSLog(ASLocalizedString(@"释放充值")); [[NSNotificationCenter defaultCenter] removeObserver:self]; } -(BogoRechargeScrollView *)scrollView{ if (!_scrollView) { _scrollView = [[BogoRechargeScrollView alloc]initWithFrame:CGRectMake(0, NavigationHeight, kScreenW , kScreenH - kTopHeight - MG_BOTTOM_MARGIN)]; _scrollView.reDelegate = self; _scrollView.isRecharge = YES; } return _scrollView; } @end