Commit bb7f62fa by houweibin

调整

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