Commit 42034f2a by houweibin

Merge branch 'master' of https://git.oschina.net/kollway-kollway/newcemarose

# Conflicts:
#	iCemarose.xcodeproj/project.pbxproj
parents 0670e2bb b142b254
...@@ -14,7 +14,8 @@ pod 'SAMKeychain' ...@@ -14,7 +14,8 @@ pod 'SAMKeychain'
pod 'RXCollections','~> 1.0' pod 'RXCollections','~> 1.0'
pod 'TOWebViewController' pod 'TOWebViewController'
pod 'AFNetworking','~> 3.1' #pod 'AFNetworking','~> 3.1'
pod 'PPNetworkHelper'
pod 'JSONModel','~> 1.2.0' pod 'JSONModel','~> 1.2.0'
pod 'SDWebImage','~> 3.7.1' pod 'SDWebImage','~> 3.7.1'
pod 'SAMCategories', '~> 0.5.1' pod 'SAMCategories', '~> 0.5.1'
......
...@@ -43,7 +43,9 @@ ...@@ -43,7 +43,9 @@
shopCartModel.size = item[@"variant_title"]; shopCartModel.size = item[@"variant_title"];
shopCartModel.product_id = item[@"product_id"]; shopCartModel.product_id = item[@"product_id"];
shopCartModel.quantity = [item[@"quantity"] integerValue]; shopCartModel.quantity = [item[@"quantity"] integerValue];
shopCartModel.price = [item[@"discounted_price"] floatValue] / 100; // shopCartModel.price = [item[@"discounted_price"] floatValue] / 100;
shopCartModel.price = [[NSDecimalNumber decimalNumberWithString:[item[@"discounted_price"] stringValue]] decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithDecimal:@(100).decimalValue]];
shopCartModel.line_price = [[NSDecimalNumber decimalNumberWithString:[item[@"line_price"] stringValue]] decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithDecimal:@(100).decimalValue]];
shopCartModel.imageStr = [KWMImageUtil getProductImageUrlByOriginalUrl:item[@"image"] ImageSize:NormalImage]; shopCartModel.imageStr = [KWMImageUtil getProductImageUrlByOriginalUrl:item[@"image"] ImageSize:NormalImage];
shopCartModel.shopCartDict = item; shopCartModel.shopCartDict = item;
[datas addObject:shopCartModel]; [datas addObject:shopCartModel];
......
//
// NSDecimalNumber+Currency.h
// iCemarose
//
// Created by lee on 2017/6/15.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSDecimalNumber (Currency)
- (NSString *) priceFormatted;
- (NSDecimalNumber *) priceValue;
- (NSString *) priceValueFormatted;
@end
@interface NSNumber (Currency)
- (NSString *) priceFormatted;
- (NSDecimalNumber *) priceValue;
- (NSString *) priceValueFormatted;
@end
//
// NSDecimalNumber+Currency.m
// iCemarose
//
// Created by lee on 2017/6/15.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "NSDecimalNumber+Currency.h"
#import "KWMCurrencyUtil.h"
@implementation NSDecimalNumber (Currency)
- (NSString *) priceFormatted {
return [[KWMCurrencyUtil sharedInstance] priceFormatted:self];
}
- (NSDecimalNumber *)priceValue {
return [[KWMCurrencyUtil sharedInstance] calcPriceByCurrencyCode:self];
}
- (NSString *)priceValueFormatted {
return [[KWMCurrencyUtil sharedInstance] priceFormatted:[self priceValue]];
}
@end
@implementation NSNumber (Currency)
- (NSString *)priceFormatted {
return [[KWMCurrencyUtil sharedInstance] priceFormatted:[NSDecimalNumber decimalNumberWithString:self.stringValue]];
}
- (NSDecimalNumber *)priceValue {
return [[KWMCurrencyUtil sharedInstance] calcPriceByCurrencyCode:[NSDecimalNumber decimalNumberWithString:self.stringValue]];
}
- (NSString *)priceValueFormatted {
return [[KWMCurrencyUtil sharedInstance] priceFormatted:[self priceValue]];
}
@end
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
if (finalValue > KWM_MAX_PRODUCT_COUNT) { if (finalValue > KWM_MAX_PRODUCT_COUNT) {
finalValue = KWM_MAX_PRODUCT_COUNT; finalValue = KWM_MAX_PRODUCT_COUNT;
} }
// shopCartItem.quantity = finalValue; // shopCartItem.quantity = finalValue;
[self saveAll]; [self saveAll];
} }
...@@ -122,6 +121,7 @@ ...@@ -122,6 +121,7 @@
result.size = shopCartModel.size; result.size = shopCartModel.size;
result.quantity = shopCartModel.quantity; result.quantity = shopCartModel.quantity;
result.price = shopCartModel.price; result.price = shopCartModel.price;
result.line_price = shopCartModel.line_price;
result.product_id = shopCartModel.product_id.stringValue; result.product_id = shopCartModel.product_id.stringValue;
result.shopCartDict = shopCartModel.shopCartDict; result.shopCartDict = shopCartModel.shopCartDict;
} }
...@@ -139,6 +139,7 @@ ...@@ -139,6 +139,7 @@
result.brand = shopCartItem.brand; result.brand = shopCartItem.brand;
result.size = shopCartItem.size; result.size = shopCartItem.size;
result.quantity = shopCartItem.quantity; result.quantity = shopCartItem.quantity;
result.line_price = shopCartItem.line_price;
result.shopCartDict = shopCartItem.shopCartDict; result.shopCartDict = shopCartItem.shopCartDict;
result.product_id = @(shopCartItem.product_id.integerValue); result.product_id = @(shopCartItem.product_id.integerValue);
return result; return result;
......
...@@ -23,8 +23,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -23,8 +23,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nullable, nonatomic, copy) NSString *size; @property (nullable, nonatomic, copy) NSString *size;
@property (nullable, nonatomic, copy) NSString *product_id; @property (nullable, nonatomic, copy) NSString *product_id;
@property (nonatomic) NSInteger quantity; @property (nonatomic) NSInteger quantity;
@property (nonatomic) float price; @property (nonatomic) NSDecimalNumber *price;
@property (nullable, nonatomic, retain) NSDictionary *shopCartDict; @property (nullable, nonatomic, retain) NSDictionary *shopCartDict;
@property (nullable, nonatomic) NSDecimalNumber *line_price;
@end @end
......
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
@property (nullable, nonatomic, copy) NSString *size; @property (nullable, nonatomic, copy) NSString *size;
@property (nullable, nonatomic, strong) NSNumber *product_id; @property (nullable, nonatomic, strong) NSNumber *product_id;
@property (nonatomic) NSInteger quantity; @property (nonatomic) NSInteger quantity;
@property (nonatomic) float price; @property (nullable, nonatomic, strong) NSDecimalNumber *price;
@property (nullable, nonatomic, strong) NSDecimalNumber *line_price;
@property (nullable, nonatomic, retain) NSDictionary *shopCartDict; @property (nullable, nonatomic, retain) NSDictionary *shopCartDict;
- (NSString *_Nullable) totalPrice;
@end @end
...@@ -7,7 +7,15 @@ ...@@ -7,7 +7,15 @@
// //
#import "KWMShopCartModel.h" #import "KWMShopCartModel.h"
#import "KWMCurrencyUtil.h"
@implementation KWMShopCartModel @implementation KWMShopCartModel
- (NSString *)totalPrice {
if (self.line_price) {
return [[KWMCurrencyUtil sharedInstance] priceFormattedByCurrencyCode:self.line_price];
}
return [[KWMCurrencyUtil sharedInstance] priceFormatted:[self.price.priceValue decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithString:@(self.quantity).stringValue]]];
}
@end @end
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="12141" systemVersion="16E195" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier=""> <model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="12141" systemVersion="16F73" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<entity name="KWMShopCartItem" representedClassName="KWMShopCartItem" syncable="YES"> <entity name="KWMShopCartItem" representedClassName="KWMShopCartItem" syncable="YES">
<attribute name="brand" optional="YES" attributeType="String" syncable="YES"/> <attribute name="brand" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="identifier" optional="YES" attributeType="String" syncable="YES"/> <attribute name="identifier" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="imageStr" optional="YES" attributeType="String" syncable="YES"/> <attribute name="imageStr" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="line_price" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/>
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/> <attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="price" optional="YES" attributeType="Float" defaultValueString="0.0" usesScalarValueType="YES" syncable="YES"/> <attribute name="price" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/>
<attribute name="product_id" optional="YES" attributeType="String" syncable="YES"/> <attribute name="product_id" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="quantity" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/> <attribute name="quantity" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="shopCartDict" optional="YES" attributeType="Transformable" syncable="YES"/> <attribute name="shopCartDict" optional="YES" attributeType="Transformable" syncable="YES"/>
<attribute name="size" optional="YES" attributeType="String" syncable="YES"/> <attribute name="size" optional="YES" attributeType="String" syncable="YES"/>
</entity> </entity>
<elements> <elements>
<element name="KWMShopCartItem" positionX="-63" positionY="-18" width="128" height="180"/> <element name="KWMShopCartItem" positionX="-63" positionY="-18" width="128" height="195"/>
</elements> </elements>
</model> </model>
\ No newline at end of file
//
// BUYProductVariant+Currency.h
// iCemarose
//
// Created by lee on 2017/6/14.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <Mobile-Buy-SDK/Buy/BUYProductVariant.h>
@interface BUYProductVariant (Currency)
- (NSDecimalNumber *) compareAtPriceValue;
- (NSString *) compareAtPriceFormatted;
- (NSDecimalNumber *) priceValue;
- (NSString *) priceFormatted;
@end
//
// BUYProductVariant+Currency.m
// iCemarose
//
// Created by lee on 2017/6/14.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "BUYProductVariant+Currency.h"
#import "KWMUserDao.h"
#import <RegexKitLite/RegexKitLite.h>
#import "KWMCurrencyUtil.h"
@implementation BUYProductVariant (Currency)
- (NSString *)compareAtPriceFormatted {
return [[KWMCurrencyUtil sharedInstance] priceFormattedByCurrencyCode:self.compareAtPrice];
}
- (NSString *)priceFormatted {
return [[KWMCurrencyUtil sharedInstance] priceFormattedByCurrencyCode:self.price];
}
- (NSDecimalNumber *)compareAtPriceValue {
return [[KWMCurrencyUtil sharedInstance] calcPriceByCurrencyCode:self.compareAtPrice];
}
- (NSDecimalNumber *)priceValue {
return [[KWMCurrencyUtil sharedInstance] calcPriceByCurrencyCode:self.price];
}
@end
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
*/ */
@interface KWMUserDao : NSObject @interface KWMUserDao : NSObject
@property (nonatomic, strong) NSString *currencyCode;
+ (KWMUserDao *)shareDao; + (KWMUserDao *)shareDao;
- (BOOL)checkSession; - (BOOL)checkSession;
- (KWMUser *)loginUser; - (KWMUser *)loginUser;
...@@ -26,7 +28,7 @@ ...@@ -26,7 +28,7 @@
- (void)saveUser:(KWMUser *)user; - (void)saveUser:(KWMUser *)user;
- (void)saveExchangeRate:(NSNumber *)exchangeRate; - (void)saveExchangeRate:(NSNumber *)exchangeRate;
- (NSNumber *)exchangeRate; - (NSDecimalNumber *)exchangeRate;
- (void (^)(NSURLSessionDataTask *, KWMRequestResult *))getLoginSuccessCallback:(void (^)(NSURLSessionDataTask *, KWMRequestResult *))callback; - (void (^)(NSURLSessionDataTask *, KWMRequestResult *))getLoginSuccessCallback:(void (^)(NSURLSessionDataTask *, KWMRequestResult *))callback;
......
...@@ -26,6 +26,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -26,6 +26,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
@interface KWMUserDao () @interface KWMUserDao ()
@end @end
@implementation KWMUserDao { @implementation KWMUserDao {
...@@ -40,6 +41,8 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -40,6 +41,8 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
BOOL isLogingChat; BOOL isLogingChat;
} }
@synthesize currencyCode = _currencyCode;
+ (KWMUserDao *)shareDao { + (KWMUserDao *)shareDao {
static KWMUserDao *_userDao = nil; static KWMUserDao *_userDao = nil;
static dispatch_once_t oncePredicate; static dispatch_once_t oncePredicate;
...@@ -209,10 +212,15 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -209,10 +212,15 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
[defaults synchronize]; [defaults synchronize];
} }
- (NSNumber *)exchangeRate { - (NSDecimalNumber *)exchangeRate {
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
NSString *exchageRateString = [defaults objectForKey:kwmKeyExchangeRate]; NSString *exchageRateString = [defaults objectForKey:kwmKeyExchangeRate];
return [KWMStringUtil stringToNumber:exchageRateString]; // NSNumber *rate = [KWMStringUtil stringToNumber:exchageRateString];
// return rate;
if ([KWMStringUtil isEmpty:exchageRateString]) {
return [NSDecimalNumber decimalNumberWithString:ExchangeRateString];
}
return [NSDecimalNumber decimalNumberWithString:exchageRateString];
} }
-(void)saveCollectionCache:(NSArray *)products collectionId:(NSNumber *)collectionId tags:(NSArray *)tags{ -(void)saveCollectionCache:(NSArray *)products collectionId:(NSNumber *)collectionId tags:(NSArray *)tags{
...@@ -429,5 +437,20 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -429,5 +437,20 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
} }
} }
-(NSString *)currencyCode {
if (!_currencyCode) {
_currencyCode = [[NSUserDefaults standardUserDefaults] stringForKey:@"_current_currency_code"];
if (!_currencyCode) {
_currencyCode = [@"zh" isEqualToString:[[NSLocale currentLocale] languageCode]] ? @"CNY" : @"EUR";
}
}
return _currencyCode;
}
-(void)setCurrencyCode:(NSString *)currencyCode {
_currencyCode = currencyCode;
[[NSUserDefaults standardUserDefaults] setObject:currencyCode forKey:@"_current_currency_code"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
@end @end
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
- (void)kwm_clickBackBtn; - (void)kwm_clickBackBtn;
- (void)kwm_HitShopCartBtn; - (void)kwm_HitShopCartBtn;
- (void)kwm_hitSearchBtn;
@end @end
......
...@@ -68,6 +68,10 @@ ...@@ -68,6 +68,10 @@
} }
} }
- (IBAction)onClickSearchBtn:(id)sender {
[self.delegate kwm_hitSearchBtn];
}
- (IBAction)onClickBackBtn:(id)sender { - (IBAction)onClickBackBtn:(id)sender {
NSLog(@"点击了返回按钮"); NSLog(@"点击了返回按钮");
if ([self.delegate respondsToSelector:@selector(kwm_clickBackBtn)]) { if ([self.delegate respondsToSelector:@selector(kwm_clickBackBtn)]) {
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
...@@ -20,14 +23,17 @@ ...@@ -20,14 +23,17 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="w07-X3-TZc"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="w07-X3-TZc">
<rect key="frame" x="0.0" y="0.0" width="375" height="20"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="20" id="I5b-cU-UJp"/> <constraint firstAttribute="height" constant="20" id="I5b-cU-UJp"/>
</constraints> </constraints>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LhU-hy-cgg"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LhU-hy-cgg">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="CAEAMEL" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eLp-Fc-DGP"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="CAEAMEL" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eLp-Fc-DGP">
<rect key="frame" x="50" y="11" width="78" height="22"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="22" id="Bqy-qp-TtK"/> <constraint firstAttribute="height" constant="22" id="Bqy-qp-TtK"/>
<constraint firstAttribute="width" constant="90" id="vmB-ph-xU7"/> <constraint firstAttribute="width" constant="90" id="vmB-ph-xU7"/>
...@@ -42,6 +48,7 @@ ...@@ -42,6 +48,7 @@
</variation> </variation>
</label> </label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jot-my-Skn"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jot-my-Skn">
<rect key="frame" x="321" y="0.0" width="44" height="44"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="44" id="Se9-VU-U3c"/> <constraint firstAttribute="height" constant="44" id="Se9-VU-U3c"/>
<constraint firstAttribute="width" constant="44" id="dQW-nU-NqO"/> <constraint firstAttribute="width" constant="44" id="dQW-nU-NqO"/>
...@@ -52,6 +59,7 @@ ...@@ -52,6 +59,7 @@
</connections> </connections>
</button> </button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qzz-HS-1ka" userLabel="back"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qzz-HS-1ka" userLabel="back">
<rect key="frame" x="0.0" y="7" width="30" height="30"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="30" id="2zo-GE-glc"/> <constraint firstAttribute="width" constant="30" id="2zo-GE-glc"/>
<constraint firstAttribute="height" constant="30" id="dsr-NJ-Brr"/> <constraint firstAttribute="height" constant="30" id="dsr-NJ-Brr"/>
...@@ -62,6 +70,7 @@ ...@@ -62,6 +70,7 @@
</connections> </connections>
</button> </button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ffN-14-C4W"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ffN-14-C4W">
<rect key="frame" x="340" y="17" width="14" height="14"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="14" id="JCv-Vl-bjz"/> <constraint firstAttribute="width" constant="14" id="JCv-Vl-bjz"/>
<constraint firstAttribute="height" constant="14" id="ni4-e6-xAG"/> <constraint firstAttribute="height" constant="14" id="ni4-e6-xAG"/>
...@@ -70,6 +79,17 @@ ...@@ -70,6 +79,17 @@
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PaU-vd-maA">
<rect key="frame" x="269" y="0.0" width="44" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="4KS-bk-nto"/>
<constraint firstAttribute="width" constant="44" id="ulA-Nm-ETK"/>
</constraints>
<state key="normal" image="btn_ nav_search"/>
<connections>
<action selector="onClickSearchBtn:" destination="-1" eventType="touchUpInside" id="FQi-ND-qmV"/>
</connections>
</button>
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
...@@ -78,8 +98,11 @@ ...@@ -78,8 +98,11 @@
<constraint firstItem="eLp-Fc-DGP" firstAttribute="centerY" secondItem="LhU-hy-cgg" secondAttribute="centerY" id="CYF-jt-pNn"/> <constraint firstItem="eLp-Fc-DGP" firstAttribute="centerY" secondItem="LhU-hy-cgg" secondAttribute="centerY" id="CYF-jt-pNn"/>
<constraint firstItem="ffN-14-C4W" firstAttribute="bottom" secondItem="jot-my-Skn" secondAttribute="bottom" constant="-13" id="FCE-d3-9F6"/> <constraint firstItem="ffN-14-C4W" firstAttribute="bottom" secondItem="jot-my-Skn" secondAttribute="bottom" constant="-13" id="FCE-d3-9F6"/>
<constraint firstItem="Qzz-HS-1ka" firstAttribute="centerY" secondItem="LhU-hy-cgg" secondAttribute="centerY" id="VW7-ru-rft"/> <constraint firstItem="Qzz-HS-1ka" firstAttribute="centerY" secondItem="LhU-hy-cgg" secondAttribute="centerY" id="VW7-ru-rft"/>
<constraint firstItem="jot-my-Skn" firstAttribute="leading" secondItem="PaU-vd-maA" secondAttribute="trailing" constant="8" id="d18-gM-JWM"/>
<constraint firstItem="ffN-14-C4W" firstAttribute="trailing" secondItem="jot-my-Skn" secondAttribute="trailing" constant="-11" id="ddE-oR-ylC"/> <constraint firstItem="ffN-14-C4W" firstAttribute="trailing" secondItem="jot-my-Skn" secondAttribute="trailing" constant="-11" id="ddE-oR-ylC"/>
<constraint firstAttribute="trailing" secondItem="jot-my-Skn" secondAttribute="trailing" constant="10" id="ewH-at-Gll"/> <constraint firstAttribute="trailing" secondItem="jot-my-Skn" secondAttribute="trailing" constant="10" id="ewH-at-Gll"/>
<constraint firstItem="jot-my-Skn" firstAttribute="centerY" secondItem="PaU-vd-maA" secondAttribute="centerY" id="sX1-bj-cl2"/>
<constraint firstItem="jot-my-Skn" firstAttribute="centerY" secondItem="PaU-vd-maA" secondAttribute="centerY" id="x6e-HO-bFW"/>
<constraint firstItem="Qzz-HS-1ka" firstAttribute="leading" secondItem="LhU-hy-cgg" secondAttribute="leading" id="zaO-mI-Gl2"/> <constraint firstItem="Qzz-HS-1ka" firstAttribute="leading" secondItem="LhU-hy-cgg" secondAttribute="leading" id="zaO-mI-Gl2"/>
</constraints> </constraints>
</view> </view>
...@@ -106,6 +129,7 @@ ...@@ -106,6 +129,7 @@
</view> </view>
</objects> </objects>
<resources> <resources>
<image name="btn_ nav_search" width="22" height="22"/>
<image name="btn_ nav_shop cart" width="21" height="22"/> <image name="btn_ nav_shop cart" width="21" height="22"/>
<image name="btn_nav_back" width="10" height="20"/> <image name="btn_nav_back" width="10" height="20"/>
</resources> </resources>
......
...@@ -196,7 +196,8 @@ ...@@ -196,7 +196,8 @@
compareAtPrice = @(0); compareAtPrice = @(0);
} }
if( compareAtPrice.integerValue!=0 ){ if( compareAtPrice.integerValue!=0 ){
NSString *oldString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:compareAtPrice]]; // NSString *oldString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:compareAtPrice]];
NSString *oldString = compareAtPrice.priceValueFormatted;
//中划线 //中划线
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:oldString attributes:attribtDic]; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:oldString attributes:attribtDic];
...@@ -205,22 +206,26 @@ ...@@ -205,22 +206,26 @@
self.priceLeft.constant = -30; self.priceLeft.constant = -30;
self.lbDiscountLeft.hidden = NO; self.lbDiscountLeft.hidden = NO;
self.lbPriceLeft.attributedText = attribtStr; self.lbPriceLeft.attributedText = attribtStr;
self.lbDiscountLeft.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:price]]; // self.lbDiscountLeft.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:price]];
self.lbDiscountLeft.text = price.priceValueFormatted;
}else{ }else{
self.priceRight.constant = -30; self.priceRight.constant = -30;
self.lbDiscountRight.hidden = NO; self.lbDiscountRight.hidden = NO;
self.lbPriceRight.attributedText = attribtStr; self.lbPriceRight.attributedText = attribtStr;
self.lbDiscountRight.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:price]]; // self.lbDiscountRight.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:price]];
self.lbDiscountRight.text = price.priceValueFormatted;
} }
}else{ }else{
if (isLeft) { if (isLeft) {
self.priceLeft.constant = 0; self.priceLeft.constant = 0;
self.lbDiscountLeft.hidden = YES; self.lbDiscountLeft.hidden = YES;
self.lbPriceLeft.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring: price]]; // self.lbPriceLeft.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring: price]];
self.lbPriceLeft.text = price.priceValueFormatted;
}else{ }else{
self.priceRight.constant = 0; self.priceRight.constant = 0;
self.lbDiscountRight.hidden = YES; self.lbDiscountRight.hidden = YES;
self.lbPriceRight.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:price]]; // self.lbPriceRight.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:price]];
self.lbPriceRight.text = price.priceValueFormatted;
} }
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
@protocol KWMCarCountViewDelegate <NSObject> @protocol KWMCarCountViewDelegate <NSObject>
- (void)kwm_touchShopCartBtn; - (void)kwm_touchShopCartBtn;
- (void)kwm_touchSearchBtn;
@end @end
@interface KWMCarCountView : UIView @interface KWMCarCountView : UIView
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
@property (weak, nonatomic) id<KWMCarCountViewDelegate> delegate; @property (weak, nonatomic) id<KWMCarCountViewDelegate> delegate;
- (IBAction)onClickShopCartBtn:(id)sender; - (IBAction)onClickShopCartBtn:(id)sender;
- (IBAction)onClickSearchBtn:(id)sender;
@end @end
...@@ -63,4 +63,8 @@ ...@@ -63,4 +63,8 @@
[self.delegate kwm_touchShopCartBtn]; [self.delegate kwm_touchShopCartBtn];
} }
} }
- (void)onClickSearchBtn:(id)sender {
[self.delegate kwm_touchSearchBtn];
}
@end @end
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
...@@ -19,14 +22,17 @@ ...@@ -19,14 +22,17 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jaQ-9K-pwB"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jaQ-9K-pwB">
<rect key="frame" x="0.0" y="0.0" width="375" height="20"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="20" id="1db-NU-cyT"/> <constraint firstAttribute="height" constant="20" id="1db-NU-cyT"/>
</constraints> </constraints>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="k5I-0u-ww6"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="k5I-0u-ww6">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oya-px-46r"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oya-px-46r">
<rect key="frame" x="321" y="0.0" width="44" height="44"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="44" id="EuD-IV-fdo"/> <constraint firstAttribute="width" constant="44" id="EuD-IV-fdo"/>
<constraint firstAttribute="height" constant="44" id="pd0-mz-6I3"/> <constraint firstAttribute="height" constant="44" id="pd0-mz-6I3"/>
...@@ -37,6 +43,7 @@ ...@@ -37,6 +43,7 @@
</connections> </connections>
</button> </button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JyV-gT-W6k"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JyV-gT-W6k">
<rect key="frame" x="340" y="17" width="14" height="14"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="14" id="6iD-hl-uNU"/> <constraint firstAttribute="height" constant="14" id="6iD-hl-uNU"/>
<constraint firstAttribute="width" constant="14" id="WBS-Yd-LKE"/> <constraint firstAttribute="width" constant="14" id="WBS-Yd-LKE"/>
...@@ -46,15 +53,29 @@ ...@@ -46,15 +53,29 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="品牌" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Rt2-0b-5Qg"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="品牌" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Rt2-0b-5Qg">
<rect key="frame" x="171.5" y="12.5" width="32" height="19"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="16"/> <fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="16"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XCu-Vw-UbS">
<rect key="frame" x="269" y="0.0" width="44" height="44"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="PPp-fS-VbO"/>
<constraint firstAttribute="height" constant="44" id="QxY-Op-FL8"/>
</constraints>
<state key="normal" image="btn_ nav_search"/>
<connections>
<action selector="onClickSearchBtn:" destination="-1" eventType="touchUpInside" id="NSH-6w-dmi"/>
</connections>
</button>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstItem="JyV-gT-W6k" firstAttribute="trailing" secondItem="oya-px-46r" secondAttribute="trailing" constant="-11" id="1ix-zq-Mor"/> <constraint firstItem="JyV-gT-W6k" firstAttribute="trailing" secondItem="oya-px-46r" secondAttribute="trailing" constant="-11" id="1ix-zq-Mor"/>
<constraint firstItem="oya-px-46r" firstAttribute="centerY" secondItem="XCu-Vw-UbS" secondAttribute="centerY" id="3Ys-1m-sUe"/>
<constraint firstAttribute="bottom" secondItem="oya-px-46r" secondAttribute="bottom" id="FAW-tW-q9a"/> <constraint firstAttribute="bottom" secondItem="oya-px-46r" secondAttribute="bottom" id="FAW-tW-q9a"/>
<constraint firstItem="oya-px-46r" firstAttribute="leading" secondItem="XCu-Vw-UbS" secondAttribute="trailing" constant="8" id="IsE-2T-b1e"/>
<constraint firstItem="Rt2-0b-5Qg" firstAttribute="centerY" secondItem="k5I-0u-ww6" secondAttribute="centerY" id="M7w-JU-b4j"/> <constraint firstItem="Rt2-0b-5Qg" firstAttribute="centerY" secondItem="k5I-0u-ww6" secondAttribute="centerY" id="M7w-JU-b4j"/>
<constraint firstItem="Rt2-0b-5Qg" firstAttribute="centerX" secondItem="k5I-0u-ww6" secondAttribute="centerX" id="k5U-pP-UxB"/> <constraint firstItem="Rt2-0b-5Qg" firstAttribute="centerX" secondItem="k5I-0u-ww6" secondAttribute="centerX" id="k5U-pP-UxB"/>
<constraint firstAttribute="height" constant="44" id="p0A-9X-4Pb"/> <constraint firstAttribute="height" constant="44" id="p0A-9X-4Pb"/>
...@@ -79,6 +100,7 @@ ...@@ -79,6 +100,7 @@
</view> </view>
</objects> </objects>
<resources> <resources>
<image name="btn_ nav_search" width="22" height="22"/>
<image name="btn_ nav_shop cart" width="21" height="22"/> <image name="btn_ nav_shop cart" width="21" height="22"/>
</resources> </resources>
</document> </document>
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
- (IBAction)onClickSearchBtn:(id)sender; - (IBAction)onClickSearchBtn:(id)sender;
- (IBAction)onClickACancelBtn:(id)sender; - (IBAction)onClickACancelBtn:(id)sender;
- (IBAction)onClickBackBtn:(id)sender; - (IBAction)onClickBackBtn:(id)sender;
- (IBAction)tfValueChanged:(id)sender; - (IBAction)tfValueChanged:(id)sender;
@end @end
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#import "KWMFilterVC.h" #import "KWMFilterVC.h"
#import "KWMShoppingCart.h" #import "KWMShoppingCart.h"
#import <RXCollections/RXCollection.h> #import <RXCollections/RXCollection.h>
#import "KWMSearchFeedbackVC.h"
@interface KWMBrandCaramelVC ()<UITableViewDelegate,UITableViewDataSource,KWMBrandCaramelCellDelegate> @interface KWMBrandCaramelVC ()<UITableViewDelegate,UITableViewDataSource,KWMBrandCaramelCellDelegate>
@property (nonatomic) KWMBarandSelectView *barandSelectView; @property (nonatomic) KWMBarandSelectView *barandSelectView;
...@@ -199,6 +200,12 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -199,6 +200,12 @@ static NSString *idStr = @"KWMBrandCaramelCell";
[self.navigationController pushViewController:shopCartVC animated:YES]; [self.navigationController pushViewController:shopCartVC animated:YES];
} }
- (void)kwm_hitSearchBtn {
KWMSearchFeedbackVC *vc = (KWMSearchFeedbackVC *)[KWMBaseVC findControllerBy:[KWMSearchFeedbackVC kwmTag] fromStoryboard:@"New"];
// vc.searchText = @"";
[self.navigationController pushViewController:vc animated:YES];
}
#pragma mark -- KWMFilterDelegate #pragma mark -- KWMFilterDelegate
-(void)kwm_onFilterFinish:(KWMFilterView *)filterView{ -(void)kwm_onFilterFinish:(KWMFilterView *)filterView{
self.filterView.hidden = YES; self.filterView.hidden = YES;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#import "KWMBrandsTypeModel.h" #import "KWMBrandsTypeModel.h"
#import "UIColor+SAMAdditions.h" #import "UIColor+SAMAdditions.h"
#import "KWMShoppingCart.h" #import "KWMShoppingCart.h"
#import "KWMSearchFeedbackVC.h"
@interface KWMBrandVC ()<KWMCarCountViewDelegate> @interface KWMBrandVC ()<KWMCarCountViewDelegate>
...@@ -124,6 +125,12 @@ static NSString *cellId = @"KWMBrandCell"; ...@@ -124,6 +125,12 @@ static NSString *cellId = @"KWMBrandCell";
[self.navigationController pushViewController:ShopCartVC animated:YES]; [self.navigationController pushViewController:ShopCartVC animated:YES];
} }
- (void)kwm_touchSearchBtn {
KWMSearchFeedbackVC *vc = (KWMSearchFeedbackVC *)[KWMBaseVC findControllerBy:[KWMSearchFeedbackVC kwmTag] fromStoryboard:@"New"];
// vc.searchText = @"";
[self.navigationController pushViewController:vc animated:YES];
}
#pragma mark -- UICollectionViewDataSource #pragma mark -- UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1; return 1;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#import "UIImageView+WebCache.h" #import "UIImageView+WebCache.h"
#import "UIColor+SAMAdditions.h" #import "UIColor+SAMAdditions.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
#import "KWMCurrencyUtil.h"
@implementation KWMOrderCell{ @implementation KWMOrderCell{
BOOL isShow; BOOL isShow;
...@@ -54,7 +54,8 @@ ...@@ -54,7 +54,8 @@
if (order != nil) { if (order != nil) {
_order = order; _order = order;
_lbOrderNum.text = [NSString stringWithFormat:@"订单 %@",order.identifier ? order.identifier.stringValue:@""]; _lbOrderNum.text = [NSString stringWithFormat:@"订单 %@",order.identifier ? order.identifier.stringValue:@""];
_lbTotalPrice.text = [NSString stringWithFormat:@"%@",[KWMStringUtil getEUR2CNYstring:order.totalPrice]]; // _lbTotalPrice.text = [NSString stringWithFormat:@"%@",[KWMStringUtil getEUR2CNYstring:order.totalPrice]];
_lbTotalPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormattedByCurrencyCode:order.totalPrice];
__block NSInteger fulfilledCount = 0; __block NSInteger fulfilledCount = 0;
[order.lineItems enumerateObjectsUsingBlock:^(BUYLineItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { [order.lineItems enumerateObjectsUsingBlock:^(BUYLineItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
...@@ -62,7 +63,6 @@ ...@@ -62,7 +63,6 @@
fulfilledCount += 1; fulfilledCount += 1;
} }
}]; }];
// TODO: 加入取消订单的状态
NSString *orderStatus = order.cancelled ? @"已取消" : fulfilledCount == 0 ? @"待发货" : fulfilledCount == order.lineItems.count ? @"已发货" : @"部分发货"; NSString *orderStatus = order.cancelled ? @"已取消" : fulfilledCount == 0 ? @"待发货" : fulfilledCount == order.lineItems.count ? @"已发货" : @"部分发货";
self.lbOrderStatus.text = orderStatus; self.lbOrderStatus.text = orderStatus;
} }
...@@ -71,7 +71,8 @@ ...@@ -71,7 +71,8 @@
- (void)setLineItem:(BUYLineItem *)lineItem{ - (void)setLineItem:(BUYLineItem *)lineItem{
if (lineItem != nil) { if (lineItem != nil) {
_lineItem = lineItem; _lineItem = lineItem;
self.lbPrice.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:lineItem.price]]; // self.lbPrice.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:lineItem.price]];
self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormattedByCurrencyCode:lineItem.price];
self.lbName.text = lineItem.title; self.lbName.text = lineItem.title;
self.lbSize.text = [NSString stringWithFormat:@"x%@/%@",lineItem.quantity,lineItem.variantTitle]; self.lbSize.text = [NSString stringWithFormat:@"x%@/%@",lineItem.quantity,lineItem.variantTitle];
} }
......
//
// KWMSelectCurrencyCell.h
// iCemarose
//
// Created by lee on 2017/6/16.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface KWMSelectCurrencyCell : UITableViewCell
- (void) fillData:(NSString *) name;
@end
//
// KWMSelectCurrencyCell.m
// iCemarose
//
// Created by lee on 2017/6/16.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMSelectCurrencyCell.h"
@interface KWMSelectCurrencyCell ()
@property (nonatomic, weak) IBOutlet UILabel *title;
@end
@implementation KWMSelectCurrencyCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)fillData:(NSString *)name {
self.title.text = name;
}
@end
...@@ -81,6 +81,10 @@ ...@@ -81,6 +81,10 @@
self.title = @"我的"; self.title = @"我的";
} }
-(IBAction)onClickCurrency:(id)sender {
[self performSegueWithIdentifier:@"MeToCurrency" sender:nil];
}
-(void)onClickOrder:(id)sender{ -(void)onClickOrder:(id)sender{
if (!_user.status) { if (!_user.status) {
//登录 //登录
......
//
// KWMSelectCurrencyVC.h
// iCemarose
//
// Created by lee on 2017/6/16.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface KWMSelectCurrencyVC : UITableViewController
@end
//
// KWMSelectCurrencyVC.m
// iCemarose
//
// Created by lee on 2017/6/16.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMSelectCurrencyVC.h"
#import "KWMSelectCurrencyCell.h"
#import "KWMUserDao.h"
@interface KWMSelectCurrencyVC ()
@property (nonatomic, strong) NSArray *titles;
@property (nonatomic, strong) NSArray *codes;
@end
@implementation KWMSelectCurrencyVC
- (void)viewDidLoad {
[super viewDidLoad];
_titles = @[@"人民币",@"Euro"];
_codes = @[@"CNY",@"EUR"];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.titles.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
KWMSelectCurrencyCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CurrencyCell" forIndexPath:indexPath];
[cell fillData:self.titles[indexPath.row]];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[[KWMUserDao shareDao] setCurrencyCode:self.codes[indexPath.row]];
[self.navigationController popViewControllerAnimated:YES];
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "Buy/Buy.h" #import "Buy/Buy.h"
@interface KWMCollectionCell : UICollectionViewCell @interface KWMCollectionCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *ivCollectionCell; @property (weak, nonatomic) IBOutlet UIImageView *ivCollectionCell;
@property (weak, nonatomic) IBOutlet UILabel *lbBrand; @property (weak, nonatomic) IBOutlet UILabel *lbBrand;
@property (weak, nonatomic) IBOutlet UILabel *lbDiscount; @property (weak, nonatomic) IBOutlet UILabel *lbDiscount;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "UIImageView+WebCache.h" #import "UIImageView+WebCache.h"
#import "KWMImageUtil.h" #import "KWMImageUtil.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
#import "BUYProductVariant+Currency.h"
@implementation KWMCollectionCell @implementation KWMCollectionCell
...@@ -39,7 +40,8 @@ ...@@ -39,7 +40,8 @@
NSString *priceString,*discountStr; NSString *priceString,*discountStr;
if (productVariant.compareAtPrice) { if (productVariant.compareAtPrice) {
priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]]; // priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]];
priceString = productVariant.compareAtPriceFormatted;
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.lbPrice.attributedText = attribtStr; self.lbPrice.attributedText = attribtStr;
...@@ -48,8 +50,8 @@ ...@@ -48,8 +50,8 @@
self.discountLeft.constant = -28; self.discountLeft.constant = -28;
self.lbDiscount.textAlignment = NSTextAlignmentCenter; self.lbDiscount.textAlignment = NSTextAlignmentCenter;
} }
discountStr = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.price]]; // discountStr = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.price]];
discountStr = productVariant.priceFormatted;
self.lbDiscount.text = discountStr; self.lbDiscount.text = discountStr;
}else{ }else{
self.lbBrand.text = @""; self.lbBrand.text = @"";
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
@property (weak, nonatomic) id<KWMProductDetailViewDelegate>delegate; @property (weak, nonatomic) id<KWMProductDetailViewDelegate>delegate;
@property (weak, nonatomic) IBOutlet UIButton *sizeGuide;
-(void)setData:(BUYProduct *)product; -(void)setData:(BUYProduct *)product;
@end @end
...@@ -186,9 +186,11 @@ ...@@ -186,9 +186,11 @@
BUYProductVariant *productVariant= product.variants.firstObject; BUYProductVariant *productVariant= product.variants.firstObject;
NSAttributedString *detailAttr = [[NSAttributedString alloc] initWithData:[self.product.htmlDescription dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil]; NSAttributedString *detailAttr = [[NSAttributedString alloc] initWithData:[self.product.htmlDescription dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
self.lbDetail.attributedText = detailAttr; self.lbDetail.attributedText = detailAttr;
self.lbPrice.text = [KWMStringUtil getEUR2CNYstring:productVariant.price]; // self.lbPrice.text = [KWMStringUtil getEUR2CNYstring:productVariant.price];
self.lbPrice.text = productVariant.price.priceValueFormatted;
if (productVariant.compareAtPrice) { if (productVariant.compareAtPrice) {
NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]]; // NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]];
NSString *priceString = productVariant.compareAtPrice.priceValueFormatted;
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;
...@@ -196,12 +198,12 @@ ...@@ -196,12 +198,12 @@
self.lbOldPrice.hidden = YES; self.lbOldPrice.hidden = YES;
} }
UITapGestureRecognizer *priceTap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickPrice:)]; // 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.lbUnit addGestureRecognizer:priceTap1];
[self.lbPrice addGestureRecognizer:priceTap2]; // [self.lbPrice addGestureRecognizer:priceTap2];
[self.lbOldPrice addGestureRecognizer:priceTap3]; // [self.lbOldPrice addGestureRecognizer:priceTap3];
self.lbUnit.userInteractionEnabled = YES; self.lbUnit.userInteractionEnabled = YES;
self.lbPrice.userInteractionEnabled = YES; self.lbPrice.userInteractionEnabled = YES;
self.lbOldPrice.userInteractionEnabled = YES; self.lbOldPrice.userInteractionEnabled = YES;
...@@ -227,9 +229,11 @@ ...@@ -227,9 +229,11 @@
BUYProductVariant *productVariant= self.product.variants.firstObject; BUYProductVariant *productVariant= self.product.variants.firstObject;
if(self.isShowCNY){ if(self.isShowCNY){
self.lbUnit.text = @"¥"; self.lbUnit.text = @"¥";
self.lbPrice.text = [KWMStringUtil getEUR2CNYstring:productVariant.price]; // self.lbPrice.text = [KWMStringUtil getEUR2CNYstring:productVariant.price];
self.lbPrice.text = productVariant.price.priceValueFormatted;
if (productVariant.compareAtPrice) { if (productVariant.compareAtPrice) {
NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]]; // NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]];
NSString *priceString = productVariant.compareAtPrice.priceValueFormatted;
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;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<outlet property="lbPrice" destination="gpT-Sg-ghu" id="FGd-AA-Yiv"/> <outlet property="lbPrice" destination="gpT-Sg-ghu" id="FGd-AA-Yiv"/>
<outlet property="lbUnit" destination="wfT-JC-g9d" id="MSn-kd-aQ2"/> <outlet property="lbUnit" destination="wfT-JC-g9d" id="MSn-kd-aQ2"/>
<outlet property="pageControl" destination="M6v-TN-2WE" id="QPe-TI-LdG"/> <outlet property="pageControl" destination="M6v-TN-2WE" id="QPe-TI-LdG"/>
<outlet property="sizeGuide" destination="EM9-Ay-Qxk" id="4Dh-eU-qhb"/>
<outlet property="vView" destination="iN0-l3-epB" id="TQD-W9-jEg"/> <outlet property="vView" destination="iN0-l3-epB" id="TQD-W9-jEg"/>
</connections> </connections>
</placeholder> </placeholder>
...@@ -79,23 +80,20 @@ ...@@ -79,23 +80,20 @@
<color key="textColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wfT-JC-g9d"> <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wfT-JC-g9d">
<rect key="frame" x="21" y="66" width="9" height="21"/> <rect key="frame" x="21" y="66" width="9" height="21"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="15"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="15"/>
<color key="textColor" red="0.94509803921568625" green="0.5725490196078431" blue="0.60392156862745094" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.94509803921568625" green="0.5725490196078431" blue="0.60392156862745094" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gpT-Sg-ghu"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gpT-Sg-ghu">
<rect key="frame" x="40" y="62" width="80.5" height="28"/> <rect key="frame" x="20" y="62" width="27" height="28"/>
<constraints>
<constraint firstAttribute="width" constant="80" id="0Pv-kq-UND"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="20"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="20"/>
<color key="textColor" red="0.94509803921568625" green="0.5725490196078431" blue="0.60392156862745094" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.94509803921568625" green="0.5725490196078431" blue="0.60392156862745094" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥ " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Mql-V1-hiE"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥ " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Mql-V1-hiE">
<rect key="frame" x="120.5" y="68.5" width="25.5" height="18.5"/> <rect key="frame" x="55" y="68.5" width="25.5" height="18.5"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/>
<color key="textColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
...@@ -140,7 +138,7 @@ ...@@ -140,7 +138,7 @@
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="gpT-Sg-ghu" firstAttribute="bottom" secondItem="wfT-JC-g9d" secondAttribute="bottom" constant="3" id="0gt-hJ-gW7"/> <constraint firstItem="gpT-Sg-ghu" firstAttribute="bottom" secondItem="wfT-JC-g9d" secondAttribute="bottom" constant="3" id="0gt-hJ-gW7"/>
<constraint firstItem="Mql-V1-hiE" firstAttribute="leading" secondItem="gpT-Sg-ghu" secondAttribute="trailing" id="2kJ-k6-7uE"/> <constraint firstItem="Mql-V1-hiE" firstAttribute="leading" secondItem="gpT-Sg-ghu" secondAttribute="trailing" constant="8" id="2kJ-k6-7uE"/>
<constraint firstAttribute="trailing" secondItem="DbC-Os-2e9" secondAttribute="trailing" constant="19" id="3Gy-6z-Jli"/> <constraint firstAttribute="trailing" secondItem="DbC-Os-2e9" secondAttribute="trailing" constant="19" id="3Gy-6z-Jli"/>
<constraint firstAttribute="trailing" secondItem="s6N-a3-C4Z" secondAttribute="trailing" constant="21" id="BH6-4A-Psp"/> <constraint firstAttribute="trailing" secondItem="s6N-a3-C4Z" secondAttribute="trailing" constant="21" id="BH6-4A-Psp"/>
<constraint firstItem="asI-Rf-ZXG" firstAttribute="centerY" secondItem="EM9-Ay-Qxk" secondAttribute="centerY" id="Bx2-7F-7xQ"/> <constraint firstItem="asI-Rf-ZXG" firstAttribute="centerY" secondItem="EM9-Ay-Qxk" secondAttribute="centerY" id="Bx2-7F-7xQ"/>
...@@ -156,7 +154,7 @@ ...@@ -156,7 +154,7 @@
<constraint firstItem="wfT-JC-g9d" firstAttribute="top" secondItem="SQm-rY-OyA" secondAttribute="bottom" constant="7.5" id="gcI-jU-lhJ"/> <constraint firstItem="wfT-JC-g9d" firstAttribute="top" secondItem="SQm-rY-OyA" secondAttribute="bottom" constant="7.5" id="gcI-jU-lhJ"/>
<constraint firstAttribute="height" constant="130" id="nLX-8H-mni"/> <constraint firstAttribute="height" constant="130" id="nLX-8H-mni"/>
<constraint firstItem="SQm-rY-OyA" firstAttribute="leading" secondItem="iJa-Oj-Sd2" secondAttribute="leading" constant="21" id="njb-yV-RRh"/> <constraint firstItem="SQm-rY-OyA" firstAttribute="leading" secondItem="iJa-Oj-Sd2" secondAttribute="leading" constant="21" id="njb-yV-RRh"/>
<constraint firstItem="gpT-Sg-ghu" firstAttribute="leading" secondItem="wfT-JC-g9d" secondAttribute="trailing" constant="10" id="o9j-pp-GRZ"/> <constraint firstItem="gpT-Sg-ghu" firstAttribute="leading" secondItem="wfT-JC-g9d" secondAttribute="trailing" constant="-10" id="o9j-pp-GRZ"/>
<constraint firstItem="asI-Rf-ZXG" firstAttribute="centerY" secondItem="RNK-se-cgR" secondAttribute="centerY" id="pfI-QQ-uu0"/> <constraint firstItem="asI-Rf-ZXG" firstAttribute="centerY" secondItem="RNK-se-cgR" secondAttribute="centerY" id="pfI-QQ-uu0"/>
<constraint firstItem="RNK-se-cgR" firstAttribute="top" secondItem="gpT-Sg-ghu" secondAttribute="bottom" constant="8" id="pjQ-9v-2rS"/> <constraint firstItem="RNK-se-cgR" firstAttribute="top" secondItem="gpT-Sg-ghu" secondAttribute="bottom" constant="8" id="pjQ-9v-2rS"/>
<constraint firstItem="EM9-Ay-Qxk" firstAttribute="leading" secondItem="iJa-Oj-Sd2" secondAttribute="leading" constant="21" id="rJ1-DF-mLV"/> <constraint firstItem="EM9-Ay-Qxk" firstAttribute="leading" secondItem="iJa-Oj-Sd2" secondAttribute="leading" constant="21" id="rJ1-DF-mLV"/>
......
...@@ -100,6 +100,7 @@ static NSString * idStr = @"KWMNewGoodsCell"; ...@@ -100,6 +100,7 @@ static NSString * idStr = @"KWMNewGoodsCell";
} }
[_searchBar resumeView]; [_searchBar resumeView];
_vBackground.hidden = YES; _vBackground.hidden = YES;
[self.tbvNewGoods reloadData];
} }
- (void)viewWillDisappear:(BOOL)animated{ - (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated]; [super viewWillDisappear:animated];
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#import <TOWebViewController/TOWebViewController.h> #import <TOWebViewController/TOWebViewController.h>
#import <AFNetworking/AFNetworking.h> #import <AFNetworking/AFNetworking.h>
#import <TOWebViewController/NJKWebViewProgress.h> #import <TOWebViewController/NJKWebViewProgress.h>
#import <PPNetworkHelper/PPNetworkHelper.h>
@interface KWMProductDetailVC ()<KWMBottomViewDelegate,KWMProductDetailViewDelegate,KWMSelectSizeVCDelegate,UIScrollViewDelegate> @interface KWMProductDetailVC ()<KWMBottomViewDelegate,KWMProductDetailViewDelegate,KWMSelectSizeVCDelegate,UIScrollViewDelegate>
...@@ -41,6 +42,8 @@ ...@@ -41,6 +42,8 @@
@property (nonatomic) BUYCollection *collectionSameBrand; @property (nonatomic) BUYCollection *collectionSameBrand;
@property (nonatomic) NSString *typeTag;
@property (weak, nonatomic) IBOutlet UIButton *btnShopCart; @property (weak, nonatomic) IBOutlet UIButton *btnShopCart;
@property (weak, nonatomic) IBOutlet UIButton *btnShare; @property (weak, nonatomic) IBOutlet UIButton *btnShare;
...@@ -64,6 +67,16 @@ ...@@ -64,6 +67,16 @@
if(self.product && self.product.identifier && !self.product.JSONDictionary){ if(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"];
for (NSString *tag in self.product.tags) {
if ([types containsObject:tag.lowercaseString]) {
self.typeTag = tag.lowercaseString;
break;
}
}
if (!self.typeTag) {
self.productDetailView.sizeGuide.hidden = YES;
}
} }
- (BOOL)prefersStatusBarHidden { - (BOOL)prefersStatusBarHidden {
...@@ -110,41 +123,61 @@ ...@@ -110,41 +123,61 @@
- (void)kwm_onClickSizeGuide { - (void)kwm_onClickSizeGuide {
NSString *brand = [self.product.vendor stringByReplacingOccurrencesOfRegex:@"\\s*\\W\\s*" withString:@"-"].lowercaseString; NSString *brand = [self.product.vendor stringByReplacingOccurrencesOfRegex:@"\\s*\\W\\s*" withString:@"-"].lowercaseString;
NSString *type = @"";
NSArray *types = @[@"baby",@"girls",@"boys",@"shoes"];
for (NSString *tag in self.product.tags) {
if ([types containsObject:tag.lowercaseString]) {
type = tag.lowercaseString;
break;
}
}
// NSString *url= [NSString stringWithFormat:@"https://cemarose.myshopify.com/pages/%@-size-guide-%@",brand,type];
NSString *baseUrl = @"http://www.cemarose.cn/pages/"; NSString *baseUrl = @"http://www.cemarose.cn/pages/";
NSString *url= [NSString stringWithFormat:@"%@%@-size-guide-%@",baseUrl,brand,type]; NSString *url= [NSString stringWithFormat:@"%@%@-size-guide-%@",baseUrl,brand,self.typeTag];
NSLog(@"size guide url: %@",url);
// TOWebViewController *wv = [[TOWebViewController alloc] initWithURLString:url]; // TOWebViewController *wv = [[TOWebViewController alloc] initWithURLString:url];
TOWebViewController *wv = [[TOWebViewController alloc] init]; TOWebViewController *wv = [[TOWebViewController alloc] init];
__unused id _ = wv.view;
wv.showPageTitles = NO; wv.showPageTitles = NO;
wv.title = @"Size Guide"; wv.title = @"Size Guide";
wv.navigationButtonsHidden = YES; wv.navigationButtonsHidden = YES;
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; // AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
// manager.responseSerializer = [AFXMLParserResponseSerializer serializer]; //// manager.responseSerializer = [AFXMLParserResponseSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer]; // manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil]; // manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
[manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) { // [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
// NJKWebViewProgress *wvp = [vc valueForKeyPath:@"progressManager"]; //// NJKWebViewProgress *wvp = [vc valueForKeyPath:@"progressManager"];
// [wvp.progressDelegate webViewProgress:wvp updateProgress:downloadProgress.fractionCompleted]; //// [wvp.progressDelegate webViewProgress:wvp updateProgress:downloadProgress.fractionCompleted];
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { // } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSString *body = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]; // NSString *body = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
body = [NSString stringWithFormat:@"<meta name='viewport' content='width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no'/><style type='text/css'>" // body = [body stringByReplacingOccurrencesOfRegex:@"<meta[\\w\\W]*?/?>" withString:@""];
@".main-header-wrap,.main-footer,.doubly-float{display:none}" // body = [body stringByReplacingOccurrencesOfRegex:@"<script[\\w\\W]*?</script>" withString:@""];
// body = [body stringByReplacingOccurrencesOfRegex:@"<header[\\w\\W]*?</header>" withString:@""];
// body = [body stringByReplacingOccurrencesOfRegex:@"<footer[\\w\\W]*?</footer>" withString:@""];
// body = [body stringByReplacingOccurrencesOfRegex:@"<head>" withString:@"<head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no\" /><style type='text/css'>"
// @".page-title h1.label{font-size:17px;}"
// @".rte.text-content td{padding-left:10px;}"
// @"</style>"];
// [wv.webView loadHTMLString:body baseURL:[NSURL URLWithString:baseUrl]];
// } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// }];
void(^success)(id) = ^(id body){
if (!body) {
return;
}
body = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];
body = [body stringByReplacingOccurrencesOfRegex:@"<meta[\\w\\W]*?/?>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<script[\\w\\W]*?</script>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<header[\\w\\W]*?</header>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<footer[\\w\\W]*?</footer>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<head>" withString:@"<head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no\" /><style type='text/css'>"
@".page-title h1.label{font-size:17px;}" @".page-title h1.label{font-size:17px;}"
@".rte.text-content td{padding-left:10px;}" @".rte.text-content td{padding-left:10px;}"
@"</style>%@",body]; @"</style>"];
[wv.webView loadHTMLString:body baseURL:[NSURL URLWithString:baseUrl]]; [wv.webView loadHTMLString:body baseURL:[NSURL URLWithString:baseUrl]];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
};
__weak typeof(self) this = self;
[PPNetworkHelper setAFHTTPSessionManagerProperty:^(AFHTTPSessionManager *sessionManager) {
sessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
sessionManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
}];
[PPNetworkHelper GET:url parameters:nil responseCache:success success:success failure:^(NSError *error) {
[this showError:error];
}]; }];
[self.navigationController pushViewController:wv animated:YES]; [self.navigationController pushViewController:wv animated:YES];
__unused id _ = wv.view;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(200 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(200 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
NJKWebViewProgress *wvp = [wv valueForKeyPath:@"progressManager"]; NJKWebViewProgress *wvp = [wv valueForKeyPath:@"progressManager"];
[wvp.progressDelegate webViewProgress:wvp updateProgress:0.1]; [wvp.progressDelegate webViewProgress:wvp updateProgress:0.1];
...@@ -274,7 +307,8 @@ ...@@ -274,7 +307,8 @@
model.name = this.product.title; model.name = this.product.title;
model.brand = this.product.vendor; model.brand = this.product.vendor;
model.size = variant.title; model.size = variant.title;
model.price = variant.price.floatValue; // model.price = variant.price.floatValue;
model.price = variant.price;
model.product_id = this.product.identifier; model.product_id = this.product.identifier;
} }
if (!error) { if (!error) {
......
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
[self.navigationController setNavigationBarHidden:YES]; [self.navigationController setNavigationBarHidden:YES];
self.vBackground.hidden = YES; self.vBackground.hidden = YES;
[self initHeardView]; [self initHeardView];
if (!self.searchText) {
[self.vSearchFB.tfSearch becomeFirstResponder];
}
} }
- (UITableView *)targetTableView{ - (UITableView *)targetTableView{
...@@ -49,7 +52,7 @@ ...@@ -49,7 +52,7 @@
- (void)reLoadData{ - (void)reLoadData{
[self getSearchProduct]; // [self getSearchProduct];
} }
static NSString *idStr = @"KWMBrandCaramelCell"; static NSString *idStr = @"KWMBrandCaramelCell";
- (void)viewDidLoad { - (void)viewDidLoad {
...@@ -64,8 +67,9 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -64,8 +67,9 @@ static NSString *idStr = @"KWMBrandCaramelCell";
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickBackgroundView:)]; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickBackgroundView:)];
[self.vBackground addGestureRecognizer:tapGesture]; [self.vBackground addGestureRecognizer:tapGesture];
if (self.searchText) {
[self getSearchProduct]; [self getSearchProduct];
}
} }
- (void)onClickBackgroundView:(UITapGestureRecognizer *)tapGesture{ - (void)onClickBackgroundView:(UITapGestureRecognizer *)tapGesture{
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "KWMShippingCell.h" #import "KWMShippingCell.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
#import "KWMCurrencyUtil.h"
@implementation KWMShippingCell @implementation KWMShippingCell
...@@ -38,7 +39,8 @@ ...@@ -38,7 +39,8 @@
} }
self.shippingRate = shippingRate; self.shippingRate = shippingRate;
self.lbTitle.text = shippingRate.title; self.lbTitle.text = shippingRate.title;
self.lbPrice.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:shippingRate.price]]; // self.lbPrice.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:shippingRate.price]];
self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormattedByCurrencyCode:shippingRate.price];
} }
@end @end
...@@ -30,8 +30,9 @@ ...@@ -30,8 +30,9 @@
_lbBrand.text = shopCartModel.brand; _lbBrand.text = shopCartModel.brand;
_lbSize.text = shopCartModel.size; _lbSize.text = shopCartModel.size;
_lbCount.text = [NSString stringWithFormat:@"%ld",(long)shopCartModel.quantity]; _lbCount.text = [NSString stringWithFormat:@"%ld",(long)shopCartModel.quantity];
NSInteger totalPrice = shopCartModel.price*shopCartModel.quantity; // NSInteger totalPrice = shopCartModel.price*shopCartModel.quantity;
_lbPrice.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:@(totalPrice)]]; // _lbPrice.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:@(totalPrice)]];
_lbPrice.text = shopCartModel.totalPrice;
NSURL *imageURL = [NSURL URLWithString: shopCartModel.imageStr]; NSURL *imageURL = [NSURL URLWithString: shopCartModel.imageStr];
[_ivImage sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]]; [_ivImage sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
} }
......
...@@ -210,7 +210,8 @@ ...@@ -210,7 +210,8 @@
} }
//总价 //总价
if(self.checkout!=nil){ if(self.checkout!=nil){
self.lbTotalPrice.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:self.checkout.totalPrice]]; // self.lbTotalPrice.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:self.checkout.totalPrice]];
self.lbTotalPrice.text = self.checkout.totalPrice.priceValueFormatted;
} }
} }
......
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
BUYDiscount *discount = [self.client.modelManager discountWithCode:code]; BUYDiscount *discount = [self.client.modelManager discountWithCode:code];
self.checkout.discount = discount; self.checkout.discount = discount;
self.checkout.attributes = nil;
[self.client updateCheckout:self.checkout completion:^(NSDictionary *dictionary, BUYCheckout *checkout, NSError *error) { [self.client updateCheckout:self.checkout completion:^(NSDictionary *dictionary, BUYCheckout *checkout, NSError *error) {
[self hideLoading]; [self hideLoading];
if (error == nil && checkout) { if (error == nil && checkout) {
...@@ -101,8 +102,13 @@ ...@@ -101,8 +102,13 @@
if(self.delegate != nil){ if(self.delegate != nil){
[self.delegate kwm_addedDiscount:self.checkout]; [self.delegate kwm_addedDiscount:self.checkout];
} }
[self showToast:@"添加优惠码失败"]; // 八成是因为checkout是web生成的所以如果discount如果传的有问题返回的是500如果没问题的话是正常的
[self showError:error]; if ([@"Internal Server Error" isEqualToString:error.userInfo[@"errors"]]) {
[self showToast:@"您输入的优惠码有误"];
}else {
[self showError:error];
}
// [self showToast:@"添加优惠码失败"];
NSLog(@"Error applying checkout: %@", error); NSLog(@"Error applying checkout: %@", error);
} }
}]; }];
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#import "KWMLoginVC.h" #import "KWMLoginVC.h"
#import "KWMLoadingView.h" #import "KWMLoadingView.h"
#import "UIColor+SAMAdditions.h" #import "UIColor+SAMAdditions.h"
#import "BUYProductVariant+Currency.h"
#import "KWMCurrencyUtil.h"
@interface KWMSelectSizeVC () @interface KWMSelectSizeVC ()
...@@ -177,7 +179,8 @@ ...@@ -177,7 +179,8 @@
- (void)initBySelectSize{ - (void)initBySelectSize{
_shopCartModel.size = _selectSize.title; _shopCartModel.size = _selectSize.title;
_shopCartModel.price = _selectSize.price.integerValue; // _shopCartModel.price = _selectSize.price.integerValue;
_shopCartModel.price = _selectSize.price;
_shopCartModel.identifier = [NSString stringWithFormat:@"%@",_selectSize.identifier]; _shopCartModel.identifier = [NSString stringWithFormat:@"%@",_selectSize.identifier];
_shopCartModel.quantity = _count; _shopCartModel.quantity = _count;
} }
...@@ -359,9 +362,10 @@ ...@@ -359,9 +362,10 @@
if (defalutSize.identifier.integerValue == self.selectSize.identifier.integerValue && isDefalut) { if (defalutSize.identifier.integerValue == self.selectSize.identifier.integerValue && isDefalut) {
self.count = defalutCount; self.count = defalutCount;
} }
double price = self.selectSize.price.doubleValue * self.count; // double price = self.selectSize.price.doubleValue * self.count;
NSDecimalNumber *totalPrice = [self.selectSize.priceValue decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithDecimal:@(self.count).decimalValue]];
self.lbPrice.text = [NSString stringWithFormat: @"¥ %@", [KWMStringUtil getEUR2CNYstring:@(price)]]; // self.lbPrice.text = [NSString stringWithFormat: @"¥ %@", [KWMStringUtil getEUR2CNYstring:@(price)]];
self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormatted:totalPrice];
}else{ }else{
self.lbCount.text = @"0"; self.lbCount.text = @"0";
self.lbPrice.text = @"¥ 0.00"; self.lbPrice.text = @"¥ 0.00";
......
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
tmp.size = variant.title; tmp.size = variant.title;
tmp.brand = model.brand; tmp.brand = model.brand;
tmp.name = model.name; tmp.name = model.name;
tmp.price = variant.price.floatValue; tmp.price = variant.price;
tmp.product_id = model.product_id; tmp.product_id = model.product_id;
} }
success(error,cart); success(error,cart);
...@@ -253,11 +253,19 @@ ...@@ -253,11 +253,19 @@
//计算总价格 //计算总价格
- (void) setTotalPrice{ - (void) setTotalPrice{
NSInteger price = 0; // NSInteger price = 0;
NSDecimalNumber *total = [NSDecimalNumber decimalNumberWithDecimal:@(0).decimalValue];
for (KWMShopCartModel *model in _shopCartList) { for (KWMShopCartModel *model in _shopCartList) {
price += model.price * model.quantity; if (model.line_price) {
// price += model.line_price.priceValue.integerValue;
total = [total decimalNumberByAdding:model.line_price.priceValue];
}else{
// price += [model.price.priceValue decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithString:@(model.quantity).stringValue]].integerValue;
total = [total decimalNumberByAdding:[model.price.priceValue decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithString:@(model.quantity).stringValue]]];
}
} }
_lbTotalPrice.text = [NSString stringWithFormat: @"¥%@",[KWMStringUtil getEUR2CNYstring:@(price)]]; // _lbTotalPrice.text = [NSString stringWithFormat: @"¥%@",[KWMStringUtil getEUR2CNYstring:@(price)]];
_lbTotalPrice.text = total.priceFormatted;
} }
@end @end
//
// KWNCurrencyUtil.h
// iCemarose
//
// Created by lee on 2017/6/15.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface KWMCurrencyUtil : NSObject
+ (instancetype) sharedInstance;
- (NSString *)priceFormatted:(NSDecimalNumber *) price;
- (NSString *)priceFormattedByCurrencyCode:(NSDecimalNumber *) pric;
- (NSString *)fixFormatted:(NSString *) price;
- (NSDecimalNumber *) calcPriceByCurrencyCode:(NSDecimalNumber *) price;
@end
//
// KWNCurrencyUtil.m
// iCemarose
//
// Created by lee on 2017/6/15.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMCurrencyUtil.h"
#import "KWMUserDao.h"
@interface KWMCurrencyUtil ()
@property (nonatomic, strong) NSNumberFormatter *numberFormatter;
@end
@implementation KWMCurrencyUtil
+ (instancetype) sharedInstance {
static KWMCurrencyUtil *instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[super allocWithZone:NULL] init];
});
return instance;
}
+ (instancetype)allocWithZone:(struct _NSZone *)zone {
return [self sharedInstance];
}
- (NSNumberFormatter *) numberFormatter {
if (!_numberFormatter) {
_numberFormatter = [[NSNumberFormatter alloc] init];
_numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
}
_numberFormatter.currencyCode = [self getCurrencyCode];
return _numberFormatter;
}
- (NSString *) getCurrencyCode {
// NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
// return [language isEqualToString:@"zh-CN"] ? @"CNY" : @"EUR"; // @"EUR"
// TODO: 这里应该写到设置中 设置中来设置CurrencyCode
// return [@"zh" isEqualToString:[[NSLocale currentLocale] languageCode]] ? @"CNY" : @"EUR";
return [[KWMUserDao shareDao] currencyCode];
}
- (NSString *)priceFormattedByCurrencyCode:(NSDecimalNumber *) price {
// return [[[self numberFormatter] stringFromNumber:[self calcPriceByCurrencyCode:self.price]] stringByReplacingOccurrencesOfRegex:@"\\.00" withString:@""];
return [self fixFormatted:[[self numberFormatter] stringFromNumber:[self calcPriceByCurrencyCode:price]]];
}
- (NSString *)priceFormatted:(NSDecimalNumber *)price {
return [self fixFormatted:[[self numberFormatter] stringFromNumber:price]];
}
//- (NSString *)
- (NSString *)fixFormatted:(NSString *) price {
// return [price stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@00",[self numberFormatter].currencyDecimalSeparator] withString:@""];
return price;
}
- (NSDecimalNumber *) calcPriceByCurrencyCode:(NSDecimalNumber *) price {
if ([[self getCurrencyCode] isEqualToString:@"CNY"]) {
NSDecimalNumber *rate = [[KWMUserDao shareDao] exchangeRate];
price = [[rate decimalNumberByMultiplyingBy:price] decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithString:@"1.03"]];
}
return price;
}
@end
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
+ (NSString *)transform:(NSString *)chinese; + (NSString *)transform:(NSString *)chinese;
//欧元转人民币 //欧元转人民币
+ (NSString *)getEUR2CNYstring:(NSNumber *)price; //+ (NSString *)getEUR2CNYstring:(NSNumber *)price;
@end @end
...@@ -493,9 +493,9 @@ static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu ...@@ -493,9 +493,9 @@ static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu
return CNYstring; return CNYstring;
} }
float exchageRate = [[KWMUserDao shareDao] exchangeRate].floatValue; float exchageRate = [[KWMUserDao shareDao] exchangeRate].floatValue;
if(exchageRate == 0){ // if(exchageRate == 0){
exchageRate = ExchangeRate; // exchageRate = ExchangeRate;
} // }
CNYstring = [NSString stringWithFormat:@"%.0f",price.floatValue * exchageRate]; CNYstring = [NSString stringWithFormat:@"%.0f",price.floatValue * exchageRate];
// CNYstring = [NSString stringWithFormat:@"%.2f",price.floatValue]; // CNYstring = [NSString stringWithFormat:@"%.2f",price.floatValue];
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "KWMAPIManager.h" #import "KWMAPIManager.h"
#import <MagicalRecord/MagicalRecord.h> #import <MagicalRecord/MagicalRecord.h>
#import "NSDecimalNumber+Currency.h"
#ifndef Header_Prefix_h #ifndef Header_Prefix_h
#define Header_Prefix_h #define Header_Prefix_h
...@@ -92,7 +93,8 @@ ...@@ -92,7 +93,8 @@
#define BigImage 3 #define BigImage 3
//默认欧元汇率,如果安装后第一次请求最新汇率数据失败,会使用该汇率显示价格 //默认欧元汇率,如果安装后第一次请求最新汇率数据失败,会使用该汇率显示价格
#define ExchangeRate 7.6625 //#define ExchangeRate 7.6625
#define ExchangeRateString @"7.6625"
//品牌图片url //品牌图片url
#define Burberry @"https://cdn.shopify.com/s/files/1/1089/5284/collections/Burberry_Childrenswear_Campaign_July_2016_001.jpg?v=1473238213" #define Burberry @"https://cdn.shopify.com/s/files/1/1089/5284/collections/Burberry_Childrenswear_Campaign_July_2016_001.jpg?v=1473238213"
......
...@@ -38,6 +38,14 @@ ...@@ -38,6 +38,14 @@
<string>iCemarose</string> <string>iCemarose</string>
</array> </array>
</dict> </dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>cemarose</string>
</array>
</dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2017060917</string> <string>2017060917</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