You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.5 KiB

2 years ago
//
// ProblemTableViewController.m
// LekangGuard
//
// Created by ecell on 2022/12/30.
//
#import "ProblemTableViewController.h"
#import "ProblemTableViewCell.h"
#import "ProblemDetailsViewController.h"
@interface ProblemTableViewController ()
@property (nonatomic ,strong) UIView *headerView;
@property (nonatomic ,strong) CommonTableView *problemTable;
@end
@implementation ProblemTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.zx_navTitle = GJText(@"常见问题");
[self.view addSubview:self.problemTable];
[self.problemTable mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view).inset(20);
make.top.equalTo(self.view).offset(iPhoneX_NavHeight+20);
make.bottom.equalTo(self.view.mas_bottom);
}];
}
- (void)setModelArr:(NSMutableArray *)modelArr
{
_modelArr = modelArr;
self.modelListArr = modelArr;
self.problemTable.cellRow = modelArr.count;
[self.problemTable reloadData];
}
- (CommonTableView *)problemTable
{
if (!_problemTable)
{
kWeakSelf(self)
_problemTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:48 cellRow:0 isAdaptive:NO isLine:YES commonCell:ProblemTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) {
ProblemTableViewCell *cell = (ProblemTableViewCell *)cells;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if (indexPath.row < weakself.modelListArr.count)
{
ProblemModel *model = weakself.modelListArr[indexPath.row];
cell.cenText = model.content;
}
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) {
ProblemModel *model = weakself.modelListArr[indexPath.row];
ProblemDetailsViewController *vc = [ProblemDetailsViewController new];
vc.pModel = model;
[weakself.navigationController pushViewController:vc animated:YES];
} DidscrollView:^(UIScrollView * _Nonnull scrollView) {
}];
[UICommon setExtraCellLineHidden:_problemTable];
_problemTable.backgroundColor = KKClearColor;
_problemTable.tableHeaderView = self.headerView;
_problemTable.tableHeaderView.height = 30;
}
return _problemTable;
}
- (UIView *)headerView
{
if (!_headerView)
{
_headerView = [UIView new];
_headerView.backgroundColor = KKClearColor;
_headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH-40, 30);
UIImageView *line = [UIImageView new];
line.frame = CGRectMake(0, 0, 3, 15);
line.backgroundColor = KKMainColor;
[_headerView addSubview:line];
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontADA_(13) textColor:KKTextBlackColor text:GJText(self.titleStr) Radius:0];
[_headerView addSubview:titleLabel];
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(line).offset(10);
make.centerY.equalTo(line);
}];
}
return _headerView;
}
- (void)setPModel:(ProblemModel *)pModel
{
_pModel = pModel;
[UICommon MessageUpload:@"加载中"];
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
[parameters setValue:pModel.Id forKey:@"categoryId"];
[[[APIManager sharedManager] APGET:QueryContentById_URL parameters:parameters resultClass:nil] subscribeNext:^(NSArray *arr) {
[UICommon HidenLoading];
for (NSDictionary *dic in arr)
{
ProblemModel *model = [ProblemModel yy_modelWithJSON:dic];
[self.modelListArr addObject:model];
}
self.problemTable.cellRow = self.modelListArr.count;
[self.problemTable reloadData];
} error:^(NSError * _Nullable error) {
NSDictionary *dic = error.userInfo;
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]];
}];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end