| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- //
- // HJMyWalletViewController.m
- // HappyJob
- //
- // Created by 张晓光 on 2019/9/5.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJMyWalletViewController.h"
- #import "HJMyWalletDetailViewController.h"//明细
- #import "HJMyWalletWithdrawalViewController.h"//提现
- #import "HJMyWalletView.h"
- #import "HJMyWalletAPI.h"
- #import "HJApproveStatusAPIManager.h"
- #import "HJMyWalletModel.h"
- #import "HJAuthViewController.h"//认证
- #import "HJAuthingViewController.h"//认证中
- #import "HJAuthFailedViewController.h"//认证失败
- @interface HJMyWalletViewController ()
- <
- UIGestureRecognizerDelegate,
- FBAPIManagerDelegate,
- FBAPIManagerInterceptor
- >
- @property (nonatomic, strong) HJMyWalletView *walletView;
- @property (nonatomic, strong) HJMyWalletAPI *walletAPI;//钱包余额
- @property (nonatomic, strong) HJApproveStatusAPIManager *approveStatusAPI;//认证状态的
- @property (nonatomic, assign) HJAuthStatusType authStatus;//实名认证状态
- @property (nonatomic, strong) HJConfirmPanelSingleView *confirmPanelView;
- @end
- @implementation HJMyWalletViewController
- #pragma mark - life cycle
- - (void)viewWillAppear:(BOOL)animated {
-
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:YES animated:animated];
- self.navigationController.interactivePopGestureRecognizer.delegate = self;
- [self.view.errorView.refreshButton addTarget:self
- action:@selector(refreshButtonClicked:)
- forControlEvents:UIControlEventTouchUpInside];
- }
- - (void)viewDidLoad {
-
- [super viewDidLoad];
- [self initSubViews];
- [self.walletAPI start];
- }
- #pragma mark - init
- - (void)initSubViews {
-
- [self.view addSubview:self.walletView];
- [self.walletView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.top.right.bottom.equalTo(self.view).offset(0);
- }];
- }
- #pragma mark - FBAPIManagerInterceptor
- - (BOOL)manager:(FBBaseAPIManager *)manager shouldStartCallAPIWithParams:(NSDictionary *)params {
-
- [self.view fb_showLoading];
- return YES;
- }
- - (void)managerShouldFinishCallAPI:(FBBaseAPIManager *)manager {
-
- [self.view fb_dismiss];
- }
- #pragma mark - FBAPIManagerDelegate
- - (void)managerCallAPIDidSuccess:(FBBaseAPIManager *)manager {
-
- if (manager == self.walletAPI)
- {
- [self.view dismissErrorView];
- id fetchData = [manager fetchDataWithBox:nil];
- if ([fetchData isKindOfClass:[NSDictionary class]])
- {
- HJMyWalletModel *model = [HJMyWalletModel yy_modelWithDictionary:fetchData[@"data"][@"MpMemberAccountAPI"]];
- self.walletView.moneyLabel.text = [NSString stringWithFormat:@"¥%@",[HJAppService thousandSeparatorStringWithNumber:model.moneyBalance]];
- }
- }
- if (manager == self.approveStatusAPI)
- {
- self.authStatus = (HJAuthStatusType)[[[manager fetchDataWithBox:nil] valueForKeyPath:@"data.approveStatus"] integerValue];
- if (self.authStatus == HJAuthStatusTypeAuthSuccess)
- {//认证成功(提现)
- HJMyWalletWithdrawalViewController *vc = [[HJMyWalletWithdrawalViewController alloc]init];
- [self.navigationController pushViewController:vc animated:YES];
- }
- if (self.authStatus == HJAuthStatusTypeNoAuth)
- {//没有认证
- self.confirmPanelView.titleLabel.text = @"为了保证资金安全, 请先进行实名认证。";
- [self.confirmPanelView ShowConfirmPanelSingleView];
- }
- else if (self.authStatus == HJAuthStatusTypeAuthing)
- {//认证中
- self.confirmPanelView.titleLabel.text = @"实名认证正在审核中,请耐心等待。";
- [self.confirmPanelView ShowConfirmPanelSingleView];
- }
- else if (self.authStatus == HJAuthStatusTypeAuthFailed)
- {//失败
- self.confirmPanelView.titleLabel.text = @"实名认证失败,请重新提交认证。";
- [self.confirmPanelView ShowConfirmPanelSingleView];
- }
- }
- }
- - (void)managerCallAPIDidFailed:(FBBaseAPIManager *)manager {
-
- FBAPIManagerErrorType type = manager.errorType;
-
- if (manager == self.walletAPI)
- {
- NSLog(@"------------------");
- [self.view showErrorView];
- }
- if (type == FBAPIManagerErrorTypeNoContent)
- {
- id fetchData = [manager fetchDataWithBox:nil];
- if ([fetchData isKindOfClass:[NSDictionary class]])
- {
- [self.view fb_showFailureWithStatus:fetchData[@"errmsg"]];
- }
- }
- else
- {
- [self.view fb_showFailureWithStatus:manager.errorMessage];
- }
- }
- #pragma mark - event response
- /* 错误刷新 */
- - (void)refreshButtonClicked:(UIButton *)btn {
-
- [self.walletAPI start];
- }
- /* 返回 */
- - (void)backButtonClick:(UIButton *)btn {
-
- [self.navigationController popViewControllerAnimated:YES];
- }
- /* 明细 */
- - (void)detailButtonClick:(UIButton *)btn {
-
- HJMyWalletDetailViewController *vc = [[HJMyWalletDetailViewController alloc]init];
- [self.navigationController pushViewController:vc animated:YES];
- }
- /* 提现 */
- - (void)withdrawalButtonClick:(UIButton *)btn {
-
- [self.approveStatusAPI start];
- }
- /* 好的*/
- - (void)confirmButtonClick:(UIButton *)btn {
-
- self.confirmPanelView = nil;
- if (self.authStatus == HJAuthStatusTypeNoAuth)
- {//没有认证
- HJAuthViewController *authVC = [[HJAuthViewController alloc] init];
- [self.navigationController pushViewController:authVC animated:YES];
- }
- else if (self.authStatus == HJAuthStatusTypeAuthing)
- {//认证中
- HJAuthingViewController *authingVC = [[HJAuthingViewController alloc] init];
- [self.navigationController pushViewController:authingVC animated:YES];
- }
- else if (self.authStatus == HJAuthStatusTypeAuthFailed)
- {//失败
- HJAuthFailedViewController *authFailedVC = [[HJAuthFailedViewController alloc] init];
- [self.navigationController pushViewController:authFailedVC animated:YES];
- }
- }
- #pragma mark - setter and getter
- - (HJMyWalletView *)walletView {
-
- if (_walletView == nil)
- {
- _walletView = [[HJMyWalletView alloc]init];
- [_walletView.backBtn addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- [_walletView.detailBtn addTarget:self action:@selector(detailButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- [_walletView.withdrawalBtn addTarget:self action:@selector(withdrawalButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _walletView;
- }
- - (HJMyWalletAPI *)walletAPI {
-
- if (_walletAPI == nil)
- {
- _walletAPI = [[HJMyWalletAPI alloc]init];
- _walletAPI.APIManagerDelegate = self;
- _walletAPI.APIManagerInterceptor = self;
- }
- return _walletAPI;
- }
- - (HJApproveStatusAPIManager *)approveStatusAPI {
-
- if (_approveStatusAPI == nil)
- {
- _approveStatusAPI = [[HJApproveStatusAPIManager alloc]init];
- _approveStatusAPI.APIManagerDelegate = self;
- _approveStatusAPI.APIManagerInterceptor = self;
- }
- return _approveStatusAPI;
- }
- - (HJConfirmPanelSingleView *)confirmPanelView {
-
- if (_confirmPanelView == nil)
- {
- _confirmPanelView = [[HJConfirmPanelSingleView alloc]init];
- [_confirmPanelView.confirmButton setTitle:@"好的" forState:UIControlStateNormal];
- [_confirmPanelView.confirmButton addTarget:self action:@selector(confirmButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _confirmPanelView;
- }
- /*
- #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
|