Commit bb7f62fa by houweibin

调整

parent baacd509
...@@ -118,6 +118,7 @@ ...@@ -118,6 +118,7 @@
NSString *productVendor = self.vendor? [self.vendor lowercaseString] : @""; NSString *productVendor = self.vendor? [self.vendor lowercaseString] : @"";
BOOL isMoncler = [productVendor isEqualToString:@"moncler"]; BOOL isMoncler = [productVendor isEqualToString:@"moncler"];
if(isMoncler && self.productId){ if(isMoncler && self.productId){
//这个api获取的商品只能用于展示,不能出售,商品詳情的admin api与商品列表的admin api字段不同,转化为BuyProduct后,一些字段可能是缺失的。
[self requestAdminProductDetail]; [self requestAdminProductDetail];
}else{ }else{
[self requestProductDetail]; [self requestProductDetail];
...@@ -542,6 +543,7 @@ ...@@ -542,6 +543,7 @@
} }
} }
//这个api获取的商品只能用于展示,不能出售,商品詳情的admin api与商品列表的admin api字段不同,转化为BuyProduct后,一些字段可能是缺失的。
-(void)requestAdminProductDetail{ -(void)requestAdminProductDetail{
NSNumber *productId = self.product?self.product.identifier:self.productId; NSNumber *productId = self.product?self.product.identifier:self.productId;
if(!productId){ if(!productId){
...@@ -549,34 +551,39 @@ ...@@ -549,34 +551,39 @@
} }
[self showLoading]; [self showLoading];
__weak KWMNewProductVC *weakSelf = self; __weak KWMNewProductVC *weakSelf = self;
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
[weakSelf hideLoading]; NSString *apiPath = [[NSString alloc] initWithFormat:@"https://%@/admin/products/%@.json",Shopify_SHOP_DOMAIN,productId.stringValue];
[weakSelf showError:error]; AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];
}; [sessionManager.requestSerializer setValue:@"Basic YWRlMDgzZGU2YWJjYjljYjk0ODY5NDg1ZWUwZGQyNmE6MWYyYzVlM2I4N2YyZGJlMTkwZGEzMzU4NmMyMmY3YzQ=" forHTTPHeaderField:@"Authorization"];
void(^success)(NSURLSessionDataTask *,KWMProductResult *) = ^(NSURLSessionDataTask *task,KWMProductResult *result){ [sessionManager GET:apiPath parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[weakSelf hideLoading]; [weakSelf hideLoading];
BUYProduct *product = nil; BUYProduct *product = nil;
if(result && result.productDict){ if(responseObject){
NSDictionary *dataDictionary = responseObject[@"product"];
if(dataDictionary){
@try{ @try{
BUYModelManager *modelManager = [[BUYModelManager alloc]init]; BUYModelManager *modelManager = [[BUYModelManager alloc]init];
product = (BUYProduct *)[modelManager buy_objectWithEntityName:[BUYProduct entityName] JSONDictionary:result.productDict]; product = (BUYProduct *)[modelManager buy_objectWithEntityName:[BUYProduct entityName] JSONDictionary:dataDictionary];
} }
@catch (NSException *exception){ @catch (NSException *exception){
NSLog( @"exception Name: %@", exception.name); NSLog( @"exception Name: %@", exception.name);
NSLog( @"exception Reason: %@", exception.reason ); NSLog( @"exception Reason: %@", exception.reason );
} }
} }
}
if(product){ if(product){
weakSelf.product = product; weakSelf.product = product;
weakSelf.productId = product.identifier; //weakSelf.productId = product.identifier;
[weakSelf initBottomViewHidden]; [weakSelf initBottomViewHidden];
weakSelf.midDetailView.product = product; weakSelf.midDetailView.product = product;
[weakSelf.detailView1 setData:product]; [weakSelf.detailView1 setData:product];
[weakSelf requestBrandProducts:1]; [weakSelf requestBrandProducts:1];
[weakSelf requestCategoryProducts:1]; [weakSelf requestCategoryProducts:1];
} }
}; } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self.api getAdminProduct:nil productId:productId success:success failure:failure]; [weakSelf hideLoading];
[weakSelf 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