| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- //
- // PersonalinformationViewController.m
- // jitao
- //
- // Created by 罗云飞 on 2017/12/7.
- // Copyright © 2017年 罗云飞. All rights reserved.
- //
- #import "PersonalinformationViewController.h"
- #import "ReviseHeadCell.h"
- #import "BlankCell.h"
- #import "ReviseinfoCell.h"
- #import "NewChoiceFileController.h"
- #import "AmendnameViewController.h"
- #import "ModifypasswordViewController.h"
- #import "Userinfomodel.h"
- @interface PersonalinformationViewController ()<UITableViewDelegate,UITableViewDataSource>{
- UITableView *newtableView;
- NSMutableArray *dataArray;
- NewChoiceFileController *cont;
- Userinfomodel *model;
-
- }
- @end
- @implementation PersonalinformationViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setNavTitle:@"个人信息"];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(UserinfoNotificationMethod) name:@"个人信息修改" object:nil];
- [self dataInitialization];
- [self Networkrequest];
- [self loadsView];
- // Do any additional setup after loading the view.
- }
- #pragma mark ---通知修改个人信息
- - (void)UserinfoNotificationMethod {
- [self Networkrequest];
- }
- - (void)Networkrequest {
- [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
- NSMutableDictionary *parameters = NewMutableDictionaryInit;
- [NetworkRequestManager requestGetWithInterfacePrefix:JT_userInfo parameters:parameters onSuccess:^(id requestData) {
- [MBProgressHUD hideHUDForView:self.view];
- NSLog(@"服务器返回数据 :%@",requestData);
- model = [[Userinfomodel alloc] initWithDictionary:requestData[@"data"] error:nil];
- if([requestData[@"data"][@"headPortraitUrl"] isEqual:[NSNull null]]) {
- [UserEntity sharedInstance].headPortraitUrl = @"";
- }else{
- [UserEntity sharedInstance].headPortraitUrl = requestData[@"data"][@"headPortraitUrl"];
- }
- [UserEntity sharedInstance].name = requestData[@"data"][@"nickname"];
- [UserHelper cacheUserInfoFromLocation];
- [newtableView reloadData];
- } onFailure:^{
- [MBProgressHUD hideHUDForView:self.view];
- }];
-
- }
- #pragma mark - 数据初始化
- - (void)dataInitialization{
- dataArray = NewMutableArrayInit;
- for (int i=0; i<5; i++) {
- NSDictionary *dataDic = [NSDictionary dictionary];
- switch (i) {
- case 0:
- dataDic = @{@"nameKey":@"修改头像",@"imageKey":@"",@"classKey":@"",@"info":@""};
- [dataArray addObject:dataDic];
- break;
- case 1:
- dataDic = @{@"nameKey":@"",@"imageKey":@"",@"classKey":@"",@"info":@""};
- [dataArray addObject:dataDic];
- break;
- case 2:
- dataDic = @{@"nameKey":@"账 号",@"imageKey":@"账号",@"classKey":@"",@"info": [UserEntity sharedInstance].account};
- [dataArray addObject:dataDic];
- break;
- case 3:
- dataDic = @{@"nameKey":@"修改密码",@"imageKey":@"修改密码",@"classKey":@"",@"info":@"输入新密码"};
- [dataArray addObject:dataDic];
- break;
- case 4:
- dataDic = @{@"nameKey":@"您的姓名",@"imageKey":@"您的姓名",@"classKey":@"",@"info":@"修改姓名"};
- [dataArray addObject:dataDic];
- break;
- default:
- break;
- }
- }
- }
- #pragma mark ----加载界面
- - (void)loadsView{
- cont = [[NewChoiceFileController alloc]init];
- cont.view.backgroundColor = NewClearColor;
- [self.view addSubview:cont.view];
- [self.view sendSubviewToBack:cont.view];
-
- [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, ViewStartY, SCREEN_WIDTH, SCREEN_HEIGHT-ViewStartY) backgroundColor:NewNavigationColor style:UITableViewStyleGrouped delegate:self dataSource:self showsHorizontalScrollIndicator:NO showsVerticalScrollIndicator:NO hidden:NO tag:100 userInteractionEnabled:YES]];
- newtableView.separatorStyle = NO;
-
- }
- #pragma mark-------------------------UITableView------------------------------------
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- //返回每段行数
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return dataArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *Cell = @"Cell";
- static NSString *Cell1 = @"BlankCell";
- static NSString *Cell2 = @"ReviseinfoCell";
-
- if (indexPath.row == 0) {
- ReviseHeadCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell];
- if (cell == nil) {
- cell = [[ReviseHeadCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- [cell assignment:model.nickname headimageurl:model.headPortraitUrl];
- return cell;
- }else if (indexPath.row == 1 ){
- BlankCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell1];
- if (cell == nil) {
- cell = [[BlankCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell1];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- return cell;
- }else{
- ReviseinfoCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell2];
- if (cell == nil) {
- cell = [[ReviseinfoCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell2];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- [cell assignment:dataArray[indexPath.row]];
- if (indexPath.row == 4) {
- cell.line.hidden = YES;
- }
- return cell;
- }
- return [[UITableViewCell alloc] init];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.row == 0) {
- return fitScreenHeight(88);
- }else if (indexPath.row == 1 ){
- return fitScreenHeight(10);
- }
- return fitScreenHeight(44);
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"修改头像"]) {
- [self upHeadPortrait];
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"账 号"]) {
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"修改密码"]) {
- ModifypasswordViewController *vc = [[ModifypasswordViewController alloc] init];
- NewPushViewController(vc);
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"您的姓名"]) {
- AmendnameViewController *vc = [[AmendnameViewController alloc] init];
- NewPushViewController(vc);
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- return [[UIView alloc] init];
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
- return [[UIView alloc] init];
- }
- - (void)upHeadPortrait
- {
- __weak typeof(self) wself = self;
- [cont choiceFile:self type:@"修改头像" action:^(NSString *imagePath) {
- if (imagePath.length>0) {
- [wself avatarImageReplacement:imagePath];
- }
- }];
- }
- - (void)avatarImageReplacement:(NSString *)imagePath
- {
- [[NSNotificationCenter defaultCenter]postNotificationName:@"修改头像" object:nil];
- [self Networkrequest];
- }
- - (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
|