CNLiveBalanceController.m
3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//
// CNLiveBalanceController.m
// CNLiveBalanceModule
//
// Created by 153993236@qq.com on 11/12/2019.
// Copyright (c) 2019 153993236@qq.com. All rights reserved.
//
#import "CNLiveBalanceController.h"
#import "MJExtension.h"
#import <SDWebImage/SDWebImage.h>
#import "QMUIKit.h"
#import "CNUserInfoManager.h"
#import "CNLiveBaseKit.h"
#import "CNLiveServices.h"
#import "CNLiveCategory.h"
#import "CNLiveBalanceRequest.h"
#import "CNLiveBalanceNavigationBar.h"
#import "CNLiveBalanceView.h"
#import "CNLivePayCenterController.h"
@interface CNLiveBalanceController ()<CNLiveBalanceNavigationBarDelegate>
@property (nonatomic, strong) CNLiveBalanceNavigationBar *navigationBar;
@property (nonatomic, strong) CNLiveBalanceView *balanceView;
@property (nonatomic, copy) NSString *type;
@property (nonatomic, copy) NSString *ID;
@end
@implementation CNLiveBalanceController
- (instancetype)initWithType:(NSString *)type ID:(NSString *)ID{
if(self = [super init]){
self.type = type;
self.ID = ID;
}
return self;
}
#pragma mark - 加载数据
- (void)loadData {
[CNLiveBalanceRequest getBalance:self.type ID:self.ID block:^(BOOL isSuccess, NSString * _Nonnull number) {
if(isSuccess){
self.balanceView.number = number;
}
}];
}
#pragma mark - 生命周期
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
if (@available(iOS 11, *)) {
}
else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
[self createSubViews];
[self loadData];
}
- (void)createSubViews {
[self.view addSubview:self.balanceView];
[self.view addSubview:self.navigationBar];
}
#pragma mark - 状态栏
- (UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
#pragma mark - 懒加载
- (CNLiveBalanceNavigationBar *)navigationBar {
if (!_navigationBar) {
_navigationBar = [[CNLiveBalanceNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
_navigationBar.delegate = self;
if([self.type isEqualToString:@"1"]){
// 个人余额
_navigationBar.title.text = @"中国网家家补贴余额";
UIImage *image = [self getImageWithImageName:@"balance_pay_center" bundleName:@"CNLiveBalanceModule" targetClass:[self class]];
[_navigationBar.right setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
}else if ([self.type isEqualToString:@"2"]){
// 特色群组
_navigationBar.title.text = @"余额";
[_navigationBar.right setTitle:@"明细" forState:UIControlStateNormal];
}
}
return _navigationBar;
}
- (CNLiveBalanceView *)balanceView{
if(!_balanceView){
_balanceView = [[CNLiveBalanceView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 220+kStatusHeight)];
}
return _balanceView;
}
#pragma mark - 响应方法
- (void)goBack {
if (self.presentingViewController != nil) {
[self dismissViewControllerAnimated:YES completion:nil];
}
else {
[self.navigationController popViewControllerAnimated:YES];
}
}
#pragma mark - CNLiveBalanceNavigationBarDelegate
- (void)navigationBar:(CNLiveBalanceNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
if ([actionEvents isEqualToString:@"1"]) {
[self goBack];
}else if ([actionEvents isEqualToString:@"2"]){
if ([self.type isEqualToString:@"1"]) { // 支付中心
CNLivePayCenterController *vc = [CNLivePayCenterController new];
[self.navigationController pushViewController:vc animated:YES];
} else if ([self.type isEqualToString:@"2"]) { // 明细
}
}
}
@end