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
//
// DiscussModuleViewController.m
// Lighting
//
// Created by 曹云霄 on 2017/3/15.
// Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//
#import "DiscussModuleViewController.h"
#import "DiscussModuleCollectionViewCell.h"
#import "ForumItemListViewController.h"
@interface DiscussModuleViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong) ForumTypeResponse *result;
@end
@implementation DiscussModuleViewController
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self getClassificationList];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self uiConfigAction];
}
#pragma mark - 获取分类帖子列表
- (void)getClassificationList
{
[XBLoadingView showHUDViewWithDefaultWithView:self.view];
WS(weakSelf);
[HTTP networkWithDictionaryRequestWithURL:[NSString stringWithFormat:SERVERREQUESTURL(DEFAULTFORUM_CATEGORY),[Shoppersmanager manager].shoppers.employee.fid] withRequestType:GET withParameter:nil withReturnValueBlock:^(id returnValue) {
[XBLoadingView hideHUDViewWithDefaultWithView:self.view];
if (RESULT(returnValue)) {
weakSelf.result = [[ForumTypeResponse alloc] initWithDictionary:RESPONSE(returnValue) error:nil];
[weakSelf.moduleCollectionView reloadData];
}else {
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
[weakSelf.moduleCollectionView reloadData];
} withFailureBlock:^(NSError *error) {
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
}
#pragma mark -UI
- (void)uiConfigAction
{
self.moduleFlowLayout.itemSize = CGSizeMake((ScreenWidth-60)/3.0, (ScreenWidth-60)/3.0*0.4);
self.moduleFlowLayout.minimumInteritemSpacing = 10;
self.moduleFlowLayout.minimumLineSpacing = 10;
}
#pragma mark -<UICollectionViewDelegate,UICollectionViewDataSource>
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.result.list.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
DiscussModuleCollectionViewCell *moduleCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DiscussModuleCollectionViewCell" forIndexPath:indexPath];
TOForumCategoryEntity *entity = self.result.list[indexPath.item];
[moduleCell refreshCell:entity];
return moduleCell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
ForumItemListViewController *itemListVc = [ForumItemListViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_LEARNINGCENTER];
TOForumCategoryEntity *category = self.result.list[indexPath.row];
category.typeId = self.result.forumType.fid;
itemListVc.category = category;
itemListVc.isPosting = [category.name isEqualToString:@"欧普问问"]?2:1;
[self pushViewController:itemListVc animated:YES];
}
@end