YOUPAILZVipSetterVC.m 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // YOUPAILZVipSetterVC.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/8/21.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZVipSetterVC.h"
  9. #import "YOUPAILZVipSetterCell.h"
  10. #import "YOUPAILZVipSetterModel.h"
  11. @interface YOUPAILZVipSetterVC () <UITableViewDelegate,UITableViewDataSource>
  12. @property (nonatomic,weak) UITableView *youpaiptableView;
  13. @property (nonatomic,strong) NSArray <YOUPAILZVipSetterModel *>*youpaipdataSource;
  14. @end
  15. @implementation YOUPAILZVipSetterVC
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.title = @"贵族设置";
  19. self.view.backgroundColor = [UIColor whiteColor];
  20. [self youpaifinitUI];
  21. [self youpaifrequestVipSetterList];
  22. }
  23. - (void)youpaifinitUI{
  24. UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  25. tableView.delegate = self;
  26. tableView.dataSource = self;
  27. tableView.rowHeight = 70.0f;
  28. tableView.estimatedRowHeight = 70.0f;
  29. tableView.estimatedSectionHeaderHeight = 0.0f;
  30. tableView.estimatedSectionFooterHeight = 0.0f;
  31. tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  32. tableView.backgroundColor = [UIColor clearColor];
  33. [self.view addSubview:tableView];
  34. self.youpaiptableView = tableView;
  35. [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.top.offset(NavBarHeight);
  37. make.left.right.bottom.offset(0.0f);
  38. }];
  39. }
  40. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  41. return self.youpaipdataSource.count;
  42. }
  43. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  44. YOUPAILZVipSetterCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  45. if (cell == nil) {
  46. cell = [[YOUPAILZVipSetterCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  47. }
  48. [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row]];
  49. @weakify(self);
  50. [cell setSwitchBlock:^(YOUPAILZVipSetterModel * _Nonnull model) {
  51. @strongify(self);
  52. [self youpaifitemSwitchWithModel:model];
  53. }];
  54. return cell;
  55. }
  56. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  57. return CGFLOAT_MIN;
  58. }
  59. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  60. return CGFLOAT_MIN;
  61. }
  62. - (void)youpaifitemSwitchWithModel:(YOUPAILZVipSetterModel *)model{
  63. [LCHttpHelper requestWithURLString:NobleSetting parameters:@{model.youpaipicon:@(model.youpaipstatus)} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  64. } failure:^(NSError *error) {
  65. [ZCHUDHelper showTitle:error.localizedDescription];
  66. }];
  67. }
  68. - (void)youpaifrequestVipSetterList{
  69. @weakify(self);
  70. [LCHttpHelper requestWithURLString:GetNobleSetting parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  71. @strongify(self);
  72. NSDictionary* dict = (NSDictionary*)responseObject;
  73. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  74. if (code == 0) {
  75. self.youpaipdataSource = [YOUPAILZVipSetterModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]].mutableCopy;
  76. [self.youpaiptableView reloadData];
  77. }else{
  78. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  79. }
  80. } failure:^(NSError *error) {
  81. [ZCHUDHelper showTitle:error.localizedDescription];
  82. }];
  83. }
  84. @end