ASHelpListViewController.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // ASHelpListViewController.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/7/5.
  6. //
  7. #import "ASHelpListViewController.h"
  8. #import "ASSettingListCell.h"
  9. #import "ASHelpListUrlModel.h"
  10. @interface ASHelpListViewController ()<UITableViewDelegate,UITableViewDataSource>
  11. @property (nonatomic, strong) UITableView *tableV;
  12. @property (nonatomic, strong) NSArray<ASHelpListUrlModel *> *linkArr;
  13. @end
  14. @implementation ASHelpListViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. self.titleStr = @"Help & Support";
  18. [self setNavRightSearch:^{
  19. }];
  20. self.statusBgV.backgroundColor = Col_FFF;
  21. self.customNavBar.backgroundColor = Col_FFF;
  22. [self loadSubVs];
  23. [self configData];
  24. }
  25. - (void)configData {
  26. [MBProgressHUD showHUDAddedTo:self.view animated:true];
  27. __weak typeof(self) weakSelf = self;
  28. [ASNetTools.shared getWithPath:helpCenterUrl param:@{} success:^(id _Nonnull json) {
  29. [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
  30. weakSelf.linkArr = [ASHelpListUrlModel mj_objectArrayWithKeyValuesArray:json];
  31. [weakSelf.tableV reloadData];
  32. } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
  33. [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
  34. weakSelf.linkArr = @[];
  35. [weakSelf.tableV reloadData];
  36. NSLog(@"----code:%@-msg:%@--", code, msg);
  37. }];
  38. }
  39. - (void)loadSubVs {
  40. [self.view addSubview:self.tableV];
  41. [self.tableV mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.top.equalTo(self.customNavBar.mas_bottom);
  43. make.left.right.equalTo(self.view);
  44. make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
  45. }];
  46. }
  47. - (UITableView *)tableV {
  48. if (!_tableV) {
  49. UITableView *tabV = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  50. tabV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  51. [tabV registerClass:[ASSettingListCell class] forCellReuseIdentifier:@"ASSettingListCell"];
  52. tabV.delegate = self;
  53. tabV.dataSource = self;
  54. tabV.rowHeight = UITableViewAutomaticDimension;
  55. tabV.estimatedRowHeight = 100;
  56. tabV.separatorStyle = UITableViewCellSeparatorStyleNone;
  57. UIView *v = [UIView new];
  58. v.frame = CGRectMake(0, 0, KScreenWidth, 10);
  59. v.backgroundColor = [UIColor colorWithHexString:@"#f8f8f8"];
  60. tabV.tableHeaderView = v;
  61. _tableV = tabV;
  62. }
  63. return _tableV;
  64. }
  65. - (void)toActiveVc:(NSString *)pageUrl title:(NSString *)tit {
  66. UIViewController *vc = [CTMediator.sharedInstance getWebViewVc:@{
  67. @"title":tit,
  68. @"url":pageUrl
  69. }];
  70. [self.navigationController pushViewController:vc animated:true];
  71. }
  72. #pragma mark - UITableViewDelegate,UITableViewDataSource
  73. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  74. ASHelpListUrlModel *linkM = self.linkArr[indexPath.row];
  75. [self toActiveVc:linkM.value title:linkM.title];
  76. }
  77. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  78. return self.linkArr.count;
  79. }
  80. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  81. ASSettingListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASSettingListCell" forIndexPath:indexPath];
  82. ASHelpListUrlModel *link = self.linkArr[indexPath.row];
  83. [cell setTitle:link.title points:@"" enable:true];
  84. return cell;
  85. }
  86. @end