This commit is contained in:
lianxiang
2018-09-17 22:58:04 +08:00
parent 718900a428
commit 1a4b9db16f
22 changed files with 17646 additions and 32 deletions
@@ -37,10 +37,11 @@
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, 1, KMainW, self.view.bounds.size.height - SAFE_NAV_HEIGHT);
[self loadUserInfo];
}
-(void)loadUserInfo{
GiGaUser *currentuser = [[GiGaUserManager shareUser] getCurrentUser];
@@ -16,18 +16,31 @@
#import "GiGaUserManager.h"
#import "LYSDatePickerController.h"
#import "JYAddressPicker.h"
#import "GiGaBaseAPiRequest.h"
#import "GiGaUserJobViewCell.h"
@interface GiGaUserViewController ()<LYSDatePickerSelectDelegate>
@property (nonatomic,strong) GiGaUser *user;
@property (nonatomic,strong) NSMutableArray *jobArr;
@property (nonatomic) BOOL jobSpread;
@end
@implementation GiGaUserViewController
- (NSArray *)jobArr{
if (!_jobArr) {
_jobArr = [NSMutableArray new];
}
return _jobArr;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
//self.title = @"个人中心";
_jobSpread = NO;
[self getJobInfos];
self.user = [[GiGaUserManager shareUser] getCurrentUser];
[self addNavTitile:@"个人信息"];
@@ -50,15 +63,18 @@
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
self.tableView.sectionFooterHeight = 0;
self.tableView.estimatedSectionFooterHeight= 0;
self.tableView.estimatedSectionFooterHeight= 10;
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 10)];
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.bounces = NO;
self.tableView.frame = CGRectMake(0,PhoneX_TopMargin + 1, KMainW,KMainH - PhoneX_BottomMargin);
self.tableView.bounces = YES;
self.tableView.frame = CGRectMake(0, 1, KMainW,self.view.bounds.size.height - SAFE_NAV_HEIGHT);
[self.tableView registerClass: [GiGaUserJobViewCell class] forCellReuseIdentifier:@"GiGaUserJobViewCell"];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 3;
return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
@@ -67,8 +83,11 @@
return 1;
}else if (section == 1){
return 3;
}else if (section == 3){
return 1;
}
return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
@@ -86,7 +105,6 @@
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserIDViewCell" owner:self options:nil] lastObject];
}
[cell loadCellData:indexPath user: self.user];
return cell;
@@ -121,8 +139,30 @@
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserCityViewCell" owner:self options:nil] lastObject];
}
[cell loadCellData:indexPath user:self.user];
return cell;
}else if (indexPath.section == 3){
static NSString *cellID = @"GiGaUserJobViewCell";
GiGaUserJobViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
if (!cell) {
cell = [[GiGaUserJobViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
}
[cell userSelectjobAction:^() {
self.jobSpread = !self.jobSpread;
[tableView reloadSections:[NSIndexSet indexSetWithIndex:3] withRowAnimation:UITableViewRowAnimationNone];
}];
[cell setButtnImage:self.jobSpread with:self.jobArr];
[cell userSelectjob:^(NSString *title) {
self.user.occupationCode = title;
[tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:3 inSection:2]] withRowAnimation:UITableViewRowAnimationNone];
}];
return cell;
}
return nil;
}
@@ -131,33 +171,47 @@
if (indexPath.section == 2 && indexPath.row == 1) {
[LYSDatePickerController alertDatePickerWithController:self type:(LYSDatePickerTypeDay)];
[LYSDatePickerController customPickerDelegate:self];
weakify(self);
[LYSDatePickerController customdidSelectDatePicker:^(NSDate *date) {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy/MM/dd"];
NSString *currentDate = [dateFormat stringFromDate:date];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.detailTextLabel.text = currentDate;
GIGaUserCityViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
weakSelf.user.birthday = currentDate;
[cell loadCellData:indexPath user:weakSelf.user];
}];
}else if (indexPath.section == 2 && indexPath.row == 2){
JYAddressPicker *addressPicker = [JYAddressPicker jy_showAt:self];
weakify(self);
addressPicker.selectedItemBlock = ^(NSArray *addressArr) {
NSString *province = [addressArr objectAtIndex:0][@"text"];
NSString *city = [addressArr objectAtIndex:1][@"text"];
NSString *county = [addressArr objectAtIndex:2][@"text"];
NSString *addres = [NSString stringWithFormat:@"%@%@%@",province,city,county];
GILog(@"%@",addres);
GIGaUserCityViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
weakSelf.user.provinceName = province;
weakSelf.user.cityName = city;
weakSelf.user.areaName = county;
[cell loadCellData:indexPath user:self.user];
};
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.section==0){
return 133;
}else if (indexPath.section==3){
if (self.jobArr.count <= 0) {
return 0;
}else{
return self.jobSpread == YES ? 246 : 85;
}
}else {
return 44;
}
@@ -168,6 +222,7 @@
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 1){
return 10;
}else if (section == 2){
@@ -192,10 +247,67 @@
}
#pragma mark - 保存用户信息
-(void)saveUserInfo{
if (!self.user.nickName || [self.user.nickName isKindOfClass:[NSNull class]]) {
self.user.nickName = @"";
}
if (!self.user.weixin || [self.user.weixin isKindOfClass:[NSNull class]]) {
self.user.weixin = @"";
}
if (!self.user.birthday || [self.user.birthday isKindOfClass:[NSNull class]]) {
self.user.birthday = @"";
}
if (!self.user.occupationCode|| [self.user.occupationCode isKindOfClass:[NSNull class]]) {
self.user.occupationCode = @"";
}
NSDictionary *param = @{
@"provinceId":@"1_11",
@"cityId":@"1_11",
@"areaId":@"1_11_8",
@"nickName":self.user.nickName,
@"weixin":self.user.weixin,
@"sexCode":[NSString stringWithFormat:@"%d",self.user.sexCode],
@"birthday":self.user.birthday,
@"occupationCode":self.user.occupationCode
};
GiGaBaseAPiRequest *api =[GiGaBaseAPiRequest initWithRequestPath:kFixUserInfo method:RequestPostMethod parms:param];
[api requstDataWithResult:^(GiGaAPIResult *result) {
if (result.success) {
GIGA_ShowToast(@"修改成功");
}else{
GIGA_ShowToast(result.dic[@"msg"]);
}
}];
}
#pragma mark - 获取职业数据
-(void)getJobInfos{
NSDictionary *param = @{};
GiGaBaseAPiRequest *api =[GiGaBaseAPiRequest initWithRequestPath:kApiOccuption method:RequestPostMethod parms:param];
[api requstDataWithResult:^(GiGaAPIResult *result) {
if (result.success) {
GILog(@"%@",result.dic);
NSDictionary *dic = result.dic;
NSArray *josA = dic[@"list"];
for (NSDictionary *jobDic in josA ) {
[self.jobArr addObject:jobDic[@"dictLabel"]];
}
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:3] withRowAnimation:UITableViewRowAnimationNone];
}else{
NSString *msg = result.dic[@"msg"];
GIGA_ShowToast(msg);
}
}];
}
@end
+4 -4
View File
@@ -25,7 +25,7 @@
[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;
@@ -49,7 +49,6 @@
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaSettingsViewCell" owner:self options:nil] lastObject];
}
[cell loadCellDataAt:indexPath];
return cell;
@@ -59,7 +58,6 @@
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
@@ -84,11 +82,13 @@
[btn setTitle:@"退出登录" forState:UIControlStateNormal];
btn.layer.masksToBounds = YES;
btn.layer.cornerRadius = btn.frame.size.height / 2;
btn.backgroundColor = [UIColor greenColor];
btn.backgroundColor = GIGA_MAIN_BGCOLOR;
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(userLogOutAction) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:btn];
return view;
}
- (void)didReceiveMemoryWarning {