IVTMyCenterViewController.m
8.21 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
//
// IVTMyCenterViewController.m
// IVTMeLiveTwo
//
// Created by XRG on 16/8/10.
// Copyright © 2016年 QLQ. All rights reserved.
//
#import "IVTMyCenterViewController.h"
#import "IVTMyCenterTableViewCell.h"
#import "IVTMyCenterTableViewHead.h"
#import "IVTMeSupportViewController.h"
#import "IVTMyContributionListViewController.h"
#import "IVTGainsViewController.h"
#import "IVTMySettingViewController.h"
#import "IVTMyChatListViewController.h"
#import "IVTMyAccountViewController.h"
#import "IVTMyFollowListViewController.h"
#import "IVTMyFansListViewController.h"
#import "IVTMyLiveViewController.h"
#import "RealNameAuthenticationViewController.h"
@interface IVTMyCenterViewController ()<UITableViewDelegate,UITableViewDataSource,IVTMyCenterTableViewHeadDelegate>
{
NSArray *titleDataArray;
NSArray *imageDataArray;
UITableView *myTableView;
IVTMyCenterTableViewHead *headView;
}
@end
@implementation IVTMyCenterViewController
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
myTableView.contentInset = UIEdgeInsetsZero;
myTableView.scrollIndicatorInsets = UIEdgeInsetsZero;
}
-(UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- (BOOL)prefersStatusBarHidden {
return NO; // 是否隐藏状态栏
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
[self doRequest];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setNavigationBar];
titleDataArray = [NSArray arrayWithObjects:@"我的支持度",@"贡献榜",@"收益",@"认证", nil];
imageDataArray = [NSArray arrayWithObjects:@"我的支持度--图标",@"贡献榜-图标",@"收益图标",@"realNameAuth", nil];
[self initUI];
}
- (void)setNavigationBar{
self.navigationItem.title = @"我的";
}
- (void)initUI{
__weak __typeof(self)weakSelf = self;
myTableView = [[UITableView alloc]init];
myTableView.showsVerticalScrollIndicator = NO;
myTableView.showsHorizontalScrollIndicator = NO;
myTableView.delegate = self;
myTableView.dataSource = self;
myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
myTableView.backgroundColor = UIColorFromRGBAlphaHex(0xf6f6f6, 1.0);
myTableView.mj_header = [MJRefreshHeader headerWithRefreshingTarget:self refreshingAction:@selector(doRequest)];
[self.view addSubview:myTableView];
[myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(weakSelf.view.mas_left);
make.top.equalTo(weakSelf.view.mas_top);
make.right.equalTo(weakSelf.view.mas_right);
make.bottom.equalTo(weakSelf.view.mas_bottom);
}];
headView = [[IVTMyCenterTableViewHead alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 355)];
headView.delegate = self;
myTableView.tableHeaderView = headView;
headView.dictData = [IVTAccountTool getUserInfoAsDictionary];
}
#pragma --mark UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return titleDataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
IVTMyCenterTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell = [[IVTMyCenterTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.imageName = imageDataArray[indexPath.row];
cell.titleString = titleDataArray[indexPath.row];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 10;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row==0) {
IVTMeSupportViewController *meSupportVC = [[IVTMeSupportViewController alloc]init];
meSupportVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:meSupportVC animated:YES];
}
else if (indexPath.row == 1){
IVTMyContributionListViewController *myContributionListVC = [[IVTMyContributionListViewController alloc]init];
myContributionListVC.userId = [IVTAccountTool getUserId];
myContributionListVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myContributionListVC animated:YES];
}
else if (indexPath.row == 2){
IVTGainsViewController * myGainsVC = [[IVTGainsViewController alloc] init];
myGainsVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myGainsVC animated:YES];
}
else if (indexPath.row == 3){
RealNameAuthenticationViewController *realNameAuthenticationVC = [[RealNameAuthenticationViewController alloc]initWithNibName:@"RealNameAuthenticationViewController" bundle:nil];
realNameAuthenticationVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:realNameAuthenticationVC animated:YES];
}
}
#pragma --mark IVTMyCenterTableViewHeadDelegate
//设置
- (void)settingClick{
IVTMySettingViewController *mySettingVC = [[IVTMySettingViewController alloc]init];
mySettingVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:mySettingVC animated:YES];
}
//消息
- (void)messageClick{
IVTMyChatListViewController *myChatListVC = [[IVTMyChatListViewController alloc]init];
myChatListVC.isSmall = NO;
myChatListVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myChatListVC animated:YES];
}
//我的账号
- (void)myAccountClick{
IVTMyAccountViewController *myAccountVC = [[IVTMyAccountViewController alloc]init];
myAccountVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myAccountVC animated:YES];
}
//关注
- (void)followListClick{
IVTMyFollowListViewController *myFollowListVC = [[IVTMyFollowListViewController alloc]init];
myFollowListVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myFollowListVC animated:YES];
}
//粉丝
- (void)fanListClick{
IVTMyFansListViewController *myFansListVC = [[IVTMyFansListViewController alloc]init];
myFansListVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myFansListVC animated:YES];
}
//进入直播
- (void)enterMyLiveClick{
IVTMyLiveViewController *myLiveVC = [[IVTMyLiveViewController alloc]init];
myLiveVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myLiveVC animated:YES];
}
- (void)doRequest{
[[IVTNetworkAPIClient sharedClient] getUserInfoOfSelfSuccess:^(NSDictionary *successData) {
[myTableView.mj_header endRefreshing];
NSDictionary *dict = successData[@"data"];
headView.dictData = dict;
NSMutableDictionary *dictForCache = [dict mutableCopy];
[dictForCache setObject:[IVTAccountTool getUserName] forKey:@"msisdn"];
[dictForCache setObject:[IVTAccountTool getPassword] forKey:@"captcha"];
[dictForCache setObject:[NSNumber numberWithBool:NO] forKey:@"isLoginFromThirdParty"];
[IVTAccountTool saveUserInfoToDictionary:dictForCache];
} error:^(NSDictionary *successData) {
[myTableView.mj_header endRefreshing];
} failure:^(NSError *failureError) {
[myTableView.mj_header endRefreshing];
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#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