fix 首页

This commit is contained in:
lianxiang
2018-09-13 23:42:18 +08:00
parent 7d0027f58d
commit fada68d22d
62 changed files with 860 additions and 158 deletions
@@ -13,8 +13,11 @@
#import "GiSysSettingsVC.h"
#import "GiMaskTimeHistoryVC.h"
#import "UINavigationBar+Custom.h"
#import "GiGaBaseAPiRequest.h"
#import "GiGaUserManager.h"
@interface GiGaMeViewController ()
@property (nonatomic,strong) GiGaUser *user;
@end
@@ -28,14 +31,52 @@
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.backgroundColor = [UIColor lightGrayColor];
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
self.tableView.sectionFooterHeight = 0;
self.tableView.estimatedSectionFooterHeight= 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.bounces = NO;
self.tableView.frame = CGRectMake(0, PhoneX_TopMargin + 1, KMainW,KMainH - PhoneX_BottomMargin);
[self loadUserInfo];
}
-(void)loadUserInfo{
GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser];
if (!user) {
[self requstUserinfo];
}else{
self.user = user;
}
}
-(void)requstUserinfo{
GiGaBaseAPiRequest *requst = [GiGaBaseAPiRequest initWithRequestPath:@"user/v1/info" method:RequestPostMethod parms:nil];
[self.view makeToastActivity:CSToastPositionCenter];
weakify(self);
[requst requstDataWithResult:^(GiGaAPIResult *result) {
[self.view hideToastActivity];
if (result.success) {
//更新用户信息
NSDictionary *userDic = result.dic[@"userInfo"];
GiGaUser *user = [[GiGaUser alloc] initWithDictionary:userDic error:nil];
weakSelf.user = user;
[[GiGaUserManager shareUser] saveUser:user];
NSIndexSet *set = [NSIndexSet indexSetWithIndex:0];
[self.tableView reloadSections:set withRowAnimation:UITableViewRowAnimationNone];
NSLog(@"user dic ***\n%@",result.dic);
}
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
@@ -45,7 +86,7 @@
if (section == 0){
return 1;
}
return 2;
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
@@ -55,6 +96,10 @@
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaMineUserViewCell" owner:self options:nil] lastObject];
}
if (self.user) {
[cell loadUserinfoWith:self.user];
}
return cell;
}
GiGaMineInfoViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaMineInfoViewCell"];
@@ -83,21 +128,20 @@
GiMaskTimeHistoryVC *historyVC= [[GiMaskTimeHistoryVC alloc] init];
[self.navigationController pushViewController:historyVC animated:YES];
}else if (indexPath.section == 1 && indexPath.row == 1){
}else{
//系统设置
GiSysSettingsVC*settingsVC= [[GiSysSettingsVC alloc] init];
[self.navigationController pushViewController:settingsVC animated:YES];
}
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.section==0){
return 180;
return 139;
}else {
return 54;
}
@@ -109,11 +153,20 @@
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 1){
return 20;
return 6;
}
return 0.1;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (section == 1) {
UIView *view = [[UIView alloc] init];
view.backgroundColor = GIGARGB(222, 222, 222, 1);
return view;
}
return nil;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];