Commit e81f69b1 by houweibin

1,首页缓存问题

2,品牌商品页,根据是否有品牌图来判断是否显示品牌图区域
3,去掉所有品牌的获取缓存失败提示。
parent 2fb9f93c
...@@ -65,9 +65,23 @@ ...@@ -65,9 +65,23 @@
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
[self initView]; [self initView];
[self initTableViewHeaderHidden];
[self getCollection:_handle]; [self getCollection:_handle];
} }
- (void)initTableViewHeaderHidden{
//判断是否有品牌图,有就显示
if(self.collection &&
self.collection.image && self.collection.image.sourceURL &&
![KWMStringUtil isEmpty:self.collection.image.sourceURL.absoluteString]){
self.tbvBrandCaramel.tableHeaderView.frame = CGRectMake(0, 0, UI_SCREEN_WIDTH, 210);
self.tbvBrandCaramel.tableHeaderView.hidden = NO;
}else{
self.tbvBrandCaramel.tableHeaderView.frame = CGRectMake(0, 0, 0, 0);
self.tbvBrandCaramel.tableHeaderView.hidden = YES;
}
}
- (void)setBackColor{ - (void)setBackColor{
colorArr = [NSArray arrayWithObjects:@"#D8A88D",@"#A4C8C6",@"#E6C995",@"#718473",@"#D7B48B", nil]; colorArr = [NSArray arrayWithObjects:@"#D8A88D",@"#A4C8C6",@"#E6C995",@"#718473",@"#D7B48B", nil];
int num = arc4random_uniform(10); int num = arc4random_uniform(10);
...@@ -313,6 +327,7 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -313,6 +327,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
} }
- (void)setBrandData{ - (void)setBrandData{
[self initTableViewHeaderHidden];
//图片 //图片
if(_collection!=nil && _collection.image!=nil){ if(_collection!=nil && _collection.image!=nil){
NSURL *url = [_collection.image sourceURL]; NSURL *url = [_collection.image sourceURL];
......
...@@ -322,14 +322,16 @@ static NSString *identify = @"KWMSearchBrandsCell"; ...@@ -322,14 +322,16 @@ static NSString *identify = @"KWMSearchBrandsCell";
[weakSelf.tbvSearchBrand reloadData]; [weakSelf.tbvSearchBrand reloadData];
}; };
void(^cacheCallback)(KWMBrandsResult *) = ^(KWMBrandsResult *result){ void(^cacheCallback)(KWMBrandsResult *) = ^(KWMBrandsResult *result){
if([weakSelf hasCemaroseError:result]){ // if([weakSelf hasCemaroseError:result]){
return ; // return ;
} // }
if(result && result.brands){
NSArray *indexArray= [[result.brands rx_filterWithBlock:^BOOL(id each) { NSArray *indexArray= [[result.brands rx_filterWithBlock:^BOOL(id each) {
return each && each != [NSNull null]; return each && each != [NSNull null];
}] arrayWithPinYinFirstLetterFormat]; }] arrayWithPinYinFirstLetterFormat];
_dataArray =[NSMutableArray arrayWithArray:indexArray]; _dataArray =[NSMutableArray arrayWithArray:indexArray];
[weakSelf.tbvSearchBrand reloadData]; [weakSelf.tbvSearchBrand reloadData];
}
}; };
[self.api getAllBrand:nil cacheCallback:cacheCallback success:success failure:failure]; [self.api getAllBrand:nil cacheCallback:cacheCallback success:success failure:failure];
// [self showLoading]; // [self showLoading];
......
...@@ -300,10 +300,12 @@ ...@@ -300,10 +300,12 @@
} }
}; };
void(^cacheCallback)(KWMBrandsResult *) = ^(KWMBrandsResult *result){ void(^cacheCallback)(KWMBrandsResult *) = ^(KWMBrandsResult *result){
if([weakSelf hasCemaroseError:result]){ // if([weakSelf hasCemaroseError:result]){
return ; // return ;
} // }
if(result && result.brands){
self.allBrands = result.brands; self.allBrands = result.brands;
}
}; };
[self.api getAllBrand:nil cacheCallback:cacheCallback success:success failure:failure]; [self.api getAllBrand:nil cacheCallback:cacheCallback success:success failure:failure];
} }
......
...@@ -455,6 +455,7 @@ typedef enum{ ...@@ -455,6 +455,7 @@ typedef enum{
#pragma mark -cache #pragma mark -cache
/** 因为homedata api的url是动态的,url上的时间戳随时间的改变,所以需要手动保存,和获取 **/ /** 因为homedata api的url是动态的,url上的时间戳随时间的改变,所以需要手动保存,和获取 **/
//缓存规则:网络请求数据照常,如果没网络,并且缓存有数据,会拿缓存的数据显示。
-(BOOL)isUseHomeDataCache{ -(BOOL)isUseHomeDataCache{
if(!kIsNetwork){ if(!kIsNetwork){
KWMHomeData *homeData = [KWMPPCacheUtil getHomeDataByCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess]; KWMHomeData *homeData = [KWMPPCacheUtil getHomeDataByCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess];
...@@ -462,7 +463,6 @@ typedef enum{ ...@@ -462,7 +463,6 @@ typedef enum{
self.homeData = homeData; self.homeData = homeData;
[self.cvHome reloadData]; [self.cvHome reloadData];
}else{ }else{
[self showToast:CACHE_KEY_FAIL_HINT];
return false; return false;
} }
} }
...@@ -486,6 +486,7 @@ typedef enum{ ...@@ -486,6 +486,7 @@ typedef enum{
return params; return params;
} }
//缓存规则:网络请求数据照常,如果没网络,并且缓存有数据,会拿缓存的数据显示。
-(BOOL)isUseProductDataCache:(NSDictionary *)cacheKeyDictionary valueKeyPath:(NSString *)valueKeyPath page:(NSUInteger)page isHome:(BOOL)isHome{ -(BOOL)isUseProductDataCache:(NSDictionary *)cacheKeyDictionary valueKeyPath:(NSString *)valueKeyPath page:(NSUInteger)page isHome:(BOOL)isHome{
if(!kIsNetwork){ if(!kIsNetwork){
[self hideLoading]; [self hideLoading];
...@@ -498,10 +499,6 @@ typedef enum{ ...@@ -498,10 +499,6 @@ typedef enum{
products.count ? [self.cvHome.mj_footer endRefreshing] : [self.cvHome.mj_footer endRefreshingWithNoMoreData]; products.count ? [self.cvHome.mj_footer endRefreshing] : [self.cvHome.mj_footer endRefreshingWithNoMoreData];
} }
}else{ }else{
[self showToast:CACHE_KEY_FAIL_HINT];
if (isHome) {
[self.cvHome.mj_footer endRefreshing];
}
return false; return false;
} }
} }
......
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