Commit 827cd36c by houweibin
parents 8d5eb243 23f1b4a7
......@@ -12,6 +12,7 @@
#import "KWMProductDetailVC.h"
#import "KWMSelectedGoodsVC.h"
#import "KWMBlogDetailVC.h"
#import "KWMNewProductVC.h"
@implementation AppDelegate (Deeplink)
......@@ -30,11 +31,12 @@
}];
[routes addRoute:@"/products/:id" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
NSLog(@"product id %@",parameters[@"id"]);
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC*)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"];
KWMNewProductVC *vc = [KWMNewProductVC getNewInstance];
// KWMProductDetailVC *productDetailVC = (KWMProductDetailVC*)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"];
// productDetailVC.product = brandCell.leftProduct;
productDetailVC.handle = parameters[@"id"];
NSLog(@"%@",[AppDelegate mainViewController].selectedViewController);
[[AppDelegate mainViewController].selectedViewController pushViewController:productDetailVC animated:YES];
// productDetailVC.handle = parameters[@"id"];
// NSLog(@"%@",[AppDelegate mainViewController].selectedViewController);
[[AppDelegate mainViewController].selectedViewController pushViewController:vc animated:YES];
return YES;
}];
[routes addRoute:@"/blogs/:blog/:handle" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
......
......@@ -28,8 +28,10 @@
@property (nonatomic) CGFloat keyboardHeight;
+ (NSString *)kwmTag;
+ (NSString *)kwmBoard;
+ (KWMBaseVC *)findControllerBy:(NSString *)controllerId
fromStoryboard:(NSString *)storyboardName;
+ (instancetype) getNewInstance;
- (void(^)(NSURLSessionDataTask *, NSError *))defaultFailure;
- (void)popDelay;
......
......@@ -36,6 +36,11 @@
return NSStringFromClass([self class]);
}
+ (NSString *)kwmBoard {
[self doesNotRecognizeSelector:@selector(kwmBoard)];
return nil;
}
+ (KWMBaseVC *)findControllerBy:(NSString *)controllerId
fromStoryboard:(NSString *)storyboardName {
UIStoryboard *myStoryboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
......@@ -43,6 +48,10 @@
return baseController;
}
+ (instancetype) getNewInstance {
return [self findControllerBy:[self kwmTag] fromStoryboard:[self kwmBoard]];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.extendedLayoutIncludesOpaqueBars = YES;
......
......@@ -336,6 +336,24 @@ typedef enum{
}];
}
//- (void) requestProductWithId:(NSNumber *) identifier tags:(NSArray *) tags valueKeyPath:(NSString *) valueKeyPath home:(BOOL) isHome page:(NSInteger) cpage{
// [self showLoading];
// [self.client getProductsPage:cpage inCollection:identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) {
// [self hideLoading];
//
// if (!error) {
// [self setValue:products forKeyPath:valueKeyPath];
// [self.cvHome reloadData];
// }else{
// [self showError:error];
// }
// if (isHome) {
// self.page = self.page + 1;
// products.count ? [self.cvHome.mj_footer endRefreshing] : [self.cvHome.mj_footer endRefreshingWithNoMoreData];
// }
// }];
//}
- (void) loadHomeData {
[self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"];
[self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) {
......@@ -348,7 +366,6 @@ typedef enum{
- (void)setHomeData:(KWMHomeData *)homeData {
_homeData = homeData;
[homeData.ad_banner[0] setUrl:@"https://www.cemarose.com/blogs/news/article-1"];
self.adHeader.adArray = self.homeData.ad_banner;
// self.recommendHeader.productArray = self.productArray;
// self.clothingSetsHeader.productArray = self.productArray;
......
......@@ -18,6 +18,8 @@
@property(nonatomic) BUYProduct *product;
@property(nonatomic) NSString *handle;
@property(nonatomic) NSNumber *productId;
@end
......@@ -59,6 +59,10 @@
@implementation KWMNewProductVC
+ (NSString *)kwmBoard {
return @"NewProduct";
}
- (void)viewDidLoad {
[super viewDidLoad];
......@@ -333,12 +337,12 @@
#pragma mark - API BUYClient+Storefront
-(void)requestProductDetail{
if(!self.productId && !self.product){
if(!(self.productId || self.product || self.handle)){
return;
}
[self showLoading];
__weak KWMNewProductVC *weakSelf = self;
[self.client getProductById:self.productId?:self.product.identifier completion:^(BUYProduct * _Nullable product, NSError * _Nullable error) {
void(^completion)(BUYProduct*,NSError*) = ^(BUYProduct * _Nullable product, NSError * _Nullable error) {
[weakSelf hideLoading];
if(error){
[weakSelf showError:error];
......@@ -350,7 +354,12 @@
[self requestBrandProducts:1];
[self requestCategoryProducts:1];
}
}];
};
if (self.handle) {
[self.client getProductByHandle:self.handle completion:completion];
}else{
[self.client getProductById:self.productId?:self.product.identifier completion:completion];
}
}
......
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