Commit b142b254 by lee

add currency select

parent 68a4164f
......@@ -67,6 +67,8 @@
80F82E611D704E34008B470B /* KWMBrandCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 80F82E5F1D704E34008B470B /* KWMBrandCell.m */; };
80F82E621D704E34008B470B /* KWMBrandCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 80F82E601D704E34008B470B /* KWMBrandCell.xib */; };
80FBF7E18C063DB9E8DC7502 /* libPods-iCemarose.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 450DA8BB947651E9A9B38BEB /* libPods-iCemarose.a */; };
9B01488B1EF3B5330056D937 /* KWMSelectCurrencyVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B01488A1EF3B5330056D937 /* KWMSelectCurrencyVC.m */; };
9B01488E1EF3B8760056D937 /* KWMSelectCurrencyCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B01488D1EF3B8760056D937 /* KWMSelectCurrencyCell.m */; };
9B0F56B81ECD3424009FC5FE /* UIViewController+AppearLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0F56B71ECD3424009FC5FE /* UIViewController+AppearLog.m */; };
9B166F511ED6DBCF003E9F03 /* KWMHttpUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B166F501ED6DBCF003E9F03 /* KWMHttpUtil.m */; };
9B18C11F1EF1270A001DD59B /* BUYProductVariant+Currency.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B18C11E1EF1270A001DD59B /* BUYProductVariant+Currency.m */; };
......@@ -412,6 +414,10 @@
80F82E5E1D704E34008B470B /* KWMBrandCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMBrandCell.h; sourceTree = "<group>"; };
80F82E5F1D704E34008B470B /* KWMBrandCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMBrandCell.m; sourceTree = "<group>"; };
80F82E601D704E34008B470B /* KWMBrandCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMBrandCell.xib; sourceTree = "<group>"; };
9B0148891EF3B5330056D937 /* KWMSelectCurrencyVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMSelectCurrencyVC.h; sourceTree = "<group>"; };
9B01488A1EF3B5330056D937 /* KWMSelectCurrencyVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMSelectCurrencyVC.m; sourceTree = "<group>"; };
9B01488C1EF3B8750056D937 /* KWMSelectCurrencyCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMSelectCurrencyCell.h; sourceTree = "<group>"; };
9B01488D1EF3B8760056D937 /* KWMSelectCurrencyCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMSelectCurrencyCell.m; sourceTree = "<group>"; };
9B0F56B61ECD3424009FC5FE /* UIViewController+AppearLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+AppearLog.h"; sourceTree = "<group>"; };
9B0F56B71ECD3424009FC5FE /* UIViewController+AppearLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+AppearLog.m"; sourceTree = "<group>"; };
9B166F4F1ED6DBCF003E9F03 /* KWMHttpUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMHttpUtil.h; sourceTree = "<group>"; };
......@@ -1305,6 +1311,8 @@
C06665111D767A0A00F02EF4 /* KWMContactUsVC.m */,
C03A05041E35DC5800BAA889 /* KWMNewGiftCardVC.h */,
C03A05051E35DC5800BAA889 /* KWMNewGiftCardVC.m */,
9B0148891EF3B5330056D937 /* KWMSelectCurrencyVC.h */,
9B01488A1EF3B5330056D937 /* KWMSelectCurrencyVC.m */,
);
path = Mine;
sourceTree = "<group>";
......@@ -1708,6 +1716,8 @@
C05910911E34A729002990B3 /* KWMNewGiftCardCell.h */,
C05910921E34A729002990B3 /* KWMNewGiftCardCell.m */,
C05910931E34A729002990B3 /* KWMNewGiftCardCell.xib */,
9B01488C1EF3B8750056D937 /* KWMSelectCurrencyCell.h */,
9B01488D1EF3B8760056D937 /* KWMSelectCurrencyCell.m */,
);
path = Cell;
sourceTree = "<group>";
......@@ -2179,6 +2189,7 @@
C0F5867A1E24F820001248E2 /* KWMDoubleTitleView.m in Sources */,
8091DFBB1D6EC1DD0020519C /* KWMThreeView.m in Sources */,
C0DD53371EE55190002D1E0C /* KWMLoadingView.m in Sources */,
9B01488E1EF3B8760056D937 /* KWMSelectCurrencyCell.m in Sources */,
C03120B01EF2B26B00E49EFA /* KWMPayUtil.m in Sources */,
9BE61CFB1ECD56E70031D21E /* KWMDictioaryResult.m in Sources */,
C034E6D81D6AEF1B006EE129 /* KWMImageUtil.m in Sources */,
......@@ -2317,6 +2328,7 @@
C0DD533B1EE55190002D1E0C /* KWMSuperLoadingView.m in Sources */,
C034E85D1D6B10A0006EE129 /* PBConst.m in Sources */,
C0CCB3D11EEA765B00BC2FB8 /* KWMNormalFilterTab.m in Sources */,
9B01488B1EF3B5330056D937 /* KWMSelectCurrencyVC.m in Sources */,
C0CC140F1D7926DF007B5986 /* KWMBeforePayVC.m in Sources */,
C034E8441D6B10A0006EE129 /* NSObject+Extend.m in Sources */,
80A611B21D6DB0EC00709E09 /* KWMShopCartVC.m in Sources */,
......
......@@ -18,6 +18,8 @@
*/
@interface KWMUserDao : NSObject
@property (nonatomic, strong) NSString *currencyCode;
+ (KWMUserDao *)shareDao;
- (BOOL)checkSession;
- (KWMUser *)loginUser;
......
......@@ -26,6 +26,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
@interface KWMUserDao ()
@end
@implementation KWMUserDao {
......@@ -40,6 +41,8 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
BOOL isLogingChat;
}
@synthesize currencyCode = _currencyCode;
+ (KWMUserDao *)shareDao {
static KWMUserDao *_userDao = nil;
static dispatch_once_t oncePredicate;
......@@ -434,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
//
// 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 @@
self.title = @"我的";
}
-(IBAction)onClickCurrency:(id)sender {
[self performSegueWithIdentifier:@"MeToCurrency" sender:nil];
}
-(void)onClickOrder:(id)sender{
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 @@
#import "Buy/Buy.h"
@interface KWMCollectionCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *ivCollectionCell;
@property (weak, nonatomic) IBOutlet UILabel *lbBrand;
@property (weak, nonatomic) IBOutlet UILabel *lbDiscount;
......
......@@ -100,6 +100,7 @@ static NSString * idStr = @"KWMNewGoodsCell";
}
[_searchBar resumeView];
_vBackground.hidden = YES;
[self.tbvNewGoods reloadData];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
......
......@@ -44,7 +44,8 @@
// 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 [@"zh" isEqualToString:[[NSLocale currentLocale] languageCode]] ? @"CNY" : @"EUR";
return [[KWMUserDao shareDao] currencyCode];
}
- (NSString *)priceFormattedByCurrencyCode:(NSDecimalNumber *) price {
......@@ -59,14 +60,15 @@
//- (NSString *)
- (NSString *)fixFormatted:(NSString *) price {
return [price stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@00",[self numberFormatter].currencyDecimalSeparator] withString:@""];
// 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 = [NSDecimalNumber decimalNumberWithString:@(ceil([[rate decimalNumberByMultiplyingBy:price] decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithString:@"1.03"]].doubleValue)).stringValue];
price = [[rate decimalNumberByMultiplyingBy:price] decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithString:@"1.03"]];
}
return price;
}
......
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