PersonalinformationViewController.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. //
  2. // PersonalinformationViewController.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2017/12/7.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "PersonalinformationViewController.h"
  9. #import "ReviseHeadCell.h"
  10. #import "BlankCell.h"
  11. #import "ReviseinfoCell.h"
  12. #import "NewChoiceFileController.h"
  13. #import "AmendnameViewController.h"
  14. #import "ModifypasswordViewController.h"
  15. #import "Userinfomodel.h"
  16. @interface PersonalinformationViewController ()<UITableViewDelegate,UITableViewDataSource>{
  17. UITableView *newtableView;
  18. NSMutableArray *dataArray;
  19. NewChoiceFileController *cont;
  20. Userinfomodel *model;
  21. }
  22. @end
  23. @implementation PersonalinformationViewController
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. [self setNavTitle:@"个人信息"];
  27. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(UserinfoNotificationMethod) name:@"个人信息修改" object:nil];
  28. [self dataInitialization];
  29. [self Networkrequest];
  30. [self loadsView];
  31. // Do any additional setup after loading the view.
  32. }
  33. #pragma mark ---通知修改个人信息
  34. - (void)UserinfoNotificationMethod {
  35. [self Networkrequest];
  36. }
  37. - (void)Networkrequest {
  38. [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
  39. NSMutableDictionary *parameters = NewMutableDictionaryInit;
  40. [NetworkRequestManager requestGetWithInterfacePrefix:JT_userInfo parameters:parameters onSuccess:^(id requestData) {
  41. [MBProgressHUD hideHUDForView:self.view];
  42. NSLog(@"服务器返回数据 :%@",requestData);
  43. model = [[Userinfomodel alloc] initWithDictionary:requestData[@"data"] error:nil];
  44. if([requestData[@"data"][@"headPortraitUrl"] isEqual:[NSNull null]]) {
  45. [UserEntity sharedInstance].headPortraitUrl = @"";
  46. }else{
  47. [UserEntity sharedInstance].headPortraitUrl = requestData[@"data"][@"headPortraitUrl"];
  48. }
  49. [UserEntity sharedInstance].name = requestData[@"data"][@"nickname"];
  50. [UserHelper cacheUserInfoFromLocation];
  51. [newtableView reloadData];
  52. } onFailure:^{
  53. [MBProgressHUD hideHUDForView:self.view];
  54. }];
  55. }
  56. #pragma mark - 数据初始化
  57. - (void)dataInitialization{
  58. dataArray = NewMutableArrayInit;
  59. for (int i=0; i<5; i++) {
  60. NSDictionary *dataDic = [NSDictionary dictionary];
  61. switch (i) {
  62. case 0:
  63. dataDic = @{@"nameKey":@"修改头像",@"imageKey":@"",@"classKey":@"",@"info":@""};
  64. [dataArray addObject:dataDic];
  65. break;
  66. case 1:
  67. dataDic = @{@"nameKey":@"",@"imageKey":@"",@"classKey":@"",@"info":@""};
  68. [dataArray addObject:dataDic];
  69. break;
  70. case 2:
  71. dataDic = @{@"nameKey":@"账 号",@"imageKey":@"账号",@"classKey":@"",@"info": [UserEntity sharedInstance].account};
  72. [dataArray addObject:dataDic];
  73. break;
  74. case 3:
  75. dataDic = @{@"nameKey":@"修改密码",@"imageKey":@"修改密码",@"classKey":@"",@"info":@"输入新密码"};
  76. [dataArray addObject:dataDic];
  77. break;
  78. case 4:
  79. dataDic = @{@"nameKey":@"您的姓名",@"imageKey":@"您的姓名",@"classKey":@"",@"info":@"修改姓名"};
  80. [dataArray addObject:dataDic];
  81. break;
  82. default:
  83. break;
  84. }
  85. }
  86. }
  87. #pragma mark ----加载界面
  88. - (void)loadsView{
  89. cont = [[NewChoiceFileController alloc]init];
  90. cont.view.backgroundColor = NewClearColor;
  91. [self.view addSubview:cont.view];
  92. [self.view sendSubviewToBack:cont.view];
  93. [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]];
  94. newtableView.separatorStyle = NO;
  95. }
  96. #pragma mark-------------------------UITableView------------------------------------
  97. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  98. {
  99. return 1;
  100. }
  101. //返回每段行数
  102. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  103. {
  104. return dataArray.count;
  105. }
  106. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  107. {
  108. static NSString *Cell = @"Cell";
  109. static NSString *Cell1 = @"BlankCell";
  110. static NSString *Cell2 = @"ReviseinfoCell";
  111. if (indexPath.row == 0) {
  112. ReviseHeadCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell];
  113. if (cell == nil) {
  114. cell = [[ReviseHeadCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
  115. }
  116. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
  117. cell.accessoryType = UITableViewCellAccessoryNone;
  118. [cell assignment:model.nickname headimageurl:model.headPortraitUrl];
  119. return cell;
  120. }else if (indexPath.row == 1 ){
  121. BlankCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell1];
  122. if (cell == nil) {
  123. cell = [[BlankCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell1];
  124. }
  125. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
  126. cell.accessoryType = UITableViewCellAccessoryNone;
  127. return cell;
  128. }else{
  129. ReviseinfoCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell2];
  130. if (cell == nil) {
  131. cell = [[ReviseinfoCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell2];
  132. }
  133. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
  134. cell.accessoryType = UITableViewCellAccessoryNone;
  135. [cell assignment:dataArray[indexPath.row]];
  136. if (indexPath.row == 4) {
  137. cell.line.hidden = YES;
  138. }
  139. return cell;
  140. }
  141. return [[UITableViewCell alloc] init];
  142. }
  143. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  144. {
  145. if (indexPath.row == 0) {
  146. return fitScreenHeight(88);
  147. }else if (indexPath.row == 1 ){
  148. return fitScreenHeight(10);
  149. }
  150. return fitScreenHeight(44);
  151. }
  152. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  153. if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"修改头像"]) {
  154. [self upHeadPortrait];
  155. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"账 号"]) {
  156. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"修改密码"]) {
  157. ModifypasswordViewController *vc = [[ModifypasswordViewController alloc] init];
  158. NewPushViewController(vc);
  159. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"您的姓名"]) {
  160. AmendnameViewController *vc = [[AmendnameViewController alloc] init];
  161. NewPushViewController(vc);
  162. }
  163. }
  164. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  165. return CGFLOAT_MIN;
  166. }
  167. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  168. return CGFLOAT_MIN;
  169. }
  170. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  171. return [[UIView alloc] init];
  172. }
  173. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  174. return [[UIView alloc] init];
  175. }
  176. - (void)upHeadPortrait
  177. {
  178. __weak typeof(self) wself = self;
  179. [cont choiceFile:self type:@"修改头像" action:^(NSString *imagePath) {
  180. if (imagePath.length>0) {
  181. [wself avatarImageReplacement:imagePath];
  182. }
  183. }];
  184. }
  185. - (void)avatarImageReplacement:(NSString *)imagePath
  186. {
  187. [[NSNotificationCenter defaultCenter]postNotificationName:@"修改头像" object:nil];
  188. [self Networkrequest];
  189. }
  190. - (void)didReceiveMemoryWarning {
  191. [super didReceiveMemoryWarning];
  192. // Dispose of any resources that can be recreated.
  193. }
  194. /*
  195. #pragma mark - Navigation
  196. // In a storyboard-based application, you will often want to do a little preparation before navigation
  197. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  198. // Get the new view controller using [segue destinationViewController].
  199. // Pass the selected object to the new view controller.
  200. }
  201. */
  202. @end