add files
This commit is contained in:
@@ -37,43 +37,23 @@
|
||||
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.tableView.frame = CGRectMake(0,PhoneX_TopMargin + 1, KMainW,KMainH - PhoneX_BottomMargin);
|
||||
[self loadUserInfo];
|
||||
|
||||
}
|
||||
-(void)loadUserInfo{
|
||||
|
||||
GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser];
|
||||
GiGaUser *currentuser = [[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) {
|
||||
if (!currentuser) {
|
||||
[self.view makeToastActivity:CSToastPositionCenter];
|
||||
[[GiGaUserManager shareUser] synsisUserInfo:^(GiGaUser *user) {
|
||||
[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);
|
||||
}
|
||||
}];
|
||||
self.user = user;
|
||||
}];
|
||||
}else{
|
||||
self.user = currentuser;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
//
|
||||
|
||||
#import "GiGaUserViewController.h"
|
||||
#import "GIGaUserInfoAvatorCell.h"
|
||||
#import "GIGaUserIDViewCell.h"
|
||||
#import "GIGaUserWeChatViewCell.h"
|
||||
#import "GiGaUserSexViewCell.h"
|
||||
#import "GIGaUserCityViewCell.h"
|
||||
|
||||
@interface GiGaUserViewController ()
|
||||
|
||||
@@ -19,8 +24,129 @@
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
//self.title = @"个人中心";
|
||||
[self addNavTitile:@"个人中心"];
|
||||
[self addNavTitile:@"个人信息"];
|
||||
|
||||
UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[saveBtn addTarget:self action:@selector(saveUserInfo) forControlEvents:UIControlEventTouchUpInside];
|
||||
saveBtn.frame = CGRectMake(0, 0,40, 36);
|
||||
|
||||
NSAttributedString *attrititle = [GiGaHelper stringWithText:@"保存" textColor:[UIColor whiteColor] textFont:GIGA_TEXTFONTMEDIUM(16) leterSpace:0];
|
||||
[saveBtn setAttributedTitle:attrititle forState:UIControlStateNormal];
|
||||
UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithCustomView:saveBtn];
|
||||
self.navigationItem.rightBarButtonItem = saveItem;
|
||||
|
||||
[self creatTab];
|
||||
}
|
||||
|
||||
-(void)creatTab{
|
||||
[self.view addSubview:self.tableView];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||||
return 3;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
|
||||
if (section == 0){
|
||||
return 1;
|
||||
}else if (section == 1){
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if(indexPath.section ==0){
|
||||
GIGaUserInfoAvatorCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserInfoAvatorCell"];
|
||||
if(!cell){
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserInfoAvatorCell" owner:self options:nil] lastObject];
|
||||
|
||||
}
|
||||
|
||||
return cell;
|
||||
}else if (indexPath.section == 1 && indexPath.row < 2){
|
||||
GIGaUserIDViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserIDViewCell"];
|
||||
if(!cell){
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserIDViewCell" owner:self options:nil] lastObject];
|
||||
|
||||
}
|
||||
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section == 1 && indexPath.row == 2){
|
||||
GIGaUserWeChatViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserWeChatViewCell"];
|
||||
if(!cell){
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserWeChatViewCell" owner:self options:nil] lastObject];
|
||||
}
|
||||
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section == 2 && indexPath.row == 0){
|
||||
GiGaUserSexViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaUserSexViewCell"];
|
||||
if(!cell){
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaUserSexViewCell" owner:self options:nil] lastObject];
|
||||
|
||||
}
|
||||
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section == 2 && indexPath.row >= 1){
|
||||
GIGaUserCityViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserCityViewCell"];
|
||||
if(!cell){
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserCityViewCell" owner:self options:nil] lastObject];
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if(indexPath.section==0){
|
||||
return 133;
|
||||
}else {
|
||||
return 44;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||||
return 0.1;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||||
if (section == 1){
|
||||
return 10;
|
||||
}else if (section == 2){
|
||||
return 4;
|
||||
}
|
||||
return 0.1;
|
||||
}
|
||||
|
||||
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||||
|
||||
if (section == 1 || section == 2) {
|
||||
UIView *view = [[UIView alloc] init];
|
||||
view.backgroundColor = GIGARGB(222, 222, 222, 1);
|
||||
return view;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
@@ -28,15 +154,11 @@
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
#pragma mark - 保存用户信息
|
||||
|
||||
/*
|
||||
#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.
|
||||
-(void)saveUserInfo{
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "GiGaSettingsViewCell.h"
|
||||
#import "JXTAlertController.h"
|
||||
#import "GiGaUserDefault.h"
|
||||
#import "GiGaUserManager.h"
|
||||
|
||||
@interface GiSysSettingsVC ()
|
||||
|
||||
@@ -121,7 +122,9 @@
|
||||
}
|
||||
|
||||
-(void)userlogOut{
|
||||
[GiGaUserDefault userLogOut];
|
||||
|
||||
[[GiGaUserManager shareUser] loginOut];
|
||||
NC_POST_NAME_OBJECT(kUserLogOutNotify, nil);
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user