Commit 0684b989f519053fecfa3cf605b683feee7452be

Authored by yanglingyu
1 parent 6d71e738

首页逻辑动态修改

CNLiveCServiceModule/Classes/Present/CNLiveServicePresent.m
@@ -106,10 +106,10 @@ static const CGFloat margin = 15; @@ -106,10 +106,10 @@ static const CGFloat margin = 15;
106 [dataArray addObject:categoryModel]; 106 [dataArray addObject:categoryModel];
107 } 107 }
108 } 108 }
109 - CNLiveSearchHotsModel *serviceModel = nil;  
110 if (model.allList && model.allList.count > 0) { 109 if (model.allList && model.allList.count > 0) {
111 for (NSDictionary *dic in model.allList) { 110 for (NSDictionary *dic in model.allList) {
112 @autoreleasepool { 111 @autoreleasepool {
  112 + CNLiveSearchHotsModel *serviceModel = nil;
113 CGFloat cellheight = 0; 113 CGFloat cellheight = 0;
114 NSInteger showNum = 0; 114 NSInteger showNum = 0;
115 NSString *title = dic[@"name"]; 115 NSString *title = dic[@"name"];
@@ -233,6 +233,7 @@ static const CGFloat margin = 15; @@ -233,6 +233,7 @@ static const CGFloat margin = 15;
233 if (array &&[array isKindOfClass:[NSArray class]]) { 233 if (array &&[array isKindOfClass:[NSArray class]]) {
234 for (int i = 0;i < array.count;i ++) { 234 for (int i = 0;i < array.count;i ++) {
235 NSMutableDictionary *mDic = [[NSMutableDictionary alloc] initWithDictionary:array[i]]; 235 NSMutableDictionary *mDic = [[NSMutableDictionary alloc] initWithDictionary:array[i]];
  236 + NSArray *contents = mDic[@"contents"];
236 if ([mDic[@"blockName"] isEqualToString:@"疫情服务专区"]) { 237 if ([mDic[@"blockName"] isEqualToString:@"疫情服务专区"]) {
237 [mDic setObject:array[i + 1][@"contents"] forKey:@"rightLists"]; 238 [mDic setObject:array[i + 1][@"contents"] forKey:@"rightLists"];
238 [mDic setObject:@(214*KScreenWidth/375 ) forKey:@"cellHeight"]; 239 [mDic setObject:@(214*KScreenWidth/375 ) forKey:@"cellHeight"];
@@ -245,7 +246,8 @@ static const CGFloat margin = 15; @@ -245,7 +246,8 @@ static const CGFloat margin = 15;
245 }else{ 246 }else{
246 [mDic setObject:@(170) forKey:@"cellHeight"]; 247 [mDic setObject:@(170) forKey:@"cellHeight"];
247 } 248 }
248 - if (![mDic[@"blockName"] isEqualToString:@"疫情服务"]){ 249 +
  250 + if (![mDic[@"blockName"] isEqualToString:@"疫情服务"] && contents&&[contents isKindOfClass:[NSArray class]] && contents.count>0){
249 CNliveServicePageModel *model = [CNliveServicePageModel mj_objectWithKeyValues:mDic]; 251 CNliveServicePageModel *model = [CNliveServicePageModel mj_objectWithKeyValues:mDic];
250 [dataArray addObject:model]; 252 [dataArray addObject:model];
251 } 253 }
CNLiveCServiceModule/Classes/ViewController/CNLiveServiceVC.m
@@ -35,11 +35,13 @@ static NSString *CNGoodsOrVideoheaderID = @&quot;CNLiveGoodsOrVideoHeaderView&quot;; @@ -35,11 +35,13 @@ static NSString *CNGoodsOrVideoheaderID = @&quot;CNLiveGoodsOrVideoHeaderView&quot;;
35 @property (nonatomic, strong) NSArray *pageListSource; 35 @property (nonatomic, strong) NSArray *pageListSource;
36 @property (nonatomic, strong) NSArray *hots; 36 @property (nonatomic, strong) NSArray *hots;
37 @property (nonatomic, strong) UICollectionView *listCollectionView; 37 @property (nonatomic, strong) UICollectionView *listCollectionView;
  38 +@property (nonatomic, assign) BOOL isError;
38 39
39 @end 40 @end
40 41
41 @implementation CNLiveServiceVC 42 @implementation CNLiveServiceVC
42 - (void)requestService{ 43 - (void)requestService{
  44 + self.isError = NO;
43 if (![CNLiveNetworking isNetworking]) { 45 if (![CNLiveNetworking isNetworking]) {
44 if (self.dataSource.count>0 && self.pageListSource.count>0) { 46 if (self.dataSource.count>0 && self.pageListSource.count>0) {
45 return; 47 return;
@@ -64,9 +66,7 @@ static NSString *CNGoodsOrVideoheaderID = @&quot;CNLiveGoodsOrVideoHeaderView&quot;; @@ -64,9 +66,7 @@ static NSString *CNGoodsOrVideoheaderID = @&quot;CNLiveGoodsOrVideoHeaderView&quot;;
64 if (self.dataSource.count>0 && self.pageListSource.count>0) { 66 if (self.dataSource.count>0 && self.pageListSource.count>0) {
65 return; 67 return;
66 } 68 }
67 - [self showEmptyViewWithImage:[UIImage loadCServiceBundle:@"service_failure"] text:@"加载失败,请点击重试" detailText:nil buttonTitle:@" 重试 " buttonAction:@selector(requestService)];  
68 - self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop);  
69 - [self setCNAPIErrorEmptyView]; 69 + self.isError = YES;
70 dispatch_group_leave(requestGroup); 70 dispatch_group_leave(requestGroup);
71 }]; 71 }];
72 dispatch_group_enter(requestGroup); 72 dispatch_group_enter(requestGroup);
@@ -79,17 +79,20 @@ static NSString *CNGoodsOrVideoheaderID = @&quot;CNLiveGoodsOrVideoHeaderView&quot;; @@ -79,17 +79,20 @@ static NSString *CNGoodsOrVideoheaderID = @&quot;CNLiveGoodsOrVideoHeaderView&quot;;
79 if (self.dataSource.count>0 && self.pageListSource.count>0) { 79 if (self.dataSource.count>0 && self.pageListSource.count>0) {
80 return; 80 return;
81 } 81 }
82 - [self showEmptyViewWithImage:[UIImage loadCServiceBundle:@"service_failure"] text:@"加载失败,请点击重试" detailText:nil buttonTitle:@" 重试 " buttonAction:@selector(requestService)];  
83 - self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop);  
84 - [self setCNAPIErrorEmptyView]; 82 + self.isError = YES;
85 dispatch_group_leave(requestGroup); 83 dispatch_group_leave(requestGroup);
86 }]; 84 }];
87 dispatch_group_notify(requestGroup, dispatch_get_main_queue(), ^{ 85 dispatch_group_notify(requestGroup, dispatch_get_main_queue(), ^{
88 strongself 86 strongself
89 - if (self.dataSource.count>0&&self.pageListSource.count>0) {  
90 - [self.listCollectionView reloadData]; 87 + if (!self.isError) {
  88 + if (self.dataSource.count>0||self.pageListSource.count>0) {
  89 + [self.listCollectionView reloadData];
  90 + }
  91 + }else{
  92 + [self showEmptyViewWithImage:[UIImage loadCServiceBundle:@"service_failure"] text:@"加载失败,请点击重试" detailText:nil buttonTitle:@" 重试 " buttonAction:@selector(requestService)];
  93 + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop);
  94 + [self setCNAPIErrorEmptyView];
91 } 95 }
92 -  
93 }); 96 });
94 } 97 }
95 -(void)removeEmptyView 98 -(void)removeEmptyView