YBDestroyAccount.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // YBDestroyAccount.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2020/6/22.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "YBDestroyAccount.h"
  9. #import "YBDestroyCell.h"
  10. #import "YBDestroySureVC.h"
  11. @interface YBDestroyAccount ()<UITableViewDelegate,UITableViewDataSource>
  12. @property(nonatomic,strong)UIView *stateView;
  13. @property(nonatomic,strong)NSArray *dataArray;
  14. @property(nonatomic,strong)UITableView *tableView;
  15. @property(nonatomic,strong)UIButton *nextBtn;
  16. @end
  17. @implementation YBDestroyAccount
  18. - (void)viewWillAppear:(BOOL)animated {
  19. [super viewWillAppear:animated];
  20. [self pullData];
  21. }
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.titleL.text = YZMsg(@"注销条件");
  25. self.dataArray = [NSArray array];
  26. [self.view addSubview:self.stateView];
  27. [self.view addSubview:self.nextBtn];
  28. [_nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.height.mas_equalTo(40);
  30. make.centerX.equalTo(self.view);
  31. make.width.equalTo(self.view.mas_width).offset(-40);
  32. make.bottom.equalTo(self.view.mas_bottom).offset(-ShowDiff-20);
  33. }];
  34. [self changeNextBtn:NO];
  35. [self.view addSubview:self.tableView];
  36. [_tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  37. make.width.centerX.equalTo(self.view);
  38. make.top.equalTo(_stateView.mas_bottom);
  39. make.bottom.equalTo(_nextBtn.mas_top).offset(-10);
  40. }];
  41. }
  42. - (UIView *)stateView {
  43. if (!_stateView) {
  44. _stateView = [[UIView alloc]initWithFrame:CGRectMake(0, self.naviView.bottom, _window_width, 40)];
  45. _stateView.backgroundColor = UIColor.clearColor;
  46. UILabel *stateL = [[UILabel alloc]init];
  47. stateL.text = YZMsg(@"满足以下条件,才能注销当前账户");
  48. stateL.textColor = RGB_COLOR(@"#ffffff", 0.61);
  49. stateL.font = [UIFont boldSystemFontOfSize:15];
  50. stateL.numberOfLines = 0;
  51. [_stateView addSubview:stateL];
  52. [stateL mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.equalTo(_stateView.mas_left).offset(15);
  54. make.centerY.equalTo(_stateView);
  55. make.height.lessThanOrEqualTo(_stateView);
  56. make.right.lessThanOrEqualTo(_stateView.mas_right).offset(-15);
  57. }];
  58. }
  59. return _stateView;
  60. }
  61. - (UIButton *)nextBtn {
  62. if (!_nextBtn) {
  63. _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  64. [_nextBtn setTitle:YZMsg(@"下一步") forState:0];
  65. _nextBtn.backgroundColor = Pink_Cor;
  66. _nextBtn.layer.cornerRadius = 20;
  67. _nextBtn.layer.masksToBounds = YES;
  68. _nextBtn.titleLabel.font = SYS_Font(16);
  69. [_nextBtn setTitleColor:RGB_COLOR(@"#ffffff", 1) forState:0];
  70. [_nextBtn addTarget:self action:@selector(clickNextBtn) forControlEvents:UIControlEventTouchUpInside];
  71. }
  72. return _nextBtn;
  73. }
  74. -(void)changeNextBtn:(BOOL)enabled {
  75. _nextBtn.userInteractionEnabled = enabled;
  76. if (enabled) {
  77. _nextBtn.alpha = 1;
  78. }else{
  79. _nextBtn.alpha = 0.5;
  80. }
  81. }
  82. -(void)clickNextBtn {
  83. YBDestroySureVC *sureVC = [[YBDestroySureVC alloc]init];
  84. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:sureVC animated:YES];
  85. }
  86. #pragma mark -
  87. -(void)pullData {
  88. YBWeakSelf;
  89. [YBNetworking postWithUrl:@"Login.getCancelCondition" Dic:nil Suc:^(int code, id info, NSString *msg) {
  90. if (code == 0) {
  91. NSDictionary *infoDic = [info firstObject];
  92. NSString *canDestroy = minstr([infoDic valueForKey:@"can_cancel"]);
  93. if ([canDestroy isEqual:@"1"]) {
  94. [weakSelf changeNextBtn:YES];
  95. }
  96. _dataArray = [NSArray arrayWithArray:[infoDic valueForKey:@"list"]];
  97. [_tableView reloadData];
  98. }else{
  99. [MBProgressHUD showPop:msg];
  100. }
  101. } Fail:^(id fail) {
  102. }];
  103. }
  104. #pragma mark - UITableViewDelegate、UITableViewDataSource
  105. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  106. return _dataArray.count;
  107. }
  108. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  109. YBDestroyCell *cell = [YBDestroyCell cellWithTab:tableView index:indexPath];
  110. cell.dataDic = _dataArray[indexPath.row];
  111. return cell;
  112. }
  113. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  114. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  115. }
  116. #pragma mark - set/get
  117. -(UITableView *)tableView {
  118. if (!_tableView) {
  119. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,_stateView.bottom, _window_width, _window_height - 64-statusbarHeight-_stateView.height-ShowDiff-40-60)style:UITableViewStylePlain];
  120. _tableView.delegate = self;
  121. _tableView.dataSource = self;
  122. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  123. _tableView.backgroundColor = Normal_Color;
  124. _tableView.bounces = NO;
  125. _tableView.estimatedRowHeight = 100;
  126. _tableView.estimatedSectionFooterHeight = 0;
  127. _tableView.estimatedSectionHeaderHeight = 0;
  128. }
  129. return _tableView;
  130. }
  131. @end