Commit 4ad67998 by lee

u exchange rate|UI issue

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