Commit 9408a76a by lee

fix add bag bug, change add bag logic

parent 985d1cf9
......@@ -65,7 +65,9 @@
- (void) addTasksObject:(NSURLSessionDataTask *)object {
if (self.tasks.lastObject && [self.tasks.lastObject.currentRequest.URL.absoluteString isEqualToString:object.currentRequest.URL.absoluteString] && [object.currentRequest.URL.absoluteString isMatchedByRegex:@"cart.js$"]) {
if(!self.sync)return;
if(!self.sync) {
return;
}
}
[self.tasks addObject:object];
if (self.tasks.count == 1) {
......
......@@ -34,13 +34,21 @@
}
- (void)animating{
CABasicAnimation *textAnimation = [self getShowAnimation];
[self.lbText.layer addAnimation:textAnimation forKey:@"textAnimation"];
// CABasicAnimation *textAnimation = [self getShowAnimation];
// [self.lbText.layer addAnimation:textAnimation forKey:@"textAnimation"];
self.lbText.alpha = 0;
self.btnEnter.alpha = 0;
[UIView animateWithDuration:1.5 animations:^{
self.lbText.alpha = 1;
}];
[UIView animateWithDuration:1.5 delay:0.8 options:0 animations:^{
self.btnEnter.alpha = 1;
} completion:nil];
}
- (CABasicAnimation *)getShowAnimation{
CABasicAnimation *enterAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
enterAnimation.duration = 3.0f;
enterAnimation.duration = 1.5f;
enterAnimation.repeatCount = 1;
enterAnimation.delegate = self;
enterAnimation.fromValue = [NSNumber numberWithDouble:0.0f];
......@@ -58,6 +66,7 @@
self.lbText.alpha = 1.0;
[self.lbText.layer removeAllAnimations];
CABasicAnimation *enterAnimation = [self getShowAnimation];
enterAnimation.beginTime = 0;
[self.btnEnter.layer addAnimation:enterAnimation forKey:@"enterAnimation"];
}
}
......
......@@ -64,7 +64,7 @@
image:(UIImage *)image
action:(SEL)action;
- (void)showPresentation:(UIViewController *)vc size:(CGSize)size tapOutsideClose:(BOOL)tapOutsideClose style:(MZFormSheetPresentationTransitionStyle)style;
- (MZFormSheetPresentationViewController *)showPresentation:(UIViewController *)vc size:(CGSize)size tapOutsideClose:(BOOL)tapOutsideClose style:(MZFormSheetPresentationTransitionStyle)style;
/**将URL转成UIImage*/
- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;
......
......@@ -535,7 +535,7 @@
return [[UIBarButtonItem alloc] initWithCustomView:btnView];
}
- (void)showPresentation:(UIViewController *)vc size:(CGSize)size tapOutsideClose:(BOOL)tapOutsideClose style:(MZFormSheetPresentationTransitionStyle)style {
- (MZFormSheetPresentationViewController *)showPresentation:(UIViewController *)vc size:(CGSize)size tapOutsideClose:(BOOL)tapOutsideClose style:(MZFormSheetPresentationTransitionStyle)style {
MZFormSheetPresentationViewController *mz = [[MZFormSheetPresentationViewController alloc] initWithContentViewController:vc];
mz.presentationController.shouldDismissOnBackgroundViewTap = tapOutsideClose;
mz.presentationController.movementActionWhenKeyboardAppears = MZFormSheetActionWhenKeyboardAppearsCenterVertically;
......@@ -544,10 +544,10 @@
mz.presentationController.contentViewSize = size;
}
mz.presentationController.shouldCenterVertically = YES;
[self presentViewController:mz
animated:YES
completion:nil];
return mz;
}
......
......@@ -38,6 +38,9 @@
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightMidView;
// 0 非自动 1 是加购 2 是立即购买
@property (assign, nonatomic) NSInteger autoAddToBag;
//颜色扩展字段
@property (nonatomic) KWMMetafield *colorMeterfield;
......@@ -213,9 +216,11 @@
}
-(IBAction)onClickComplete:(UIButton *)sender{
BOOL buyNow = sender.tag == 1;
BOOL buyNow = sender.tag == 1 || self.autoAddToBag == 2;
if(!self.variant){
[self showToast:@"请选择商品"];
// [self showToast:@"请选择商品"];
self.autoAddToBag = buyNow ? 2 : 1;
[self kwm_onClickSizeBtn];
return;
}
[self showLoading];
......@@ -261,9 +266,11 @@
KWMUserModel *useModel = [KWMUserModel shareUser];
if (!useModel.status) {
//登录
KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc];
[self presentViewController:nav animated:YES completion:nil];
dispatch_after(0, dispatch_get_main_queue(), ^{
KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc];
[self presentViewController:nav animated:YES completion:nil];
});
return;
}
[self showLoading];
......@@ -312,7 +319,10 @@
[variantsVC setDefaultSelect:self.variant color:self.color count:self.count];
}
CGSize size = [UIScreen mainScreen].bounds.size;
[self showPresentation:variantsVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade];
MZFormSheetPresentationViewController * mz = [self showPresentation:variantsVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleSlideFromBottom];
mz.didDismissContentViewControllerHandler = ^(UIViewController * _Nonnull contentViewController) {
self.autoAddToBag = 0;
};
}
- (void)kwm_sizeGuide {
......@@ -419,6 +429,10 @@
self.isLikeVariant = NO;
[self requestWishList];
if (self.autoAddToBag) {
[self onClickComplete:nil];
self.autoAddToBag = 0;
}
}
#pragma mark - API BUYClient+Storefront
......
......@@ -58,9 +58,10 @@
- (void) checkInStockAndRefresh {
__weak typeof(self) this = self;
[self showLoading];
[[KWMShoppingCart sharedInstance] setSync:YES];
[[KWMShoppingCart sharedInstance] allItemsWithCallback:^(NSError *error, KWMCartResult *cart) {
[this refresh];
[[KWMShoppingCart sharedInstance] setSync:NO];
NSArray *ids = [cart.items rx_mapWithBlock:^id(KWMShopCartModel *each) {
return each.product_id;
}];
......
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