DelAccountViewController.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. //
  2. // DelAccountViewController.m
  3. // AICity
  4. //
  5. // Created by 刘伟伟 on 2023/7/17.
  6. // Copyright © 2023 wei.z. All rights reserved.
  7. //
  8. #import "DelAccountViewController.h"
  9. #import "CommonBarView.h"
  10. #import "AppDelegate.h"
  11. #import "LoginViewController.h"
  12. #import "LoginWithPassViewController.h"
  13. #import "ComonWKWebViewController.h"
  14. @interface DelAccountViewController ()<UITextViewDelegate>
  15. @property(nonatomic,strong)CommonBarView *customerbar;
  16. @end
  17. @implementation DelAccountViewController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self setupUI];
  21. }
  22. -(void)setupUI{
  23. [self.view addSubview:self.customerbar];
  24. self.view.backgroundColor = rgba(18, 23, 41, 1);
  25. self.fd_prefersNavigationBarHidden = true;
  26. UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
  27. NSDictionary * dic = [[NSUserDefaults standardUserDefaults] objectForKey:@"existUserData"];
  28. [iv sd_setImageWithURL:dic[@"avatar"]];
  29. [self.view addSubview:iv];
  30. [iv mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.centerX.equalTo(self.view);
  32. make.top.equalTo(self.customerbar.mas_bottom).offset(60);
  33. make.size.mas_equalTo(CGSizeMake(60, 60));
  34. }];
  35. UIImageView *iv2 = [UIImageView new];
  36. iv2.image =[UIImage imageNamed:@"Frame 9541"];
  37. [self.view addSubview:iv2];
  38. [iv2 mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.right.bottom.equalTo(iv);
  40. make.size.mas_equalTo(CGSizeMake(20, 20));
  41. }];
  42. UILabel *label = [UILabel new];
  43. label.text = dic[@"username"];
  44. label.textColor = rgba(255, 255, 255, 1);
  45. label.font = [UIFont systemFontOfSize:14];
  46. [self.view addSubview:label];
  47. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.top.equalTo(iv.mas_bottom).offset(8);
  49. make.centerX.equalTo(self.view);
  50. }];
  51. UILabel *label2 = [UILabel new];
  52. label2.text = @"开始注销前请确认以下内容";
  53. label2.textColor = rgba(255, 255, 255, 1);
  54. label2.font = [UIFont boldSystemFontOfSize:16];
  55. [self.view addSubview:label2];
  56. [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.top.equalTo(label.mas_bottom).offset(32);
  58. make.centerX.equalTo(self.view);
  59. }];
  60. UIImageView *line = [UIImageView new];
  61. line.image =[UIImage imageNamed:@"Vector 19"];
  62. [self.view addSubview:line];
  63. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.top.equalTo(label2.mas_bottom).offset(16);
  65. make.centerX.equalTo(self.view);
  66. make.size.mas_equalTo(CGSizeMake(200, 4));
  67. }];
  68. UILabel *label3 = [UILabel new];
  69. label3.numberOfLines = 0;
  70. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  71. paragraphStyle.lineSpacing = 5;// 字体的行间距
  72. NSDictionary *defaultAttributesC = @{
  73. NSFontAttributeName:[UIFont systemFontOfSize:14],
  74. NSForegroundColorAttributeName:rgba(255, 255, 255, 0.4),
  75. NSParagraphStyleAttributeName:paragraphStyle
  76. };
  77. NSMutableAttributedString * attributedStrX = [[NSMutableAttributedString alloc] initWithString:@"1.该账号是您本人注册的账号\n2.注销后,该账号内的全部权益将被清除\n3.注销后,该账号下的所有个人数据、记录将无法访问和找回\n4.该账号一旦注销完成,将无法恢复" attributes:defaultAttributesC];
  78. // label3.text = @"1.该账号是您本人注册的账号\n2.注销后,该账号内的全部权益将被清除\n3.注销后,该账号下的所有个人数据、记录将无法访问和找回\n4.该账号一旦注销完成,将无法恢复";
  79. label3.textColor = rgba(255, 255, 255, 0.4);
  80. label3.font = [UIFont boldSystemFontOfSize:14];
  81. label3.attributedText = attributedStrX;
  82. [self.view addSubview:label3];
  83. [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.top.equalTo(line.mas_bottom).offset(16);
  85. make.centerX.equalTo(self.view);
  86. make.width.mas_equalTo(@(SCREEN_WIDTH - 80));
  87. }];
  88. UITextView *label4 = [UITextView new];
  89. NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:@"已阅读并同意"];
  90. [attributedStr addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.4) range:NSMakeRange(0, attributedStr.length)];
  91. [attributedStr addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr.length)];
  92. NSMutableAttributedString *attributedStr2 = [[NSMutableAttributedString alloc] initWithString:@"《快影账号注销协议》"];
  93. [attributedStr2 addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.8) range:NSMakeRange(0, attributedStr2.length)];
  94. [attributedStr2 addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr2.length)];
  95. NSURL *baiduURL = [NSURL URLWithString:@"delprotocol://www.com"];
  96. [attributedStr2 addAttribute:NSLinkAttributeName value:baiduURL range:NSMakeRange(0, attributedStr2.length)];
  97. [attributedStr appendAttributedString:attributedStr2];
  98. label4.attributedText = attributedStr;
  99. label4.linkTextAttributes = @{NSForegroundColorAttributeName:rgba(255, 255, 255, 1)};
  100. label4.backgroundColor = [UIColor clearColor];
  101. label4.delegate = self;
  102. label4.editable = NO;
  103. label4.scrollEnabled = NO;
  104. label4.textAlignment = NSTextAlignmentCenter;
  105. // label4.textColor = rgba(255, 255, 255, 1);
  106. // label4.font = [UIFont boldSystemFontOfSize:16];
  107. [self.view addSubview:label4];
  108. [label4 mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.top.equalTo(label3.mas_bottom).offset(40);
  110. make.centerX.equalTo(self.view);
  111. // make.width.mas_equalTo(@(SCREEN_WIDTH));
  112. }];
  113. UIButton *sel = [UIButton new];
  114. sel.tag = 130;
  115. [sel setImage:[UIImage imageNamed:@"login_cirle"] forState:UIControlStateNormal];
  116. [sel setImage:[UIImage imageNamed:@"login_chick"] forState:UIControlStateSelected];
  117. [sel addTarget:self action:@selector(changeSelState) forControlEvents:UIControlEventTouchUpInside];
  118. [self.view addSubview:sel];
  119. [sel mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.centerY.equalTo(label4);
  121. make.right.equalTo(label4.mas_left).offset(-4);
  122. make.size.mas_equalTo(CGSizeMake(12, 12));
  123. }];
  124. UIButton *btn = [UIButton new];
  125. [btn setTitle:@"继续注销" forState:UIControlStateNormal];
  126. [btn setTitleColor:rgba(109, 66, 0, 1) forState:UIControlStateNormal];
  127. [btn setBackgroundImage:[UIImage imageNamed:@"Rectangle 19465"] forState:UIControlStateNormal];
  128. [btn addTarget:self action:@selector(delAccountAct) forControlEvents:UIControlEventTouchUpInside];
  129. [self.view addSubview:btn];
  130. [btn mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.centerX.equalTo(self.view);
  132. make.top.equalTo(label4.mas_bottom).offset(16);
  133. make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 80, 40));
  134. }];
  135. iv.layer.cornerRadius = 30;
  136. iv.layer.masksToBounds = true;
  137. iv.layer.borderColor = rgba(199, 190, 181, 1).CGColor;
  138. iv.layer.borderWidth = 2;
  139. iv2.layer.cornerRadius = 10;
  140. iv2.layer.masksToBounds = true;
  141. }
  142. -(void)changeSelState{
  143. UIButton *selbtn = [self.view viewWithTag:130];
  144. selbtn.selected = !selbtn.isSelected;
  145. }
  146. -(void)delAccountAct{
  147. UIButton *selbtn = [self.view viewWithTag:130];
  148. if(!selbtn.isSelected){
  149. [MBProgressHUD showMessage:@"请阅读并同意《快影账号注销协议》"];
  150. return;
  151. }
  152. [RequestTool post:@"user/userUnregister" params:@{} success:^(id responseObject) {
  153. NSLog(@"user/userUnregister-%@",responseObject);
  154. if([responseObject[@"code"] intValue] == 0 || [responseObject[@"code"] intValue] == 200){
  155. //清理token
  156. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"existUserData"];
  157. //清理我的收藏
  158. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"mycollectlist"];
  159. //清理历史播放记录
  160. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"myhistoryplaylist"];
  161. //清理搜索历史
  162. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"mylocationhistory"];
  163. //清理历史播放进度
  164. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"playProcessData"];
  165. AppDelegate *myDelegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
  166. LoginWithPassViewController * vc = [[LoginWithPassViewController alloc] init];
  167. myDelegate.window.rootViewController = vc;
  168. }
  169. } failure:^(NSError *error) {}];
  170. }
  171. -(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(nonnull NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction
  172. {
  173. if ([[URL scheme] isEqualToString:@"delprotocol"]) {
  174. ComonWKWebViewController *vc = [ComonWKWebViewController new];
  175. vc.title = @"账户注销协议";
  176. vc.url = @"https://backend.jsnoopyay.com/unregister.html";
  177. [self.navigationController pushViewController:vc animated:true];
  178. return NO;
  179. }
  180. return YES;
  181. }
  182. -(void)backAction{
  183. [self.navigationController popViewControllerAnimated:true];
  184. }
  185. -(CommonBarView *)customerbar{
  186. if(!_customerbar){
  187. CGFloat h=0;
  188. if(@available(iOS 13.0, *)){
  189. UIStatusBarManager *sc= [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager;
  190. CGRect f=sc.statusBarFrame;
  191. h=f.size.height;
  192. }else{
  193. h=[UIApplication sharedApplication].statusBarFrame.size.height;
  194. }
  195. if(h>=40){
  196. h=30;
  197. }
  198. _customerbar =[[CommonBarView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 72-20+h)];
  199. _customerbar.bgView.backgroundColor = [UIColor clearColor];
  200. _customerbar.label.text=@"温馨提示";
  201. _customerbar.bgView.alpha = 1;
  202. _customerbar.label.textColor = rgba(255, 255, 255, 1);
  203. // _customerbar.leftButton.hidden = true;
  204. // [_customerbar.leftButton setImage:[UIImage imageNamed:@"his_back"] forState:UIControlStateNormal];
  205. // [_customerbar.rightButton setImage:[UIImage imageNamed:@"Frame 9411"] forState:UIControlStateNormal];
  206. // [_customerbar.rightButton setTitle:@"编辑" forState:UIControlStateNormal];
  207. // [_customerbar.rightButton setImage:[self imageWithColor:[UIColor clearColor]] forState:UIControlStateSelected];
  208. // [_customerbar.rightButton setTitle:@"取消" forState:UIControlStateSelected];
  209. // [_customerbar.rightButton setTitleColor:rgba(255, 255, 255, 1) forState:UIControlStateNormal];
  210. // _customerbar.rightButton.titleLabel.font =[UIFont systemFontOfSize:14];
  211. [_customerbar.leftButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  212. // [_customerbar.rightButton addTarget:self action:@selector(changeSelState:) forControlEvents:UIControlEventTouchUpInside];
  213. // [_customerbar.rightButton addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside];
  214. // [_customerbar.rightButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  215. // make.centerY.equalTo(_customerbar.leftButton);
  216. // make.right.equalTo(_customerbar).offset(-15);
  217. // make.size.mas_equalTo(CGSizeMake(23, 23));
  218. // }];
  219. }
  220. return _customerbar;
  221. }
  222. @end