AccountCenterViewController.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. // MineViewController.m
  2. // AICity
  3. //
  4. // Created by 刘伟伟 on 2023/7/7.
  5. // Copyright © 2023 wei.z. All rights reserved.
  6. //
  7. #import "AccountCenterViewController.h"
  8. #import "FavViewController.h"
  9. #import "PlayHistoryViewController.h"
  10. #import "CommonBarView.h"
  11. #import "DelAccountViewController.h"
  12. #import "LoginWithPassViewController.h"
  13. #import "AppDelegate.h"
  14. @interface AccountCenterViewController ()<UITableViewDelegate,UITableViewDataSource>
  15. @property(nonatomic,strong)UITableView *tableView;
  16. @property(nonatomic,strong)NSArray *imagesName;
  17. @property(nonatomic,strong)NSArray *titName;
  18. @property(nonatomic,strong)CommonBarView *customerbar;
  19. @end
  20. @implementation AccountCenterViewController
  21. -(UIStatusBarStyle)preferredStatusBarStyle{
  22. return UIStatusBarStyleLightContent;
  23. }
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. self.view.backgroundColor = rgba(18, 23, 41, 1);
  27. self.fd_prefersNavigationBarHidden = true;
  28. self.imagesName = @[@"Frame 9353",@"Frame 9355",@"Frame 9359",@"Frame 9363",@"Frame 9365",@"Frame 9371"];
  29. self.titName = @[@"我的收藏",@"账号中心",@"用户协议",@"隐私政策",@"去评分鼓励我们",@"当前版本"];
  30. // Do any additional setup after loading the view.
  31. [self.view addSubview:self.customerbar];
  32. [self.view addSubview:self.tableView];
  33. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.top.equalTo(self.customerbar.mas_bottom);
  35. make.left.right.bottom.equalTo(self.view);
  36. }];
  37. }
  38. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  39. return 1;
  40. }
  41. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  42. return 12;
  43. }
  44. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  45. if(indexPath.row==0){
  46. return 50;
  47. }else{
  48. return 62;
  49. }
  50. }
  51. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  52. return 0.01;
  53. }
  54. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  55. return 2;
  56. }
  57. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  58. if(indexPath.row == 0){
  59. DelAccountViewController *vc = [DelAccountViewController new];
  60. [self.navigationController pushViewController:vc animated:true];
  61. }else if(indexPath.row == 1) {
  62. //清理token
  63. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"existUserData"];
  64. //清理我的收藏
  65. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"mycollectlist"];
  66. //清理历史播放记录
  67. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"myhistoryplaylist"];
  68. //清理搜索历史
  69. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"mylocationhistory"];
  70. //清理历史播放进度
  71. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"playProcessData"];
  72. AppDelegate *myDelegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
  73. LoginWithPassViewController * vc = [[LoginWithPassViewController alloc] init];
  74. myDelegate.window.rootViewController = vc;
  75. }
  76. }
  77. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  78. if(indexPath.row == 0){
  79. AccountCenterCell *cell = [AccountCenterCell cellWithTableView:tableView];
  80. cell.type = 3;//0.没有 1.上 2.下 3.全
  81. cell.showContentType = 0;//0 剪头 1 文字
  82. // cell.icon.image = [UIImage imageNamed:@"Frame 9370"];
  83. cell.tit.text=@"注销账号";
  84. return cell;
  85. }else{
  86. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCellStyleDefault001"];
  87. cell.backgroundColor = [UIColor clearColor];
  88. UILabel *lab = [UILabel new];
  89. lab.text = @"退出登录";
  90. lab.font = [UIFont systemFontOfSize:16];
  91. lab.textColor = rgba(255, 255, 255, 0.8);
  92. lab.textAlignment = NSTextAlignmentCenter;
  93. [cell.contentView addSubview:lab];
  94. lab.backgroundColor = rgba(27, 31, 48, 1);
  95. [lab mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.left.equalTo(cell.contentView).offset(12);
  97. make.right.equalTo(cell.contentView).offset(-12);
  98. make.bottom.equalTo(cell.contentView);
  99. make.height.mas_equalTo(@50);
  100. }];
  101. lab.layer.cornerRadius = 12;
  102. lab.layer.masksToBounds = true;
  103. return cell;
  104. }
  105. // MineCenterCell *cell = [MineCenterCell cellWithTableView:tableView];
  106. // if(indexPath.row == 0){
  107. // cell.type = 1;
  108. // cell.showContentType = 0;
  109. // }else if(indexPath.row == 5){
  110. // cell.type = 2;
  111. // cell.showContentType = 1;
  112. // }else{
  113. // cell.type = 0;
  114. // cell.showContentType = 0;
  115. // }
  116. // cell.icon.image = [UIImage imageNamed:self.imagesName[indexPath.row]];
  117. // cell.tit.text = self.titName[indexPath.row];
  118. // return cell;
  119. }
  120. -(UITableView *)tableView{
  121. if(!_tableView){
  122. _tableView =[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
  123. _tableView.delegate = self;
  124. _tableView.dataSource = self;
  125. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  126. _tableView.showsVerticalScrollIndicator = false;
  127. _tableView.showsHorizontalScrollIndicator = false;
  128. _tableView.backgroundColor = rgba(18, 23, 41, 1);//rgba(18, 23, 41, 1);
  129. // _tableView.backgroundColor = [UIColor redColor];
  130. if (@available(iOS 11, *)) {
  131. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  132. _tableView.estimatedRowHeight = 0;
  133. _tableView.estimatedSectionFooterHeight = 0;
  134. _tableView.estimatedSectionHeaderHeight = 0;
  135. // UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
  136. // UIEdgeInsets safeAreaInsets = keyWindow.safeAreaInsets;
  137. // CGFloat topSafeArea = safeAreaInsets.top;
  138. _tableView.contentInset = UIEdgeInsetsMake(24, 0, BAR_HEIGHT, 0);
  139. // _tableView2.contentInset = UIEdgeInsetsMake(-35, 0, 0, 0);
  140. }
  141. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 // only Xcode 13+ needs and can compile this
  142. if (@available(iOS 15.0, *)) {
  143. _tableView.sectionHeaderTopPadding = 0;
  144. }
  145. #endif
  146. }
  147. return _tableView;
  148. }
  149. -(CommonBarView *)customerbar{
  150. if(!_customerbar){
  151. CGFloat h=0;
  152. if(@available(iOS 13.0, *)){
  153. UIStatusBarManager *sc= [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager;
  154. CGRect f=sc.statusBarFrame;
  155. h=f.size.height;
  156. }else{
  157. h=[UIApplication sharedApplication].statusBarFrame.size.height;
  158. }
  159. if(h>=40){
  160. h=30;
  161. }
  162. _customerbar =[[CommonBarView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 72-20+h)];
  163. _customerbar.bgView.backgroundColor = [UIColor clearColor];
  164. _customerbar.label.text=@"账号安全中心";
  165. _customerbar.bgView.alpha = 1;
  166. _customerbar.label.textColor = rgba(255, 255, 255, 1);
  167. // _customerbar.leftButton.hidden = true;
  168. // [_customerbar.leftButton setImage:[UIImage imageNamed:@"his_back"] forState:UIControlStateNormal];
  169. [_customerbar.rightButton setImage:[UIImage imageNamed:@"Frame 9411"] forState:UIControlStateNormal];
  170. [_customerbar.rightButton setTitle:@"编辑" forState:UIControlStateNormal];
  171. // [_customerbar.rightButton setImage:[self imageWithColor:[UIColor clearColor]] forState:UIControlStateSelected];
  172. [_customerbar.rightButton setTitle:@"取消" forState:UIControlStateSelected];
  173. [_customerbar.rightButton setTitleColor:rgba(255, 255, 255, 1) forState:UIControlStateNormal];
  174. _customerbar.rightButton.titleLabel.font =[UIFont systemFontOfSize:14];
  175. _customerbar.rightButton.hidden = true;
  176. [_customerbar.leftButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  177. // [_customerbar.rightButton addTarget:self action:@selector(changeSelState:) forControlEvents:UIControlEventTouchUpInside];
  178. // [_customerbar.rightButton addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside];
  179. // [_customerbar.rightButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  180. // make.centerY.equalTo(_customerbar.leftButton);
  181. // make.right.equalTo(_customerbar).offset(-15);
  182. // make.size.mas_equalTo(CGSizeMake(23, 23));
  183. // }];
  184. }
  185. return _customerbar;
  186. }
  187. -(void)backAction{
  188. [self.navigationController popViewControllerAnimated:true];
  189. }
  190. @end
  191. @implementation AccountTopCell
  192. + (instancetype)cellWithTableView:(UITableView *)tableView{
  193. static NSString *identifier = @"AccountTopCell";
  194. AccountTopCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  195. if (cell == nil) {
  196. cell = [[AccountTopCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
  197. }
  198. return cell;
  199. }
  200. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  201. {
  202. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  203. if (self) {
  204. [self creatView];
  205. }
  206. return self;
  207. }
  208. -(void)creatView{
  209. self.selectionStyle = UITableViewCellSelectionStyleNone;
  210. self.backgroundColor = [UIColor clearColor];
  211. UIImageView *bigimage=[UIImageView new];
  212. bigimage.image = [UIImage imageNamed:@"Ellipse 128"];
  213. [self.contentView addSubview:bigimage];
  214. [bigimage mas_makeConstraints:^(MASConstraintMaker *make) {
  215. make.size.mas_equalTo(CGSizeMake(60, 60));
  216. make.left.equalTo(self.contentView).offset(20);
  217. make.top.equalTo(self.contentView);
  218. }];
  219. UIImageView *smallimage=[UIImageView new];
  220. smallimage.image = [UIImage imageNamed:@"Frame 1"];
  221. [bigimage addSubview:smallimage];
  222. [smallimage mas_makeConstraints:^(MASConstraintMaker *make) {
  223. make.size.mas_equalTo(CGSizeMake(36, 36));
  224. make.center.equalTo(bigimage);
  225. }];
  226. UILabel *name = [UILabel new];
  227. name.font = [UIFont systemFontOfSize:20];
  228. name.text = @"登录/注册";
  229. name.textColor = rgba(255, 255, 255, 1);
  230. [self.contentView addSubview:name];
  231. [name mas_makeConstraints:^(MASConstraintMaker *make) {
  232. make.top.equalTo(bigimage).offset(5);
  233. make.left.equalTo(bigimage.mas_right).offset(12);
  234. }];
  235. UILabel *welcome = [UILabel new];
  236. welcome.font = [UIFont systemFontOfSize:14];
  237. welcome.text = @"Hi,欢迎来到快影";
  238. welcome.textColor = rgba(246, 234, 167, 0.6);
  239. [self.contentView addSubview:welcome];
  240. [welcome mas_makeConstraints:^(MASConstraintMaker *make) {
  241. make.top.equalTo(name.mas_bottom).offset(6);
  242. make.left.equalTo(name);
  243. }];
  244. // CGFloat top = 10; // 拉伸区域距离顶端高度
  245. // CGFloat bottom = 10 ; //拉伸区域距离底端高度
  246. // CGFloat left = 10; // 拉伸区域距离左端宽度
  247. // CGFloat right = 10; // 拉伸区域距离右端宽度
  248. // UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
  249. // UIImageView *bimage=[UIImageView new];
  250. // bimage.image = [[UIImage imageNamed:@"Rectangle 18183"] resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];;
  251. // [self.contentView addSubview:bimage];
  252. // [bimage mas_makeConstraints:^(MASConstraintMaker *make) {
  253. // make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-24, 81));
  254. // make.top.equalTo(bigimage.mas_bottom).offset(25);
  255. // make.left.equalTo(self.contentView).offset(12);
  256. // }];
  257. //
  258. // UIImageView *lefttopbg=[UIImageView new];
  259. // lefttopbg.image =[UIImage imageNamed:@"Rectangle 18188"];
  260. // [bimage addSubview:lefttopbg];
  261. // [lefttopbg mas_makeConstraints:^(MASConstraintMaker *make) {
  262. // make.size.mas_equalTo(CGSizeMake(94, 19));
  263. // make.top.left.equalTo(bimage);
  264. // }];
  265. //
  266. // UIImageView *lefttoplock=[UIImageView new];
  267. // lefttoplock.image = [UIImage imageNamed:@"Frame 4"];
  268. // [lefttopbg addSubview:lefttoplock];
  269. // [lefttoplock mas_makeConstraints:^(MASConstraintMaker *make) {
  270. // make.size.mas_equalTo(CGSizeMake(12, 12));
  271. // make.top.equalTo(lefttopbg).offset(3);
  272. // make.left.equalTo(lefttopbg).offset(11);
  273. // }];
  274. //
  275. // UILabel *lefttoptip=[UILabel new];
  276. // lefttoptip.font = [UIFont systemFontOfSize:10];
  277. // lefttoptip.text = @"未解锁";
  278. // lefttoptip.textColor = rgba(255, 243, 181, 1);
  279. // [lefttopbg addSubview:lefttoptip];
  280. // [lefttoptip mas_makeConstraints:^(MASConstraintMaker *make) {
  281. // make.centerY.equalTo(lefttoplock);
  282. // make.left.equalTo(lefttoplock.mas_right).offset(2);
  283. // }];
  284. //
  285. // UILabel *viptit=[UILabel new];
  286. // viptit.font = [UIFont systemFontOfSize:16];
  287. // viptit.text = @"影视VIP";
  288. // viptit.textColor = rgba(255, 212, 0, 1);
  289. // [bimage addSubview:viptit];
  290. // [viptit mas_makeConstraints:^(MASConstraintMaker *make) {
  291. // make.top.equalTo(lefttopbg.mas_bottom).offset(8);
  292. // make.left.equalTo(bimage).offset(12);
  293. // }];
  294. //
  295. // UILabel *openVip=[UILabel new];
  296. // openVip.font = [UIFont systemFontOfSize:14];
  297. // openVip.text = @"立即开通";
  298. // openVip.textColor = rgba(246, 234, 167, 0.6);
  299. // [bimage addSubview:openVip];
  300. // [openVip mas_makeConstraints:^(MASConstraintMaker *make) {
  301. // make.bottom.equalTo(bimage.mas_bottom).offset(-12);
  302. // make.left.equalTo(viptit);
  303. // }];
  304. //
  305. // UIImageView *openVipTip=[UIImageView new];
  306. // openVipTip.image = [UIImage imageNamed:@"Frame 9334"];
  307. // [bimage addSubview:openVipTip];
  308. // [openVipTip mas_makeConstraints:^(MASConstraintMaker *make) {
  309. // make.size.mas_equalTo(CGSizeMake(16, 16));
  310. // make.centerY.equalTo(openVip);
  311. // make.left.equalTo(openVip.mas_right).offset(2);
  312. // }];
  313. //
  314. // UIImageView *vipicon=[UIImageView new];
  315. // vipicon.image = [UIImage imageNamed:@"image 96"];
  316. // [self.contentView addSubview:vipicon];
  317. // [vipicon mas_makeConstraints:^(MASConstraintMaker *make) {
  318. // make.size.mas_equalTo(CGSizeMake(119, 109));
  319. // make.bottom.equalTo(bimage);
  320. // make.right.equalTo(bimage.mas_right).offset(-12);
  321. // }];
  322. }
  323. @end
  324. @implementation AccountCenterCell
  325. + (instancetype)cellWithTableView:(UITableView *)tableView{
  326. static NSString *identifier = @"AccountCenterCell";
  327. AccountCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  328. if (cell == nil) {
  329. cell = [[AccountCenterCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
  330. }
  331. return cell;
  332. }
  333. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  334. {
  335. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  336. if (self) {
  337. [self creatView];
  338. }
  339. return self;
  340. }
  341. -(void)setShowContentType:(int)showContentType{
  342. _showContentType = showContentType;
  343. if(showContentType==0){
  344. [self.bgView viewWithTag:310].hidden = true;
  345. [self.bgView viewWithTag:311].hidden = false;
  346. }else{
  347. [self.bgView viewWithTag:310].hidden = false;
  348. [self.bgView viewWithTag:311].hidden = true;
  349. }
  350. }
  351. -(void)setType:(int)type{
  352. _type = type;
  353. self.bgView.layer.mask = nil;
  354. if(self.type != 0){
  355. // 创建一个 UIView
  356. UIView *view = self.bgView;
  357. // 设置圆角大小和边框宽度
  358. CGFloat cornerRadius = 12.0; // 设置圆角半径
  359. // CGFloat borderWidth = 2.0; // 设置边框宽度
  360. // 创建圆角路径
  361. UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
  362. if(self.type == 1){
  363. path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
  364. }else if(self.type ==2){
  365. path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
  366. }else if(self.type == 3){
  367. path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
  368. }
  369. // 创建圆角图层
  370. CAShapeLayer *maskLayer = [CAShapeLayer layer];
  371. maskLayer.path = path.CGPath;
  372. view.layer.mask = maskLayer;
  373. }
  374. }
  375. //0.没有 1.上 2.下 3.全
  376. -(void)creatView{
  377. self.selectionStyle = UITableViewCellSelectionStyleNone;
  378. self.backgroundColor = [UIColor clearColor];
  379. UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(12, 0, kScreenWidth - 24, 50)];
  380. self.bgView = bgView;
  381. bgView.backgroundColor = rgba(27, 31, 48, 1);
  382. [self.contentView addSubview:bgView];
  383. [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  384. make.bottom.top.equalTo(self.contentView);
  385. make.left.equalTo(self.contentView).offset(12);
  386. make.right.equalTo(self.contentView).offset(-12);
  387. }];
  388. // UIImageView *icon=[UIImageView new];
  389. // self.icon = icon;
  390. // [bgView addSubview:icon];
  391. // [icon mas_makeConstraints:^(MASConstraintMaker *make) {
  392. // make.size.mas_equalTo(CGSizeMake(18, 18));
  393. // make.centerY.equalTo(bgView);
  394. // make.left.equalTo(bgView).offset(12);
  395. // }];
  396. UILabel *tit=[UILabel new];
  397. self.tit = tit;
  398. tit.font = [UIFont systemFontOfSize:16];
  399. tit.text = @"历史记录";
  400. tit.textColor = rgba(255, 255, 255, 0.8);
  401. [bgView addSubview:tit];
  402. [tit mas_makeConstraints:^(MASConstraintMaker *make) {
  403. make.centerY.equalTo(bgView);
  404. make.left.equalTo(bgView).offset(16);
  405. }];
  406. UIImageView *tip=[UIImageView new];
  407. tip.image = [UIImage imageNamed:@"Frame 9366"];
  408. tip.tag = 311;
  409. [bgView addSubview:tip];
  410. [tip mas_makeConstraints:^(MASConstraintMaker *make) {
  411. make.size.mas_equalTo(CGSizeMake(16, 16));
  412. make.centerY.equalTo(bgView);
  413. make.right.equalTo(bgView).offset(-16);
  414. }];
  415. UILabel *titDetail=[UILabel new];
  416. titDetail.tag = 310;
  417. titDetail.font = [UIFont systemFontOfSize:14];
  418. titDetail.text = @"1.0.0";
  419. titDetail.textColor = rgba(255, 255, 255, 0.6);
  420. [bgView addSubview:titDetail];
  421. [titDetail mas_makeConstraints:^(MASConstraintMaker *make) {
  422. make.centerY.equalTo(bgView);
  423. make.right.equalTo(bgView).offset(-16);
  424. }];
  425. }
  426. @end