Commit 21d4ff21 by houweibin

搜索moncler商品后,商品详情页显示获取商品数据失败的问题。

parent 53469421
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
@property (nonatomic) id<Optional> product; @property (nonatomic) id<Optional> product;
@property (nonatomic) NSDictionary <Ignore> *productDict;
@property (nonatomic) NSArray<Optional> *products; @property (nonatomic) NSArray<Optional> *products;
@end @end
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
if (self) { if (self) {
NSDictionary *dataDictionary = dict[@"product"]; NSDictionary *dataDictionary = dict[@"product"];
if(dataDictionary){ if(dataDictionary){
self.productDict = dataDictionary;
self.product = [self buildData:modelClass jsonDictionary:dataDictionary]; self.product = [self buildData:modelClass jsonDictionary:dataDictionary];
} }
......
...@@ -22,4 +22,7 @@ ...@@ -22,4 +22,7 @@
@property(nonatomic) NSNumber *productId; @property(nonatomic) NSNumber *productId;
//当传入的vendor为moncler时,会进行处理
@property(nonatomic) NSString *vendor;
@end @end
...@@ -115,7 +115,13 @@ ...@@ -115,7 +115,13 @@
[self requestBrandProducts:1]; [self requestBrandProducts:1];
[self requestCategoryProducts:1]; [self requestCategoryProducts:1];
}else{ }else{
[self requestProductDetail]; NSString *productVendor = self.vendor? [self.vendor lowercaseString] : @"";
BOOL isMoncler = [productVendor isEqualToString:@"moncler"];
if(isMoncler && self.productId){
[self requestAdminProductDetail];
}else{
[self requestProductDetail];
}
} }
[self requestColorMetafield]; [self requestColorMetafield];
[self requestAdminProduct]; [self requestAdminProduct];
...@@ -536,6 +542,43 @@ ...@@ -536,6 +542,43 @@
} }
} }
-(void)requestAdminProductDetail{
NSNumber *productId = self.product?self.product.identifier:self.productId;
if(!productId){
return;
}
[self showLoading];
__weak KWMNewProductVC *weakSelf = self;
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
[weakSelf hideLoading];
[weakSelf showError:error];
};
void(^success)(NSURLSessionDataTask *,KWMProductResult *) = ^(NSURLSessionDataTask *task,KWMProductResult *result){
[weakSelf hideLoading];
BUYProduct *product = nil;
if(result && result.productDict){
@try{
BUYModelManager *modelManager = [[BUYModelManager alloc]init];
product = (BUYProduct *)[modelManager buy_objectWithEntityName:[BUYProduct entityName] JSONDictionary:result.productDict];
}
@catch (NSException *exception){
NSLog( @"exception Name: %@", exception.name);
NSLog( @"exception Reason: %@", exception.reason );
}
}
if(product){
weakSelf.product = product;
weakSelf.productId = product.identifier;
[weakSelf initBottomViewHidden];
weakSelf.midDetailView.product = product;
[weakSelf.detailView1 setData:product];
[weakSelf requestBrandProducts:1];
[weakSelf requestCategoryProducts:1];
}
};
[self.api getAdminProduct:nil productId:productId success:success failure:failure];
}
-(void)requestProductByColor:(KWMColor *)color{ -(void)requestProductByColor:(KWMColor *)color{
__weak KWMNewProductVC *weakSelf = self; __weak KWMNewProductVC *weakSelf = self;
......
...@@ -94,6 +94,7 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -94,6 +94,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
- (void)kwm_onClickLeftIamge:(KWMBrandCaramelCell *)brandCell{ - (void)kwm_onClickLeftIamge:(KWMBrandCaramelCell *)brandCell{
KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance]; KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
productDetailVC.productId = brandCell.leftDataProduct.id; productDetailVC.productId = brandCell.leftDataProduct.id;
productDetailVC.vendor = brandCell.leftDataProduct.vendor;
[self.navigationController pushViewController:productDetailVC animated:YES]; [self.navigationController pushViewController:productDetailVC animated:YES];
} }
...@@ -101,6 +102,7 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -101,6 +102,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
- (void)kwm_onClickRightIamge:(KWMBrandCaramelCell *)brandCell{ - (void)kwm_onClickRightIamge:(KWMBrandCaramelCell *)brandCell{
KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance]; KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
productDetailVC.productId = brandCell.rightDataProduct.id; productDetailVC.productId = brandCell.rightDataProduct.id;
productDetailVC.vendor = brandCell.rightDataProduct.vendor;
[self.navigationController pushViewController:productDetailVC animated:YES]; [self.navigationController pushViewController:productDetailVC animated:YES];
} }
......
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