Commit e01dbf27 by houweibin

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

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