Commit 7edd04d3 by lee

deeplink

parent 6c19ff05
...@@ -19,14 +19,18 @@ ...@@ -19,14 +19,18 @@
[routes addRoute:@"/collections/*" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) { [routes addRoute:@"/collections/*" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
NSArray *tags = parameters[JLRouteWildcardComponentsKey]; NSArray *tags = parameters[JLRouteWildcardComponentsKey];
NSLog(@"trace tags %@",[tags componentsJoinedByString:@","]); NSLog(@"trace tags %@",[tags componentsJoinedByString:@","]);
KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"];
selectedGoodsVC.ctags = tags;
[[AppDelegate mainViewController].selectedViewController pushViewController:selectedGoodsVC animated:YES];
return YES; return YES;
}]; }];
[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"]; 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"];
// [[AppDelegate mainViewController].selectedViewController.navigationController pushViewController:productDetailVC animated:YES]; NSLog(@"%@",[AppDelegate mainViewController].selectedViewController);
[[AppDelegate mainViewController].selectedViewController pushViewController:productDetailVC animated:YES];
return YES; return YES;
}]; }];
} }
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
[self initRecommendProduct]; [self initRecommendProduct];
// [self initShopCartCount]; // [self initShopCartCount];
//刷新product,如果是缓存的product,因为没有字典,所以会发生错误,需要重新请求一个有字典的product //刷新product,如果是缓存的product,因为没有字典,所以会发生错误,需要重新请求一个有字典的product
if(!self.handle || (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]; [self getProductBy:nil product:self.product];
} }
NSArray *types = @[@"baby",@"girls",@"boys",@"shoes",@"newborn"]; NSArray *types = @[@"baby",@"girls",@"boys",@"shoes",@"newborn"];
...@@ -449,6 +449,7 @@ ...@@ -449,6 +449,7 @@
[self hideLoading]; [self hideLoading];
if (product != nil && error == nil) { if (product != nil && error == nil) {
self.product = product; self.product = product;
[self.productDetailView setData:product];
if(productId){ if(productId){
[self kwm_clickCollectionCell:product]; [self kwm_clickCollectionCell:product];
} }
...@@ -464,5 +465,4 @@ ...@@ -464,5 +465,4 @@
} }
} }
@end @end
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
@property (nonatomic) BOOL isLoading; @property (nonatomic) BOOL isLoading;
/**
* deeplink tags
*/
@property (strong, nonatomic) NSArray *ctags; @property (strong, nonatomic) NSArray *ctags;
@property (nonatomic) KWMProductType *productType; @property (nonatomic) KWMProductType *productType;
......
...@@ -52,6 +52,9 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -52,6 +52,9 @@ static NSString *idStr = @"KWMBrandCaramelCell";
self.hasNextPage = NO; self.hasNextPage = NO;
self.collectionSort = BUYCollectionSortCreatedDescending; self.collectionSort = BUYCollectionSortCreatedDescending;
if (self.ctags) {
self.title = self.ctags.firstObject;
}else
if(self.productType != nil){ if(self.productType != nil){
//初始化双行标题栏 //初始化双行标题栏
NSString *mTitle; NSString *mTitle;
...@@ -239,6 +242,38 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -239,6 +242,38 @@ static NSString *idStr = @"KWMBrandCaramelCell";
} }
- (void)requestProductList{ - (void)requestProductList{
__weak KWMSelectedGoodsVC *weakSelf = self;
NSInteger tagetPage = self.currentPage.integerValue + 1;
void(^completion)(NSArray<BUYProduct *> *,NSUInteger,BOOL,NSError*) = ^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
[weakSelf hideLoading];
if(tagetPage == 1){
if(!products || products.count == 0){
self.vNoData.hidden = NO;
[weakSelf.dataList removeAllObjects];
[weakSelf.tbvSelectedGoods reloadData];
return;
}
}
weakSelf.isLoading = NO;
if (error == nil && products) {
self.vNoData.hidden = YES;
weakSelf.hasNextPage = !reachedEnd;
[weakSelf appendDataList:products setPage:page];
}
else {
[self showError:error];
NSLog(@"Error fetching products: %@", error);
}
};
if (self.ctags) {
[self.client getCollectionByHandle:self.ctags.lastObject completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
[self.client getProductsPage:tagetPage inCollection:collection.identifier withTags:self.ctags sortOrder:self.filterView.selectedSort completion:completion];
}];
// [self.client getProductsPage:tagetPage inCollection:nil withTags:self.ctags sortOrder:self.filterView.selectedSort completion:completion];
return;
}
NSNumber *collectionId; NSNumber *collectionId;
if(self.collection!=nil){ if(self.collection!=nil){
collectionId = self.collection.identifier; collectionId = self.collection.identifier;
...@@ -269,36 +304,9 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -269,36 +304,9 @@ static NSString *idStr = @"KWMBrandCaramelCell";
} }
self.isLoading = YES; self.isLoading = YES;
__weak KWMSelectedGoodsVC *weakSelf = self;
NSInteger tagetPage = self.currentPage.integerValue + 1;
[self.client getProductsPage:tagetPage inCollection:collectionId withTags:tags sortOrder:collectionSort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){ [self.client getProductsPage:tagetPage inCollection:collectionId withTags:tags sortOrder:collectionSort completion:completion];
[weakSelf hideLoading];
if(tagetPage == 1){
if(tags.count == 1){
[weakSelf.userDao saveCollectionCache:products collectionId:collectionId tags:tags];
}
if(!products || products.count == 0){
self.vNoData.hidden = NO;
[weakSelf.dataList removeAllObjects];
[weakSelf.tbvSelectedGoods reloadData];
return;
}
}
weakSelf.isLoading = NO;
if (error == nil && products) {
self.vNoData.hidden = YES;
weakSelf.hasNextPage = !reachedEnd;
[weakSelf appendDataList:products setPage:page];
}
else {
[self showError:error];
NSLog(@"Error fetching products: %@", error);
}
}];
} }
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
#define User_Pay_KEY @"bd3f58f5cd3d7a217ac8c8e655ab52f8" #define User_Pay_KEY @"bd3f58f5cd3d7a217ac8c8e655ab52f8"
#if DEBUG && 1 #if DEBUG && 0
//测试 //测试
#define TestModel @"YES" #define TestModel @"YES"
......
...@@ -46,6 +46,14 @@ ...@@ -46,6 +46,14 @@
<string>cemarose</string> <string>cemarose</string>
</array> </array>
</dict> </dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>I</string>
</array>
</dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2017070509</string> <string>2017070509</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