Commit 38be4224 by houweibin

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

parent bb7f62fa
......@@ -404,7 +404,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
//初始化排序及筛选tag
NSString *apiPath = [[NSString alloc] initWithFormat:@"https://%@/admin/product_listings.json",Shopify_SHOP_DOMAIN];
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) {
NSArray *result = nil;
[weakSelf hideLoading];
......
......@@ -118,7 +118,6 @@
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];
......@@ -543,7 +542,6 @@
}
}
//这个api获取的商品只能用于展示,不能出售,商品詳情的admin api与商品列表的admin api字段不同,转化为BuyProduct后,一些字段可能是缺失的。
-(void)requestAdminProductDetail{
NSNumber *productId = self.product?self.product.identifier:self.productId;
if(!productId){
......@@ -552,18 +550,24 @@
[self showLoading];
__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];
[sessionManager.requestSerializer setValue:@"Basic YWRlMDgzZGU2YWJjYjljYjk0ODY5NDg1ZWUwZGQyNmE6MWYyYzVlM2I4N2YyZGJlMTkwZGEzMzU4NmMyMmY3YzQ=" forHTTPHeaderField:@"Authorization"];
[sessionManager GET:apiPath parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[sessionManager.requestSerializer setValue:Moncler_Vendor_Auth forHTTPHeaderField:@"Authorization"];
NSMutableDictionary *params = @{
@"product_ids" : productId
}.mutableCopy;
[sessionManager GET:apiPath parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[weakSelf hideLoading];
BUYProduct *product = nil;
if(responseObject){
NSDictionary *dataDictionary = responseObject[@"product"];
if(dataDictionary){
id jsonDictionary = responseObject[@"product_listings"];
if(jsonDictionary){
@try{
NSArray *array = (NSArray *)jsonDictionary;
if(array && array.count > 0){
BUYModelManager *modelManager = [[BUYModelManager alloc]init];
product = (BUYProduct *)[modelManager buy_objectWithEntityName:[BUYProduct entityName] JSONDictionary:dataDictionary];
product = (BUYProduct *)[modelManager buy_objectWithEntityName:[BUYProduct entityName] JSONDictionary:array.firstObject];
}
}
@catch (NSException *exception){
NSLog( @"exception Name: %@", exception.name);
......@@ -573,7 +577,7 @@
}
if(product){
weakSelf.product = product;
//weakSelf.productId = product.identifier;
weakSelf.productId = product.identifier;
[weakSelf initBottomViewHidden];
weakSelf.midDetailView.product = product;
[weakSelf.detailView1 setData:product];
......
......@@ -60,6 +60,8 @@
#define Order_API_Auth @"Basic YzJmNmZhZTk3NzQxZWE2ZGI0Y2FkN2FlOGY3MGZlZjM=="
#define Moncler_Vendor_Auth @"Basic YWRlMDgzZGU2YWJjYjljYjk0ODY5NDg1ZWUwZGQyNmE6MWYyYzVlM2I4N2YyZGJlMTkwZGEzMzU4NmMyMmY3YzQ="
//正式的微信key
#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