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.
147 lines
4.5 KiB
147 lines
4.5 KiB
// |
|
// AllQViewController.m |
|
// tongxin |
|
// |
|
// Created by WeiChaoZheng on 2018/10/23. |
|
// Copyright © 2018年 xTT. All rights reserved. |
|
// |
|
|
|
#import "AllQViewController.h" |
|
#import "WebViewController.h" |
|
#import "QDetailViewController.h" |
|
|
|
@interface AllQViewController () |
|
|
|
@end |
|
|
|
@implementation AllQViewController |
|
|
|
@synthesize myDataSource = _myDataSource; |
|
|
|
- (NSMutableArray *)myDataSource{ |
|
if (!_myDataSource) { |
|
_myDataSource = [[NSMutableArray alloc] init]; |
|
} |
|
return _myDataSource; |
|
} |
|
|
|
- (void)viewDidLoad { |
|
[super viewDidLoad]; |
|
// Do any additional setup after loading the view. |
|
self.myTableView.backgroundColor = tabViewBG; |
|
self.view.backgroundColor = tabViewBG; |
|
self.myTableView.layer.cornerRadius = 3; |
|
self.myTableView.layer.masksToBounds = YES; |
|
|
|
|
|
self.zx_navTitle = @"常见问题"; |
|
if(self.categoryTitle){ |
|
self.titleLabel.text = self.categoryTitle; |
|
} |
|
self.titleTempView.backgroundColor = mainColor; |
|
[self.titleTempView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.top.equalTo(self.view).offset(iPhoneX_NavHeight+15); |
|
make.left.equalTo(self.view).offset(15); |
|
make.size.mas_equalTo(CGSizeMake(3, 15)); |
|
}]; |
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerY.equalTo(self.titleTempView); |
|
make.left.equalTo(self.titleTempView).offset(10); |
|
}]; |
|
|
|
[self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.top.equalTo(self.titleTempView.mas_bottom).offset(10); |
|
make.left.right.equalTo(self.view).inset(15); |
|
make.bottom.equalTo(self.view.mas_bottom); |
|
}]; |
|
|
|
[self loadData]; |
|
} |
|
|
|
-(void)loadData{ |
|
WEAKSELF |
|
if(self.categoryid){ |
|
|
|
[User getAllCategoryQWithCID:self.categoryid success:^(id responseObject) { |
|
NSArray *titles = responseObject[@"titles"]; |
|
NSMutableArray *arr = [NSMutableArray new]; |
|
|
|
if(cUser.cDevice.support_whiteList&&cUser.cDevice.support_whiteList.intValue!=0){ |
|
for (int i=0; i<titles.count; i++) { |
|
NSDictionary *dic = titles[i]; |
|
NSString *index = dic[@"index"]; |
|
if ([@"1" isEqualToString:index] || [@"3" isEqualToString:index]) { |
|
continue; |
|
} |
|
[arr addObject:dic]; |
|
} |
|
[weakSelf.myDataSource addObject:arr]; |
|
} else { |
|
[weakSelf.myDataSource addObject:titles]; |
|
} |
|
|
|
[weakSelf.myTableView reloadData]; |
|
|
|
} failure:^(id faiObject) { |
|
|
|
}]; |
|
}else{ |
|
|
|
[User getCategoryQAndHotQSuccess:^(id responseObject) { |
|
//热门问题 |
|
NSArray * titles = responseObject[@"titles"]; |
|
|
|
[weakSelf.myDataSource addObject:titles]; |
|
|
|
[weakSelf.myTableView reloadData]; |
|
|
|
} failure:^(id faiObject) { |
|
|
|
}]; |
|
} |
|
|
|
} |
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ |
|
if(section == 0){ |
|
return [self.myDataSource[section] count]; |
|
}else{ |
|
return 1; |
|
} |
|
} |
|
|
|
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ |
|
return 49; |
|
} |
|
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ |
|
|
|
|
|
NSDictionary *dic = self.myDataSource[indexPath.section][indexPath.row]; |
|
baseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"baseCell"]; |
|
if (!cell) { |
|
cell = [[baseCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"baseCell"]; |
|
cell.textLabel.text = dic[@"title"]; |
|
|
|
} |
|
return cell; |
|
} |
|
|
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ |
|
NSDictionary *dic = self.myDataSource[indexPath.section][indexPath.row]; |
|
NSString *content = dic[@"content"]; |
|
NSString *titleStr = dic[@"title"]; |
|
QDetailViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"QDetailViewController"]; |
|
vc.content = content; |
|
vc.titleStr = titleStr; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
// WebViewController *vc = [WebViewController new]; |
|
// vc.content = content; |
|
// [self.navigationController pushViewController:vc animated:YES]; |
|
} |
|
|
|
|
|
@end
|
|
|