CNLiveCommuntViewController.m
10.6 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//
// CNLiveCommuntViewController.m
// AFNetworking
//
// Created by open on 2022/2/1.
//
#import "CNLiveCommuntViewController.h"
#import "CNLiveCommuntPartyViewController.h"
#import "CNLiveCommuntConsuViewController.h"
#import "CNLiveCommuntActiviViewController.h"
#import "CNLiveCommuntServiceViewController.h"
@interface CNLiveCommuntViewController ()
@property (nonatomic, copy) NSString *nbhdId;
@end
@implementation CNLiveCommuntViewController
- (instancetype)initWithNBhdId:(NSString *)nbhdId
{
self = [super init];
if (self) {
_nbhdId = nbhdId;
}
return self;
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSMutableArray * tempArray = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers];
for (UIViewController * vc in self.navigationController.viewControllers) {
if ([vc isKindOfClass:CNLiveCommuntyHomeListViewController.class]) {
[tempArray removeObject:vc];
break;
}
}
self.navigationController.viewControllers = tempArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.selectColor = [UIColor colorWithHexString:@"0xCD0302"];
self.normalColor = [UIColor colorWithHexString:@"0x979797"];
self.hidesBottomBarWhenPushed = YES;
self.tabBar.backgroundColor = UIColorHex(#f9f9f9);
__weak typeof(self) weakSelf = self;
[QMUITips showLoadingInView:self.view];
[CNLiveCommuntViewModel requestWithCommuntyHomeNBhdAppIndexWithNBhdId:self.nbhdId CompleterBlock:^(NSArray * _Nonnull homeArray) {
if (homeArray) {
__block NSMutableArray * array = [[NSMutableArray alloc] init];
for (CNLiveCommuntyHomeModel * homeModel in homeArray) {
if ([homeModel.columnColour isNotBlank]) weakSelf.selectColor = [UIColor colorWithHexString:homeModel.columnColour];
if ([homeModel.columnColourUncheck isNotBlank]) weakSelf.normalColor = [UIColor colorWithHexString:homeModel.columnColourUncheck];
[weakSelf settingTabberWithImages:@[homeModel.columnImgUncheck,homeModel.columnImg] CompleterBlock:^(NSDictionary *tempDict) {
NSMutableDictionary * dict = [[NSMutableDictionary alloc] init];
[dict addEntriesFromDictionary:tempDict];
[dict setObject:homeModel forKey:@"model"];
[array addObject:dict];
if (array.count == homeArray.count) {
[QMUITips hideAllTipsInView:weakSelf.view];
weakSelf.tabBar.backgroundColor = [UIColor whiteColor];
for (NSDictionary * subDict in array) {
CNLiveCommuntyHomeModel * homeModel = [subDict objectForKey:@"model"];
UIImage *nomal_image = [[UIImage alloc] initWithData:[subDict objectForKey:@"nomal"]];
UIImage *select_image = [[UIImage alloc] initWithData:[subDict objectForKey:@"select"]];
if (homeModel.contentColumnList.count > 0) {
CNLiveCommuntConsuViewController * vc = [[CNLiveCommuntConsuViewController alloc] initWithHomeArray:homeModel.contentColumnList titles:homeModel.titles NBhdId:weakSelf.nbhdId];
vc.title = homeModel.columnName;
vc.view.backgroundColor = [UIColor whiteColor];
[weakSelf addChildViewController:vc noralImage:nomal_image selectImage:select_image];
}else{
if ([homeModel.type isEqualToString:@"3"]) {//生活服务界面 原生
if ([homeModel.cmsPageType isEqualToString:@"1"]) {
CNLiveCommuntActiviViewController * vc = [[CNLiveCommuntActiviViewController alloc] initWithWebUrl:homeModel.cmsPageUrl isRootVC:YES Type:@"1"];
vc.title = homeModel.columnName;
vc.view.backgroundColor = [UIColor whiteColor];
[weakSelf addChildViewController:vc noralImage:nomal_image selectImage:select_image];
}else{
CNLiveCommuntServiceViewController * vc = [[CNLiveCommuntServiceViewController alloc] initWithHomeModel:homeModel isRootVC:YES isShowLocation:YES];
vc.title = homeModel.columnName;
vc.view.backgroundColor = [UIColor whiteColor];
[weakSelf addChildViewController:vc noralImage:nomal_image selectImage:select_image];
}
}
if ([homeModel.type isEqualToString:@"2"]) {
CNLiveCommuntListViewController * vc = [[CNLiveCommuntListViewController alloc] initWithShowType:CNLiveCommuntListShowTypeHome NBhdId:homeModel.idStr];
vc.title = homeModel.columnName;
vc.view.backgroundColor = [UIColor whiteColor];
[weakSelf addChildViewController:vc noralImage:nomal_image selectImage:select_image];
}
if (![homeModel.type isNotBlank] && [homeModel.cmsPageType isNotBlank] && ![homeModel.cmsPageType isEqualToString:@"4"]) {
CNLiveCommuntActiviViewController * vc = [[CNLiveCommuntActiviViewController alloc] initWithWebUrl:homeModel.cmsPageUrl isRootVC:YES Type:homeModel.cmsPageType];
vc.title = homeModel.columnName;
vc.view.backgroundColor = [UIColor whiteColor];
[weakSelf addChildViewController:vc noralImage:nomal_image selectImage:select_image];
}
if (![homeModel.type isNotBlank] && [homeModel.cmsPageType isEqualToString:@"4"]) {
CNLiveCommuntServiceViewController * vc = [[CNLiveCommuntServiceViewController alloc] initWithHomeModel:homeModel isRootVC:YES isShowLocation:NO];
vc.title = homeModel.columnName;
vc.view.backgroundColor = [UIColor whiteColor];
[weakSelf addChildViewController:vc noralImage:nomal_image selectImage:select_image];
}
if (![homeModel.type isNotBlank] && ![homeModel.cmsPageType isNotBlank] && [homeModel.cmsPageUrl isNotBlank]) {
CNLiveCommuntActiviViewController * vc = [[CNLiveCommuntActiviViewController alloc] initWithWebUrl:homeModel.cmsPageUrl isRootVC:YES Type:@"1"];
vc.title = homeModel.columnName;
vc.view.backgroundColor = [UIColor whiteColor];
[weakSelf addChildViewController:vc noralImage:nomal_image selectImage:select_image];
}
}
}
}
}];
}
}else{
NSString * nb_info = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithFormat:@"%@%@",kCNLiveCommuntyNBhdInfoIdentifier,[CNUserInfoManager manager].userInfoModel.uid]];
if ([nb_info isNotBlank]) {
CNLiveCommuntyHomeListViewController * listView = [[CNLiveCommuntyHomeListViewController alloc] init];
[weakSelf.navigationController dsPushViewController:listView animated:YES];
}else{
[QMUITips hideAllTipsInView:weakSelf.view];
[weakSelf.navigationController popViewControllerAnimated:YES];
}
}
}];
}
-(void)settingTabberWithImages:(NSArray *)images CompleterBlock:(void(^)(NSDictionary * tempDict))completerBlock
{
__block NSMutableDictionary * tempDict = [[NSMutableDictionary alloc] init];
for (int i = 0; i < images.count; i++) {
NSString * imageUrl = images[i];
if ([imageUrl isNotBlank]) {
[SDWebImageManager.sharedManager loadImageWithURL:[NSURL URLWithString:imageUrl] options:SDWebImageRetryFailed progress:NULL completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
[tempDict setObject:UIImagePNGRepresentation(image) forKey:[images indexOfObject:imageURL.absoluteString] == 0 ? @"nomal" : @"select"];
if (tempDict.count == images.count && completerBlock) completerBlock(tempDict);
}];
}
}
}
-(void)settingTabBar
{
//带分页的显示界面的
CNLiveCommuntConsuViewController * vc02 = [[CNLiveCommuntConsuViewController alloc] init];
vc02.title = @"权威资讯";
vc02.view.backgroundColor = [UIColor whiteColor];
[self addChildViewController:vc02 noralImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_consu_nomal"] selectImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_consu_select"]];
//准备放WebView的
CNLiveCommuntPartyViewController * vc01 = [[CNLiveCommuntPartyViewController alloc] init];
vc01.title = @"数字党建";
vc01.view.backgroundColor = [UIColor whiteColor];
[self addChildViewController:vc01 noralImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_party_nomal"] selectImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_party_select"]];
CNLiveCommuntActiviViewController * vc03 = [[CNLiveCommuntActiviViewController alloc] init];
vc03.title = @"公益活动";
vc03.view.backgroundColor = [UIColor whiteColor];
[self addChildViewController:vc03 noralImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_public_nomal"] selectImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_public_select"]];
//块状结构的
CNLiveCommuntServiceViewController * vc04 = [[CNLiveCommuntServiceViewController alloc] init];
vc04.title = @"生活服务";
vc04.view.backgroundColor = [UIColor whiteColor];
[self addChildViewController:vc04 noralImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_service_nomal"] selectImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_service_select"]];
}
@end