Commit 38be4224 by houweibin

换成商品列表的admin api,以获取完整的BuyProduct数据

parent bb7f62fa
...@@ -404,7 +404,7 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -404,7 +404,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
//初始化排序及筛选tag //初始化排序及筛选tag
NSString *apiPath = [[NSString alloc] initWithFormat:@"https://%@/admin/product_listings.json",Shopify_SHOP_DOMAIN]; NSString *apiPath = [[NSString alloc] initWithFormat:@"https://%@/admin/product_listings.json",Shopify_SHOP_DOMAIN];
AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager]; AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];
[sessionManager.requestSerializer setValue:@"Basic YWRlMDgzZGU2YWJjYjljYjk0ODY5NDg1ZWUwZGQyNmE6MWYyYzVlM2I4N2YyZGJlMTkwZGEzMzU4NmMyMmY3YzQ=" forHTTPHeaderField:@"Authorization"]; [sessionManager.requestSerializer setValue:Moncler_Vendor_Auth forHTTPHeaderField:@"Authorization"];
[sessionManager GET:apiPath parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { [sessionManager GET:apiPath parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSArray *result = nil; NSArray *result = nil;
[weakSelf hideLoading]; [weakSelf hideLoading];
......
...@@ -118,7 +118,6 @@ ...@@ -118,7 +118,6 @@
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];
...@@ -543,7 +542,6 @@ ...@@ -543,7 +542,6 @@
} }
} }
//这个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){
...@@ -552,18 +550,24 @@ ...@@ -552,18 +550,24 @@
[self showLoading]; [self showLoading];
__weak KWMNewProductVC *weakSelf = self; __weak KWMNewProductVC *weakSelf = self;
NSString *apiPath = [[NSString alloc] initWithFormat:@"https://%@/admin/products/%@.json",Shopify_SHOP_DOMAIN,productId.stringValue]; NSString *apiPath = [[NSString alloc] initWithFormat:@"https://%@/admin/product_listings.json",Shopify_SHOP_DOMAIN];
AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager]; AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];
[sessionManager.requestSerializer setValue:@"Basic YWRlMDgzZGU2YWJjYjljYjk0ODY5NDg1ZWUwZGQyNmE6MWYyYzVlM2I4N2YyZGJlMTkwZGEzMzU4NmMyMmY3YzQ=" forHTTPHeaderField:@"Authorization"]; [sessionManager.requestSerializer setValue:Moncler_Vendor_Auth forHTTPHeaderField:@"Authorization"];
[sessionManager GET:apiPath parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSMutableDictionary *params = @{
@"product_ids" : productId
}.mutableCopy;
[sessionManager GET:apiPath parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[weakSelf hideLoading]; [weakSelf hideLoading];
BUYProduct *product = nil; BUYProduct *product = nil;
if(responseObject){ if(responseObject){
NSDictionary *dataDictionary = responseObject[@"product"]; id jsonDictionary = responseObject[@"product_listings"];
if(dataDictionary){ if(jsonDictionary){
@try{ @try{
BUYModelManager *modelManager = [[BUYModelManager alloc]init]; NSArray *array = (NSArray *)jsonDictionary;
product = (BUYProduct *)[modelManager buy_objectWithEntityName:[BUYProduct entityName] JSONDictionary:dataDictionary]; if(array && array.count > 0){
BUYModelManager *modelManager = [[BUYModelManager alloc]init];
product = (BUYProduct *)[modelManager buy_objectWithEntityName:[BUYProduct entityName] JSONDictionary:array.firstObject];
}
} }
@catch (NSException *exception){ @catch (NSException *exception){
NSLog( @"exception Name: %@", exception.name); NSLog( @"exception Name: %@", exception.name);
...@@ -573,7 +577,7 @@ ...@@ -573,7 +577,7 @@
} }
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];
......
...@@ -60,6 +60,8 @@ ...@@ -60,6 +60,8 @@
#define Order_API_Auth @"Basic YzJmNmZhZTk3NzQxZWE2ZGI0Y2FkN2FlOGY3MGZlZjM==" #define Order_API_Auth @"Basic YzJmNmZhZTk3NzQxZWE2ZGI0Y2FkN2FlOGY3MGZlZjM=="
#define Moncler_Vendor_Auth @"Basic YWRlMDgzZGU2YWJjYjljYjk0ODY5NDg1ZWUwZGQyNmE6MWYyYzVlM2I4N2YyZGJlMTkwZGEzMzU4NmMyMmY3YzQ="
//正式的微信key //正式的微信key
#define WechatAppKey @"wx355a497b2a2dd6d5" #define WechatAppKey @"wx355a497b2a2dd6d5"
......
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