Setting_VC.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. //
  2. // Setting_VC.m
  3. // Haishenghai-master
  4. //
  5. // Created by 刘云鸽 on 2019/3/2.
  6. // Copyright © 2019年 Haishenghai intelligence network technology. All rights reserved.
  7. //
  8. #import "Setting_VC.h"
  9. #import "Header.h"
  10. #import <JPUSHService.h>
  11. @interface Setting_VC ()<UITableViewDelegate,UITableViewDataSource>
  12. @end
  13. @implementation Setting_VC
  14. static NSInteger seq = 0;
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. [self setUPUI];
  18. }
  19. -(void)setUPUI{
  20. self.navigationItem.title = @"设置";
  21. self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:114/255.0 blue:255/255.0 alpha:1];
  22. [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
  23. self.view.backgroundColor = [UIColor whiteColor];
  24. UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  25. [backBtn setImage:[UIImage imageNamed:@"hsh_return"] forState:UIControlStateNormal];
  26. backBtn.frame = CGRectMake(0, 0, 44, 44);
  27. [backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  28. backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  29. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
  30. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, HEIGHT) style:UITableViewStylePlain];
  31. _tableView.delegate = self;
  32. _tableView.dataSource = self;
  33. _tableView.userInteractionEnabled = YES;
  34. //表禁止滑动
  35. _tableView.scrollEnabled =NO;
  36. [self.view addSubview:_tableView];
  37. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  38. }
  39. -(void)backClick{
  40. [self.navigationController popViewControllerAnimated:YES];
  41. }
  42. #pragma mark-- tableviewDelegate
  43. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  44. return 3;
  45. }
  46. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  47. if (section==0) {
  48. return 1;
  49. }else if (section==1){
  50. return 3;
  51. }else{
  52. return 1;
  53. }
  54. return 0;
  55. }
  56. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  57. if (indexPath.section==0) {
  58. return 44;
  59. }else if(indexPath.section==1){
  60. return 44;
  61. }else{
  62. return 44;
  63. }
  64. return 0;
  65. }
  66. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  67. return 10;
  68. }
  69. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  70. UIView *header = [[UIView alloc]init];
  71. header.backgroundColor = [UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1];
  72. return header;
  73. }
  74. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  75. static NSString *cellId = @"cell";
  76. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  77. if (!cell) {
  78. cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
  79. }
  80. cell.preservesSuperviewLayoutMargins = false;
  81. cell.separatorInset = UIEdgeInsetsZero;
  82. cell.layoutMargins = UIEdgeInsetsZero;
  83. if (indexPath.section==0){
  84. cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
  85. cell.imageView.image = [UIImage imageNamed:@"hsh_user_push"];
  86. cell.textLabel.text = @"推送管理";
  87. }else if(indexPath.section ==1){
  88. cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
  89. NSArray *images = @[@"hsh_user_we",@"hsh_user_agreement",@"hsh_user_agreement"];
  90. NSArray *titles = @[@"关于我们",@"用户协议",@"隐私政策"];
  91. cell.imageView.image = [UIImage imageNamed:images[indexPath.row]];
  92. cell.textLabel.text = titles[indexPath.row];
  93. }else{
  94. UILabel *quitLabel = [[UILabel alloc]init];
  95. quitLabel.frame = CGRectMake(0, 0, self.view.frame.size.width, 44);
  96. quitLabel.textAlignment = NSTextAlignmentCenter;
  97. [cell.contentView addSubview:quitLabel];
  98. quitLabel.text = @"退出登录";
  99. quitLabel.textColor = [UIColor redColor];
  100. }
  101. return cell;
  102. }
  103. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  104. [tableView deselectRowAtIndexPath:indexPath animated:YES];//反选
  105. switch (indexPath.section) {
  106. case 0:
  107. {
  108. PushManage_VC *pushVC = [[PushManage_VC alloc]init];
  109. pushVC.hidesBottomBarWhenPushed =YES;
  110. [self.navigationController pushViewController:pushVC animated:YES];
  111. } break;
  112. case 1:
  113. {
  114. if (indexPath.row==0) {
  115. About_VC *aboutVC = [[About_VC alloc]init];
  116. aboutVC.hidesBottomBarWhenPushed =YES;
  117. [self.navigationController pushViewController:aboutVC animated:YES];
  118. }else if(indexPath.row==1){
  119. //用户协议
  120. Protcol_VC *proVC = [[Protcol_VC alloc]init];
  121. proVC.hidesBottomBarWhenPushed =YES;
  122. [self.navigationController pushViewController:proVC animated:YES];
  123. }else{
  124. // //隐私条款
  125. privacy_VC *pri = [[privacy_VC alloc]init];
  126. pri.hidesBottomBarWhenPushed = YES;
  127. [self.navigationController pushViewController:pri animated:YES];
  128. }
  129. } break;
  130. case 2:
  131. {
  132. //退出登录
  133. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"你确定要退出当前账户吗?" preferredStyle:UIAlertControllerStyleAlert];
  134. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  135. [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  136. [DataSourceManager setLoginoutWithUrlcompletionBlock:^(NSDictionary *dic) {
  137. // //删除alias
  138. // [JPUSHService deleteAlias:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
  139. // } seq:[self seq]];
  140. //退出
  141. UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[UserLogin_VC alloc] init]];
  142. [UIApplication sharedApplication].keyWindow.rootViewController = nav;
  143. }];
  144. //删除alias
  145. // [JPUSHService deleteAlias:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
  146. // } seq:[self seq]];
  147. //退出
  148. UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[UserLogin_VC alloc] init]];
  149. [UIApplication sharedApplication].keyWindow.rootViewController = nav;
  150. }]];
  151. [self presentViewController:alert animated:YES completion:nil];
  152. } break;
  153. default:
  154. break;
  155. }
  156. }
  157. - (NSInteger)seq {
  158. return ++ seq;
  159. }
  160. - (void)didReceiveMemoryWarning {
  161. [super didReceiveMemoryWarning];
  162. // Dispose of any resources that can be recreated.
  163. }
  164. /*
  165. #pragma mark - Navigation
  166. // In a storyboard-based application, you will often want to do a little preparation before navigation
  167. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  168. // Get the new view controller using [segue destinationViewController].
  169. // Pass the selected object to the new view controller.
  170. }
  171. */
  172. @end