SetTableViewCell.m 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //
  2. // SetTableViewself.m
  3. // BuguLive
  4. //
  5. // Created by GuoMs on 16/7/18.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "SetTableViewCell.h"
  9. #import "BogoNobleViewController.h"
  10. @implementation SetTableViewCell
  11. - (void)awakeFromNib
  12. {
  13. [super awakeFromNib];
  14. self.setText.textColor = self.loginBack.textColor = kAppGrayColor1;
  15. self.memoryText.textColor = kAppGrayColor3;
  16. self.labOutLogin.text = ASLocalizedString(@"退出登录");
  17. // NSString *is_noble_mysterious = [dic objectForKey:@"is_noble_mysterious"];
  18. // //是否是神秘人
  19. // if ([is_noble_mysterious integerValue] == 1){
  20. // //如果是
  21. // sender.head_image = [dic valueForKey:@"mysterious_picture"];
  22. // sender.nick_name = [dic valueForKey:@"mysterious_name"];
  23. // }
  24. //
  25. // self.nobleOpenSwitch.onImage = [UIImage imageNamed:@"bogo_set_privite_on"];
  26. // self.nobleOpenSwitch.offImage = [UIImage imageNamed:@"bogo_set_privite_off"];
  27. self.nobleOpenSwitch.onTintColor = kAppNewMainColor;
  28. _nobleOpenSwitch.transform = CGAffineTransformMakeScale(0.75, 0.75);
  29. [self.nobleOpenSwitch addTarget:self action:@selector(onSwitchChanged:) forControlEvents:UIControlEventValueChanged];
  30. self.line.hidden = YES;
  31. }
  32. - (void)setIndexRow:(NSInteger)indexRow{
  33. _indexRow = indexRow;
  34. if (indexRow == 0) {//隐身进场
  35. if ([[GlobalVariables sharedInstance].userModel.is_noble_mysterious isEqualToString:@"1"]) {
  36. self.nobleOpenSwitch.on = YES;
  37. }else{
  38. self.nobleOpenSwitch.on = NO;
  39. }
  40. }else if (indexRow == 1){//榜单隐身
  41. if ([[GlobalVariables sharedInstance].userModel.is_noble_ranking_stealth isEqualToString:@"1"]) {
  42. self.nobleOpenSwitch.on = YES;
  43. }else{
  44. self.nobleOpenSwitch.on = NO;
  45. }
  46. }
  47. }
  48. - (void)configurationCellWithSection:(NSInteger)section row:(NSInteger)row distribution_module:(NSString *)distribution_module
  49. {
  50. self.indexRow = row;
  51. self.indexSection = section;
  52. self.nobleOpenSwitch.hidden = YES;
  53. if (section == 3)
  54. {
  55. self.setText.hidden = YES;
  56. self.memoryText.hidden = YES;
  57. self.comeBackIMG.hidden = YES;
  58. self.loginBack.textColor = kAppGrayColor1;
  59. }
  60. else
  61. {
  62. self.loginBack.hidden = YES;
  63. }
  64. if (section == 0)
  65. {
  66. NSArray *text = @[ASLocalizedString(@"帐号与安全")];
  67. self.setText.text = text[row];
  68. }
  69. else if (section == 1)
  70. {
  71. NSArray *sectionArr;
  72. if ([[GlobalVariables sharedInstance].appModel.open_noble isEqualToString:@"1"]) {
  73. sectionArr = @[ASLocalizedString(@"黑名单管理"),ASLocalizedString(@"隐私特权设置"),ASLocalizedString(@"消息推送设置"),ASLocalizedString(@"聊天设置"),ASLocalizedString(@"切换语言")];
  74. }else{
  75. sectionArr = @[ASLocalizedString(@"黑名单管理"),ASLocalizedString(@"消息推送设置"),ASLocalizedString(@"聊天设置"),ASLocalizedString(@"切换语言")];
  76. }
  77. self.setText.text = sectionArr[row];
  78. }
  79. else if (section == 2)
  80. {
  81. if (row == 2 || row == 1)
  82. {
  83. self.memoryText.hidden = NO;
  84. }
  85. NSMutableArray * sectionArr = [NSMutableArray arrayWithObjects:ASLocalizedString(@"帮助与反馈"),ASLocalizedString(@"清理缓存"),ASLocalizedString(@"检查更新"),ASLocalizedString(@"关于我们"), nil];
  86. if (kIsCheckingVersion()) {
  87. [sectionArr removeAllObjects];
  88. sectionArr = [NSMutableArray arrayWithObjects:ASLocalizedString(@"帮助与反馈"),ASLocalizedString(@"清理缓存"),ASLocalizedString(@"关于我们"), nil];
  89. }
  90. if (row == 1) {
  91. [[SDImageCache sharedImageCache] calculateSizeWithCompletionBlock:^(NSUInteger fileCount, NSUInteger totalSize) {
  92. self.memoryText.text = [NSString stringWithFormat:@"%ldMB",totalSize/1024/1024];
  93. }];
  94. }
  95. else if (row == 2 && !kIsCheckingVersion()) {
  96. NSString *buildVersion = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleVersion"];
  97. self.memoryText.text = buildVersion;
  98. // VersionNum;
  99. }
  100. self.setText.text = sectionArr[row];
  101. }
  102. }
  103. -(void)onSwitchChanged:(UISwitch *)sender{
  104. NSString *actStr = @"";
  105. if (self.indexRow == 0) {//隐身进场
  106. actStr = @"is_noble_mysterious";
  107. }else{
  108. actStr = @"is_noble_ranking_stealth";
  109. }
  110. NSMutableDictionary * parmDict = [NSMutableDictionary dictionary];
  111. [parmDict setObject:@"user" forKey:@"ctl"];
  112. [parmDict setObject:actStr forKey:@"act"];
  113. if (sender.on) {
  114. [parmDict setObject:@"1" forKey:@"type"];
  115. }else{
  116. [parmDict setObject:@"0" forKey:@"type"];
  117. }
  118. [[NetHttpsManager manager]POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  119. if ([[responseJson valueForKeyPath:@"status"]integerValue] == 0) {
  120. [FanweMessage alert:@"" message:[responseJson valueForKeyPath:@"error"] destructiveAction:^{
  121. BogoNobleViewController *vc = [BogoNobleViewController new];
  122. [[AppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
  123. } cancelAction:^{
  124. }];
  125. // [BGHUDHelper alert:[responseJson valueForKeyPath:@"error"] action:^{
  126. //
  127. // }];
  128. self.nobleOpenSwitch.on = NO;
  129. }else if([[responseJson valueForKeyPath:@"status"]integerValue] == 200){
  130. sender.on = !sender.on;
  131. }
  132. } FailureBlock:^(NSError *error) {
  133. }];
  134. }
  135. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  136. [super setSelected:selected animated:animated];
  137. // Configure the view for the selected state
  138. }
  139. @end