1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//
// ForumViewController.m
// Lighting
//
// Created by 曹云霄 on 2016/11/24.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "ForumViewController.h"
#import "ForumTableViewCell.h"
#import "ForumItemListViewController.h"
@interface ForumViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) ForumCategoryResponse *category;
@end
@implementation ForumViewController
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.tableView.mj_header beginRefreshing];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpForumTableView];
}
#pragma mark - UITableView
- (void)setUpForumTableView
{
self.tableView.rowHeight = 90;
[Notification addObserver:self selector:@selector(refreshForumList:) name:REFRESH_FROUMLIST object:nil];
}
#pragma mark -选中时间轴刷新列表
- (void)refreshForumList:(NSNotification *)object
{
self.typeId = object.object;
[self.tableView.mj_header beginRefreshing];
}
#pragma mark - 加载数据
- (void)loadWebDataSource
{
WS(weakSelf);
[self getForumAllTypeActionCompleted:^(ForumCategoryResponse *result) {
[weakSelf endRefresh:EndRefreshNotData];
}];
}
#pragma mark - 获取论坛项Type
- (void)getForumAllTypeActionCompleted:(void(^)(ForumCategoryResponse *result))completed
{
WS(weakSelf);
NSString *urlString = [NSString stringWithFormat:SERVERREQUESTURL(FORUMCATEGORYS),self.typeId,[Shoppersmanager manager].shoppers.employee.fid];
[HTTP networkWithDictionaryRequestWithURL:urlString withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
if (RESULT(returnValue)) {
weakSelf.category = [[ForumCategoryResponse alloc] initWithDictionary:RESPONSE(returnValue) error:nil];
completed(weakSelf.category);
[weakSelf.tableView reloadData];
}else{
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
} withFailureBlock:^(NSError *error) {
[weakSelf endRefresh:EndRefreshDefault];
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
}
#pragma mark - <UITableViewDelegate,UITableViewDataSource>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ForumTableViewCell *forumCell = [tableView dequeueReusableCellWithIdentifier:@"ForumTableViewCell" forIndexPath:indexPath];
forumCell.categoryEntity = self.category.categories[indexPath.row];
return forumCell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.category.categories.count;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ForumItemListViewController *itemListVc = [ForumItemListViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_LEARNINGCENTER];
TOForumCategoryEntity *category = self.category.categories[indexPath.row];
category.typeId = self.typeId;
itemListVc.category = category;
itemListVc.isPosting = [category.name isEqualToString:@"欧普问问"]?0:1;
[self pushViewController:itemListVc animated:YES];
}
@end