Person_VC.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. //
  2. // Person_VC.m
  3. // Haishenghai-master
  4. //
  5. // Created by GG on 2018/12/30.
  6. // Copyright © 2018年 Haishenghai intelligence network technology. All rights reserved.
  7. //
  8. #import "Person_VC.h"
  9. @interface Person_VC ()<UITableViewDelegate,UITableViewDataSource>
  10. @end
  11. @implementation Person_VC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. // Do any additional setup after loading the view.
  15. self.view.backgroundColor = [UIColor whiteColor];
  16. self.navigationItem.title =@"我的";
  17. [self setupUI];
  18. }
  19. -(void)viewWillAppear:(BOOL)animated{
  20. [super viewWillAppear:animated];
  21. //设置导航栏背景图片空image透明
  22. [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
  23. //掉透明导航栏边黑边
  24. [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
  25. }
  26. // 如果不想让其他页面的导航栏变为透明 需要重置
  27. - (void)viewWillDisappear:(BOOL)animated{
  28. [super viewWillAppear:animated];
  29. [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
  30. [self.navigationController.navigationBar setShadowImage:nil];
  31. }
  32. -(void)setupUI{
  33. [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor whiteColor]}];
  34. UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
  35. rightButton.frame = CGRectMake(0, 12, 20, 20);
  36. [rightButton setBackgroundImage:[UIImage imageNamed:@"hsh_home_set"] forState:UIControlStateNormal];
  37. [rightButton addTarget:self action:@selector(addBtnClick) forControlEvents:UIControlEventTouchUpInside];
  38. UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
  39. self.navigationItem.rightBarButtonItem = rightItem;
  40. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, HEIGHT/4+308) style:UITableViewStylePlain];
  41. _tableView.delegate = self;
  42. _tableView.dataSource = self;
  43. _tableView.userInteractionEnabled = YES;
  44. //表禁止滑动
  45. _tableView.scrollEnabled =NO;
  46. [self.view addSubview:_tableView];
  47. //设置表头
  48. _topImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"hsh_user_background"]];
  49. _topImageView.frame = CGRectMake(0, 0, self.view.frame.size.width, HEIGHT/4);
  50. _topImageView.contentMode = UIViewContentModeScaleToFill;
  51. _tableView.tableHeaderView = _topImageView;
  52. self.tableView.showsVerticalScrollIndicator = NO;
  53. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  54. _detailImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"user"]];
  55. _detailImageView.layer.cornerRadius = 30;
  56. _detailImageView.backgroundColor = [UIColor whiteColor];
  57. //联系人信息
  58. _detailImageView.frame = CGRectMake(40, _topImageView.frame.size.height/2-20, 60, 60);
  59. [_topImageView addSubview:_detailImageView];
  60. UILabel *titleLabel =[[UILabel alloc]init];
  61. titleLabel.frame = CGRectMake(110, _topImageView.frame.size.height/2-20, 200, 30);
  62. NSString *username =[[NSUserDefaults standardUserDefaults]objectForKey:@"username"];
  63. titleLabel.text = username;
  64. titleLabel.textColor = [UIColor whiteColor];
  65. titleLabel.font = [UIFont systemFontOfSize:18];
  66. [_topImageView addSubview:titleLabel];
  67. UILabel *phoneLabel =[[UILabel alloc]init];
  68. phoneLabel.frame = CGRectMake(110, _topImageView.frame.size.height/2+10, 200, 30);
  69. NSString *phone =[[NSUserDefaults standardUserDefaults]objectForKey:@"phone"];
  70. phoneLabel.text = phone;
  71. phoneLabel.textColor = [UIColor whiteColor];
  72. phoneLabel.font = [UIFont systemFontOfSize:18];
  73. [_topImageView addSubview:phoneLabel];
  74. if (@available (iOS 11.0,*)) {
  75. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  76. }else{
  77. self.automaticallyAdjustsScrollViewInsets = NO;
  78. }
  79. }
  80. #pragma mark-- tableviewDelegate
  81. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  82. return 4;
  83. }
  84. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  85. if (indexPath.section==0) {
  86. return 44;
  87. }
  88. return 0;
  89. }
  90. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  91. static NSString *cellId = @"cell";
  92. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  93. if (!cell) {
  94. cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
  95. }
  96. cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
  97. cell.preservesSuperviewLayoutMargins = false;
  98. cell.separatorInset = UIEdgeInsetsZero;
  99. cell.layoutMargins = UIEdgeInsetsZero;
  100. NSArray *images = @[@"hsh_user_place",/*@"hsh_user_equipment"*/@"hsh_user_alert",@"hsh_user_problem",@"hsh_user_tel"];
  101. NSArray *titles = @[@"场所管理",/*@"设备管理",*/@"火警通知",@"常见问题",@"联系我们"];
  102. cell.imageView.image = [UIImage imageNamed:images[indexPath.row]];
  103. cell.textLabel.text = titles[indexPath.row];
  104. return cell;
  105. }
  106. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  107. [tableView deselectRowAtIndexPath:indexPath animated:YES];//反选
  108. switch (indexPath.row) {
  109. case 0:
  110. {
  111. PlaceList_VC *placeVC = [[PlaceList_VC alloc]init];
  112. placeVC.hidesBottomBarWhenPushed = YES;
  113. [self.navigationController pushViewController:placeVC animated:YES];
  114. } break;
  115. /* case 1:
  116. {
  117. ManageDeveceList_VC *listVC = [[ManageDeveceList_VC alloc]init];
  118. listVC.hidesBottomBarWhenPushed = YES;
  119. [self.navigationController pushViewController:listVC animated:YES];
  120. } break;*/
  121. case 1:
  122. {
  123. FireAlarm_VC *fireVC = [[FireAlarm_VC alloc]init];
  124. fireVC.hidesBottomBarWhenPushed = YES;
  125. [self.navigationController pushViewController:fireVC animated:YES];
  126. } break;
  127. case 2:
  128. {
  129. ProblemViewController *proVC = [[ProblemViewController alloc]init];
  130. proVC.hidesBottomBarWhenPushed = YES;
  131. [self.navigationController pushViewController:proVC animated:YES];
  132. } break;
  133. case 3:
  134. {
  135. Service_VC *serviceVC = [[Service_VC alloc]init];
  136. serviceVC.hidesBottomBarWhenPushed = YES;
  137. serviceVC.navigationItem.title = @"客服电话";
  138. [self.navigationController pushViewController:serviceVC animated:YES];
  139. } break;
  140. default:
  141. break;
  142. }
  143. }
  144. #pragma mark---respose Event
  145. -(void)addBtnClick{
  146. Setting_VC *setVC = [[Setting_VC alloc]init];
  147. setVC.hidesBottomBarWhenPushed = YES;
  148. [self.navigationController pushViewController:setVC animated:YES];
  149. }
  150. /*
  151. -(void)quitLoginBtnClick:(UIButton *)quitBtn{
  152. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"你确定要退出当前账户吗?" preferredStyle:UIAlertControllerStyleAlert];
  153. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  154. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  155. NSString *userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userid"];
  156. [DataSourceManager setLoginoutWithUrlwithuser:userId completionBlock:^(NSDictionary *dic) {
  157. //退出
  158. UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[UserLogin_VC alloc] init]];
  159. [UIApplication sharedApplication].keyWindow.rootViewController = nav;
  160. }];
  161. }]];
  162. [self presentViewController:alert animated:YES completion:nil];
  163. NSLog(@"点了");
  164. }*/
  165. - (void)didReceiveMemoryWarning {
  166. [super didReceiveMemoryWarning];
  167. // Dispose of any resources that can be recreated.
  168. }
  169. /*
  170. #pragma mark - Navigation
  171. // In a storyboard-based application, you will often want to do a little preparation before navigation
  172. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  173. // Get the new view controller using [segue destinationViewController].
  174. // Pass the selected object to the new view controller.
  175. }
  176. */
  177. @end