Commit 5ae12c6c by lee

deeplink

parent 73874a8f
......@@ -16,7 +16,7 @@
- (void)toLogin;
- (void)toGuide;
+ (UITabBarController *) mainViewController;
@end
......@@ -83,6 +83,11 @@
return YES;
}
+ (UIViewController *)mainViewController {
UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
return vc;
}
//去到引导界面
- (void)toGuide{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Guide" bundle:nil];
......
......@@ -8,6 +8,9 @@
#import "AppDelegate+Deeplink.h"
#import <JLRoutes/JLRoutes.h>
#import "AppDelegate.h"
#import "KWMProductDetailVC.h"
#import "KWMSelectedGoodsVC.h"
@implementation AppDelegate (Deeplink)
......@@ -20,6 +23,10 @@
}];
[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"];
// productDetailVC.product = brandCell.leftProduct;
productDetailVC.handle = parameters[@"id"];
[[AppDelegate mainViewController].selectedViewController.navigationController pushViewController:productDetailVC animated:YES];
return YES;
}];
}
......
......@@ -14,4 +14,9 @@
@property (nonatomic) NSNumber *productId;
/**
* SKU 人为定义的SKU
*/
@property (nonatomic) NSString *handle;
@end
......@@ -64,7 +64,7 @@
[self initRecommendProduct];
// [self initShopCartCount];
//刷新product,如果是缓存的product,因为没有字典,所以会发生错误,需要重新请求一个有字典的product
if(self.product && self.product.identifier && !self.product.JSONDictionary){
if(!self.handle || (self.product && self.product.identifier && !self.product.JSONDictionary)){
[self getProductBy:nil product:self.product];
}
NSArray *types = @[@"baby",@"girls",@"boys",@"shoes",@"newborn"];
......@@ -441,11 +441,11 @@
//查找商品API
- (void)getProductBy:(NSNumber *)productId product:(BUYProduct *)product{
if(productId == nil && product == nil){
if(productId == nil && product == nil && !self.handle){
return;
}
[self showLoading];
[self.client getProductById:productId?productId:product.identifier completion:^(BUYProduct * _Nullable product, NSError * _Nullable error) {
void(^completion)(BUYProduct *, NSError *) = ^(BUYProduct * _Nullable product, NSError * _Nullable error) {
[self hideLoading];
if (product != nil && error == nil) {
self.product = product;
......@@ -456,7 +456,12 @@
self.product = nil;
[self showError:error];
}
}];
};
if (self.handle) {
[self.client getProductByHandle:self.handle completion:completion];
}else{
[self.client getProductById:productId?productId:product.identifier completion:completion];
}
}
......
......@@ -32,6 +32,8 @@
@property (nonatomic) BOOL isLoading;
@property (strong, nonatomic) NSArray *ctags;
@property (nonatomic) KWMProductType *productType;
@property (nonatomic) BUYCollectionSort collectionSort;
......
......@@ -10,7 +10,7 @@
#import <JRSwizzle/JRSwizzle.h>
@implementation UIViewController (AppearLog)
#if DEBUG
#if DEBUG || 1
+ (void)load
{
[self jr_swizzleMethod:@selector(viewWillAppear:) withMethod:@selector(logViewWillAppear:) error:nil];
......
......@@ -48,7 +48,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2017060917</string>
<string>2017063017</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
......
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