Commit 5aa0904e by lee

u

parent 2d878d7a
......@@ -30,4 +30,6 @@ typedef void(^ShoppingCartCallBack) (NSError *error,KWMCartResult *cart);
- (void)deleteProductWithVariantId:(NSNumber *) variantId callback:(ShoppingCartCallBack) callback;
- (void)clearCartWithCallback:(ShoppingCartCallBack) callback;
@end
......@@ -10,6 +10,7 @@
#import "KWMCartResult.h"
#import "KWMShopCartData.h"
#import <RegexKitLite/RegexKitLite.h>
#import <RXCollections/RXCollection.h>
@interface KWMShoppingCart ()
......@@ -142,7 +143,7 @@
// callback(error,nil);
}];
[self addTasksObject:task];
for (int i=0; i<quantites.count; i++) {
for (int i=0; i<quantites.count && self.items.count; i++) {
[self changeLocalCartWithVariantId:variantIds[i] quantity:quantites[i].integerValue flag:quantites[i].integerValue ? 2 : 0];
}
callback(nil,self.result);
......@@ -152,6 +153,27 @@
[self changeProductWithVariantId:variantId quantity:0 callback:callback];
}
- (void)clearCartWithCallback:(ShoppingCartCallBack)callback {
NSMutableArray *quantity = [NSMutableArray new];
NSArray *ids = [self.items rx_mapWithBlock:^id(KWMShopCartModel* each) {
[quantity addObject:@(0)];
return each.identifier;
}];
[self setResult:[KWMCartResult new]];
__weak typeof(self) this = self;
id task = [[KWMAPIManager sharedManager] updateProductWithVariantIds:ids quantities:quantity success:^(NSURLSessionDataTask *task, KWMCartResult *result) {
[this missionCompleted];
// if (version == this.version) {
[[KWMShoppingCart sharedInstance] setResult:result];
callback(nil,result);
// }
} failure:^(NSURLSessionDataTask *task, NSError *error) {
[this missionCompleted];
callback(error,nil);
}];
[self addTasksObject:task];
}
- (KWMCartResult *) changeLocalCartWithVariantId:(NSNumber *) variantId quantity:(NSInteger) quantity flag:(NSInteger) flag {
NSMutableArray<KWMShopCartModel *> *items= self.items;
NSInteger count = self.result.item_count.integerValue;
......
......@@ -184,8 +184,9 @@
[self.btnBrand setTitle:product.vendor forState:UIControlStateNormal];
self.lbName.text = product.title;
BUYProductVariant *productVariant= product.variants.firstObject;
NSAttributedString *detailAttr = [[NSAttributedString alloc] initWithData:[self.product.htmlDescription dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
self.lbDetail.attributedText = detailAttr;
// 2017-06-30 暂时注释
// NSAttributedString *detailAttr = [[NSAttributedString alloc] initWithData:[self.product.htmlDescription dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
// self.lbDetail.attributedText = detailAttr;
// self.lbPrice.text = [KWMStringUtil getEUR2CNYstring:productVariant.price];
self.lbPrice.text = productVariant.price.priceValueFormatted;
if (productVariant.compareAtPrice) {
......@@ -222,32 +223,32 @@
}
-(void)onClickPrice:(UITapGestureRecognizer *)tapGesture{
if(self.product == nil){
return;
}
self.isShowCNY = !self.isShowCNY;
BUYProductVariant *productVariant= self.product.variants.firstObject;
if(self.isShowCNY){
self.lbUnit.text = @"¥";
// self.lbPrice.text = [KWMStringUtil getEUR2CNYstring:productVariant.price];
self.lbPrice.text = productVariant.price.priceValueFormatted;
if (productVariant.compareAtPrice) {
// NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]];
NSString *priceString = productVariant.compareAtPrice.priceValueFormatted;
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
self.lbOldPrice.attributedText = attribtStr;
}
}else{
self.lbUnit.text = @"€";
self.lbPrice.text = productVariant.price.stringValue;
if (productVariant.compareAtPrice) {
NSString *priceString = [NSString stringWithFormat:@"€%@",productVariant.compareAtPrice.stringValue];
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
self.lbOldPrice.attributedText = attribtStr;
}
}
// if(self.product == nil){
// return;
// }
// self.isShowCNY = !self.isShowCNY;
// BUYProductVariant *productVariant= self.product.variants.firstObject;
// if(self.isShowCNY){
// self.lbUnit.text = @"¥";
//// self.lbPrice.text = [KWMStringUtil getEUR2CNYstring:productVariant.price];
// self.lbPrice.text = productVariant.price.priceValueFormatted;
// if (productVariant.compareAtPrice) {
//// NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]];
// NSString *priceString = productVariant.compareAtPrice.priceValueFormatted;
// NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
// NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
// self.lbOldPrice.attributedText = attribtStr;
// }
// }else{
// self.lbUnit.text = @"€";
// self.lbPrice.text = productVariant.price.stringValue;
// if (productVariant.compareAtPrice) {
// NSString *priceString = [NSString stringWithFormat:@"€%@",productVariant.compareAtPrice.stringValue];
// NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
// NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
// self.lbOldPrice.attributedText = attribtStr;
// }
// }
}
......
......@@ -22,6 +22,7 @@
#import "KWMValidateUtil.h"
#import "KWMPayUtil.h"
#import "KWMShopCartData.h"
#import "KWMShoppingCart.h"
@interface KWMBeforePayVC ()
@property (nonatomic) BUYCustomer *customer;
......@@ -719,8 +720,13 @@
-(void) clearCheckout {
self.cartCookie = nil;
[KWMHttpUtil deleteCookie:@"cart"];
[[KWMShopCartData alloc] removeAllItems];
[[KWMShoppingCart sharedInstance] clearCartWithCallback:^(NSError *error, KWMCartResult *cart) {
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[KWMHttpUtil deleteCookie:@"cart"];
// });
}];
// [KWMHttpUtil deleteCookie:@"cart"];
// [[KWMShopCartData alloc] removeAllItems];
[self.userDao deleteCheckoutCache];
}
......
......@@ -71,7 +71,8 @@
- (NSDecimalNumber *) calcPriceByCurrencyCode:(NSDecimalNumber *) price {
if ([[self getCurrencyCode] isEqualToString:@"CNY"]) {
NSDecimalNumber *rate = [[KWMUserDao shareDao] exchangeRate];
price = [[rate decimalNumberByMultiplyingBy:price] decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithString:@"1.03"]];
// price = [[rate decimalNumberByMultiplyingBy:price] decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithString:@"1.03"]];
price = [rate decimalNumberByMultiplyingBy:price];
}
return price;
}
......
......@@ -78,7 +78,7 @@
#define Shopify_SHOP_DOMAIN @"cemarose.myshopify.com"
#define Shopify_API_KEY @"c2f6fae97741ea6db4cad7ae8f70fef3"
#define Shopify_APP_ID @"8"
#end
#endif
//软键盘输入限制
#define NUM @"0123456789"
......
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