Commit 4ad67998 by lee

u exchange rate|UI issue

parent db4977fb
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[NSThread sleepForTimeInterval:1]; // [NSThread sleepForTimeInterval:1];
[_window makeKeyAndVisible]; // [_window makeKeyAndVisible];
//UI: Appearance //UI: Appearance
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
......
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
@interface KWMExchangeRateResult : KWMCemaroseResult @interface KWMExchangeRateResult : KWMCemaroseResult
@property (nonatomic) NSNumber* exchangeRate; //@property (nonatomic) NSNumber* exchangeRate;
@property (nonatomic, strong) NSString *status;
@property (nonatomic, strong) NSNumber *code;
@property (nonatomic, strong) NSDictionary *message;
@property (nonatomic, strong) NSString *currency;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSDecimalNumber *exchange_rate;
@end @end
...@@ -13,15 +13,21 @@ ...@@ -13,15 +13,21 @@
- (instancetype)initWithDictionary:(NSDictionary *)dict - (instancetype)initWithDictionary:(NSDictionary *)dict
modelClass:(Class)modelClass modelClass:(Class)modelClass
error:(NSError **)err { error:(NSError **)err {
if (dict) { // if (dict) {
NSArray *dataArray = (NSArray *)dict; // NSArray *dataArray = (NSArray *)dict;
if(dataArray && dataArray.count>0){ // if(dataArray && dataArray.count>0){
NSDictionary *exchangedata = [dataArray objectAtIndex:0]; // NSDictionary *exchangedata = [dataArray objectAtIndex:0];
if(exchangedata[@"CNY"]){ // if(exchangedata[@"CNY"]){
self.exchangeRate = [exchangedata objectForKey:@"CNY"]; // self.exchangeRate = [exchangedata objectForKey:@"CNY"];
} // }
} // }
} // }
self.status = dict[@"status"];
self.code = dict[@"code"];
self.message = dict[@"message"];
self.currency = self.message[@"currency"];
self.name = self.message[@"name"];
self.exchange_rate = self.message[@"exchange_rate"];
return self; return self;
} }
......
...@@ -650,15 +650,19 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -650,15 +650,19 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *) getExchangeRate:(NSDictionary *)parameters - (NSURLSessionDataTask *) getExchangeRate:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMExchangeRateResult *result))success success:(void(^)(NSURLSessionDataTask *task,KWMExchangeRateResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{ failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = @"https://ogbgohpla.qnssl.com/App.Currency.json"; #if DEBUG
NSString *apiPath = @"https://liang.tofnews.com/app/exchange/rate";
#else
NSString *apiPath = @"https://apps.cemarose.com/app/exchange/rate";
#endif
// NSString *sign = [KWMStringUtil MD5:[KWMStringUtil BASE64:@"currency=EUR&key=bd3f58f5cd3d7a217ac8c8e655ab52f8"]];
// NSLog(@"rate sign: %@",sign);
// NSDictionary *params = @{@"currency":@"EUR",@"sign":sign};
NSDictionary *params = @{@"currency":@"EUR",@"sign":@"665d9716511eb11f68a1a7a862ed2ddd"};
NSTimeInterval interval = [[NSDate date] timeIntervalSince1970]/100; return [self startSessionTask:KWMHTTPMethodPOST
long long time = interval;
apiPath = [[NSString alloc] initWithFormat:@"%@?_=%llu", apiPath, time];
return [self startSessionTask:KWMHTTPMethodGET
apiPath:apiPath apiPath:apiPath
parameters:parameters parameters:params
result:[KWMExchangeRateResult class] result:[KWMExchangeRateResult class]
model:nil model:nil
success:success success:success
......
...@@ -39,6 +39,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -39,6 +39,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
BOOL isSkipLoginChat; BOOL isSkipLoginChat;
BOOL isLoginedChat; BOOL isLoginedChat;
BOOL isLogingChat; BOOL isLogingChat;
NSDecimalNumber *_exchangeRate;
} }
@synthesize currencyCode = _currencyCode; @synthesize currencyCode = _currencyCode;
...@@ -206,6 +207,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -206,6 +207,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
if(exchangeRate == nil){ if(exchangeRate == nil){
return; return;
} }
_exchangeRate = [NSDecimalNumber decimalNumberWithDecimal:exchangeRate.decimalValue];
NSString *exchangeString = exchangeRate.stringValue; NSString *exchangeString = exchangeRate.stringValue;
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
[defaults setObject:exchangeString forKey:kwmKeyExchangeRate]; [defaults setObject:exchangeString forKey:kwmKeyExchangeRate];
...@@ -213,14 +215,18 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -213,14 +215,18 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
} }
- (NSDecimalNumber *)exchangeRate { - (NSDecimalNumber *)exchangeRate {
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults]; if (!_exchangeRate) {
NSString *exchageRateString = [defaults objectForKey:kwmKeyExchangeRate]; NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
// NSNumber *rate = [KWMStringUtil stringToNumber:exchageRateString]; NSString *exchageRateString = [defaults objectForKey:kwmKeyExchangeRate];
// return rate; // NSNumber *rate = [KWMStringUtil stringToNumber:exchageRateString];
if ([KWMStringUtil isEmpty:exchageRateString]) { // return rate;
return [NSDecimalNumber decimalNumberWithString:ExchangeRateString]; if ([KWMStringUtil isEmpty:exchageRateString]) {
_exchangeRate = [NSDecimalNumber decimalNumberWithString:ExchangeRateString];
} else {
_exchangeRate = [NSDecimalNumber decimalNumberWithString:exchageRateString];
}
} }
return [NSDecimalNumber decimalNumberWithString:exchageRateString]; return _exchangeRate;
} }
-(void)saveCollectionCache:(NSArray *)products collectionId:(NSNumber *)collectionId tags:(NSArray *)tags{ -(void)saveCollectionCache:(NSArray *)products collectionId:(NSNumber *)collectionId tags:(NSArray *)tags{
......
...@@ -219,11 +219,13 @@ ...@@ -219,11 +219,13 @@
if (isLeft) { if (isLeft) {
self.priceLeft.constant = 0; self.priceLeft.constant = 0;
self.lbDiscountLeft.hidden = YES; self.lbDiscountLeft.hidden = YES;
self.lbDiscountLeft.text = nil;
// self.lbPriceLeft.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring: price]]; // self.lbPriceLeft.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring: price]];
self.lbPriceLeft.text = price.priceValueFormatted; self.lbPriceLeft.text = price.priceValueFormatted;
}else{ }else{
self.priceRight.constant = 0; self.priceRight.constant = 0;
self.lbDiscountRight.hidden = YES; self.lbDiscountRight.hidden = YES;
self.lbDiscountRight.text = nil;
// self.lbPriceRight.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:price]]; // self.lbPriceRight.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:price]];
self.lbPriceRight.text = price.priceValueFormatted; self.lbPriceRight.text = price.priceValueFormatted;
} }
......
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
} }
} }
- (void)initSplash{ - (void)initSplash{
...@@ -196,12 +195,12 @@ ...@@ -196,12 +195,12 @@
-(void)requestExchangeRateApi{ -(void)requestExchangeRateApi{
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){ void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
NSLog(@"%@",error);
}; };
void(^success)(NSURLSessionDataTask *,KWMExchangeRateResult *) = ^(NSURLSessionDataTask *task,KWMExchangeRateResult *result){ void(^success)(NSURLSessionDataTask *,KWMExchangeRateResult *) = ^(NSURLSessionDataTask *task,KWMExchangeRateResult *result){
if(result){ if(result){
NSNumber *exchangeRate = result.exchangeRate; // NSNumber *exchangeRate = result.exchangeRate;
[[KWMUserDao shareDao] saveExchangeRate:exchangeRate]; [[KWMUserDao shareDao] saveExchangeRate:result.exchange_rate];
} }
}; };
[[KWMAPIManager sharedManager] getExchangeRate:nil success:success failure:failure]; [[KWMAPIManager sharedManager] getExchangeRate:nil success:success failure:failure];
......
...@@ -39,14 +39,14 @@ ...@@ -39,14 +39,14 @@
if(productVariant == nil){ if(productVariant == nil){
return; return;
} }
self.lbPrice.hidden = NO;
self.priceSpace.constant = 4;
// self.discountLeft.constant = 5; // self.discountLeft.constant = 5;
// self.lbPrice.textAlignment = NSTextAlignmentRight; // self.lbPrice.textAlignment = NSTextAlignmentRight;
// self.lbDiscount.textAlignment = NSTextAlignmentLeft; // self.lbDiscount.textAlignment = NSTextAlignmentLeft;
NSString *priceString,*discountStr; NSString *priceString,*discountStr;
if (productVariant.compareAtPrice) { if (productVariant.compareAtPrice) {
self.lbPrice.hidden = NO;
self.priceSpace.constant = 4;
// priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]]; // priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:productVariant.compareAtPrice]];
priceString = productVariant.compareAtPriceFormatted; priceString = productVariant.compareAtPriceFormatted;
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
self.lbPrice.attributedText = attribtStr; self.lbPrice.attributedText = attribtStr;
}else{ }else{
self.lbPrice.hidden = YES; self.lbPrice.hidden = YES;
self.lbPrice.text = nil;
self.priceSpace.constant = 0; self.priceSpace.constant = 0;
// self.discountLeft.constant = -28; // self.discountLeft.constant = -28;
// self.lbDiscount.textAlignment = NSTextAlignmentCenter; // self.lbDiscount.textAlignment = NSTextAlignmentCenter;
......
...@@ -94,7 +94,8 @@ ...@@ -94,7 +94,8 @@
//默认欧元汇率,如果安装后第一次请求最新汇率数据失败,会使用该汇率显示价格 //默认欧元汇率,如果安装后第一次请求最新汇率数据失败,会使用该汇率显示价格
//#define ExchangeRate 7.6625 //#define ExchangeRate 7.6625
#define ExchangeRateString @"7.6625" //#define ExchangeRateString @"7.6625"
#define ExchangeRateString @"8.0"
//品牌图片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"
......
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