|
@@ -46,12 +46,29 @@
|
|
return localCur;
|
|
return localCur;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//获取当前汇率 (保留两位小数的字符串)
|
|
|
|
+- (NSString *)getCurrentCurrencyRate {
|
|
|
|
+ NSString *rateStr = @"1";
|
|
|
|
+ for (int i = 0; i < self.exchange_rates.count; i++) {
|
|
|
|
+ NSDictionary *rateDic = [self.exchange_rates objectAtIndex:i];
|
|
|
|
+ NSString *tempCurrency = rateDic[@"currency_to"];
|
|
|
|
+
|
|
|
|
+ if ([self.currentCur isEqualToString:tempCurrency]) {
|
|
|
|
+ rateStr = rateDic[@"rate"];
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return rateStr;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
- (void)getAllCurrencyData {
|
|
- (void)getAllCurrencyData {
|
|
__weak typeof(self) weakSelf = self;
|
|
__weak typeof(self) weakSelf = self;
|
|
[ASNetTools.shared getWithPath:getAllCurrencyUrl param:@{} success:^(id _Nonnull json) {
|
|
[ASNetTools.shared getWithPath:getAllCurrencyUrl param:@{} success:^(id _Nonnull json) {
|
|
NSDictionary *dic = (NSDictionary *)json;
|
|
NSDictionary *dic = (NSDictionary *)json;
|
|
weakSelf.avaiCurencys = dic[@"available_currency_codes"];
|
|
weakSelf.avaiCurencys = dic[@"available_currency_codes"];
|
|
|
|
+
|
|
|
|
+ weakSelf.exchange_rates = dic[@"exchange_rates"];
|
|
|
|
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
} faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
|
|
|