Commit b1906ed2 by houweibin

店家详情:根据选择的规格显示不同的价格

parent 27ec3fbb
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "KWMImageUtil.h" #import "KWMImageUtil.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
#import "KWMPageControl.h" #import "KWMPageControl.h"
#import "KWMUserDao.h"
//#import "YYWebImage/YYWebImage.h" //#import "YYWebImage/YYWebImage.h"
#import <SDCycleScrollView/SDCycleScrollView.h> #import <SDCycleScrollView/SDCycleScrollView.h>
...@@ -31,9 +32,6 @@ ...@@ -31,9 +32,6 @@
@property(nonatomic,weak) IBOutlet UIView *freeShipping; @property(nonatomic,weak) IBOutlet UIView *freeShipping;
//单位label
@property(nonatomic,weak) IBOutlet UILabel *lbUnit;
//@property(nonatomic,weak) IBOutlet KWMPageControl *pageControl; //@property(nonatomic,weak) IBOutlet KWMPageControl *pageControl;
@property (weak, nonatomic) IBOutlet UIView *sizeGuideView; @property (weak, nonatomic) IBOutlet UIView *sizeGuideView;
...@@ -134,7 +132,7 @@ ...@@ -134,7 +132,7 @@
if(product == nil){ if(product == nil){
return; return;
} }
self.isShowCNY = YES; self.isShowCNY = [[KWMUserDao shareDao].currencyCode isEqualToString:@"CNY"];
// self.isFirstScroll = YES; // self.isFirstScroll = YES;
// [self removeTimer]; // [self removeTimer];
self.product = product; self.product = product;
...@@ -210,13 +208,10 @@ ...@@ -210,13 +208,10 @@
self.lbOldPrice.hidden = YES; self.lbOldPrice.hidden = YES;
} }
UITapGestureRecognizer *priceTap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickPrice:)];
UITapGestureRecognizer *priceTap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickPrice:)]; UITapGestureRecognizer *priceTap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickPrice:)];
UITapGestureRecognizer *priceTap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickPrice:)]; UITapGestureRecognizer *priceTap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickPrice:)];
[self.lbUnit addGestureRecognizer:priceTap1];
[self.lbPrice addGestureRecognizer:priceTap2]; [self.lbPrice addGestureRecognizer:priceTap2];
[self.lbOldPrice addGestureRecognizer:priceTap3]; [self.lbOldPrice addGestureRecognizer:priceTap3];
self.lbUnit.userInteractionEnabled = YES;
self.lbPrice.userInteractionEnabled = YES; self.lbPrice.userInteractionEnabled = YES;
self.lbOldPrice.userInteractionEnabled = YES; self.lbOldPrice.userInteractionEnabled = YES;
self.freeShipping.hidden = [product.tags containsObject:@"not-return"]; self.freeShipping.hidden = [product.tags containsObject:@"not-return"];
...@@ -243,21 +238,29 @@ ...@@ -243,21 +238,29 @@
return; return;
} }
self.isShowCNY = !self.isShowCNY; self.isShowCNY = !self.isShowCNY;
BUYProductVariant *productVariant= self.product.variants.firstObject; [self refreshPrice];
}
-(void)refreshPrice{
if(self.product == nil || !self.product.variants || self.product.variants.count == 0){
return;
}
BUYProductVariant *productVariant = self.product.variants.firstObject;
if(self.variant){
productVariant = self.variant;
}
if(self.isShowCNY){ if(self.isShowCNY){
self.lbUnit.text = @"¥";
self.lbPrice.text = [KWMStringUtil price:productVariant.price]; self.lbPrice.text = [KWMStringUtil price:productVariant.price];
if (productVariant.compareAtPrice) { if (productVariant.compareAtPrice) {
NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil price:productVariant.compareAtPrice]]; NSString *priceString = [KWMStringUtil price:productVariant.compareAtPrice];
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic]; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
self.lbOldPrice.attributedText = attribtStr; self.lbOldPrice.attributedText = attribtStr;
} }
}else{ }else{
self.lbUnit.text = @"€"; self.lbPrice.text = [NSString stringWithFormat:@"€%.2f",productVariant.price.floatValue];
self.lbPrice.text = productVariant.price.stringValue;
if (productVariant.compareAtPrice) { if (productVariant.compareAtPrice) {
NSString *priceString = [NSString stringWithFormat:@"€%@",productVariant.compareAtPrice.stringValue]; NSString *priceString = [NSString stringWithFormat:@"€%.2f",productVariant.compareAtPrice.floatValue];
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic]; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
self.lbOldPrice.attributedText = attribtStr; self.lbOldPrice.attributedText = attribtStr;
...@@ -294,6 +297,7 @@ ...@@ -294,6 +297,7 @@
NSString *colorString = color?[NSString stringWithFormat:@"%@ /",color.title]:@""; NSString *colorString = color?[NSString stringWithFormat:@"%@ /",color.title]:@"";
self.lbVariant.text = [NSString stringWithFormat:@"已选择 %@ %@ / %ld",colorString,variant.title,count]; self.lbVariant.text = [NSString stringWithFormat:@"已选择 %@ %@ / %ld",colorString,variant.title,count];
} }
[self refreshPrice];
} }
- (void)setSizeGuideHidden:(BOOL)sizeGuideHidden { - (void)setSizeGuideHidden:(BOOL)sizeGuideHidden {
......
...@@ -497,7 +497,7 @@ static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu ...@@ -497,7 +497,7 @@ static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu
// if(exchageRate == 0){ // if(exchageRate == 0){
// exchageRate = ExchangeRate; // exchageRate = ExchangeRate;
// } // }
CNYstring = [NSString stringWithFormat:@"%.0f",price.floatValue * exchageRate]; CNYstring = [NSString stringWithFormat:@"%.2f",price.floatValue * exchageRate];
// CNYstring = [NSString stringWithFormat:@"%.2f",price.floatValue]; // CNYstring = [NSString stringWithFormat:@"%.2f",price.floatValue];
return CNYstring; return CNYstring;
...@@ -505,7 +505,7 @@ static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu ...@@ -505,7 +505,7 @@ static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu
+ (NSString *)price:(NSNumber *)price{ + (NSString *)price:(NSNumber *)price{
NSString *CNYstring = [self getEUR2CNYstring:price]; NSString *CNYstring = [self getEUR2CNYstring:price];
return [NSString stringWithFormat:@"¥ %@",CNYstring]; return [NSString stringWithFormat:@"CN¥%@",CNYstring];
} }
+ (NSArray *)splitArray:(NSArray *)array withSubSize:(NSInteger)subSize{ + (NSArray *)splitArray:(NSArray *)array withSubSize:(NSInteger)subSize{
......
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