Commit 0684b989f519053fecfa3cf605b683feee7452be

Authored by yanglingyu
1 parent 6d71e738

首页逻辑动态修改

CNLiveCServiceModule/Classes/Present/CNLiveServicePresent.m
... ... @@ -106,10 +106,10 @@ static const CGFloat margin = 15;
106 106 [dataArray addObject:categoryModel];
107 107 }
108 108 }
109   - CNLiveSearchHotsModel *serviceModel = nil;
110 109 if (model.allList && model.allList.count > 0) {
111 110 for (NSDictionary *dic in model.allList) {
112 111 @autoreleasepool {
  112 + CNLiveSearchHotsModel *serviceModel = nil;
113 113 CGFloat cellheight = 0;
114 114 NSInteger showNum = 0;
115 115 NSString *title = dic[@"name"];
... ... @@ -233,6 +233,7 @@ static const CGFloat margin = 15;
233 233 if (array &&[array isKindOfClass:[NSArray class]]) {
234 234 for (int i = 0;i < array.count;i ++) {
235 235 NSMutableDictionary *mDic = [[NSMutableDictionary alloc] initWithDictionary:array[i]];
  236 + NSArray *contents = mDic[@"contents"];
236 237 if ([mDic[@"blockName"] isEqualToString:@"疫情服务专区"]) {
237 238 [mDic setObject:array[i + 1][@"contents"] forKey:@"rightLists"];
238 239 [mDic setObject:@(214*KScreenWidth/375 ) forKey:@"cellHeight"];
... ... @@ -245,7 +246,8 @@ static const CGFloat margin = 15;
245 246 }else{
246 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 251 CNliveServicePageModel *model = [CNliveServicePageModel mj_objectWithKeyValues:mDic];
250 252 [dataArray addObject:model];
251 253 }
... ...
CNLiveCServiceModule/Classes/ViewController/CNLiveServiceVC.m
... ... @@ -35,11 +35,13 @@ static NSString *CNGoodsOrVideoheaderID = @&quot;CNLiveGoodsOrVideoHeaderView&quot;;
35 35 @property (nonatomic, strong) NSArray *pageListSource;
36 36 @property (nonatomic, strong) NSArray *hots;
37 37 @property (nonatomic, strong) UICollectionView *listCollectionView;
  38 +@property (nonatomic, assign) BOOL isError;
38 39  
39 40 @end
40 41  
41 42 @implementation CNLiveServiceVC
42 43 - (void)requestService{
  44 + self.isError = NO;
43 45 if (![CNLiveNetworking isNetworking]) {
44 46 if (self.dataSource.count>0 && self.pageListSource.count>0) {
45 47 return;
... ... @@ -64,9 +66,7 @@ static NSString *CNGoodsOrVideoheaderID = @&quot;CNLiveGoodsOrVideoHeaderView&quot;;
64 66 if (self.dataSource.count>0 && self.pageListSource.count>0) {
65 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 70 dispatch_group_leave(requestGroup);
71 71 }];
72 72 dispatch_group_enter(requestGroup);
... ... @@ -79,17 +79,20 @@ static NSString *CNGoodsOrVideoheaderID = @&quot;CNLiveGoodsOrVideoHeaderView&quot;;
79 79 if (self.dataSource.count>0 && self.pageListSource.count>0) {
80 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 83 dispatch_group_leave(requestGroup);
86 84 }];
87 85 dispatch_group_notify(requestGroup, dispatch_get_main_queue(), ^{
88 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 98 -(void)removeEmptyView
... ...