// // DelAccountViewController.m // AICity // // Created by 刘伟伟 on 2023/7/17. // Copyright © 2023 wei.z. All rights reserved. // #import "DelAccountViewController.h" #import "CommonBarView.h" #import "AppDelegate.h" #import "LoginViewController.h" #import "LoginWithPassViewController.h" #import "ComonWKWebViewController.h" @interface DelAccountViewController () @property(nonatomic,strong)CommonBarView *customerbar; @end @implementation DelAccountViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupUI]; } -(void)setupUI{ [self.view addSubview:self.customerbar]; self.view.backgroundColor = rgba(18, 23, 41, 1); self.fd_prefersNavigationBarHidden = true; UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)]; NSDictionary * dic = [[NSUserDefaults standardUserDefaults] objectForKey:@"existUserData"]; [iv sd_setImageWithURL:dic[@"avatar"]]; [self.view addSubview:iv]; [iv mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view); make.top.equalTo(self.customerbar.mas_bottom).offset(60); make.size.mas_equalTo(CGSizeMake(60, 60)); }]; UIImageView *iv2 = [UIImageView new]; iv2.image =[UIImage imageNamed:@"Frame 9541"]; [self.view addSubview:iv2]; [iv2 mas_makeConstraints:^(MASConstraintMaker *make) { make.right.bottom.equalTo(iv); make.size.mas_equalTo(CGSizeMake(20, 20)); }]; UILabel *label = [UILabel new]; label.text = dic[@"username"]; label.textColor = rgba(255, 255, 255, 1); label.font = [UIFont systemFontOfSize:14]; [self.view addSubview:label]; [label mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(iv.mas_bottom).offset(8); make.centerX.equalTo(self.view); }]; UILabel *label2 = [UILabel new]; label2.text = @"开始注销前请确认以下内容"; label2.textColor = rgba(255, 255, 255, 1); label2.font = [UIFont boldSystemFontOfSize:16]; [self.view addSubview:label2]; [label2 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(label.mas_bottom).offset(32); make.centerX.equalTo(self.view); }]; UIImageView *line = [UIImageView new]; line.image =[UIImage imageNamed:@"Vector 19"]; [self.view addSubview:line]; [line mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(label2.mas_bottom).offset(16); make.centerX.equalTo(self.view); make.size.mas_equalTo(CGSizeMake(200, 4)); }]; UILabel *label3 = [UILabel new]; label3.numberOfLines = 0; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lineSpacing = 5;// 字体的行间距 NSDictionary *defaultAttributesC = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:rgba(255, 255, 255, 0.4), NSParagraphStyleAttributeName:paragraphStyle }; NSMutableAttributedString * attributedStrX = [[NSMutableAttributedString alloc] initWithString:@"1.该账号是您本人注册的账号\n2.注销后,该账号内的全部权益将被清除\n3.注销后,该账号下的所有个人数据、记录将无法访问和找回\n4.该账号一旦注销完成,将无法恢复" attributes:defaultAttributesC]; // label3.text = @"1.该账号是您本人注册的账号\n2.注销后,该账号内的全部权益将被清除\n3.注销后,该账号下的所有个人数据、记录将无法访问和找回\n4.该账号一旦注销完成,将无法恢复"; label3.textColor = rgba(255, 255, 255, 0.4); label3.font = [UIFont boldSystemFontOfSize:14]; label3.attributedText = attributedStrX; [self.view addSubview:label3]; [label3 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(line.mas_bottom).offset(16); make.centerX.equalTo(self.view); make.width.mas_equalTo(@(SCREEN_WIDTH - 80)); }]; UITextView *label4 = [UITextView new]; NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:@"已阅读并同意"]; [attributedStr addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.4) range:NSMakeRange(0, attributedStr.length)]; [attributedStr addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr.length)]; NSMutableAttributedString *attributedStr2 = [[NSMutableAttributedString alloc] initWithString:@"《快影账号注销协议》"]; [attributedStr2 addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.8) range:NSMakeRange(0, attributedStr2.length)]; [attributedStr2 addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr2.length)]; NSURL *baiduURL = [NSURL URLWithString:@"delprotocol://www.com"]; [attributedStr2 addAttribute:NSLinkAttributeName value:baiduURL range:NSMakeRange(0, attributedStr2.length)]; [attributedStr appendAttributedString:attributedStr2]; label4.attributedText = attributedStr; label4.linkTextAttributes = @{NSForegroundColorAttributeName:rgba(255, 255, 255, 1)}; label4.backgroundColor = [UIColor clearColor]; label4.delegate = self; label4.editable = NO; label4.scrollEnabled = NO; label4.textAlignment = NSTextAlignmentCenter; // label4.textColor = rgba(255, 255, 255, 1); // label4.font = [UIFont boldSystemFontOfSize:16]; [self.view addSubview:label4]; [label4 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(label3.mas_bottom).offset(40); make.centerX.equalTo(self.view); // make.width.mas_equalTo(@(SCREEN_WIDTH)); }]; UIButton *sel = [UIButton new]; sel.tag = 130; [sel setImage:[UIImage imageNamed:@"login_cirle"] forState:UIControlStateNormal]; [sel setImage:[UIImage imageNamed:@"login_chick"] forState:UIControlStateSelected]; [sel addTarget:self action:@selector(changeSelState) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:sel]; [sel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(label4); make.right.equalTo(label4.mas_left).offset(-4); make.size.mas_equalTo(CGSizeMake(12, 12)); }]; UIButton *btn = [UIButton new]; [btn setTitle:@"继续注销" forState:UIControlStateNormal]; [btn setTitleColor:rgba(109, 66, 0, 1) forState:UIControlStateNormal]; [btn setBackgroundImage:[UIImage imageNamed:@"Rectangle 19465"] forState:UIControlStateNormal]; [btn addTarget:self action:@selector(delAccountAct) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; [btn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view); make.top.equalTo(label4.mas_bottom).offset(16); make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 80, 40)); }]; iv.layer.cornerRadius = 30; iv.layer.masksToBounds = true; iv.layer.borderColor = rgba(199, 190, 181, 1).CGColor; iv.layer.borderWidth = 2; iv2.layer.cornerRadius = 10; iv2.layer.masksToBounds = true; } -(void)changeSelState{ UIButton *selbtn = [self.view viewWithTag:130]; selbtn.selected = !selbtn.isSelected; } -(void)delAccountAct{ UIButton *selbtn = [self.view viewWithTag:130]; if(!selbtn.isSelected){ [MBProgressHUD showMessage:@"请阅读并同意《快影账号注销协议》"]; return; } [RequestTool post:@"user/userUnregister" params:@{} success:^(id responseObject) { NSLog(@"user/userUnregister-%@",responseObject); if([responseObject[@"code"] intValue] == 0 || [responseObject[@"code"] intValue] == 200){ //清理token [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"existUserData"]; //清理我的收藏 [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"mycollectlist"]; //清理历史播放记录 [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"myhistoryplaylist"]; //清理搜索历史 [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"mylocationhistory"]; //清理历史播放进度 [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"playProcessData"]; AppDelegate *myDelegate =(AppDelegate *) [[UIApplication sharedApplication] delegate]; LoginWithPassViewController * vc = [[LoginWithPassViewController alloc] init]; myDelegate.window.rootViewController = vc; } } failure:^(NSError *error) {}]; } -(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(nonnull NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction { if ([[URL scheme] isEqualToString:@"delprotocol"]) { ComonWKWebViewController *vc = [ComonWKWebViewController new]; vc.title = @"账户注销协议"; vc.url = @"https://backend.jsnoopyay.com/unregister.html"; [self.navigationController pushViewController:vc animated:true]; return NO; } return YES; } -(void)backAction{ [self.navigationController popViewControllerAnimated:true]; } -(CommonBarView *)customerbar{ if(!_customerbar){ CGFloat h=0; if(@available(iOS 13.0, *)){ UIStatusBarManager *sc= [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager; CGRect f=sc.statusBarFrame; h=f.size.height; }else{ h=[UIApplication sharedApplication].statusBarFrame.size.height; } if(h>=40){ h=30; } _customerbar =[[CommonBarView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 72-20+h)]; _customerbar.bgView.backgroundColor = [UIColor clearColor]; _customerbar.label.text=@"温馨提示"; _customerbar.bgView.alpha = 1; _customerbar.label.textColor = rgba(255, 255, 255, 1); // _customerbar.leftButton.hidden = true; // [_customerbar.leftButton setImage:[UIImage imageNamed:@"his_back"] forState:UIControlStateNormal]; // [_customerbar.rightButton setImage:[UIImage imageNamed:@"Frame 9411"] forState:UIControlStateNormal]; // [_customerbar.rightButton setTitle:@"编辑" forState:UIControlStateNormal]; // [_customerbar.rightButton setImage:[self imageWithColor:[UIColor clearColor]] forState:UIControlStateSelected]; // [_customerbar.rightButton setTitle:@"取消" forState:UIControlStateSelected]; // [_customerbar.rightButton setTitleColor:rgba(255, 255, 255, 1) forState:UIControlStateNormal]; // _customerbar.rightButton.titleLabel.font =[UIFont systemFontOfSize:14]; [_customerbar.leftButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; // [_customerbar.rightButton addTarget:self action:@selector(changeSelState:) forControlEvents:UIControlEventTouchUpInside]; // [_customerbar.rightButton addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside]; // [_customerbar.rightButton mas_remakeConstraints:^(MASConstraintMaker *make) { // make.centerY.equalTo(_customerbar.leftButton); // make.right.equalTo(_customerbar).offset(-15); // make.size.mas_equalTo(CGSizeMake(23, 23)); // }]; } return _customerbar; } @end