Commit 2fb9f93c by houweibin

fix

parent 387d5843
...@@ -354,19 +354,19 @@ typedef enum{ ...@@ -354,19 +354,19 @@ typedef enum{
BOOL isHome = [handle isEqualToString:@"products-list-app-homepage"]; BOOL isHome = [handle isEqualToString:@"products-list-app-homepage"];
NSInteger cpage = isHome ? self.page : 1; NSInteger cpage = isHome ? self.page : 1;
NSDictionary *parameters = [self getProductCacheKeyDictionary:cpage tags:tags handle:handle]; NSDictionary *parameters = [self getProductCacheKeyDictionary:cpage tags:tags handle:handle];
if([self isUseProductDataCache:parameters valueKeyPath:valueKeyPath page:cpage isHome:isHome]){ BOOL isUseCache = [self isUseProductDataCache:parameters valueKeyPath:valueKeyPath page:cpage isHome:isHome];
return;
}
[self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) { [self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
[self hideLoading]; [self hideLoading];
if (!error) { if (!error) {
[self.client getProductsPage:cpage inCollection:collection.identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) { [self.client getProductsPage:cpage inCollection:collection.identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) {
if (!error) { if (!error) {
[KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage products:products]; [KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage products:products];
[self setValue:products forKeyPath:valueKeyPath]; if(!isUseCache){
[self.cvHome reloadData]; [self setValue:products forKeyPath:valueKeyPath];
[self.cvHome reloadData];
}
}else{ }else{
[self showError:error]; // [self showError:error];
} }
if (isHome) { if (isHome) {
self.page = self.page + 1; self.page = self.page + 1;
...@@ -399,15 +399,15 @@ typedef enum{ ...@@ -399,15 +399,15 @@ typedef enum{
- (void) loadHomeData { - (void) loadHomeData {
[self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"]; [self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"];
if([self isUseHomeDataCache]){ BOOL isUseCache = [self isUseHomeDataCache];
return;
}
[self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) { [self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) {
[KWMPPCacheUtil saveDataToCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess homeData:result.data]; [KWMPPCacheUtil saveDataToCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess homeData:result.data];
self.homeData = result.data; if(!isUseCache){
[self.cvHome reloadData]; self.homeData = result.data;
[self.cvHome reloadData];
}
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
[self showError:error]; // [self showError: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