Commit 737cd3ae by lee

u'

parent d148bf5c
...@@ -57,7 +57,8 @@ ...@@ -57,7 +57,8 @@
//去掉返回按钮的文字 //去掉返回按钮的文字
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-UI_SCREEN_WIDTH, -UI_SCREEN_HEITHT) forBarMetrics:UIBarMetricsDefault]; // [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-UI_SCREEN_WIDTH, -UI_SCREEN_HEITHT) forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-200, 0) forBarMetrics:UIBarMetricsDefault];
//修改系统的backbutton的图片 //修改系统的backbutton的图片
[UINavigationBar appearance].backIndicatorTransitionMaskImage = [UIImage imageNamed:@"btn_nav_back"]; [UINavigationBar appearance].backIndicatorTransitionMaskImage = [UIImage imageNamed:@"btn_nav_back"];
[UINavigationBar appearance].backIndicatorImage = [UIImage imageNamed:@"btn_nav_back"]; [UINavigationBar appearance].backIndicatorImage = [UIImage imageNamed:@"btn_nav_back"];
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<constraint firstAttribute="height" constant="24" id="x1H-Jw-5lD"/> <constraint firstAttribute="height" constant="24" id="x1H-Jw-5lD"/>
</constraints> </constraints>
</imageView> </imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="v 1.5.7" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ytF-B2-drm"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="v 1.5.8" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ytF-B2-drm">
<rect key="frame" x="168" y="631" width="39" height="16"/> <rect key="frame" x="168" y="631" width="39" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/> <fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
......
...@@ -12,4 +12,6 @@ ...@@ -12,4 +12,6 @@
@property (nonatomic) id<Optional> product; @property (nonatomic) id<Optional> product;
@property (nonatomic) NSArray<Optional> *products;
@end @end
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
if(dataDictionary){ if(dataDictionary){
self.product = [self buildData:modelClass jsonDictionary:dataDictionary]; self.product = [self buildData:modelClass jsonDictionary:dataDictionary];
} }
NSMutableArray *datas = [NSMutableArray new];
for (id d in dict[@"products"]) {
[datas addObject:[self buildData:modelClass jsonDictionary:d]];
}
self.products = datas;
} }
return self; return self;
......
...@@ -241,6 +241,9 @@ ...@@ -241,6 +241,9 @@
success:(void(^)(NSURLSessionDataTask *task,KWMProductResult *result))success success:(void(^)(NSURLSessionDataTask *task,KWMProductResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure; failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
- (NSURLSessionDataTask *) getAdminProductsById:(NSArray *) ids
success:(void(^)(NSURLSessionDataTask *task,KWMProductResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
/** /**
* 取消订单api * 取消订单api
* amount 退款金额 (default: false)(十进制:21.20)If set, Shopify will attempt to void/refund the payment depending on the status. * amount 退款金额 (default: false)(十进制:21.20)If set, Shopify will attempt to void/refund the payment depending on the status.
......
...@@ -776,6 +776,11 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -776,6 +776,11 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
failure:failure]; failure:failure];
} }
- (NSURLSessionDataTask *)getAdminProductsById:(NSArray *)ids success:(void (^)(NSURLSessionDataTask *, KWMProductResult *))success failure:(void (^)(NSURLSessionDataTask *, NSError *))failure {
NSString *apiPath = [[NSString alloc] initWithFormat:@"https://%@/admin/products.json",Shopify_SHOP_DOMAIN];
return [self startSessionTask:KWMHTTPMethodGET apiPath:apiPath parameters:@{@"ids":[ids componentsJoinedByString:@","]} result:[KWMProductResult class] model:[KWMProduct class] success:success failure:failure];
}
/** /**
* 取消订单api * 取消订单api
* @param amount 退款金额 (default: false)(十进制:21.20)If set, Shopify will attempt to void/refund the payment depending on the status. * @param amount 退款金额 (default: false)(十进制:21.20)If set, Shopify will attempt to void/refund the payment depending on the status.
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#import "KWMNewProductVC.h" #import "KWMNewProductVC.h"
#import "KWMBrandCaramelVC.h" #import "KWMBrandCaramelVC.h"
static NSMutableDictionary *controllerCache = nil;
@implementation AppDelegate (Deeplink) @implementation AppDelegate (Deeplink)
- (UINavigationController *) navigationController { - (UINavigationController *) navigationController {
...@@ -29,25 +31,36 @@ ...@@ -29,25 +31,36 @@
// JLRoutes *routes = [JLRoutes routesForScheme:@"cemarose"]; // JLRoutes *routes = [JLRoutes routesForScheme:@"cemarose"];
JLRoutes *routes = [JLRoutes globalRoutes]; JLRoutes *routes = [JLRoutes globalRoutes];
[routes addRoute:@"/collections/:handle/*" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) { [routes addRoute:@"/collections/:handle/*" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
if (!controllerCache) {
controllerCache = [NSMutableDictionary new];
}
NSString *url = parameters[JLRouteURLKey];
if ([controllerCache objectForKey:url]) {
id vc = controllerCache[url];
[self pushViewController:vc];
return YES;
}
NSArray *tags = parameters[JLRouteWildcardComponentsKey]; NSArray *tags = parameters[JLRouteWildcardComponentsKey];
NSString *handle = parameters[@"handle"]; NSString *handle = parameters[@"handle"];
tags = tags.count > 0 ? [tags[0] componentsSeparatedByString:@"+"] : nil; tags = tags.count > 0 ? [tags[0] componentsSeparatedByString:@"+"] : nil;
// NSArray *tags = [parameters[JLRouteWildcardComponentsKey] componentsSeparatedByString:@"+"]; // NSArray *tags = [parameters[JLRouteWildcardComponentsKey] componentsSeparatedByString:@"+"];
NSLog(@"trace tags %@",[tags componentsJoinedByString:@","]); NSLog(@"trace tags %@",[tags componentsJoinedByString:@","]);
NSArray *brands = @[@"amelie-wang",@"babywalker",@"beau-loves",@"billieblush",@"billybandit",@"bonpoint",@"burberry",@"caramel",@"chloe",@"collegien",@"dolce-gabbana",@"emile-et-ida",@"fendi",@"gucci",@"hucklebones",@"il-gufo",@"indikidual",@"karl-lagerfeld-kids",@"kenzo",@"lanvin",@"little-marc-jacobs",@"loud-apparel",@"louis-louise",@"louise-misha",@"marie-chantal",@"marni",@"mini-melissa",@"mini-rodini",@"mischka-aoki",@"moncler",@"moschino",@"msgm",@"nailmatic",@"nana-huchy",@"noukies",@"oeuf",@"patachou",@"paul-smith",@"pepe",@"sons-daughters-eyewear",@"stella-mccartney-kids",@"story-loris",@"tartine-et-chocolat",@"the-animals-observatory",@"tiny-cottons",@"veja",@"young-versace",@"zadig-voltaire"]; NSArray *brands = @[@"amelie-wang",@"babywalker",@"beau-loves",@"billieblush",@"billybandit",@"bonpoint",@"burberry",@"caramel",@"chloe",@"collegien",@"dolce-gabbana",@"emile-et-ida",@"fendi",@"gucci",@"hucklebones",@"il-gufo",@"indikidual",@"karl-lagerfeld-kids",@"kenzo",@"lanvin",@"little-marc-jacobs",@"loud-apparel",@"louis-louise",@"louise-misha",@"marie-chantal",@"marni",@"mini-melissa",@"mini-rodini",@"mischka-aoki",@"moncler",@"moschino",@"msgm",@"nailmatic",@"nana-huchy",@"noukies",@"oeuf",@"patachou",@"paul-smith",@"pepe",@"sons-daughters-eyewear",@"stella-mccartney-kids",@"story-loris",@"tartine-et-chocolat",@"the-animals-observatory",@"tiny-cottons",@"veja",@"young-versace",@"zadig-voltaire"];
NSDictionary *brandNames = @{@"amelie-wang":@"Amelie Wang",@"babywalker":@"Babywalker",@"beau-loves":@"Beau Loves",@"billieblush":@"Billieblush",@"billybandit":@"Billybandit",@"bonpoint":@"Bonpoint",@"burberry":@"Burberry",@"caramel":@"Caramel",@"chloe":@"Chloé",@"dolce-gabbana":@"Dolce & Gabbana",@"emile-et-ida":@"Emile et Ida",@"fendi":@"Fendi",@"givenchy":@"Givenchy",@"gucci":@"Gucci",@"hucklebones":@"Hucklebones",@"il-gufo":@"Il Gufo",@"indikidual":@"Indikidual",@"karl-lagerfeld-kids":@"Karl Lagerfeld Kids",@"kenzo":@"Kenzo",@"lanvin":@"Lanvin",@"little-marc-jacobs":@"Little Marc Jacobs",@"loud-apparel":@"Loud Apparel",@"louis-louise":@"Louis Louise",@"louise-misha":@"Louise Misha",@"marie-chantal":@"Marie-Chantal",@"marni":@"Marni",@"mini-melissa":@"Mini Melissa",@"mini-rodini":@"Mini Rodini",@"mischka-aoki":@"Mischka Aoki",@"moncler":@"Moncler",@"moschino":@"MOSCHINO",@"msgm":@"MSGM",@"nailmatic":@"Nailmatic",@"nana-huchy":@"Nana Huchy",@"noukies":@"Noukie's",@"oeuf":@"Oeuf",@"patachou":@"Patachou",@"paul-smith":@"Paul Smith",@"pepe":@"PèPè",@"sons-daughters-eyewear":@"Sons + Daughters Eyewear",@"stella-mccartney-kids":@"Stella McCartney Kids",@"story-loris":@"Story Loris",@"tartine-et-chocolat":@"Tartine et Chocolat",@"the-animals-observatory":@"The Animals Observatory",@"tiny-cottons":@"Tiny Cottons",@"tip-toey-joey":@"Tip Toey Joey",@"veja":@"Veja",@"young-versace":@"Young Versace",@"zadig-voltaire":@"Zadig & Voltaire"};
if ([brands containsObject:handle]) { if ([brands containsObject:handle]) {
KWMBrandCaramelVC *brandCaramelVC = [KWMBrandCaramelVC getNewInstance]; KWMBrandCaramelVC *brandCaramelVC = [KWMBrandCaramelVC getNewInstance];
brandCaramelVC.isSale = NO; brandCaramelVC.isSale = NO;
brandCaramelVC.handle = handle; brandCaramelVC.handle = handle;
brandCaramelVC.brand = handle; brandCaramelVC.brand = brandNames[handle];
[self pushViewController:brandCaramelVC]; [self pushViewController:brandCaramelVC];
[controllerCache setObject:brandCaramelVC forKey:url];
}else{ }else{
KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"]; KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"];
selectedGoodsVC.handle = handle; selectedGoodsVC.handle = handle;
selectedGoodsVC.ctags = tags; selectedGoodsVC.ctags = tags;
selectedGoodsVC.title = parameters[@"title"]; selectedGoodsVC.title = parameters[@"title"];
[self pushViewController:selectedGoodsVC]; [self pushViewController:selectedGoodsVC];
[controllerCache setObject:selectedGoodsVC forKey:url];
} }
return YES; return YES;
}]; }];
......
...@@ -21,5 +21,6 @@ ...@@ -21,5 +21,6 @@
@property (nonatomic) BUYCollectionSort sort; @property (nonatomic) BUYCollectionSort sort;
@property (nonatomic) NSMutableArray<KWMFilter *> *filters; @property (nonatomic) NSMutableArray<KWMFilter *> *filters;
@property (nonatomic) NSString *brand; @property (nonatomic) NSString *brand;
@property (nonatomic) CGFloat offsetY;
@end @end
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
@interface KWMProduct : KWMBaseModel @interface KWMProduct : KWMBaseModel
@property (nonatomic) NSNumber *id;
//標題 //標題
@property (nonatomic) NSString *title; @property (nonatomic) NSString *title;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
@interface KWMVariants : KWMBaseModel @interface KWMVariants : KWMBaseModel
@property (nonatomic) NSNumber * id;
//规格标题 //规格标题
@property (nonatomic) NSString *title; @property (nonatomic) NSString *title;
//库存 //库存
......
...@@ -358,7 +358,9 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -358,7 +358,9 @@ static NSString *idStr = @"KWMBrandCaramelCell";
if(self.isSale){ if(self.isSale){
[tags addObject:@"sale"]; [tags addObject:@"sale"];
} }
if (self.currentPage == 0) {
[self.tbvBrandCaramel.mj_footer resetNoMoreData]; [self.tbvBrandCaramel.mj_footer resetNoMoreData];
}
NSInteger tagetPage = self.currentPage.integerValue + 1; 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:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
if (error) { if (error) {
...@@ -369,15 +371,21 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -369,15 +371,21 @@ static NSString *idStr = @"KWMBrandCaramelCell";
[weakSelf.dataList removeAllObjects]; [weakSelf.dataList removeAllObjects];
[self.tbvBrandCaramel reloadData]; [self.tbvBrandCaramel reloadData];
}else if (error == nil && products) { }else if (error == nil && products) {
//
if(tagetPage == 1 && (tags.count == 0 || (tags.count == 1 && weakSelf.isSale)) ){ if(tagetPage == 1 && (tags.count == 0 || (tags.count == 1 && weakSelf.isSale)) ){
[weakSelf.userDao saveCollectionCache:products collectionId:collectionId tags:tags]; [weakSelf.userDao saveCollectionCache:products collectionId:collectionId tags:tags];
} }
//
weakSelf.hasNextPage = !reachedEnd; weakSelf.hasNextPage = !reachedEnd;
[weakSelf appendDataList:products setPage:page]; [weakSelf appendDataList:products setPage:page];
weakSelf.vNoneGoods.hidden = YES; weakSelf.vNoneGoods.hidden = YES;
[self.tbvBrandCaramel reloadData]; [self.tbvBrandCaramel reloadData];
// [weakSelf.dataList addObjectsFromArray:products];
// [weakSelf.tbvBrandCaramel.mj_header endRefreshing];
// [weakSelf.tbvBrandCaramel.mj_footer endRefreshing];
// [weakSelf.tbvBrandCaramel reloadData];
} }
[weakSelf hideLoading]; [weakSelf hideLoading];
}]; }];
......
...@@ -174,19 +174,21 @@ static NSString *cellId = @"KWMBrandCell"; ...@@ -174,19 +174,21 @@ static NSString *cellId = @"KWMBrandCell";
if (indexPath.row) { if (indexPath.row) {
// KWMBrandsTypeModel *brands = [bransType objectAtIndex:indexPath.row - 1]; // KWMBrandsTypeModel *brands = [bransType objectAtIndex:indexPath.row - 1];
//品牌介绍 //品牌介绍
KWMBrandCaramelVC *brandCaramelVC = (KWMBrandCaramelVC *)[KWMBaseVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"]; // KWMBrandCaramelVC *brandCaramelVC = (KWMBrandCaramelVC *)[KWMBaseVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"];
brandCaramelVC.isSale = NO; // brandCaramelVC.isSale = NO;
// brandCaramelVC.handle = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brands.designers]; // brandCaramelVC.handle = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brands.designers];
// brandCaramelVC.brand = brands.designers; // brandCaramelVC.brand = brands.designers;
NSString *brand = [bransType objectAtIndex:indexPath.row - 1]; NSString *brand = [bransType objectAtIndex:indexPath.row - 1];
brandCaramelVC.handle = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand]; // brandCaramelVC.handle = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand];
brandCaramelVC.brand = brand; // brandCaramelVC.brand = brand;
//
NSString *colorStr = [colorArr objectAtIndex:(indexPath.row)%(colorArr.count)]; // NSString *colorStr = [colorArr objectAtIndex:(indexPath.row)%(colorArr.count)];
brandCaramelVC.backColor = [UIColor sam_colorWithHex:colorStr]; // brandCaramelVC.backColor = [UIColor sam_colorWithHex:colorStr];
//
[self.navigationController pushViewController:brandCaramelVC animated:YES]; // [self.navigationController pushViewController:brandCaramelVC animated:YES];
brand = [[KWMStringUtil deleteOtherCharExceptLetterWithLine:brand] lowercaseString];
[self openURLWithString:[NSString stringWithFormat:@"https://www.cemarose.cn/collections/%@",brand]];
}else{ }else{
//品牌搜索 //品牌搜索
KWMSearchBrandVC *searchBrandVC = (KWMSearchBrandVC*)[KWMBaseVC findControllerBy:[KWMSearchBrandVC kwmTag] fromStoryboard:@"Brand"]; KWMSearchBrandVC *searchBrandVC = (KWMSearchBrandVC*)[KWMBaseVC findControllerBy:[KWMSearchBrandVC kwmTag] fromStoryboard:@"Brand"];
......
...@@ -238,14 +238,15 @@ static NSString *identify = @"KWMSearchBrandsCell"; ...@@ -238,14 +238,15 @@ static NSString *identify = @"KWMSearchBrandsCell";
brand = [dict[@"content"] objectAtIndex:indexPath.row]; brand = [dict[@"content"] objectAtIndex:indexPath.row];
} }
NSString *str = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand]; NSString *str = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand];
NSLog(@"str: %@",str); // NSLog(@"str: %@",str);
//品牌介绍 // //品牌介绍
KWMBrandCaramelVC *brandCaramelVC = (KWMBrandCaramelVC *)[KWMBaseVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"]; // KWMBrandCaramelVC *brandCaramelVC = (KWMBrandCaramelVC *)[KWMBaseVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"];
brandCaramelVC.handle = str; // brandCaramelVC.handle = str;
brandCaramelVC.brand = brand; // brandCaramelVC.brand = brand;
brandCaramelVC.isSale = NO; // brandCaramelVC.isSale = NO;
[tableView deselectRowAtIndexPath:indexPath animated:YES]; // [tableView deselectRowAtIndexPath:indexPath animated:YES];
[self.navigationController pushViewController:brandCaramelVC animated:YES]; // [self.navigationController pushViewController:brandCaramelVC animated:YES];
[self openURLWithString:[NSString stringWithFormat:@"https://www.cemarose.com/collections/%@",str]];
} }
#pragma mark---tableView索引相关设置---- #pragma mark---tableView索引相关设置----
......
...@@ -185,6 +185,8 @@ ...@@ -185,6 +185,8 @@
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// [self.cvRightProduct.mj_header endRefreshing];
// [self.cvRightProduct.mj_footer endRefreshing];
self.selectedCategory = self.categories[indexPath.row]; self.selectedCategory = self.categories[indexPath.row];
} }
...@@ -305,7 +307,13 @@ ...@@ -305,7 +307,13 @@
[self.client getProductsPage:cpage inCollection:cmodel.collection_id withTags:tags sortOrder:cmodel.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){ [self.client getProductsPage:cpage inCollection:cmodel.collection_id withTags:tags sortOrder:cmodel.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
weakSelf.cvRightProduct.mj_footer.hidden = false; weakSelf.cvRightProduct.mj_footer.hidden = false;
if (cmodel == self.selectedCategory) { if (cmodel == self.selectedCategory) {
[weakSelf.refreshUtil hideLoading]; // [weakSelf.refreshUtil hideLoading];
if ([weakSelf.cvRightProduct.mj_header isRefreshing]) {
[weakSelf.cvRightProduct.mj_header endRefreshing];
}
if ([weakSelf.cvRightProduct.mj_footer isRefreshing]) {
[weakSelf.cvRightProduct.mj_footer endRefreshing];
}
} }
if(reachedEnd){ if(reachedEnd){
[weakSelf.cvRightProduct.mj_footer endRefreshingWithNoMoreData]; [weakSelf.cvRightProduct.mj_footer endRefreshingWithNoMoreData];
...@@ -334,7 +342,12 @@ ...@@ -334,7 +342,12 @@
#pragma mark - setter #pragma mark - setter
- (void)setSelectedCategory:(KWMCategoryModel *)selectedCategory { - (void)setSelectedCategory:(KWMCategoryModel *)selectedCategory {
_selectedCategory.offsetY = self.cvRightProduct.contentOffset.y < 0 ? 0 : self.cvRightProduct.contentOffset.y;
_selectedCategory = selectedCategory; _selectedCategory = selectedCategory;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.cvRightProduct.contentOffset = CGPointMake(0, selectedCategory.offsetY);
});
// self.cvRightProduct.contentOffset = CGPointMake(0, selectedCategory.offsetY);
[self.cvRightProduct.mj_footer resetNoMoreData]; [self.cvRightProduct.mj_footer resetNoMoreData];
self.refreshUtil.page = _selectedCategory.page; self.refreshUtil.page = _selectedCategory.page;
self.refreshUtil.hasNextPage = YES; self.refreshUtil.hasNextPage = YES;
......
...@@ -31,13 +31,13 @@ ...@@ -31,13 +31,13 @@
} }
- (void)viewDidLoad { - (void)viewDidLoad {
KWMUserModel *user = [KWMUserModel shareUser]; // KWMUserModel *user = [KWMUserModel shareUser];
if (user.status != 1) { // if (user.status != 1) {
//登录 // //登录
KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"]; // KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc]; // UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc];
[self presentViewController:nav animated:YES completion:nil]; // [self presentViewController:nav animated:YES completion:nil];
} // }
[super viewDidLoad]; [super viewDidLoad];
......
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
tableView.mj_header = header; tableView.mj_header = header;
tableView.mj_header.automaticallyChangeAlpha = YES; tableView.mj_header.automaticallyChangeAlpha = YES;
tableView.mj_footer = [self createFooter]; tableView.mj_footer = [self createFooter];
} }
...@@ -89,9 +88,10 @@ ...@@ -89,9 +88,10 @@
__weak KWMBasePageVC *weakSelf = self; __weak KWMBasePageVC *weakSelf = self;
MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // 完全不知道为什么要延时2秒 现在去掉完全是浪费时间
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf loadData]; [weakSelf loadData];
}); // });
}]; }];
[footer setTitle:NO_MORE_DATA forState:MJRefreshStateNoMoreData]; [footer setTitle:NO_MORE_DATA forState:MJRefreshStateNoMoreData];
footer.hidden = YES; footer.hidden = YES;
......
...@@ -226,9 +226,35 @@ ...@@ -226,9 +226,35 @@
[self kwm_onClickSizeBtn]; [self kwm_onClickSizeBtn];
return; return;
} }
[self showLoading];
__weak KWMNewProductVC *this = self; __weak KWMNewProductVC *this = self;
[self addShopWithVariantId:self.variant.identifier quantity:self.count variant:self.variant buyNow:buyNow callback:^(BOOL success) { // TODO: this
NSArray<KWMShopCartModel *> *items = [[KWMShoppingCart sharedInstance] items];
KWMShopCartModel *item = nil;
for (KWMShopCartModel *it in items) {
if (it.identifier.integerValue == self.variant.identifier.integerValue) {
item = it;
break;
}
}
NSInteger quantity = self.count;
KWMVariants *variant = nil;
for (KWMVariants *it in self.adminProduct.variants) {
if (it.id.integerValue == self.variant.identifier.integerValue) {
variant = it;
break;
}
}
if (item.quantity + quantity > variant.inventoryQuantity.integerValue) {
quantity = variant.inventoryQuantity.integerValue - item.quantity;
if (quantity <= 0 && !buyNow) {
[self showToast:@"无库存"];
return;
}else{
[self showToast:@"库存不足"];
}
}
[self showLoading];
[self addShopWithVariantId:self.variant.identifier quantity:quantity variant:self.variant buyNow:buyNow callback:^(BOOL success) {
[this hideLoading]; [this hideLoading];
if(success) { if(success) {
if(!buyNow){ if(!buyNow){
......
...@@ -66,11 +66,15 @@ ...@@ -66,11 +66,15 @@
return each.product_id; return each.product_id;
}]; }];
if (ids && ids.count > 0) { if (ids && ids.count > 0) {
[this.client getProductsByIds:ids completion:^(NSArray<BUYProduct *> * _Nullable products, NSError * _Nullable error) { [this.api getAdminProductsById:ids success:^(NSURLSessionDataTask *task, KWMProductResult *result) {
[this hideLoading]; [this hideLoading];
// [this refresh]; [this checkInStockWithItems:cart.items products:result.products];
[this checkInStockWithItems:cart.items products:products]; } failure:nil];
}]; // [this.client getProductsByIds:ids completion:^(NSArray<BUYProduct *> * _Nullable products, NSError * _Nullable error) {
// [this hideLoading];
//// [this refresh];
// [this checkInStockWithItems:cart.items products:products];
// }];
}else{ }else{
[this hideLoading]; [this hideLoading];
[this refresh]; [this refresh];
...@@ -78,10 +82,16 @@ ...@@ -78,10 +82,16 @@
}]; }];
} }
- (void) checkInStockWithItems:(NSArray<KWMShopCartModel *> *) items products:(NSArray<BUYProduct *> *) products { - (void) checkInStockWithItems:(NSArray<KWMShopCartModel *> *) items products:(NSArray<KWMProduct *> *) products {
self.soldout = [NSMutableArray new]; self.soldout = [NSMutableArray new];
for (id item in items) { for (KWMShopCartModel *item in items) {
if(![self checkInStockWithItem:item products:products]) { NSInteger quantity = 0;
if((quantity = [self checkInStockWithItem:item products:products]) < 0) {
NSInteger has = item.quantity + quantity;
if (has < 0) {
has = 0;
}
item.quantity = has;
[self.soldout addObject:item]; [self.soldout addObject:item];
} }
} }
...@@ -95,10 +105,12 @@ ...@@ -95,10 +105,12 @@
NSArray *ids = [self.soldout rx_mapWithBlock:^id(KWMShopCartModel *each) { NSArray *ids = [self.soldout rx_mapWithBlock:^id(KWMShopCartModel *each) {
return each.identifier; return each.identifier;
}]; }];
NSArray *qus = [ids rx_mapWithBlock:^(id it){ return @(0); }]; NSArray *qus = [self.soldout rx_mapWithBlock:^(KWMShopCartModel *it){ return @(it.quantity); }];
__weak typeof(self) this = self; __weak typeof(self) this = self;
[self showLoading];
[[KWMShoppingCart sharedInstance] updateProductWithVariantIds:ids quantitties:qus callback:^(NSError *error, KWMCartResult *cart) { [[KWMShoppingCart sharedInstance] updateProductWithVariantIds:ids quantitties:qus callback:^(NSError *error, KWMCartResult *cart) {
[[KWMShoppingCart sharedInstance] setSync:NO]; [[KWMShoppingCart sharedInstance] setSync:NO];
[this hideLoading];
[this refresh]; [this refresh];
if (buttonIndex == 1) { if (buttonIndex == 1) {
[this addSoldOutProductToWishlist]; [this addSoldOutProductToWishlist];
...@@ -132,17 +144,24 @@ ...@@ -132,17 +144,24 @@
} }
- (BOOL) checkInStockWithItem:(KWMShopCartModel *) item products:(NSArray<BUYProduct *> *) products { - (NSInteger) checkInStockWithItem:(KWMShopCartModel *) item products:(NSArray<KWMProduct *> *) products {
for (BUYProduct *p in products) { for (KWMProduct *p in products) {
if (item.product_id.integerValue == p.identifier.integerValue) { if (item.product_id.integerValue == p.id.integerValue) {
for (BUYProductVariant *v in p.variants) { for (KWMVariants *v in p.variants) {
if ([item.size isEqualToString:v.title] && v.availableValue) { if (item.identifier.integerValue == v.id.integerValue) {
return YES; return v.inventoryQuantity.integerValue - item.quantity;
} }
} }
} }
// if (item.product_id.integerValue == p.identifier.integerValue) {
// for (BUYProductVariant *v in p.variants) {
// if ([item.size isEqualToString:v.title] && v.availableValue) {
// return YES;
// }
// }
// }
} }
return NO; return 0;
} }
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
#define TestModel @"YES" #define TestModel @"YES"
//额外api domain //额外api domain
#define Additional_API_DOMAIN @"liang.tofnews.com" //#define Additional_API_DOMAIN @"liang.tofnews.com"
#define WishList_API_DOMAIN @"test.cemarose.com" #define WishList_API_DOMAIN @"test.cemarose.com"
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
//正式 //正式
#define TestModel @"NO" #define TestModel @"NO"
#define Additional_API_DOMAIN @"apps.cemarose.com" //#define Additional_API_DOMAIN @"apps.cemarose.com"
#define WishList_API_DOMAIN @"apps.cemarose.com" #define WishList_API_DOMAIN @"apps.cemarose.com"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.5.7</string> <string>1.5.8</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.5.7.4</string> <string>1.5.8.3</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LSApplicationQueriesSchemes</key> <key>LSApplicationQueriesSchemes</key>
......
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