Commit 23f1b4a7 by lee

u

parent 050f30f1
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#import "KWMProductDetailVC.h" #import "KWMProductDetailVC.h"
#import "KWMSelectedGoodsVC.h" #import "KWMSelectedGoodsVC.h"
#import "KWMBlogDetailVC.h" #import "KWMBlogDetailVC.h"
#import "KWMNewProductVC.h"
@implementation AppDelegate (Deeplink) @implementation AppDelegate (Deeplink)
...@@ -30,11 +31,12 @@ ...@@ -30,11 +31,12 @@
}]; }];
[routes addRoute:@"/products/:id" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) { [routes addRoute:@"/products/:id" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
NSLog(@"product id %@",parameters[@"id"]); 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.product = brandCell.leftProduct;
productDetailVC.handle = parameters[@"id"]; // productDetailVC.handle = parameters[@"id"];
NSLog(@"%@",[AppDelegate mainViewController].selectedViewController); // NSLog(@"%@",[AppDelegate mainViewController].selectedViewController);
[[AppDelegate mainViewController].selectedViewController pushViewController:productDetailVC animated:YES]; [[AppDelegate mainViewController].selectedViewController pushViewController:vc animated:YES];
return YES; return YES;
}]; }];
[routes addRoute:@"/blogs/:blog/:handle" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) { [routes addRoute:@"/blogs/:blog/:handle" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
......
...@@ -28,8 +28,10 @@ ...@@ -28,8 +28,10 @@
@property (nonatomic) CGFloat keyboardHeight; @property (nonatomic) CGFloat keyboardHeight;
+ (NSString *)kwmTag; + (NSString *)kwmTag;
+ (NSString *)kwmBoard;
+ (KWMBaseVC *)findControllerBy:(NSString *)controllerId + (KWMBaseVC *)findControllerBy:(NSString *)controllerId
fromStoryboard:(NSString *)storyboardName; fromStoryboard:(NSString *)storyboardName;
+ (instancetype) getNewInstance;
- (void(^)(NSURLSessionDataTask *, NSError *))defaultFailure; - (void(^)(NSURLSessionDataTask *, NSError *))defaultFailure;
- (void)popDelay; - (void)popDelay;
......
...@@ -34,6 +34,11 @@ ...@@ -34,6 +34,11 @@
return NSStringFromClass([self class]); return NSStringFromClass([self class]);
} }
+ (NSString *)kwmBoard {
[self doesNotRecognizeSelector:@selector(kwmBoard)];
return nil;
}
+ (KWMBaseVC *)findControllerBy:(NSString *)controllerId + (KWMBaseVC *)findControllerBy:(NSString *)controllerId
fromStoryboard:(NSString *)storyboardName { fromStoryboard:(NSString *)storyboardName {
UIStoryboard *myStoryboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil]; UIStoryboard *myStoryboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
...@@ -41,6 +46,10 @@ ...@@ -41,6 +46,10 @@
return baseController; return baseController;
} }
+ (instancetype) getNewInstance {
return [self findControllerBy:[self kwmTag] fromStoryboard:[self kwmBoard]];
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.extendedLayoutIncludesOpaqueBars = YES; self.extendedLayoutIncludesOpaqueBars = YES;
......
...@@ -333,6 +333,24 @@ typedef enum{ ...@@ -333,6 +333,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 { - (void) loadHomeData {
[self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"]; [self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"];
[self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) { [self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) {
...@@ -345,7 +363,6 @@ typedef enum{ ...@@ -345,7 +363,6 @@ typedef enum{
- (void)setHomeData:(KWMHomeData *)homeData { - (void)setHomeData:(KWMHomeData *)homeData {
_homeData = homeData; _homeData = homeData;
[homeData.ad_banner[0] setUrl:@"https://www.cemarose.com/blogs/news/article-1"];
self.adHeader.adArray = self.homeData.ad_banner; self.adHeader.adArray = self.homeData.ad_banner;
// self.recommendHeader.productArray = self.productArray; // self.recommendHeader.productArray = self.productArray;
// self.clothingSetsHeader.productArray = self.productArray; // self.clothingSetsHeader.productArray = self.productArray;
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
@property(nonatomic) BUYProduct *product; @property(nonatomic) BUYProduct *product;
@property(nonatomic) NSString *handle;
@property(nonatomic) NSNumber *productId; @property(nonatomic) NSNumber *productId;
@end @end
...@@ -59,6 +59,10 @@ ...@@ -59,6 +59,10 @@
@implementation KWMNewProductVC @implementation KWMNewProductVC
+ (NSString *)kwmBoard {
return @"NewProduct";
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
...@@ -333,12 +337,12 @@ ...@@ -333,12 +337,12 @@
#pragma mark - API BUYClient+Storefront #pragma mark - API BUYClient+Storefront
-(void)requestProductDetail{ -(void)requestProductDetail{
if(!self.productId && !self.product){ if(!(self.productId || self.product || self.handle)){
return; return;
} }
[self showLoading]; [self showLoading];
__weak KWMNewProductVC *weakSelf = self; __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]; [weakSelf hideLoading];
if(error){ if(error){
[weakSelf showError:error]; [weakSelf showError:error];
...@@ -350,7 +354,12 @@ ...@@ -350,7 +354,12 @@
[self requestBrandProducts:1]; [self requestBrandProducts:1];
[self requestCategoryProducts: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