// // YOUPAILZVipSetterVC.m // VQU // // Created by CY on 2021/8/21. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAILZVipSetterVC.h" #import "YOUPAILZVipSetterCell.h" #import "YOUPAILZVipSetterModel.h" @interface YOUPAILZVipSetterVC () @property (nonatomic,weak) UITableView *youpaiptableView; @property (nonatomic,strong) NSArray *youpaipdataSource; @end @implementation YOUPAILZVipSetterVC - (void)viewDidLoad { [super viewDidLoad]; self.title = @"贵族设置"; self.view.backgroundColor = [UIColor whiteColor]; [self youpaifinitUI]; [self youpaifrequestVipSetterList]; } - (void)youpaifinitUI{ UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; tableView.delegate = self; tableView.dataSource = self; tableView.rowHeight = 70.0f; tableView.estimatedRowHeight = 70.0f; tableView.estimatedSectionHeaderHeight = 0.0f; tableView.estimatedSectionFooterHeight = 0.0f; tableView.separatorStyle = UITableViewCellSeparatorStyleNone; tableView.backgroundColor = [UIColor clearColor]; [self.view addSubview:tableView]; self.youpaiptableView = tableView; [tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.offset(NavBarHeight); make.left.right.bottom.offset(0.0f); }]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.youpaipdataSource.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ YOUPAILZVipSetterCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if (cell == nil) { cell = [[YOUPAILZVipSetterCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; } [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row]]; @weakify(self); [cell setSwitchBlock:^(YOUPAILZVipSetterModel * _Nonnull model) { @strongify(self); [self youpaifitemSwitchWithModel:model]; }]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return CGFLOAT_MIN; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return CGFLOAT_MIN; } - (void)youpaifitemSwitchWithModel:(YOUPAILZVipSetterModel *)model{ [LCHttpHelper requestWithURLString:NobleSetting parameters:@{model.youpaipicon:@(model.youpaipstatus)} needToken:YES type:HttpRequestTypePost success:^(id responseObject) { } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; } - (void)youpaifrequestVipSetterList{ @weakify(self); [LCHttpHelper requestWithURLString:GetNobleSetting parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) { @strongify(self); NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) { self.youpaipdataSource = [YOUPAILZVipSetterModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]].mutableCopy; [self.youpaiptableView reloadData]; }else{ [ZCHUDHelper showTitle:[dict objectForKey:@"message"]]; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; } @end