| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 | 
							- //
 
- //  ASSettingViewController.m
 
- //  Asteria
 
- //
 
- //  Created by iOS on 2023/7/5.
 
- //
 
- #import "ASSettingViewController.h"
 
- #import "ASSettingListCell.h"
 
- #import "ASInfomationSetController.h"
 
- #import "ASHelpListViewController.h"
 
- #import "ASAddressListViewController.h"
 
- @interface ASSettingViewController () <UITableViewDelegate,UITableViewDataSource>
 
- @property (nonatomic, strong) UIView *bottomV;
 
- @property (nonatomic, strong) UILabel *versionLb;
 
- @property (nonatomic, strong) UITableView *tableV;
 
- @property (nonatomic, strong) NSArray *titleArr;
 
- @property (nonatomic, strong) NSArray *detailArr;
 
- @end
 
- @implementation ASSettingViewController
 
- - (void)viewDidLoad {
 
-     [super viewDidLoad];
 
-     self.titleStr = @"Setting";
 
-     [self setNavRightSearch:^{
 
-         
 
-     }];
 
-     
 
-     self.statusBgV.backgroundColor = Col_FFF;
 
-     self.customNavBar.backgroundColor = Col_FFF;
 
-     
 
-     [self loadSubVs];
 
-     
 
- }
 
- - (void)viewWillAppear:(BOOL)animated {
 
-     [super viewWillAppear:animated];
 
-     [self configData];
 
- }
 
- - (void)configData {
 
-     
 
-     self.titleArr = @[@"INFORMATION",
 
-                       @"SHIPPING ADDRESS",
 
-                       @"SUBSCRIBE",
 
- //                      @"CUSTOMER SERVICE",
 
-                       @"HELP & SUPPORT",
 
-                       @"LOG OUT",
 
-                       @"DELETE ACCOUNT"];
 
-     /*
 
-      KWLoginedManager.shareInstance.isLogined ? @[@"Information",
 
-                              @"Shipping Address",
 
- //                             @"Account Settings",
 
-                              @"Subscribe",
 
-                              @"Customer Service",
 
-                              @"Help & Support",
 
-                             @"Log Out", @"Delete Account"] : @[@"Infomation",
 
-                       @"Shipping Address",
 
- //                      @"Account Settings",
 
-                       @"Subscribe",
 
-                       @"Customer Service",
 
-                       @"Help & Support"];
 
-      */
 
-     self.detailArr = @[@"", @"",@"",@"",@"",@"",@"",@""];
 
-     [self.tableV reloadData];
 
- }
 
- - (void)loadSubVs {
 
-     [self.view addSubview:self.tableV];
 
-     
 
-     [self.bottomV addSubview:self.versionLb];
 
-     
 
-    
 
-     [self.versionLb mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.bottomV).offset(66);
 
-         make.left.equalTo(self.bottomV).offset(20);
 
-         make.centerX.equalTo(self.bottomV);
 
-         make.height.equalTo(@20);
 
-     }];
 
-     [self.tableV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.customNavBar.mas_bottom);
 
-         make.left.right.equalTo(self.view);
 
-         make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
 
-     }];
 
-     
 
-     
 
- }
 
- - (UILabel *)versionLb {
 
-     if (!_versionLb) {
 
-         UILabel *lb = [UILabel new];
 
-         NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
 
-         NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
 
-         lb.text = [NSString stringWithFormat:@"V%@",app_Version];
 
-         lb.textColor = Col_000;
 
-         lb.textAlignment = NSTextAlignmentCenter;
 
-         lb.font = [UIFont fontWithName:Rob_Regular size:12];
 
-         lb.numberOfLines = 1;
 
-         _versionLb = lb;
 
-     }
 
-     return _versionLb;
 
- }
 
- -(UIView *)bottomV {
 
-     if (!_bottomV) {
 
-         UIView *v = [UIView new];
 
-         v.frame = CGRectMake(0, 0, KScreenWidth, 100);
 
-         v.backgroundColor = _F8F8F8;
 
-         _bottomV = v;
 
-     }
 
-     return _bottomV;
 
- }
 
- - (UITableView *)tableV {
 
-     if (!_tableV) {
 
-         UITableView *tabV = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
 
-         tabV.backgroundColor = _F8F8F8;
 
-         [tabV registerClass:[ASSettingListCell class] forCellReuseIdentifier:@"ASSettingListCell"];
 
-         tabV.delegate = self;
 
-         tabV.dataSource = self;
 
-         tabV.rowHeight = UITableViewAutomaticDimension;
 
-         tabV.estimatedRowHeight = 100;
 
-         tabV.separatorStyle = UITableViewCellSeparatorStyleNone;
 
-         UIView *v = [UIView new];
 
-         v.frame = CGRectMake(0, 0, KScreenWidth, 10);
 
-         v.backgroundColor = _F8F8F8;
 
-         tabV.tableHeaderView = v;
 
-         tabV.tableFooterView = self.bottomV;
 
-         _tableV = tabV;
 
-     }
 
-     return _tableV;
 
- }
 
- #pragma mark - UITableViewDelegate,UITableViewDataSource
 
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 
-     switch (indexPath.row) {
 
-         case 0:{
 
-             ASInfomationSetController *vc = [ASInfomationSetController new];
 
-             [self.navigationController pushViewController:vc animated:true];
 
-             break;
 
-         }
 
-         case 1:{
 
-             ASAddressListViewController *vc = [ASAddressListViewController new];
 
-             [self.navigationController pushViewController:vc animated:true];
 
-             break;
 
-         }
 
-         case 3:{
 
-             ASHelpListViewController *vc = [ASHelpListViewController new];
 
-             [self.navigationController pushViewController:vc animated:true];
 
-             break;
 
-         }
 
-         case 4: {
 
-             [self logout];
 
-             break;
 
-         }
 
-         case 5: {
 
-             [self showDeleteAccountAlert];
 
-             break;
 
-         }
 
-         default:
 
-             break;
 
-     }
 
- }
 
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 
-     return self.titleArr.count;
 
- }
 
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 
-    
 
-     ASSettingListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASSettingListCell" forIndexPath:indexPath];
 
-     [cell setTitle:self.titleArr[indexPath.row] points:self.detailArr[indexPath.row] enable:true];
 
-     if (((indexPath.row == _titleArr.count - 1) || (indexPath.row == _titleArr.count - 2))) {
 
-         cell.moreIcon.hidden = true;
 
-     } else  {
 
-         cell.moreIcon.hidden = false;
 
-     }
 
-     cell.switchBtn.hidden = !(indexPath.row == 2);
 
-     if (indexPath.row == 2) {
 
-         BOOL isSub = ASUserInfoManager.shared.userInfo.is_subscribed;
 
-         [cell.switchBtn setIsOpen:isSub animate:false];
 
-         __weak typeof(self) weakSelf = self;
 
-         [cell.switchBtn setClickBack:^{
 
-             [weakSelf configSubscrib:!isSub];
 
-         }];
 
-     } else {
 
-         cell.switchBtn.clickBack = nil;
 
-     }
 
-     return  cell;
 
- }
 
- // MARK: - 退出登录
 
- - (void)logout {
 
-     [MBProgressHUD showHUDAddedTo:self.view animated:true];
 
-     __weak typeof(self) weak_self = self;
 
-     [ASNetTools.shared postWithPath:postLogOut param:@{} success:^(id _Nonnull json) {
 
-         [MBProgressHUD hideHUDForView:weak_self.view animated:true];
 
-         [weak_self popAndToLogin];
 
-         
 
-     } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
 
-         [MBProgressHUD hideHUDForView:weak_self.view animated:true];
 
-         NSLog(@"err:%@",code);
 
-         [weak_self.view makeToast:@"Oh No, Bad Net"];
 
-     }];
 
-     
 
- }
 
- - (void)configSubscrib:(BOOL)is_subscribed {
 
-     NSDictionary *param = @{
 
-         @"customer":@{
 
-             @"email": ASUserInfoManager.shared.userInfo.email,
 
-             @"firstname": ASUserInfoManager.shared.userInfo.firstname,
 
-             @"lastname": ASUserInfoManager.shared.userInfo.lastname,
 
-             @"extension_attributes":@{
 
-                 @"is_subscribed":[NSNumber numberWithBool:is_subscribed]
 
-             }
 
-         }
 
-     };
 
-     __weak typeof(self) weakSelf = self;
 
-     [MBProgressHUD showHUDAddedTo:self.view animated:true];
 
-     [ASNetTools.shared putWithPath:putUserInfo param:param success:^(id _Nonnull json) {
 
-         [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
 
-         ASUserInfoManager.shared.userInfo.is_subscribed = is_subscribed;
 
-         [weakSelf.tableV reloadData];
 
-     } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
 
-         [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
 
-         [weakSelf.view makeToast:@"Bad Net"];
 
-         [weakSelf.tableV reloadData];
 
-     }];
 
- }
 
- // MARK: - 注销账号
 
- - (void)showDeleteAccountAlert {
 
-     __weak typeof(self) weakSelf = self;
 
-     ASCustomWindow *window = [ASCustomWindow show:@"Are You Sure To Delete Your Account?\n(This action can't be undone. All the data of your account will be delete)" isMast:false upBlock:^{
 
-     } cancelBlock:^{
 
-         [weakSelf deleteAccount:@""];
 
- //        [weakSelf showDeletedReasonInput];
 
-         
 
-     }];
 
-     window.vc.titleLb.text = @"Delete Account?";
 
-     [window.vc.sureBt setTitle:@"No" forState:UIControlStateNormal];
 
-     [window.vc.cancelBt setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
 
-     NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"Yes"];
 
-     [attStr setAttributes:@{
 
-         NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:16],
 
-         NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle],
 
-         NSUnderlineColorAttributeName:[UIColor colorWithHexString:@"#000000"],
 
-         NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#000000"]
 
-     } range:NSMakeRange(0, attStr.length)];
 
-     [window.vc.cancelBt setAttributedTitle:attStr forState:UIControlStateNormal];
 
-     
 
-     [window.vc.cancelBt mas_remakeConstraints:^(MASConstraintMaker *make) {
 
-         make.bottom.equalTo(window.vc.sureBt);
 
-         make.height.equalTo(@35);
 
-         make.right.equalTo(window.vc.sureBt.mas_left).offset(-20);
 
-         make.left.greaterThanOrEqualTo(window.vc.contentV).offset(20);
 
-     }];
 
-     
 
-     
 
- }
 
- //- (void)showDeletedReasonInput {
 
- //    __weak typeof(self) weakSelf = self;
 
- //    [APHomeActiveWindow show:@"Deleted Account" des:@"Dear user, could you tell me the reason for leaving?" sureBlock:^(NSString *reason) {
 
- //        NSString *str = @"";
 
- //        if (!reason.isEmpty) {
 
- //            str = reason;
 
- //        }
 
- //        [weakSelf deleteAccount:str];
 
- //    } cancelBlock:^{
 
- //    }];
 
- //}
 
- - (void)deleteAccount:(NSString *)msg {
 
-     
 
-     [MBProgressHUD showHUDAddedTo:self.view animated:true];
 
-     __weak typeof(self) weakSelf = self;
 
-     [ASNetTools.shared delWithPath:deleteUser param:@{} success:^(id _Nonnull json) {
 
-         [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
 
-         [weakSelf popAndToLogin];
 
-     } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
 
-         [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
 
-         [weakSelf.view makeToast:@"Oh No, Bad Net"];
 
-     }];
 
- }
 
- @end
 
 
  |