MOMineSetUpVC.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. //
  2. // MOMineSetUpVC.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/10/23.
  6. //
  7. #import "MOMineSetUpVC.h"
  8. #import "MOMineSetUpCell.h"
  9. #import "MOSetUpPlayBackCell.h"
  10. #import "MOBlackListVC.h"
  11. #import "MOChangeLanguageVC.h"
  12. #import "MOLoginChooseVC.h"
  13. #import "MOBingMobileVC.h"
  14. #import "MOSetPasswordSMS.h"
  15. #import "MOAboutUsVC.h"
  16. #import "NSDate+K1Util.h"
  17. #import "MODeleteAccountAlertView.h"
  18. #import "MOPhoneBindVC.h"
  19. #import "MONewVersionView.h"
  20. #import "MOAccountSecurityVC.h"
  21. #import "MOMinimizeManager.h"
  22. #import "MOThreeOptionAlertView.h"
  23. #if DEBUG
  24. #import "DoraemonKit.h"
  25. #endif
  26. @interface MOMineSetUpVC ()
  27. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  28. @property (weak, nonatomic) IBOutlet UISwitch *theTestSwitch;
  29. @property (nonatomic, strong) MOSecurityData *baseData;
  30. @property (nonatomic, strong) UIView *footerView;
  31. @property (weak, nonatomic) IBOutlet UIView *dokitView;
  32. @property (weak, nonatomic) IBOutlet UISwitch *dokitSwitch;
  33. @end
  34. @implementation MOMineSetUpVC
  35. - (void)viewWillAppear:(BOOL)animated
  36. {
  37. [super viewWillAppear:animated];
  38. [self.navigationController setNavigationBarHidden:NO animated:animated];
  39. [self mo_v2_setNavLeftItemWithImage:[UIImage imageNamed:@"v_2_icon_new_back_black"] andBackgroundImg:nil AndBgColor:nil];
  40. }
  41. - (void)viewDidLoad {
  42. [super viewDidLoad];
  43. self.navigationItem.title = NSLocalString(@"mimo_setting_titler");
  44. [self setupUI];
  45. [self toGetTheSecurityInfo];
  46. }
  47. - (void)toGetTheSecurityInfo{
  48. WEAKSELF
  49. [kHttpManager toGetTheUserSecurityInfoWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  50. if(kCode_Success){
  51. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  52. weakSelf.baseData = [MOSecurityData modelObjectWithDictionary:data[@"data"]];
  53. [weakSelf.tableView reloadData];
  54. }
  55. else{
  56. MOLogV(@"toGetTheUserSecurityInfoWithParams 接口报错了");
  57. kShowNetError(data)
  58. }
  59. }];
  60. }
  61. - (void)setupUI{
  62. self.view.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA"];
  63. self.tableView.estimatedRowHeight = 0;
  64. self.tableView.estimatedSectionHeaderHeight = 0;
  65. self.tableView.estimatedSectionFooterHeight = 0;
  66. //iOS15适配
  67. if (@available(iOS 15.0, *))
  68. {
  69. self.tableView.sectionHeaderTopPadding = 0;
  70. }
  71. [self.tableView registerClass:MOMineSetUpCell.class forCellReuseIdentifier:NSStringFromClass(MOMineSetUpCell.class)];
  72. [self.tableView registerClass:MOSetUpPlayBackCell.class forCellReuseIdentifier:NSStringFromClass(MOSetUpPlayBackCell.class)];
  73. self.tableView.tableFooterView = self.footerView;
  74. #if DEBUG
  75. self.theTestSwitch.hidden = NO;
  76. BOOL isTest = GetIsTest;
  77. self.theTestSwitch.on = isTest;
  78. self.dokitView.hidden = NO;
  79. self.dokitView.layer.cornerRadius = 16;
  80. [self.dokitSwitch setOn:[[DoraemonManager shareInstance] isShowDoraemon]];
  81. #endif
  82. //#if kAPP_Environment == 2
  83. // UIButton *copyIDFVBtn = [[UIButton alloc] init];
  84. // copyIDFVBtn.backgroundColor = [UIColor cyanColor];
  85. // [copyIDFVBtn setTitle:@"idfv" forState:UIControlStateNormal];
  86. // [copyIDFVBtn addTarget:self action:@selector(copyIDFVBtnAction) forControlEvents:UIControlEventTouchUpInside];
  87. // [self.view addSubview:copyIDFVBtn];
  88. // [copyIDFVBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  89. // make.bottom.equalTo(self.quitBtn.mas_top).offset(-10);
  90. // make.right.equalTo(self.quitBtn);
  91. // make.size.mas_equalTo(CGSizeMake(50, 30));
  92. // }];
  93. //
  94. //#endif
  95. }
  96. //#if kAPP_Environment == 2
  97. //- (void)copyIDFVBtnAction {
  98. // [Adjust idfvWithCompletionHandler:^(NSString * _Nullable idfv) {
  99. // UIPasteboard *pab = [UIPasteboard generalPasteboard];
  100. // [pab setString:idfv];
  101. // if (pab == nil) {
  102. // [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_money_Failed")];
  103. // } else {
  104. // [MBProgressHUD showTipMessageInWindow:idfv];
  105. // }
  106. // }];
  107. //}
  108. //#endif
  109. #pragma mark - UITableViewDelegate,UITableViewDataSource
  110. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  111. return 5;
  112. }
  113. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  114. return 1;
  115. }
  116. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  117. if (indexPath.section == 4) {//播放设置
  118. CGFloat contentHeight = [MOTools getSizeFrom:NSLocalString(@"mimo_setting_play_desc") font:[MOTextTools regularFont:12] maxSize:CGSizeMake(SCREENWIDTH - 153, MAXFLOAT)].height;
  119. return contentHeight + 60;
  120. }
  121. return 56.0;
  122. }
  123. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  124. if (indexPath.section == 4) {//播放设置
  125. MOSetUpPlayBackCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(MOSetUpPlayBackCell.class)];
  126. cell.titleLabel.text = NSLocalString(@"mimo_setting_play");
  127. [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_play"]];
  128. cell.contentLabel.text = NSLocalString(@"mimo_setting_play_desc");
  129. return cell;
  130. } else {
  131. MOMineSetUpCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(MOMineSetUpCell.class)];
  132. cell.titleLabel.text = @"";
  133. [cell hideStartImgView];
  134. if(indexPath.section == 0){
  135. cell.titleLabel.text = NSLocalString(@"mimo_mine_setting_account_security");
  136. [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_account"]];
  137. if(self.baseData){
  138. if(self.baseData.level == 2){
  139. //High
  140. [cell setupStartImageWithHight:YES];
  141. }
  142. else{
  143. //Low
  144. [cell setupStartImageWithHight:NO];
  145. }
  146. }
  147. }
  148. else if (indexPath.section == 1){
  149. cell.titleLabel.text = NSLocalString(@"mimo_setting_language");
  150. [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_language"]];
  151. }
  152. else if (indexPath.section == 2){
  153. cell.titleLabel.text = NSLocalString(@"mimo_setting_blacklist");
  154. [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_black"]];
  155. }
  156. else if (indexPath.section == 3){
  157. cell.titleLabel.text = NSLocalString(@"mimo_setting_about_us");
  158. [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_about_us"]];
  159. }
  160. return cell;
  161. }
  162. }
  163. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  164. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  165. WEAKSELF
  166. if(indexPath.section == 0){
  167. MOAccountSecurityVC *securityVc = [[MOAccountSecurityVC alloc] init];
  168. securityVc.baseModel = weakSelf.baseModel;
  169. securityVc.toRefreshTheData = ^(MOSecurityData * _Nonnull theBaseData) {
  170. weakSelf.baseData = theBaseData;
  171. [weakSelf.tableView reloadData];
  172. };
  173. [self.navigationController pushViewController:securityVc animated:YES];
  174. }
  175. else if (indexPath.section == 1){
  176. //Language
  177. MOChangeLanguageVC *vc = [[MOChangeLanguageVC alloc] init];
  178. [self.navigationController pushViewController:vc animated:YES];
  179. }
  180. else if (indexPath.section == 2){
  181. //Blacklist
  182. MOBlackListVC *vc = [[MOBlackListVC alloc] init];
  183. [self.navigationController pushViewController:vc animated:YES];
  184. }
  185. else if (indexPath.section == 3){
  186. //About Us
  187. MOAboutUsVC *vc = [[MOAboutUsVC alloc] init];
  188. [self.navigationController pushViewController:vc animated:YES];
  189. }
  190. }
  191. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  192. return 0.01;
  193. }
  194. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  195. return 8;
  196. }
  197. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  198. UIView *view = [[UIView alloc] init];
  199. view.backgroundColor = [UIColor clearColor];
  200. return view;
  201. }
  202. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  203. UIView *view = [[UIView alloc] init];
  204. view.backgroundColor = [UIColor clearColor];
  205. return view;
  206. }
  207. - (IBAction)switchChanged:(UISwitch *)sender {
  208. if(sender.isOn){
  209. [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"k_MiMo_Test"];
  210. }
  211. else{
  212. [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"k_MiMo_Test"];
  213. }
  214. }
  215. - (void)logoutButtonAction {
  216. //TODO: 退出登录
  217. //关闭最小化小窗口
  218. [[MOMinimizeManager shareManager] closeAll];
  219. WEAKSELF
  220. UIAlertController *sheetC = [UIAlertController alertControllerWithTitle:nil message:NSLocalString(@"mimo_setting_revoked_alert_title") preferredStyle:UIAlertControllerStyleActionSheet];
  221. [sheetC addAction:[UIAlertAction actionWithTitle:NSLocalString(@"mimo_common_cancel") style:UIAlertActionStyleCancel handler:nil]];
  222. [sheetC addAction:[UIAlertAction actionWithTitle:NSLocalString(@"mimo_common_confirm") style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action)
  223. {
  224. [MOMineSetUpVC toLoginVCAndShowTip:NO];
  225. }]];
  226. [self presentViewController:sheetC animated:YES completion:nil];
  227. }
  228. + (void)toLoginVCAndShowTip:(BOOL)showTip{
  229. //通知服务器
  230. [kHttpManager toLogoutWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  231. MOLogV(@"退出服务器回调");
  232. }];
  233. //RTM 退出登录
  234. [[MOAgoraRTMManager shareManager] toLogoutRtm];
  235. //删除关键信息
  236. [MODataManager deleteUserDefaultsExceptApp];
  237. MOMainTabController *mainTabbar = [MOMainTabController sharedSingleton];
  238. mainTabbar.isNormalOpen = NO;
  239. MOLoginChooseVC *vc = [[MOLoginChooseVC alloc] init];
  240. UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
  241. [nav.navigationBar setHidden:YES];
  242. UIWindow *window = [UIApplication sharedApplication].keyWindow;
  243. window.rootViewController = nav;
  244. if(showTip){
  245. UIAlertAction *noAction = [UIAlertAction actionWithTitle:NSLocalString(@"mimo_boot_action_no_location_tip_Sure") style:UIAlertActionStyleDefault handler:nil];
  246. NSString *tipStr = NSLocalString(@"mimo_login_tip_status_other_device");
  247. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:tipStr message:nil preferredStyle:UIAlertControllerStyleAlert];
  248. [alertController addAction:noAction];
  249. [nav presentViewController:alertController animated:YES completion:nil];
  250. }
  251. [MOEventDeliver notifyUserLogout];
  252. }
  253. - (UIView *)footerView {
  254. if (!_footerView) {
  255. _footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 80)];
  256. _footerView.backgroundColor = [UIColor clearColor];
  257. UIButton *logoutButton = [[UIButton alloc] init];
  258. [logoutButton setTitle:NSLocalString(@"mimo_setting_revoked") forState:UIControlStateNormal];
  259. [logoutButton setTitleColor:[MOTools colorWithHexString:@"#F23051"] forState:UIControlStateNormal];
  260. logoutButton.titleLabel.font = [MOTextTools mediumFont:16];
  261. logoutButton.layer.masksToBounds = YES;
  262. logoutButton.layer.cornerRadius = 16;
  263. logoutButton.layer.borderWidth = 1;
  264. logoutButton.layer.borderColor = [MOTools colorWithHexString:@"#DADCE6"].CGColor;
  265. [logoutButton setBackgroundImage:[MOTools createImageWithColor:[MOTools colorWithHexString:@"#FFFFFF"]] forState:UIControlStateNormal];
  266. [logoutButton setBackgroundImage:[MOTools createImageWithColor:[MOTools colorWithHexString:@"#DADCE6"]] forState:UIControlStateHighlighted];
  267. [logoutButton addTarget:self action:@selector(logoutButtonAction) forControlEvents:UIControlEventTouchUpInside];
  268. [_footerView addSubview:logoutButton];
  269. [logoutButton mas_makeConstraints:^(MASConstraintMaker *make) {
  270. make.left.mas_equalTo(12);
  271. make.right.mas_equalTo(-12);
  272. make.center.mas_equalTo(0);
  273. make.height.mas_equalTo(48);
  274. }];
  275. }
  276. return _footerView;
  277. }
  278. - (IBAction)handleDokitSwitch:(id)sender {
  279. #if DEBUG
  280. if (self.dokitSwitch.isOn) {
  281. [[DoraemonManager shareInstance] showDoraemon];
  282. } else {
  283. [[DoraemonManager shareInstance] hiddenDoraemon];
  284. }
  285. #endif
  286. }
  287. @end