Commit e01dbf27 by houweibin

修复了下拉刷新及加载更多时出现的问题

parent 5bcdb8f1
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
@property (nonatomic) NSString<Optional> *message; @property (nonatomic) NSString<Optional> *message;
//数据--存放解析后的model。 //数据--存放解析后的model。
@property (nonatomic) id<Ignore> data; @property (nonatomic) NSArray<Ignore> *data;
@end @end
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
return self; return self;
} }
- (id)buildData:(NSDictionary *)jsonDictionary { - (NSArray *)buildData:(NSDictionary *)jsonDictionary {
id result = nil; NSArray *result = nil;
if(jsonDictionary){ if(jsonDictionary){
@try{ @try{
NSArray *array = (NSArray *)jsonDictionary; NSArray *array = (NSArray *)jsonDictionary;
......
...@@ -24,5 +24,7 @@ ...@@ -24,5 +24,7 @@
@property (nonatomic) CGFloat offsetY; @property (nonatomic) CGFloat offsetY;
//切换分类后,如果原来有选中筛选规则的需要清除并重新刷新,以此字段标识 //切换分类后,如果原来有选中筛选规则的需要清除并重新刷新,以此字段标识
@property (nonatomic) BOOL isNeedReload; @property (nonatomic) BOOL isNeedReload;
//是否滑到底
@property (nonatomic) BOOL reachedEnd;
@end @end
...@@ -39,12 +39,6 @@ ...@@ -39,12 +39,6 @@
@property (nonatomic) NSArray *allBrands; @property (nonatomic) NSArray *allBrands;
//@property(nonatomic) BUYCollectionSort sort;
//@property(nonatomic) NSMutableArray<KWMFilter *> *selectFilters;
//@property(nonatomic) NSString *selectBrands;
@property(nonatomic) NSArray<KWMCategoryModel *>* categories; @property(nonatomic) NSArray<KWMCategoryModel *>* categories;
@property (nonatomic) KWMCategoryModel *selectedCategory; @property (nonatomic) KWMCategoryModel *selectedCategory;
...@@ -398,8 +392,8 @@ ...@@ -398,8 +392,8 @@
} }
[self.client getProductsPage:cpage inCollection:cmodel.collection_id withTags:tags sortOrder:cmodel.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){ [self.client getProductsPage:cpage inCollection:cmodel.collection_id withTags:tags sortOrder:cmodel.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
weakSelf.cvRightProduct.mj_footer.hidden = false; weakSelf.cvRightProduct.mj_footer.hidden = false;
weakSelf.filterTab.userInteractionEnabled = true;
if (cmodel == self.selectedCategory) { if (cmodel == self.selectedCategory) {
// [weakSelf.refreshUtil hideLoading];
if ([weakSelf.cvRightProduct.mj_header isRefreshing]) { if ([weakSelf.cvRightProduct.mj_header isRefreshing]) {
[weakSelf.cvRightProduct.mj_header endRefreshing]; [weakSelf.cvRightProduct.mj_header endRefreshing];
} }
...@@ -407,21 +401,14 @@ ...@@ -407,21 +401,14 @@
[weakSelf.cvRightProduct.mj_footer endRefreshing]; [weakSelf.cvRightProduct.mj_footer endRefreshing];
} }
} }
if(reachedEnd){
[weakSelf.cvRightProduct.mj_footer endRefreshingWithNoMoreData];
}
weakSelf.filterTab.userInteractionEnabled = true;
if(error){ if(error){
[weakSelf showError:error]; [weakSelf showError:error];
} }else{
else{
//保存缓存 //保存缓存
[KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getProductsPage products:products]; [KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getProductsPage products:products];
// weakSelf.refreshUtil.page = page;
cmodel.page = page; cmodel.page = page;
// weakSelf.refreshUtil.hasNextPage = !reachedEnd; cmodel.reachedEnd = reachedEnd;
// [weakSelf.refreshUtil appendDataList:products]; weakSelf.cvRightProduct.mj_footer.hidden = reachedEnd;
if (cpage == 1) { if (cpage == 1) {
[cmodel.products removeAllObjects]; [cmodel.products removeAllObjects];
} }
...@@ -447,9 +434,9 @@ ...@@ -447,9 +434,9 @@
self.refreshUtil.hasNextPage = YES; self.refreshUtil.hasNextPage = YES;
self.refreshUtil.dataList = _selectedCategory.products; self.refreshUtil.dataList = _selectedCategory.products;
[self.cvRightProduct reloadData]; [self.cvRightProduct reloadData];
self.refreshUtil.hasNextPage = _selectedCategory.reachedEnd;
self.cvRightProduct.mj_footer.hidden = _selectedCategory.reachedEnd;
if (_selectedCategory.products.count == 0) { if (_selectedCategory.products.count == 0) {
// [self requestProducts:1];
// [self.refreshUtil reLoadData];
if ([self.cvRightProduct.mj_header isRefreshing]) { if ([self.cvRightProduct.mj_header isRefreshing]) {
[self requestProducts:1]; [self requestProducts:1];
}else{ }else{
...@@ -460,7 +447,6 @@ ...@@ -460,7 +447,6 @@
}else if([self.cvRightProduct.mj_header isRefreshing]) { }else if([self.cvRightProduct.mj_header isRefreshing]) {
[self.cvRightProduct.mj_header endRefreshing]; [self.cvRightProduct.mj_header endRefreshing];
} }
// [self.cvRightProduct reloadData];
} }
#pragma mark -cache #pragma mark -cache
...@@ -476,6 +462,8 @@ ...@@ -476,6 +462,8 @@
[self.cvRightProduct.mj_footer endRefreshing]; [self.cvRightProduct.mj_footer endRefreshing];
} }
cmodel.page = page; cmodel.page = page;
cmodel.reachedEnd = NO;
self.cvRightProduct.mj_footer.hidden = NO;
if (page == 1) { if (page == 1) {
[cmodel.products removeAllObjects]; [cmodel.products removeAllObjects];
} }
......
...@@ -216,16 +216,13 @@ ...@@ -216,16 +216,13 @@
if (result!= nil && result.count > 0) { if (result!= nil && result.count > 0) {
[self.dataList addObjectsFromArray:result]; [self.dataList addObjectsFromArray:result];
}else{
[self removeFooterView];
} }
if ([self hasNextPage]) { if ([self hasNextPage]) {
tableView.mj_footer.hidden = NO; tableView.mj_footer.hidden = NO;
[tableView.mj_footer resetNoMoreData]; [tableView.mj_footer resetNoMoreData];
}else{ }else{
tableView.mj_footer.hidden = NO; tableView.mj_footer.hidden = YES;
// tableView.mj_footer.hidden = YES;
[tableView.mj_footer endRefreshingWithNoMoreData]; [tableView.mj_footer endRefreshingWithNoMoreData];
} }
[tableView reloadData]; [tableView reloadData];
......
...@@ -231,19 +231,13 @@ ...@@ -231,19 +231,13 @@
} }
return; return;
} }
weakSelf.hasNextPage = result.data && result.data.count > 0;
if (result.data) { if (result.data) {
NSMutableArray *showOrders = [NSMutableArray arrayWithArray:result.data]; NSMutableArray *showOrders = [NSMutableArray arrayWithArray:result.data];
BUYOrder *paidOrder = [self getPaidOrder]; BUYOrder *paidOrder = [self getPaidOrder];
if(paidOrder && targetPage ==1){ if(paidOrder && targetPage ==1){
[showOrders insertObject:paidOrder atIndex:0]; [showOrders insertObject:paidOrder atIndex:0];
} }
// if(showOrders.count <= 50){
// weakSelf.hasNextPage = false;
// weakSelf.tbvOrder.mj_footer.hidden = YES;
// }else{
// weakSelf.hasNextPage = true;
// weakSelf.tbvOrder.mj_footer.hidden = NO;
// }
if(targetPage == 1){ if(targetPage == 1){
[weakSelf.dataList removeAllObjects]; [weakSelf.dataList removeAllObjects];
[self.expandOrderId removeAllObjects]; [self.expandOrderId removeAllObjects];
......
...@@ -234,6 +234,7 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -234,6 +234,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
} }
_vSearchFB.lbGoodsNum.hidden = NO; _vSearchFB.lbGoodsNum.hidden = NO;
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
[weakSelf hideLoading];
_vSearchFB.lbGoodsNum.hidden = NO; _vSearchFB.lbGoodsNum.hidden = NO;
[weakSelf showError:error]; [weakSelf showError:error];
NSLog(@"error = %@",error); NSLog(@"error = %@",error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment