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.
130 lines
3.8 KiB
130 lines
3.8 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.title = @"常见问题"; |
|
if(self.categoryTitle){ |
|
self.titleLabel.text = self.categoryTitle; |
|
} |
|
self.titleTempView.backgroundColor = mainColor; |
|
|
|
[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
|
|
|