BogoRechargeViewController.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. //
  2. // BogoRechargeViewController.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/4/7.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoRechargeViewController.h"
  9. #import "BogoRechargeScrollView.h"
  10. #import "BogoRechargeRecordController.h"//收支记录
  11. #import "IAPManager.h"
  12. @interface BogoRechargeViewController ()<BogoRechargeDelegate>
  13. @property(nonatomic, strong) BogoRechargeScrollView *scrollView;
  14. @end
  15. @implementation BogoRechargeViewController
  16. - (void)viewWillAppear:(BOOL)animated {
  17. [super viewWillAppear:animated];
  18. self.navigationController.navigationBar.hidden = YES;
  19. }
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view.
  23. [self setUpView];
  24. // self.title =ASLocalizedString( @"充值");
  25. // self.view.backgroundColor = kWhiteColor;
  26. self.view.backgroundColor = [UIColor colorWithHexString:@"#F5F5F5"];
  27. UIImageView * navView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationHeight)];
  28. navView.image = [UIImage imageNamed:@"mine_navbg"];
  29. navView.userInteractionEnabled = YES;
  30. [self.view addSubview:navView];
  31. UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  32. [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal];
  33. backBtn.frame = CGRectMake(10, StatusBarHeight, 44, 44);
  34. [backBtn addTarget:self action:@selector(backLastVC) forControlEvents:UIControlEventTouchUpInside];
  35. [navView addSubview:backBtn];
  36. UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
  37. titleLabel.centerX = SCREEN_WIDTH/2;
  38. titleLabel.centerY = backBtn.centerY;
  39. titleLabel.text = ASLocalizedString(@"充值");
  40. titleLabel.textColor = UIColor.blackColor;
  41. titleLabel.font = [UIFont boldSystemFontOfSize:18];
  42. titleLabel.textAlignment = NSTextAlignmentCenter;
  43. [navView addSubview:titleLabel];
  44. UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  45. // [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal];
  46. rightBtn.frame = CGRectMake(SCREEN_WIDTH - 60 - 10, StatusBarHeight, 60, 44);
  47. [rightBtn addTarget:self action:@selector(clickRightItem) forControlEvents:UIControlEventTouchUpInside];
  48. [rightBtn setTitle:ASLocalizedString(@"收支记录") forState:UIControlStateNormal];
  49. rightBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  50. [rightBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
  51. [navView addSubview:rightBtn];
  52. // UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:ASLocalizedString(@"收支记录") style:UIBarButtonItemStylePlain target:self action:@selector(clickRightItem:)];
  53. // self.navigationItem.rightBarButtonItem = rightItem;
  54. // [self.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"333333"],NSFontAttributeName: [UIFont systemFontOfSize:14]} forState:UIControlStateNormal];
  55. // [self.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"333333"],NSFontAttributeName: [UIFont systemFontOfSize:14]} forState:UIControlStateHighlighted];
  56. [self setupBackBtnWithBlock:nil];
  57. }
  58. - (void)backLastVC {
  59. [self.navigationController popViewControllerAnimated:YES];
  60. }
  61. -(void)clickRightItem {
  62. BogoRechargeRecordController *vc = [BogoRechargeRecordController new];
  63. [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
  64. }
  65. -(void)setUpView{
  66. // [self.scrollView addSubview:self.topView];
  67. self.scrollView.contentSize = CGSizeMake(0, kScreenH - SafeAreaBottomHeight - NavigationHeight);
  68. [self.view addSubview:self.scrollView];
  69. }
  70. #pragma marlk 刷新账户
  71. - (void)reloadAcount
  72. {
  73. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  74. // if (_is_vip)
  75. // {
  76. // [parmDict setObject:@"vip_pay" forKey:@"ctl"];
  77. // [parmDict setObject:@"purchase" forKey:@"act"];
  78. // }
  79. // else
  80. // {
  81. [parmDict setObject:@"pay" forKey:@"ctl"];
  82. [parmDict setObject:@"recharge" forKey:@"act"];
  83. // }
  84. WeakSelf
  85. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  86. {
  87. NSInteger diamonds = [[responseJson objectForKey:@"diamonds"] integerValue];
  88. [weakSelf.scrollView updateDiamonds:diamonds];
  89. } FailureBlock:^(NSError *error)
  90. {
  91. }];
  92. }
  93. #pragma marlk 支付宝支付
  94. -(void)alipay:(NSString *)payinfo{
  95. // [self alipay:payinfo block:nil];
  96. }
  97. - (void)checkProid:(NSString *)pro_id {
  98. [[IAPManager sharedManager] buyProduct:pro_id completion:^(BOOL success, NSInteger amount, NSError * _Nullable error) {
  99. if (success) {
  100. [self.scrollView updateDiamonds:amount];
  101. [self reloadAcount];
  102. }
  103. }];
  104. }
  105. - (void)getProductInfowithprotectId:(NSString *)proId {
  106. }
  107. - (void)rechargeScrollView:(BogoRechargeScrollView *)rechargeScrollView didClickCloseBtn:(UIButton *)sender {
  108. }
  109. //- (void)alipay:(NSString*)payinfo block:(void(^)(SResBase* resb))block
  110. //{
  111. // NSString *appScheme = AlipayScheme;
  112. //
  113. // [[AlipaySDK defaultService] payOrder:payinfo fromScheme:appScheme callback:^(NSDictionary *resultDic) {
  114. //
  115. // SResBase* retobj = nil;
  116. //
  117. // if (resultDic)
  118. // {
  119. // if ( [[resultDic objectForKey:@"resultStatus"] intValue] == 9000 )
  120. // {
  121. // retobj = [[SResBase alloc]init];
  122. // retobj.msuccess = YES;
  123. // retobj.mmsg = ASLocalizedString(@"支付成功");
  124. // retobj.mcode = 1;
  125. // // block(retobj);
  126. // [FanweMessage alert:[NSString stringWithFormat:@"%@",retobj.mmsg]];
  127. //
  128. // [self reloadAcount];
  129. // }
  130. // else
  131. // {
  132. // retobj = [SResBase infoWithString: [resultDic objectForKey:@"memo" ]];
  133. // [FanweMessage alert:ASLocalizedString(@"支付失败")];
  134. // }
  135. // }
  136. // else
  137. // {
  138. // retobj = [SResBase infoWithString: ASLocalizedString(@"支付出现异常")];
  139. // [FanweMessage alert:ASLocalizedString(@"支付异常")];
  140. // }
  141. //
  142. // }];
  143. //}
  144. // 支付结果的通知:
  145. - (void)receiveResult:(NSString*)payid result:(BOOL)success message:(NSString*)message
  146. {
  147. if ( success == YES )
  148. {
  149. [self reloadAcount];
  150. [FanweMessage alert:ASLocalizedString(@"支付成功")];
  151. }
  152. else
  153. {
  154. [FanweMessage alert:ASLocalizedString(@"支付失败")];
  155. }
  156. }
  157. - (void)receiveChannelTypes:(NSArray<NSNumber *>*)types
  158. {
  159. // [BGInterface selectChannel:_juBaoModel.withType];
  160. }
  161. - (BOOL)shouldAutorotate
  162. {
  163. return YES;
  164. }
  165. - (void)didReceiveMemoryWarning
  166. {
  167. [super didReceiveMemoryWarning];
  168. }
  169. - (void)dealloc
  170. {
  171. NSLog(ASLocalizedString(@"释放充值"));
  172. [[NSNotificationCenter defaultCenter] removeObserver:self];
  173. }
  174. -(BogoRechargeScrollView *)scrollView{
  175. if (!_scrollView) {
  176. _scrollView = [[BogoRechargeScrollView alloc]initWithFrame:CGRectMake(0, NavigationHeight, kScreenW , kScreenH - kTopHeight - MG_BOTTOM_MARGIN)];
  177. _scrollView.reDelegate = self;
  178. _scrollView.isRecharge = YES;
  179. }
  180. return _scrollView;
  181. }
  182. @end