Commit ffa6d1fa82be26df819fb46080532d7d3d0cb646
1 parent
0a4eaeb4
0.0.4
Showing
14 changed files
with
103 additions
and
83 deletions
CNLiveCServiceModule.podspec
CNLiveCServiceModule/Classes/Manager/CNLiveCServiceManagerBridge.h
| ... | ... | @@ -9,8 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | typedef NS_ENUM(NSInteger , CNCServiceJumpType) { |
| 11 | 11 | CNCServiceJumpTypeService, //服务内容跳转逻辑 |
| 12 | - CNCServiceJumpTypeGoods, //商品详情页 | |
| 13 | - CNCServiceJumpTypeVideo , //音频文件 | |
| 12 | + CNCServiceJumpTypeGetPage, //getpage获取内容 | |
| 14 | 13 | CNCServiceJumpTypeWebVC //电商h5页面 |
| 15 | 14 | }; |
| 16 | 15 | @protocol CNLiveCServiceProtocol <NSObject> |
| ... | ... | @@ -55,17 +54,7 @@ NS_ASSUME_NONNULL_BEGIN |
| 55 | 54 | + (void)jumpViewControllerType:(CNCServiceJumpType)type |
| 56 | 55 | param:(NSDictionary *)param |
| 57 | 56 | controller:(UIViewController *)controller; |
| 58 | -/** | |
| 59 | - *服务号跳转 | |
| 60 | - *@param goodsId 商品id | |
| 61 | - */ | |
| 62 | -+ (void)jumpGoodsViewController:(NSString *)goodsId | |
| 63 | - controller:(UIViewController *)controller; | |
| 64 | -/** | |
| 65 | - *服务号跳转 | |
| 66 | - *@param contentId 服务id | |
| 67 | - */ | |
| 68 | -+ (void)jumpGetPageOtherVC:(NSString *)contentId controller:(UIViewController *)controller; | |
| 57 | + | |
| 69 | 58 | /** |
| 70 | 59 | *服务号跳转 |
| 71 | 60 | *@param urlStr 网页地址 | ... | ... |
CNLiveCServiceModule/Classes/Manager/CNLiveCServiceManagerBridge.m
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | |
| 31 | 31 | + (void)jumpServiceController:(NSString *)serviceId type:(NSString *)type to:(NSString *)to shopType:(NSString *)shopType controller:(UIViewController *)controller |
| 32 | 32 | { |
| 33 | + [CNLiveServicePresent usedServiceWithServingId:serviceId]; | |
| 33 | 34 | [CNLiveCServiceManagerBridge jumpServiceType:CNCServiceJumpTypeService service:serviceId type:type to:to shopType:shopType controller:controller]; |
| 34 | 35 | } |
| 35 | 36 | + (void)jumpServiceType:(CNCServiceJumpType)jumpType service:(NSString *)serviceId type:(NSString *)type to:(NSString *)to shopType:(NSString *)shopType controller:(UIViewController *)controller{ |
| ... | ... | @@ -41,22 +42,6 @@ |
| 41 | 42 | }; |
| 42 | 43 | [CNLiveCServiceManagerBridge jumpViewControllerType:jumpType param:param controller:controller]; |
| 43 | 44 | } |
| 44 | -+ (void)jumpGoodsViewController:(NSString *)goodsId controller:(UIViewController *)controller | |
| 45 | -{ | |
| 46 | - NSDictionary *param = @{ | |
| 47 | - @"goodsId":goodsId?goodsId:@"", | |
| 48 | - }; | |
| 49 | - [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeGoods param:param controller:controller]; | |
| 50 | -} | |
| 51 | -+ (void)jumpGetPageOtherVC:(NSString *)contentId controller:(UIViewController *)controller{ | |
| 52 | - [QMUITips showLoadingInView:controller.view]; | |
| 53 | - [CNLiveServicePresent loadServiceInfoServiceId:contentId result:^(CNLiveSearchModel * _Nonnull model) { | |
| 54 | - [QMUITips hideAllTips]; | |
| 55 | - [CNLiveCServiceManagerBridge jumpServiceController:model.id type:model.type to:model.to shopType:model.shopType controller:controller]; | |
| 56 | - } error:^{ | |
| 57 | - [QMUITips hideAllTips]; | |
| 58 | - }]; | |
| 59 | -} | |
| 60 | 45 | |
| 61 | 46 | + (void)jumpWebVCWithUrl:(NSString *)urlStr controller:(UIViewController *)controller{ |
| 62 | 47 | NSDictionary *param = @{ | ... | ... |
CNLiveCServiceModule/Classes/Model/CNLiveServiceModel.h
| ... | ... | @@ -98,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN |
| 98 | 98 | ///布局 |
| 99 | 99 | @property (nonatomic, strong) CNLiveLayoutModel *layout; |
| 100 | 100 | @property (nonatomic, assign) CGFloat cellHeight; |
| 101 | -@property (nonatomic, strong) NSArray <CnLivePageContentModel *> *rightLists; | |
| 101 | +@property (nonatomic, strong) NSArray *rightLists; | |
| 102 | 102 | |
| 103 | 103 | @property (nonatomic, copy) NSString *blockId; |
| 104 | 104 | @property (nonatomic, copy) NSString *blockName; | ... | ... |
CNLiveCServiceModule/Classes/Present/CNLiveServicePresent.h
| ... | ... | @@ -38,7 +38,7 @@ NS_ASSUME_NONNULL_BEGIN |
| 38 | 38 | /** |
| 39 | 39 | 请求我的服务数据 |
| 40 | 40 | */ |
| 41 | -+ (void)loadMyServicepage:(NSString *)page result:(void (^) (NSArray * dataArray)) succeed error:(void(^)(void))failure; | |
| 41 | ++ (void)loadMyServicepage:(NSString *)page result:(void (^) (NSArray * dataArray , BOOL isLastPage)) succeed error:(void(^)(void))failure; | |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * 添加最近使用服务号 | ... | ... |
CNLiveCServiceModule/Classes/Present/CNLiveServicePresent.m
| ... | ... | @@ -258,7 +258,7 @@ static const CGFloat margin = 15; |
| 258 | 258 | }]; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | -+ (void)loadMyServicepage:(NSString *)page result:(void (^)(NSArray * _Nonnull))succeed error:(void (^)(void))failure{ | |
| 261 | ++ (void)loadMyServicepage:(NSString *)page result:(nonnull void (^)(NSArray * _Nonnull, BOOL))succeed error:(nonnull void (^)(void))failure{ | |
| 262 | 262 | NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @"", |
| 263 | 263 | @"pageSize":@"10", |
| 264 | 264 | @"type":@"2", |
| ... | ... | @@ -271,15 +271,18 @@ static const CGFloat margin = 15; |
| 271 | 271 | [CNLiveNetworking setupShowResult:YES]; |
| 272 | 272 | |
| 273 | 273 | [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/servingApi/servingList") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { |
| 274 | - CNLiveServiceModel * model = [CNLiveServiceModel mj_objectWithKeyValues:responseObject[@"data"]]; | |
| 274 | + NSDictionary * dic = responseObject[@"data"]; | |
| 275 | 275 | NSMutableArray *array = [NSMutableArray array]; |
| 276 | - for (NSDictionary *dic in model.categories) { | |
| 277 | - CNLiveSearchModel *searchModel = [CNLiveSearchModel mj_objectWithKeyValues:dic]; | |
| 278 | - [array addObject:searchModel]; | |
| 276 | + if (dic[@"list"]&&[dic[@"list"] isKindOfClass:[NSArray class]]) { | |
| 277 | + NSArray *list = dic[@"list"]; | |
| 278 | + for (NSDictionary *dict in list) { | |
| 279 | + CNLiveSearchModel *searchModel = [CNLiveSearchModel mj_objectWithKeyValues:dict]; | |
| 280 | + [array addObject:searchModel]; | |
| 281 | + } | |
| 279 | 282 | } |
| 280 | - | |
| 281 | - if (model) { | |
| 282 | - !succeed?:succeed(array.copy); | |
| 283 | + if (dic) { | |
| 284 | + NSString *lastPage = dic[@"isLastPage"]; | |
| 285 | + !succeed?:succeed(array.copy,lastPage); | |
| 283 | 286 | }else{ |
| 284 | 287 | [QMUITips showError:error.localizedDescription inView:AppKeyWindow hideAfterDelay:3]; |
| 285 | 288 | !failure?:failure(); |
| ... | ... | @@ -300,13 +303,15 @@ static const CGFloat margin = 15; |
| 300 | 303 | } |
| 301 | 304 | |
| 302 | 305 | + (void)removeMyServiceResult:(void (^) (void)) succeed{ |
| 303 | - NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @""}; | |
| 306 | + NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @"", | |
| 307 | + @"id":@"" | |
| 308 | + }; | |
| 304 | 309 | |
| 305 | 310 | [CNLiveNetworking setAllowRequestDefaultArgument:YES]; |
| 306 | 311 | [CNLiveNetworking setupShowDataResult:NO]; |
| 307 | 312 | [CNLiveNetworking setupShowResult:YES]; |
| 308 | 313 | |
| 309 | - [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/servingApi/removeMyNewest") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 314 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:cn_API_Classify(@"/servingApi/removeMyNewest") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 310 | 315 | if (!error) { |
| 311 | 316 | succeed(); |
| 312 | 317 | }else{ |
| ... | ... | @@ -331,10 +336,10 @@ static const CGFloat margin = 15; |
| 331 | 336 | if (dic[@"list"]&&[dic[@"list"] isKindOfClass:[NSArray class]]) { |
| 332 | 337 | NSArray *list = dic[@"list"]; |
| 333 | 338 | |
| 334 | - for (NSDictionary *dic in list) { | |
| 339 | + for (NSDictionary *dict in list) { | |
| 335 | 340 | NSDictionary *dictionary = @{ |
| 336 | - @"title":dic[@"title"], | |
| 337 | - @"lists":dic[@"list"], | |
| 341 | + @"title":dict[@"title"], | |
| 342 | + @"lists":dict[@"list"], | |
| 338 | 343 | @"layout":@{ |
| 339 | 344 | @"width":@((SCREEN_WIDTH-4*margin-3*margin)/4.0), |
| 340 | 345 | @"height":@(70) |
| ... | ... | @@ -370,7 +375,7 @@ static const CGFloat margin = 15; |
| 370 | 375 | if (model) { |
| 371 | 376 | !succeed?:succeed(model); |
| 372 | 377 | }else{ |
| 373 | - [QMUITips showError:error.localizedDescription inView:AppKeyWindow hideAfterDelay:3]; | |
| 378 | + [QMUITips showError:error.localizedDescription inView:AppKeyWindow hideAfterDelay:2]; | |
| 374 | 379 | !failure?:failure(); |
| 375 | 380 | } |
| 376 | 381 | }]; | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveCycleActiveCell.m
| ... | ... | @@ -42,8 +42,7 @@ |
| 42 | 42 | } |
| 43 | 43 | #pragma mark - SDCycleScrollViewDelegate |
| 44 | 44 | - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{ |
| 45 | - CnLivePageContentModel *pageModel = [CnLivePageContentModel mj_objectWithKeyValues:_model.contents[index]]; | |
| 46 | - [CNLiveCServiceManagerBridge jumpGetPageOtherVC:pageModel.contentId controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 45 | + [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeGetPage param:_model.contents[index] controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 47 | 46 | } |
| 48 | 47 | #pragma mark - Setting&&Getting |
| 49 | 48 | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveCycleCell.m
| ... | ... | @@ -55,8 +55,7 @@ static NSString *CNServiceOrLookID = @"CNLiveServiceOrLookCell"; |
| 55 | 55 | [CNLiveCServiceManagerBridge jumpServiceController:searchModel.id type:searchModel.type to:searchModel.to shopType:searchModel.shopType controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; |
| 56 | 56 | } |
| 57 | 57 | if ([model isKindOfClass:[CnLivePageContentModel class]]) { |
| 58 | - CnLivePageContentModel *pageModel = (CnLivePageContentModel *)model; | |
| 59 | - [CNLiveCServiceManagerBridge jumpGetPageOtherVC:pageModel.contentId controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 58 | + [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeGetPage param:[model mj_keyValues] controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 60 | 59 | } |
| 61 | 60 | } |
| 62 | 61 | |
| ... | ... | @@ -133,8 +132,6 @@ static NSString *CNServiceOrLookID = @"CNLiveServiceOrLookCell"; |
| 133 | 132 | { |
| 134 | 133 | if (!_listCollectionView) { |
| 135 | 134 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; |
| 136 | - layout.sectionFootersPinToVisibleBounds = YES; | |
| 137 | - layout.sectionHeadersPinToVisibleBounds = YES; | |
| 138 | 135 | _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; |
| 139 | 136 | _listCollectionView.scrollEnabled = NO; |
| 140 | 137 | _listCollectionView.backgroundColor = kWhiteColor; | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveRecommendCell.m
| ... | ... | @@ -29,12 +29,8 @@ static NSString *CNVideoRecommendCellID = @"CNLiveVideoRecommendCell"; |
| 29 | 29 | } |
| 30 | 30 | #pragma mark - UICollectionViewDelegate |
| 31 | 31 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ |
| 32 | - if ([_model.blockName isEqualToString:@"精品音频"]){ | |
| 33 | - [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeVideo param:self.model.contents[indexPath.row] controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 34 | - }else{ | |
| 35 | - CnLivePageContentModel *model = [CnLivePageContentModel mj_objectWithKeyValues:self.model.contents[indexPath.row]]; | |
| 36 | - [CNLiveCServiceManagerBridge jumpGoodsViewController:model.contentId controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 37 | - } | |
| 32 | + [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeGetPage param:self.model.contents[indexPath.row] controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 33 | + | |
| 38 | 34 | } |
| 39 | 35 | #pragma mark - UICollectionViewDataSource |
| 40 | 36 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ |
| ... | ... | @@ -75,8 +71,6 @@ static NSString *CNVideoRecommendCellID = @"CNLiveVideoRecommendCell"; |
| 75 | 71 | { |
| 76 | 72 | if (!_listCollectionView) { |
| 77 | 73 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; |
| 78 | - layout.sectionFootersPinToVisibleBounds = NO; | |
| 79 | - layout.sectionHeadersPinToVisibleBounds = NO; | |
| 80 | 74 | _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; |
| 81 | 75 | _listCollectionView.backgroundColor = kWhiteColor; |
| 82 | 76 | _listCollectionView.collectionViewLayout = layout; | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveServiceEpiCell.m
| ... | ... | @@ -68,13 +68,11 @@ static NSString *CNServiceOrLookID = @"CNLiveServiceOrLookCell"; |
| 68 | 68 | #pragma mark - Action |
| 69 | 69 | - (void)ButtonClick:(UIButton *)sender |
| 70 | 70 | { |
| 71 | - CnLivePageContentModel *pageModel = [CnLivePageContentModel mj_objectWithKeyValues:_model.rightLists[sender.tag - 1000]]; | |
| 72 | - [CNLiveCServiceManagerBridge jumpGetPageOtherVC:pageModel.contentId controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 71 | + [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeGetPage param:_model.rightLists[sender.tag - 1000] controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 73 | 72 | } |
| 74 | 73 | #pragma mark - UICollectionViewDelegate |
| 75 | 74 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ |
| 76 | - CnLivePageContentModel *model = [CnLivePageContentModel mj_objectWithKeyValues:self.model.contents[indexPath.row]]; | |
| 77 | - [CNLiveCServiceManagerBridge jumpGetPageOtherVC:model.contentId controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 75 | + [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeGetPage param:self.model.contents[indexPath.row] controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]]; | |
| 78 | 76 | } |
| 79 | 77 | #pragma mark - UICollectionViewDataSource |
| 80 | 78 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ |
| ... | ... | @@ -149,8 +147,6 @@ static NSString *CNServiceOrLookID = @"CNLiveServiceOrLookCell"; |
| 149 | 147 | { |
| 150 | 148 | if (!_listCollectionView) { |
| 151 | 149 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; |
| 152 | - layout.sectionFootersPinToVisibleBounds = YES; | |
| 153 | - layout.sectionHeadersPinToVisibleBounds = YES; | |
| 154 | 150 | _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; |
| 155 | 151 | _listCollectionView.backgroundColor = kWhiteColor; |
| 156 | 152 | _listCollectionView.collectionViewLayout = layout; | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveAllServiceVC.m
| ... | ... | @@ -36,16 +36,25 @@ static NSString *HistoryFootID = @"UICollectionFooterView"; |
| 36 | 36 | return vc; |
| 37 | 37 | } |
| 38 | 38 | - (void)requestService{ |
| 39 | + if (self.page == 1) { | |
| 40 | + self.dataSource = @[]; | |
| 41 | + [self.listCollectionView reloadData]; | |
| 42 | + } | |
| 39 | 43 | if (![CNLiveNetworking isNetworking]) { |
| 40 | 44 | self.listCollectionView.mj_footer.hidden = YES; |
| 45 | + if (self.dataSource.count>0) { | |
| 46 | + return; | |
| 47 | + } | |
| 41 | 48 | [self showEmptyViewWithImage:[UIImage loadCServiceBundle:@"service_noNet"] text:@"网络开小差了,刷新试试" detailText:nil buttonTitle:@" 刷新 " buttonAction:@selector(requestService)]; |
| 42 | 49 | self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); |
| 43 | 50 | [self setCNAPIErrorEmptyView]; |
| 44 | 51 | return; |
| 45 | 52 | } |
| 53 | + [QMUITips showLoadingInView:self.view]; | |
| 46 | 54 | weakself |
| 47 | 55 | [CNLiveServicePresent loadAllServiceWithServiceId:_serviceId page:[NSString stringWithFormat:@"%ld",_page] result:^(NSArray * _Nonnull dataArray, BOOL isLastPage) { |
| 48 | 56 | strongself |
| 57 | + [QMUITips hideAllTipsInView:self.view]; | |
| 49 | 58 | [self.listCollectionView.mj_footer endRefreshing]; |
| 50 | 59 | self.listCollectionView.mj_footer.hidden = NO; |
| 51 | 60 | |
| ... | ... | @@ -53,10 +62,19 @@ static NSString *HistoryFootID = @"UICollectionFooterView"; |
| 53 | 62 | [self.listCollectionView.mj_footer endRefreshingWithNoMoreData]; |
| 54 | 63 | } |
| 55 | 64 | [self removeEmptyView]; |
| 56 | - self.dataSource = dataArray; | |
| 65 | + NSMutableArray *array = [[NSMutableArray alloc] initWithArray:self.dataSource]; | |
| 66 | + for (id object in dataArray) { | |
| 67 | + [array addObject:object]; | |
| 68 | + } | |
| 69 | + | |
| 70 | + self.dataSource = array.copy; | |
| 57 | 71 | [self.listCollectionView reloadData]; |
| 58 | 72 | }error:^{ |
| 59 | 73 | strongself |
| 74 | + [QMUITips hideAllTipsInView:self.view]; | |
| 75 | + if (self.dataSource.count > 0) { | |
| 76 | + return; | |
| 77 | + } | |
| 60 | 78 | [self.listCollectionView.mj_footer endRefreshing]; |
| 61 | 79 | self.listCollectionView.mj_footer.hidden = YES; |
| 62 | 80 | [self showEmptyViewWithImage:[UIImage loadCServiceBundle:@"service_failure"] text:@"加载失败,请点击重试" detailText:nil buttonTitle:@" 重试 " buttonAction:@selector(requestService)]; |
| ... | ... | @@ -172,8 +190,6 @@ static NSString *HistoryFootID = @"UICollectionFooterView"; |
| 172 | 190 | { |
| 173 | 191 | if (!_listCollectionView) { |
| 174 | 192 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; |
| 175 | - layout.sectionFootersPinToVisibleBounds = YES; | |
| 176 | - layout.sectionHeadersPinToVisibleBounds = YES; | |
| 177 | 193 | _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; |
| 178 | 194 | _listCollectionView.backgroundColor = kWhiteColor; |
| 179 | 195 | _listCollectionView.collectionViewLayout = layout; | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveMyServicesVC.m
| ... | ... | @@ -27,18 +27,30 @@ static NSString *HotListCellID = @"HotListCellID"; |
| 27 | 27 | return myService; |
| 28 | 28 | } |
| 29 | 29 | - (void)myServiceData{ |
| 30 | + if (self.page == 1) { | |
| 31 | + self.dataSource = @[]; | |
| 32 | + [self.listCollectionView reloadData]; | |
| 33 | + } | |
| 30 | 34 | if (![CNLiveNetworking isNetworking]) { |
| 31 | 35 | self.listCollectionView.mj_footer.hidden = YES; |
| 36 | + if (self.dataSource.count > 0) { | |
| 37 | + return; | |
| 38 | + } | |
| 32 | 39 | [self showEmptyViewWithImage:[UIImage loadCServiceBundle:@"service_noNet"] text:@"网络开小差了,刷新试试" detailText:nil buttonTitle:@" 刷新 " buttonAction:@selector(myServiceData)]; |
| 33 | 40 | self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); |
| 34 | 41 | [self setCNAPIErrorEmptyView]; |
| 35 | 42 | return; |
| 36 | 43 | } |
| 44 | + [QMUITips showLoadingInView:self.view]; | |
| 37 | 45 | weakself |
| 38 | - [CNLiveServicePresent loadMyServicepage:[NSString stringWithFormat:@"%ld",_page] result:^(NSArray * _Nonnull dataArray) { | |
| 46 | + [CNLiveServicePresent loadMyServicepage:[NSString stringWithFormat:@"%ld",_page] result:^(NSArray * _Nonnull dataArray, BOOL isLastPage) { | |
| 39 | 47 | strongself |
| 40 | 48 | [self.listCollectionView.mj_footer endRefreshing]; |
| 49 | + [QMUITips hideAllTipsInView:self.view]; | |
| 41 | 50 | if (!dataArray||dataArray.count <= 0) { |
| 51 | + if (self.dataSource.count > 0) { | |
| 52 | + return; | |
| 53 | + } | |
| 42 | 54 | self.listCollectionView.mj_footer.hidden = YES; |
| 43 | 55 | self.navigationBar.right.hidden = YES; |
| 44 | 56 | [self showEmptyViewWithImage:[UIImage loadCServiceBundle:@"service_noMsg"] text:@"暂无内容" detailText:nil buttonTitle:NULL buttonAction:NULL]; |
| ... | ... | @@ -47,15 +59,21 @@ static NSString *HotListCellID = @"HotListCellID"; |
| 47 | 59 | }else{ |
| 48 | 60 | self.listCollectionView.mj_footer.hidden = NO; |
| 49 | 61 | [self removeEmptyView]; |
| 50 | - if (dataArray.count < 10) { | |
| 62 | + if (isLastPage) { | |
| 51 | 63 | [self.listCollectionView.mj_footer endRefreshingWithNoMoreData]; |
| 52 | - | |
| 64 | + }else{ | |
| 65 | + [self.listCollectionView.mj_footer endRefreshing]; | |
| 53 | 66 | } |
| 54 | 67 | self.navigationBar.right.hidden = NO; |
| 55 | - self.dataSource = dataArray; | |
| 68 | + NSMutableArray *array = [[NSMutableArray alloc] initWithArray:self.dataSource]; | |
| 69 | + for (id object in dataArray) { | |
| 70 | + [array addObject:object]; | |
| 71 | + } | |
| 72 | + self.dataSource = array.copy; | |
| 56 | 73 | [self.listCollectionView reloadData]; |
| 57 | 74 | } |
| 58 | 75 | } error:^{ |
| 76 | + [QMUITips hideAllTipsInView:self.view]; | |
| 59 | 77 | [self.listCollectionView.mj_footer endRefreshing]; |
| 60 | 78 | self.listCollectionView.mj_footer.hidden = YES; |
| 61 | 79 | strongself |
| ... | ... | @@ -120,8 +138,6 @@ static NSString *HotListCellID = @"HotListCellID"; |
| 120 | 138 | { |
| 121 | 139 | if (!_listCollectionView) { |
| 122 | 140 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; |
| 123 | - layout.sectionFootersPinToVisibleBounds = YES; | |
| 124 | - layout.sectionHeadersPinToVisibleBounds = YES; | |
| 125 | 141 | layout.itemSize = CGSizeMake((SCREEN_WIDTH-4*15-3*15)/4.0, 80); |
| 126 | 142 | layout.sectionInset = UIEdgeInsetsMake(15, 15, 15, 15); |
| 127 | 143 | _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveServiceSearchVC.m
| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #import "CNLiveSearchHotsFooterView.h" |
| 17 | 17 | #import "CNLiveSearchHeaderView.h" |
| 18 | 18 | |
| 19 | -@interface CNLiveServiceSearchVC ()<UITableViewDelegate,UITableViewDataSource, UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> | |
| 19 | +@interface CNLiveServiceSearchVC ()<UITableViewDelegate,UITableViewDataSource, UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UIScrollViewDelegate> | |
| 20 | 20 | |
| 21 | 21 | @property (nonatomic, strong) CNLiveMainSearch *searchView;//搜索框 |
| 22 | 22 | @property (nonatomic, strong) UIButton *cancelBtn; //取消按钮 |
| ... | ... | @@ -45,32 +45,48 @@ static NSString *HistoryFootID = @"HistoryFootID"; |
| 45 | 45 | return search; |
| 46 | 46 | } |
| 47 | 47 | - (void)searchRequese{ |
| 48 | + if (self.page == 1) { | |
| 49 | + self.dataListArr = @[]; | |
| 50 | + [self.listTableView reloadData]; | |
| 51 | + } | |
| 48 | 52 | if (![CNLiveNetworking isNetworking]) { |
| 53 | + if (self.dataListArr.count > 0) { | |
| 54 | + return; | |
| 55 | + } | |
| 49 | 56 | self.listCollectionView.mj_footer.hidden = YES; |
| 50 | 57 | [self showEmptyViewWithImage:[UIImage loadCServiceBundle:@"service_noNet"] text:@"网络开小差了,刷新试试" detailText:nil buttonTitle:@" 刷新 " buttonAction:@selector(searchRequese)]; |
| 51 | 58 | self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); |
| 52 | 59 | [self setCNAPIErrorEmptyView]; |
| 53 | 60 | return; |
| 54 | 61 | } |
| 62 | + [QMUITips showLoadingInView:self.view]; | |
| 55 | 63 | weakself |
| 56 | 64 | [CNLiveServicePresent searchServiceList:_searchStr page:[NSString stringWithFormat:@"%ld",_page] result:^(NSArray<CNLiveSearchModel *> * _Nonnull dataArray, BOOL isLastPage) { |
| 57 | 65 | weakSelf.listCollectionView.hidden = YES; |
| 66 | + [QMUITips hideAllTipsInView:self.view]; | |
| 58 | 67 | strongself |
| 59 | 68 | if (!dataArray||dataArray.count <= 0) { |
| 69 | + if (self.dataListArr.count > 0) { | |
| 70 | + return; | |
| 71 | + } | |
| 60 | 72 | [self showEmptyViewWithImage:[UIImage loadCServiceBundle:@"service_noMsg"] text:@"暂无内容" detailText:nil buttonTitle:NULL buttonAction:@selector(searchRequese)]; |
| 61 | 73 | self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); |
| 62 | 74 | [self setCNAPIErrorEmptyView]; |
| 63 | 75 | }else{ |
| 76 | + [QMUITips hideAllTipsInView:self.view]; | |
| 64 | 77 | [self removeEmptyView]; |
| 65 | 78 | self.listTableView.mj_footer.hidden = NO; |
| 66 | 79 | if (isLastPage) { |
| 67 | 80 | [self.listTableView.mj_footer endRefreshingWithNoMoreData]; |
| 68 | 81 | }else{ |
| 69 | - self.page ++; | |
| 82 | + [self.listTableView.mj_footer endRefreshing]; | |
| 70 | 83 | } |
| 71 | 84 | self.listTableView.hidden = NO; |
| 72 | - | |
| 73 | - self.dataListArr = dataArray; | |
| 85 | + NSMutableArray *array = [[NSMutableArray alloc] initWithArray:self.dataListArr]; | |
| 86 | + for (id object in dataArray) { | |
| 87 | + [array addObject:object]; | |
| 88 | + } | |
| 89 | + self.dataListArr = array.copy; | |
| 74 | 90 | [self.listTableView reloadData]; |
| 75 | 91 | } |
| 76 | 92 | } error:^{ |
| ... | ... | @@ -156,9 +172,13 @@ static NSString *HistoryFootID = @"HistoryFootID"; |
| 156 | 172 | [self.navigationController popViewControllerAnimated:YES]; |
| 157 | 173 | } |
| 158 | 174 | #pragma mark - UIScrollViewDelegate |
| 159 | -- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ | |
| 175 | +- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{ | |
| 160 | 176 | [self.view endEditing:YES]; |
| 161 | 177 | } |
| 178 | +- (BOOL)shouldHideKeyboardWhenTouchInView:(UIView *)view | |
| 179 | +{ | |
| 180 | + return YES; | |
| 181 | +} | |
| 162 | 182 | #pragma mark - UITableViewDelegate |
| 163 | 183 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ |
| 164 | 184 | return 75; |
| ... | ... | @@ -305,7 +325,12 @@ static NSString *HistoryFootID = @"HistoryFootID"; |
| 305 | 325 | _listTableView.dataSource = self; |
| 306 | 326 | _listTableView.delegate = self; |
| 307 | 327 | [_listTableView registerClass:[CNLiveSearchListCell class] forCellReuseIdentifier:SearchListCellID]; |
| 308 | - _listTableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(searchRequese)]; | |
| 328 | + weakself | |
| 329 | + _listTableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{ | |
| 330 | + strongself | |
| 331 | + self.page ++; | |
| 332 | + [self searchRequese]; | |
| 333 | + }]; | |
| 309 | 334 | _listTableView.hidden = YES; |
| 310 | 335 | } |
| 311 | 336 | return _listTableView; | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveServiceVC.m
| ... | ... | @@ -246,8 +246,6 @@ static NSString *CNGoodsOrVideoheaderID = @"CNLiveGoodsOrVideoHeaderView"; |
| 246 | 246 | { |
| 247 | 247 | if (!_listCollectionView) { |
| 248 | 248 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; |
| 249 | - layout.sectionFootersPinToVisibleBounds = YES; | |
| 250 | - layout.sectionHeadersPinToVisibleBounds = YES; | |
| 251 | 249 | _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; |
| 252 | 250 | _listCollectionView.backgroundColor = kWhiteColor; |
| 253 | 251 | _listCollectionView.collectionViewLayout = layout; | ... | ... |