Commit 0185d337 by lee

fix ui,fix checkout does not have uid,fix address country can not input 中国,App.Home data cache 24H

parent e2b375ed
...@@ -696,7 +696,9 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -696,7 +696,9 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
} }
- (NSURLSessionDataTask *)getHomeDataWithSuccess:(void (^)(NSURLSessionDataTask *, KWMHomeDataResult *))success failure:(void (^)(NSURLSessionDataTask *, NSError *))failure { - (NSURLSessionDataTask *)getHomeDataWithSuccess:(void (^)(NSURLSessionDataTask *, KWMHomeDataResult *))success failure:(void (^)(NSURLSessionDataTask *, NSError *))failure {
NSString *apiPath = @"https://ogbgohpla.qnssl.com/App.Home.json?32"; NSInteger st = [[NSDate date] timeIntervalSince1970];
st = st - st % 86400 - 28800;
NSString *apiPath = [NSString stringWithFormat:@"https://ogbgohpla.qnssl.com/App.Home.json?%ld",st];
return [self startSessionTask:KWMHTTPMethodGET apiPath:apiPath parameters:nil result:[KWMHomeDataResult class] model:nil success:success failure:failure]; return [self startSessionTask:KWMHTTPMethodGET apiPath:apiPath parameters:nil result:[KWMHomeDataResult class] model:nil success:success failure:failure];
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
} }
_product = product; _product = product;
NSArray *variantsArray = product.variantsArray; NSArray *variantsArray = product.variantsArray;
self.lbTitle.text = product.vendor;
if(variantsArray && variantsArray.count > 0){ if(variantsArray && variantsArray.count > 0){
BUYProductVariant *variant = variantsArray.firstObject; BUYProductVariant *variant = variantsArray.firstObject;
// self.lbPrice.text = [KWMStringUtil price:variant.price]; // self.lbPrice.text = [KWMStringUtil price:variant.price];
......
...@@ -56,6 +56,10 @@ ...@@ -56,6 +56,10 @@
self.title = @"分类"; self.title = @"分类";
} }
+ (NSString *)kwmBoard {
return @"Main";
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self initData]; [self initData];
......
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
} }
self.vCount.hidden = self.wish?YES:NO; self.vCount.hidden = self.wish?YES:NO;
self.lbCount.text = [NSString stringWithFormat:@"%ld",(long)self.count]; self.lbCount.text = [NSString stringWithFormat:@"%ld",(long)self.count];
self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormatted:self.totalPrice]; self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormattedByCurrencyCode:self.totalPrice];
} }
-(void)initCollectionView{ -(void)initCollectionView{
......
////
//// KWMNewVC.h
//// iCemarose
////
//// Created by 陈荣科 on 16/8/23.
//// Copyright © 2016年 kollway. All rights reserved.
////
// //
// KWMNewVC.h //#import "KWMBasePageVC.h"
// iCemarose //#import "KWMSearchBar.h"
// //#import "KWMNewGoodsCell.h"
// Created by 陈荣科 on 16/8/23. //#import "KWMTBVSectionHeardView.h"
// Copyright © 2016年 kollway. All rights reserved. //#import "UIColor+SAMAdditions.h"
// //
////tab页-商品
#import "KWMBasePageVC.h" //@interface KWMNewVC : KWMBasePageVC<UITableViewDelegate,UITableViewDataSource,KWMSearchBarDelegate,KWMNewGoodsCellDelegate,KWMTBVSectionHeardViewDelegate>
#import "KWMSearchBar.h" //
#import "KWMNewGoodsCell.h" //@property (weak, nonatomic) IBOutlet UIButton *btnBaby;
#import "KWMTBVSectionHeardView.h" //
#import "UIColor+SAMAdditions.h" //@property (weak, nonatomic) IBOutlet UIButton *btnGirl;
//
//tab页-商品 //@property (weak, nonatomic) IBOutlet UIButton *btnBoy;
@interface KWMNewVC : KWMBasePageVC<UITableViewDelegate,UITableViewDataSource,KWMSearchBarDelegate,KWMNewGoodsCellDelegate,KWMTBVSectionHeardViewDelegate> //
//@property (weak, nonatomic) IBOutlet UIButton *btnShoes;
@property (weak, nonatomic) IBOutlet UIButton *btnBaby; //
//@property (weak, nonatomic) IBOutlet UIButton *btnNewGoods;
@property (weak, nonatomic) IBOutlet UIButton *btnGirl; //
//@property (weak, nonatomic) IBOutlet UIButton *btnDiscount;
@property (weak, nonatomic) IBOutlet UIButton *btnBoy; //
//@property (weak, nonatomic) IBOutlet UITableView *tbvNewGoods;
@property (weak, nonatomic) IBOutlet UIButton *btnShoes; //
//@property (weak, nonatomic) IBOutlet UIView *vLine;
@property (weak, nonatomic) IBOutlet UIButton *btnNewGoods; //
//@property (weak, nonatomic) IBOutlet UIView *vBackground;
@property (weak, nonatomic) IBOutlet UIButton *btnDiscount; //
//
@property (weak, nonatomic) IBOutlet UITableView *tbvNewGoods; //- (IBAction)onClickBabyBtn:(id)sender;
//
@property (weak, nonatomic) IBOutlet UIView *vLine; //- (IBAction)onClickGirlBtn:(id)sender;
//
@property (weak, nonatomic) IBOutlet UIView *vBackground; //- (IBAction)onClickBoyBtn:(id)sender;
//
//- (IBAction)onClickShoesBtn:(id)sender;
- (IBAction)onClickBabyBtn:(id)sender; //
//- (IBAction)onClickNewGoodsBtn:(id)sender;
- (IBAction)onClickGirlBtn:(id)sender; //
//- (IBAction)onClickDiscountBtn:(id)sender;
- (IBAction)onClickBoyBtn:(id)sender; //
//@end
- (IBAction)onClickShoesBtn:(id)sender;
- (IBAction)onClickNewGoodsBtn:(id)sender;
- (IBAction)onClickDiscountBtn:(id)sender;
@end
////
//// KWMNewVC.m
//// iCemarose
////
//// Created by 陈荣科 on 16/8/23.
//// Copyright © 2016年 kollway. All rights reserved.
////
// //
// KWMNewVC.m //#import "KWMNewVC.h"
// iCemarose //#import "KWMStringUtil.h"
// //#import "KWMSelectedGoodsVC.h"
// Created by 陈荣科 on 16/8/23. //#import "KWMNewTypeSelectedVC.h"
// Copyright © 2016年 kollway. All rights reserved. //#import "KWMSearchFeedbackVC.h"
// //#import "KWMShopCartVC.h"
//#import "KWMShopCartData.h"
#import "KWMNewVC.h" //#import "KWMNewGoodsModel.h"
#import "KWMStringUtil.h" //#import "KWMLoadStatus.h"
#import "KWMSelectedGoodsVC.h" //#import "KWMSelectedGoodsVC.h"
#import "KWMNewTypeSelectedVC.h" //#import "KWMBrandCaramelVC.h"
#import "KWMSearchFeedbackVC.h" //#import "UIColor+SAMAdditions.h"
#import "KWMShopCartVC.h" //#import "KWMNewProductVC.h"
#import "KWMShopCartData.h" //#import "KWMShoppingCart.h"
#import "KWMNewGoodsModel.h" //
#import "KWMLoadStatus.h" //
#import "KWMSelectedGoodsVC.h" //@interface KWMNewVC ()
#import "KWMBrandCaramelVC.h" //@property (nonatomic) KWMSearchBar *searchBar;
#import "UIColor+SAMAdditions.h" ////@property (nonatomic) KWMNewGoodsModel *goodsModel;
#import "KWMNewProductVC.h" //@end
#import "KWMShoppingCart.h" //
//@implementation KWMNewVC{
// NSArray *collections;
@interface KWMNewVC () // NSArray *discountCollections;
@property (nonatomic) KWMSearchBar *searchBar; // NSArray *newCollections;
//@property (nonatomic) KWMNewGoodsModel *goodsModel; // NSMutableDictionary *newsDict;
@end // NSMutableDictionary *discountDic;
// BOOL isNew;//判断当前显示的是新品还是折扣列表
@implementation KWMNewVC{ //}
NSArray *collections; //
NSArray *discountCollections; //static NSString * idStr = @"KWMNewGoodsCell";
NSArray *newCollections; //+(NSString *)kwmTag{
NSMutableDictionary *newsDict; // return @"KWMNewVC";
NSMutableDictionary *discountDic; //}
BOOL isNew;//判断当前显示的是新品还是折扣列表 //
} //- (void)viewDidDisappear:(BOOL)animated{
// [super viewDidDisappear:animated];
static NSString * idStr = @"KWMNewGoodsCell"; // [_searchBar removeFromSuperview];
+(NSString *)kwmTag{ //}
return @"KWMNewVC"; //
} //- (void)viewDidLoad {
// [super viewDidLoad];
- (void)viewDidDisappear:(BOOL)animated{ //
[super viewDidDisappear:animated]; // [self initNotification];
[_searchBar removeFromSuperview]; // // Do any additional setup after loading the view.
} // self.automaticallyAdjustsScrollViewInsets = NO;
// self.tbvNewGoods.showsVerticalScrollIndicator = NO;
- (void)viewDidLoad { // collections = [NSArray array];
[super viewDidLoad]; // discountCollections = [NSArray array];
// newCollections = [NSArray array];
[self initNotification]; // newsDict = [[NSMutableDictionary alloc] init];
// Do any additional setup after loading the view. // discountDic = [[NSMutableDictionary alloc] init];
self.automaticallyAdjustsScrollViewInsets = NO; //
self.tbvNewGoods.showsVerticalScrollIndicator = NO; // isNew = YES;
collections = [NSArray array]; // [self initView];
discountCollections = [NSArray array]; // [self requestNewProductsCollection];
newCollections = [NSArray array]; //
newsDict = [[NSMutableDictionary alloc] init]; //}
discountDic = [[NSMutableDictionary alloc] init]; //
//- (void)initNotification{
isNew = YES; // [[NSNotificationCenter defaultCenter] addObserver:self
[self initView]; // selector:@selector(onBack)
[self requestNewProductsCollection]; // name:UIApplicationDidBecomeActiveNotification object:nil];
//}
} //
//-(void)removreNotification{
- (void)initNotification{ // [[NSNotificationCenter defaultCenter] removeObserver:self];
[[NSNotificationCenter defaultCenter] addObserver:self //}
selector:@selector(onBack) //
name:UIApplicationDidBecomeActiveNotification object:nil]; //-(void)dealloc{
} // [self removreNotification];
//}
-(void)removreNotification{ //
[[NSNotificationCenter defaultCenter] removeObserver:self]; //-(void)onBack{
} // [self.tbvNewGoods reloadData];
//}
-(void)dealloc{ //
[self removreNotification]; //- (void)awakeFromNib{
} // [super awakeFromNib];
//
-(void)onBack{ // self.title = @"商品";
[self.tbvNewGoods reloadData]; //}
} //
//- (void)viewWillAppear:(BOOL)animated{
- (void)awakeFromNib{ // [super viewWillAppear:animated];
[super awakeFromNib]; // [self initHeaderView];
// [self.navigationController setNavigationBarHidden:YES];
self.title = @"商品"; // [self.tabBarController setHidesBottomBarWhenPushed:NO];
} // if (_searchBar) {
// NSInteger count = [[KWMShoppingCart sharedInstance] count].integerValue;
- (void)viewWillAppear:(BOOL)animated{ // _searchBar.count = count;
[super viewWillAppear:animated]; // }
[self initHeaderView]; // [_searchBar resumeView];
[self.navigationController setNavigationBarHidden:YES]; // _vBackground.hidden = YES;
[self.tabBarController setHidesBottomBarWhenPushed:NO]; // [self.tbvNewGoods reloadData];
if (_searchBar) { //}
NSInteger count = [[KWMShoppingCart sharedInstance] count].integerValue; //- (void)viewWillDisappear:(BOOL)animated{
_searchBar.count = count; // [super viewWillDisappear:animated];
} // [_searchBar removeFromSuperview];
[_searchBar resumeView]; //}
_vBackground.hidden = YES; //
[self.tbvNewGoods reloadData]; //
} //- (UITableView *)targetTableView{
- (void)viewWillDisappear:(BOOL)animated{ // return self.tbvNewGoods;
[super viewWillDisappear:animated]; //}
[_searchBar removeFromSuperview]; //
} //- (void)loadData{
//
// if (isNew) {
- (UITableView *)targetTableView{ // [self requestNewProductsCollection];
return self.tbvNewGoods; // }else{
} // [self requestDiscountCollection];
// }
- (void)loadData{ //}
//- (void)reLoadData{
if (isNew) { // if (isNew) {
[self requestNewProductsCollection]; // [self requestNewProductsCollection];
}else{ // }else{
[self requestDiscountCollection]; // [self requestDiscountCollection];
} // }
} //}
- (void)reLoadData{ //
if (isNew) { //- (void)initHeaderView{
[self requestNewProductsCollection]; // //添加頭部header
}else{ // _searchBar = [[KWMSearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
[self requestDiscountCollection]; // _searchBar.delegate = self;
} //
} // [self.view addSubview:_searchBar];
//}
- (void)initHeaderView{ //
//添加頭部header //- (void)initView{
_searchBar = [[KWMSearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)]; //
_searchBar.delegate = self; // [self.tbvNewGoods registerClass:[KWMNewGoodsCell class] forCellReuseIdentifier:@"KWMNewGoodsCell"];
//
[self.view addSubview:_searchBar]; // //新品
} // self.btnNewGoods.selected = YES;
// self.btnNewGoods.backgroundColor = [UIColor sam_colorWithHex:@"F19291"];
- (void)initView{ //
// self.btnNewGoods.layer.borderColor = [UIColor sam_colorWithHex:@"F19291"].CGColor;
[self.tbvNewGoods registerClass:[KWMNewGoodsCell class] forCellReuseIdentifier:@"KWMNewGoodsCell"]; // self.btnNewGoods.layer.borderWidth = 0.5;
// //打折
//新品 // self.btnDiscount.selected = NO;
self.btnNewGoods.selected = YES; // self.btnDiscount.layer.borderWidth = 0.5;
self.btnNewGoods.backgroundColor = [UIColor sam_colorWithHex:@"F19291"]; // self.btnDiscount.layer.borderColor = [UIColor sam_colorWithHex:@"F19291"].CGColor;
//
self.btnNewGoods.layer.borderColor = [UIColor sam_colorWithHex:@"F19291"].CGColor; // self.tbvNewGoods.delegate = self;
self.btnNewGoods.layer.borderWidth = 0.5; // self.tbvNewGoods.separatorStyle = UITableViewCellSelectionStyleNone;
//打折 // self.tbvNewGoods.backgroundColor = [UIColor sam_colorWithHex:@"FFFFFF"];
self.btnDiscount.selected = NO; // [self.tbvNewGoods registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr];
self.btnDiscount.layer.borderWidth = 0.5; //
self.btnDiscount.layer.borderColor = [UIColor sam_colorWithHex:@"F19291"].CGColor; // self.vLine.backgroundColor = [UIColor sam_colorWithHex:@"F5F5F5"];
//
self.tbvNewGoods.delegate = self; // UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickBackgroundView:)];
self.tbvNewGoods.separatorStyle = UITableViewCellSelectionStyleNone; // [self.vBackground addGestureRecognizer:tapGesture];
self.tbvNewGoods.backgroundColor = [UIColor sam_colorWithHex:@"FFFFFF"]; //}
[self.tbvNewGoods registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr]; //
//- (void)onClickBackgroundView:(UITapGestureRecognizer *)tapGesture{
self.vLine.backgroundColor = [UIColor sam_colorWithHex:@"F5F5F5"]; // [_searchBar.tfSearch resignFirstResponder];
// _searchBar.tfSearch.text = nil;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickBackgroundView:)]; // self.vBackground.hidden = YES;
[self.vBackground addGestureRecognizer:tapGesture]; // [_searchBar stopSearch];
} //}
//
- (void)onClickBackgroundView:(UITapGestureRecognizer *)tapGesture{ ////点击婴儿
[_searchBar.tfSearch resignFirstResponder]; //- (IBAction)onClickBabyBtn:(id)sender {
_searchBar.tfSearch.text = nil; // if([TestModel isEqualToString:@"YES"]){
self.vBackground.hidden = YES; // KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"];
[_searchBar stopSearch]; // BUYCollection *collection = [BUYCollection new];
} // collection.identifier = @(441199887);
// selectedGoodsVC.collection = collection;
//点击婴儿 // [self.navigationController pushViewController:selectedGoodsVC animated:YES];
- (IBAction)onClickBabyBtn:(id)sender { //// KWMProductDetailVC *vc = (KWMProductDetailVC *)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"];
if([TestModel isEqualToString:@"YES"]){ //// vc.productId = @(11406082255);
KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"]; //// [self.navigationController pushViewController:vc animated:YES];
BUYCollection *collection = [BUYCollection new]; //
collection.identifier = @(441199887); // return;
selectedGoodsVC.collection = collection; // }
[self.navigationController pushViewController:selectedGoodsVC animated:YES]; // [self JumpToNewSelectedVCWith:self.btnBaby.titleLabel.text type:0];
// KWMProductDetailVC *vc = (KWMProductDetailVC *)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; //}
// vc.productId = @(11406082255); ////点击女孩
// [self.navigationController pushViewController:vc animated:YES]; //- (IBAction)onClickGirlBtn:(id)sender {
// [self JumpToNewSelectedVCWith:self.btnGirl.titleLabel.text type:1];
return; //}
} ////点击男孩
[self JumpToNewSelectedVCWith:self.btnBaby.titleLabel.text type:0]; //- (IBAction)onClickBoyBtn:(id)sender {
} // [self JumpToNewSelectedVCWith:self.btnBoy.titleLabel.text type:2];
//点击女孩 //}
- (IBAction)onClickGirlBtn:(id)sender { ////点击鞋类
[self JumpToNewSelectedVCWith:self.btnGirl.titleLabel.text type:1]; //- (IBAction)onClickShoesBtn:(id)sender {
} // [self JumpToNewSelectedVCWith:self.btnShoes.titleLabel.text type:3];
//点击男孩 //}
- (IBAction)onClickBoyBtn:(id)sender { //
[self JumpToNewSelectedVCWith:self.btnBoy.titleLabel.text type:2]; //- (void)JumpToNewSelectedVCWith:(NSString *)title type:(NSInteger)type{
} // KWMNewTypeSelectedVC *newTypeSelectedVC = (KWMNewTypeSelectedVC*)[KWMBaseVC findControllerBy:[KWMNewTypeSelectedVC kwmTag] fromStoryboard:@"New"];
//点击鞋类 // newTypeSelectedVC.navTitle = title;
- (IBAction)onClickShoesBtn:(id)sender { // newTypeSelectedVC.pageType = type;
[self JumpToNewSelectedVCWith:self.btnShoes.titleLabel.text type:3]; // [self.navigationController pushViewController:newTypeSelectedVC animated:YES];
} //}
//
- (void)JumpToNewSelectedVCWith:(NSString *)title type:(NSInteger)type{ ////点击新品
KWMNewTypeSelectedVC *newTypeSelectedVC = (KWMNewTypeSelectedVC*)[KWMBaseVC findControllerBy:[KWMNewTypeSelectedVC kwmTag] fromStoryboard:@"New"]; //- (IBAction)onClickNewGoodsBtn:(id)sender {
newTypeSelectedVC.navTitle = title; // if (!isNew) {
newTypeSelectedVC.pageType = type; // isNew = YES;
[self.navigationController pushViewController:newTypeSelectedVC animated:YES]; // if (!newCollections || newCollections.count == 0) {
} // [self requestNewProductsCollection];
// }else{
//点击新品 // collections = newCollections;
- (IBAction)onClickNewGoodsBtn:(id)sender { // [self.tbvNewGoods reloadData];
if (!isNew) { // }
isNew = YES; // }
if (!newCollections || newCollections.count == 0) { // self.btnNewGoods.selected = YES;
[self requestNewProductsCollection]; // self.btnDiscount.selected = NO;
}else{ // self.btnDiscount.backgroundColor = [UIColor clearColor];
collections = newCollections; // self.btnNewGoods.backgroundColor = [UIColor sam_colorWithHex:@"F88C99"];
[self.tbvNewGoods reloadData]; //}
} ////点击打折
} //- (IBAction)onClickDiscountBtn:(id)sender {
self.btnNewGoods.selected = YES; // if (isNew) {
self.btnDiscount.selected = NO; // isNew = NO;
self.btnDiscount.backgroundColor = [UIColor clearColor]; // if (!discountCollections || discountCollections.count == 0) {
self.btnNewGoods.backgroundColor = [UIColor sam_colorWithHex:@"F88C99"]; // collections = [NSArray array];
} // [self requestDiscountCollection];
//点击打折 // }else{
- (IBAction)onClickDiscountBtn:(id)sender { // collections = discountCollections;
if (isNew) { // [self.tbvNewGoods reloadData];
isNew = NO; // }
if (!discountCollections || discountCollections.count == 0) { // }
collections = [NSArray array]; // self.btnDiscount.selected = YES;
[self requestDiscountCollection]; // self.btnNewGoods.selected = NO;
}else{ // self.btnDiscount.backgroundColor = [UIColor sam_colorWithHex:@"F88C99"];
collections = discountCollections; // self.btnNewGoods.backgroundColor = [UIColor clearColor];
[self.tbvNewGoods reloadData]; //
} //}
} //
self.btnDiscount.selected = YES; //#pragma mark -- KWMTBVSectionHeardViewDelegate
self.btnNewGoods.selected = NO; //- (void)kwm_watchMoreProductsByBrand:(KWMNewGoodsModel *)goodsModel AndTitle:(NSString *)titel{
self.btnDiscount.backgroundColor = [UIColor sam_colorWithHex:@"F88C99"]; // KWMBrandCaramelVC *brandVC = (KWMBrandCaramelVC *)[KWMBrandCaramelVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"];
self.btnNewGoods.backgroundColor = [UIColor clearColor]; // brandVC.brand = titel;
// brandVC.goodModel = goodsModel;
} // brandVC.isSale = !isNew;
//
#pragma mark -- KWMTBVSectionHeardViewDelegate // [self.navigationController pushViewController:brandVC animated:YES];
- (void)kwm_watchMoreProductsByBrand:(KWMNewGoodsModel *)goodsModel AndTitle:(NSString *)titel{ //}
KWMBrandCaramelVC *brandVC = (KWMBrandCaramelVC *)[KWMBrandCaramelVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"]; //
brandVC.brand = titel; //#pragma mark -- KWMSearchBarDelegate
brandVC.goodModel = goodsModel; //- (void)kwm_tfSearchBeginEditing{
brandVC.isSale = !isNew; // self.vBackground.hidden = NO;
//}
[self.navigationController pushViewController:brandVC animated:YES]; //
} //- (void)kwm_onCancel{
// self.vBackground.hidden = YES;
#pragma mark -- KWMSearchBarDelegate //}
- (void)kwm_tfSearchBeginEditing{ //
self.vBackground.hidden = NO; //- (void)kwm_tfSearchFinished:(NSString *)text{
} // if ([text isEqualToString:@""] || text == nil) {
// [self showToast:@"请输入需要搜索的内容"];
- (void)kwm_onCancel{ // return;
self.vBackground.hidden = YES; // }
} // KWMSearchFeedbackVC *searchFBVC = (KWMSearchFeedbackVC *)[KWMBaseVC findControllerBy:[KWMSearchFeedbackVC kwmTag] fromStoryboard:@"New"];
// searchFBVC.searchText = text;
- (void)kwm_tfSearchFinished:(NSString *)text{ // [self.navigationController pushViewController:searchFBVC animated:YES];
if ([text isEqualToString:@""] || text == nil) { //}
[self showToast:@"请输入需要搜索的内容"]; //
return; //- (void)kwm_onClickShopCar{
} //
KWMSearchFeedbackVC *searchFBVC = (KWMSearchFeedbackVC *)[KWMBaseVC findControllerBy:[KWMSearchFeedbackVC kwmTag] fromStoryboard:@"New"]; // KWMShopCartVC *contactVC = (KWMShopCartVC *)[KWMBaseVC findControllerBy:[KWMShopCartVC kwmTag] fromStoryboard:@"ShopCart"];
searchFBVC.searchText = text; // [self.navigationController pushViewController:contactVC animated:YES];
[self.navigationController pushViewController:searchFBVC animated:YES]; //
} //}
//
- (void)kwm_onClickShopCar{ //#pragma mark -- KWMNewGoodsCellDelegate
//- (void)kwm_selectCollectionCell:(BUYProduct *)product{
KWMShopCartVC *contactVC = (KWMShopCartVC *)[KWMBaseVC findControllerBy:[KWMShopCartVC kwmTag] fromStoryboard:@"ShopCart"]; // if (product == nil) {
[self.navigationController pushViewController:contactVC animated:YES]; // return;
// }
} //// KWMProductDetailVC *goodsDetailvc = (KWMProductDetailVC *)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"];
// KWMNewProductVC *goodsDetailvc = [KWMNewProductVC getNewInstance];
#pragma mark -- KWMNewGoodsCellDelegate // goodsDetailvc.product = product;
- (void)kwm_selectCollectionCell:(BUYProduct *)product{ // [self.navigationController pushViewController:goodsDetailvc animated:YES];
if (product == nil) { //}
return; //
} //#pragma mark - UITableViewDelegate
// KWMProductDetailVC *goodsDetailvc = (KWMProductDetailVC *)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; //- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
KWMNewProductVC *goodsDetailvc = [KWMNewProductVC getNewInstance]; // return collections?collections.count:0 ;
goodsDetailvc.product = product; //}
[self.navigationController pushViewController:goodsDetailvc animated:YES]; //
} //- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
// return 1;
#pragma mark - UITableViewDelegate //}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ //
return collections?collections.count:0 ; //- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
} //
// KWMNewGoodsCell *newGoodsCell = [tableView dequeueReusableCellWithIdentifier:idStr forIndexPath:indexPath];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ //// if(!newGoodsCell){
return 1; //// [tableView registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr];
} //// newGoodsCell = [tableView dequeueReusableCellWithIdentifier:idStr forIndexPath:indexPath];
//// }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ // newGoodsCell.isDetail = NO;
// newGoodsCell.delegate = self;
KWMNewGoodsCell *newGoodsCell = [tableView dequeueReusableCellWithIdentifier:idStr forIndexPath:indexPath]; //
// if(!newGoodsCell){ // if(!collections || collections.count <= indexPath.section){
// [tableView registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr]; // return newGoodsCell;
// newGoodsCell = [tableView dequeueReusableCellWithIdentifier:idStr forIndexPath:indexPath]; // }
// KWMNewGoodsModel *goodsModel = [collections objectAtIndex:indexPath.section];
// if(!goodsModel){
// return newGoodsCell;
// }
// NSString *row = @(indexPath.section).stringValue;
// NSMutableDictionary *selectDict = isNew?newsDict:discountDic;
// KWMLoadStatus *loadStatus = [selectDict objectForKey:row];
// if (!loadStatus) {
// loadStatus = [[KWMLoadStatus alloc] init];
// [selectDict setObject:loadStatus forKey:row];
// //設置緩存數據
// loadStatus.cacheData = [self.userDao getCollectionCache:goodsModel.id tags:isNew?nil:[NSArray arrayWithObjects:@"sale", nil]];
// }
// //如果该行未拿到数据(包括空数据),向服务器请求数据
// if (!loadStatus.firstLoad && !loadStatus.isLoading) {
// [self requesProductList:BUYCollectionSortCreatedDescending WithCollectionId:goodsModel.id AndIndex:row];
// } // }
newGoodsCell.isDetail = NO; // [newGoodsCell setLoadStatusData:loadStatus];
newGoodsCell.delegate = self; // return newGoodsCell;
//}
if(!collections || collections.count <= indexPath.section){ //
return newGoodsCell; //#pragma mark - UITableViewDataSource
} //- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
KWMNewGoodsModel *goodsModel = [collections objectAtIndex:indexPath.section]; // NSString *row = @(indexPath.section).stringValue;
if(!goodsModel){ // KWMLoadStatus *loadStatus = isNew ? [newsDict objectForKey:row]:[discountDic objectForKey:row];
return newGoodsCell; // return [self isEmptyCollection:loadStatus]? 0.01f:173.0f;
} //}
NSString *row = @(indexPath.section).stringValue; //
NSMutableDictionary *selectDict = isNew?newsDict:discountDic; //- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
KWMLoadStatus *loadStatus = [selectDict objectForKey:row]; //
if (!loadStatus) { // NSString *row = @(section).stringValue;
loadStatus = [[KWMLoadStatus alloc] init]; // KWMNewGoodsModel *goodsModel = [collections objectAtIndex:section];
[selectDict setObject:loadStatus forKey:row]; // KWMTBVSectionHeardView * vTBVSectionHeard = [[KWMTBVSectionHeardView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 60)];
//設置緩存數據 // vTBVSectionHeard.goodsModel = goodsModel;
loadStatus.cacheData = [self.userDao getCollectionCache:goodsModel.id tags:isNew?nil:[NSArray arrayWithObjects:@"sale", nil]]; // vTBVSectionHeard.delegate = self;
} // vTBVSectionHeard.clipsToBounds = YES;
//如果该行未拿到数据(包括空数据),向服务器请求数据 // vTBVSectionHeard.backgroundColor = [UIColor whiteColor];
if (!loadStatus.firstLoad && !loadStatus.isLoading) { // KWMLoadStatus *loadStatus = isNew ? [newsDict objectForKey:row]:[discountDic objectForKey:row];
[self requesProductList:BUYCollectionSortCreatedDescending WithCollectionId:goodsModel.id AndIndex:row]; // //判断该collection是否有数据来隐藏头部,如果第一次请求成功且并没有请求到数据
} // vTBVSectionHeard.hidden = [self isEmptyCollection:loadStatus];
[newGoodsCell setLoadStatusData:loadStatus]; // return vTBVSectionHeard;
return newGoodsCell; //}
} //
////判斷該collection是否為空
#pragma mark - UITableViewDataSource //- (BOOL)isEmptyCollection:(KWMLoadStatus *)loadStatus{
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ // if(!loadStatus){
NSString *row = @(indexPath.section).stringValue; // return NO;
KWMLoadStatus *loadStatus = isNew ? [newsDict objectForKey:row]:[discountDic objectForKey:row]; // }
return [self isEmptyCollection:loadStatus]? 0.01f:173.0f; // return (loadStatus.firstLoad && (!loadStatus.data || loadStatus.data.count == 0));
} //}
//
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
// NSString * row = @(section).stringValue;
NSString *row = @(section).stringValue; // KWMLoadStatus *loadStatus = isNew ? [newsDict objectForKey:row]:[discountDic objectForKey:row];
KWMNewGoodsModel *goodsModel = [collections objectAtIndex:section]; // return [self isEmptyCollection:loadStatus]? 0.01f:60.0f;
KWMTBVSectionHeardView * vTBVSectionHeard = [[KWMTBVSectionHeardView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 60)]; // return 60.0f;
vTBVSectionHeard.goodsModel = goodsModel; //}
vTBVSectionHeard.delegate = self; //
vTBVSectionHeard.clipsToBounds = YES; //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
vTBVSectionHeard.backgroundColor = [UIColor whiteColor]; // return 0.01f;
KWMLoadStatus *loadStatus = isNew ? [newsDict objectForKey:row]:[discountDic objectForKey:row]; //}
//判断该collection是否有数据来隐藏头部,如果第一次请求成功且并没有请求到数据 //
vTBVSectionHeard.hidden = [self isEmptyCollection:loadStatus]; ////请求新品collection列表
return vTBVSectionHeard; //- (void)requestNewProductsCollection{
} // BOOL mIsNew = isNew;
// __weak KWMNewVC *weakSelf = self;
//判斷該collection是否為空 // [self.api getNewProducts:nil success:^(NSURLSessionDataTask *task, KWMNewProducts *result) {
- (BOOL)isEmptyCollection:(KWMLoadStatus *)loadStatus{ // [weakSelf hideLoading];
if(!loadStatus){ // newCollections = result.collections;
return NO; // if(mIsNew == isNew){
} // collections = newCollections;
return (loadStatus.firstLoad && (!loadStatus.data || loadStatus.data.count == 0)); // [self.tbvNewGoods reloadData];
} // }
// } failure:^(NSURLSessionDataTask *task, NSError *error) {
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ // [weakSelf showError:error];
NSString * row = @(section).stringValue; // NSLog(@"error");
KWMLoadStatus *loadStatus = isNew ? [newsDict objectForKey:row]:[discountDic objectForKey:row]; // }];
return [self isEmptyCollection:loadStatus]? 0.01f:60.0f; // [self showLoading];
return 60.0f; //}
} //
////请求打折collection列表
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ //- (void)requestDiscountCollection{
return 0.01f; // BOOL mIsNew = isNew;
} // __weak KWMNewVC *weakSelf = self;
// [self.api getDiscountProducts:nil success:^(NSURLSessionDataTask *task, KWMNewProducts *result) {
//请求新品collection列表 // [weakSelf hideLoading];
- (void)requestNewProductsCollection{ // [result setCollectionsTag];
BOOL mIsNew = isNew; // discountCollections = result.collections;
__weak KWMNewVC *weakSelf = self; // if(mIsNew == isNew){
[self.api getNewProducts:nil success:^(NSURLSessionDataTask *task, KWMNewProducts *result) { // collections = discountCollections;
[weakSelf hideLoading]; // [self.tbvNewGoods reloadData];
newCollections = result.collections; // }
if(mIsNew == isNew){ // } failure:^(NSURLSessionDataTask *task, NSError *error) {
collections = newCollections; // [self showError:error];
[self.tbvNewGoods reloadData]; // NSLog(@"error");
} // }];
} failure:^(NSURLSessionDataTask *task, NSError *error) { // [self showLoading];
[weakSelf showError:error]; //}
NSLog(@"error"); //
}]; ////请求product列表
[self showLoading]; //- (void)requesProductList:(BUYCollectionSort)collectionSort WithCollectionId:(NSNumber *)identify AndIndex:(NSString *)keyStr{
} // BOOL mIsNew = isNew;
// KWMLoadStatus *loadStatus = isNew ? [newsDict objectForKey:keyStr]:[discountDic objectForKey:keyStr];
//请求打折collection列表 // if(!loadStatus){
- (void)requestDiscountCollection{ // return;
BOOL mIsNew = isNew; // }
__weak KWMNewVC *weakSelf = self; // //设置该行状态为正在加载
[self.api getDiscountProducts:nil success:^(NSURLSessionDataTask *task, KWMNewProducts *result) { // loadStatus.isLoading = YES;
[weakSelf hideLoading]; // __weak KWMNewVC *weakSelf = self;
[result setCollectionsTag]; // NSInteger tagetPage = 1;
discountCollections = result.collections; // NSArray *tags = nil;
if(mIsNew == isNew){ // if(!isNew){
collections = discountCollections; // NSString *tag;
[self.tbvNewGoods reloadData]; // tag = @"sale";
} // tags = [NSArray arrayWithObjects:tag, nil];
} failure:^(NSURLSessionDataTask *task, NSError *error) { // }
[self showError:error]; // [self.client getProductsPage:tagetPage inCollection:identify withTags:tags sortOrder:collectionSort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
NSLog(@"error"); // [weakSelf hideLoading];
}]; // loadStatus.isLoading = NO;
[self showLoading]; // if (error == nil && products) {
} // if(tagetPage == 1){
// [weakSelf.userDao saveCollectionCache:products collectionId:identify tags:tags];
//请求product列表 // }
- (void)requesProductList:(BUYCollectionSort)collectionSort WithCollectionId:(NSNumber *)identify AndIndex:(NSString *)keyStr{ // weakSelf.hasNextPage = !reachedEnd;
BOOL mIsNew = isNew; // loadStatus.data = products;
KWMLoadStatus *loadStatus = isNew ? [newsDict objectForKey:keyStr]:[discountDic objectForKey:keyStr]; // //设置第一次加载的状态为已成功加载
if(!loadStatus){ // loadStatus.firstLoad = YES;
return; // if(mIsNew == isNew ){
} // if([KWMStringUtil isEmpty:keyStr]){
//设置该行状态为正在加载 // return ;
loadStatus.isLoading = YES; // }
__weak KWMNewVC *weakSelf = self; // NSInteger section = keyStr.integerValue;
NSInteger tagetPage = 1; // if(section < (collections?collections.count:0)){
NSArray *tags = nil; // [weakSelf.tbvNewGoods reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationNone];
if(!isNew){ // }
NSString *tag; // }
tag = @"sale"; // }else {
tags = [NSArray arrayWithObjects:tag, nil]; // [self showError:error];
} // NSLog(@"Error fetching products: %@", error);
[self.client getProductsPage:tagetPage inCollection:identify withTags:tags sortOrder:collectionSort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){ // }
[weakSelf hideLoading]; // }];
loadStatus.isLoading = NO; // [self showLoading];
if (error == nil && products) { //}
if(tagetPage == 1){ //
[weakSelf.userDao saveCollectionCache:products collectionId:identify tags:tags]; //
} //
weakSelf.hasNextPage = !reachedEnd; //@end
loadStatus.data = products;
//设置第一次加载的状态为已成功加载
loadStatus.firstLoad = YES;
if(mIsNew == isNew ){
if([KWMStringUtil isEmpty:keyStr]){
return ;
}
NSInteger section = keyStr.integerValue;
if(section < (collections?collections.count:0)){
[weakSelf.tbvNewGoods reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationNone];
}
}
}else {
[self showError:error];
NSLog(@"Error fetching products: %@", error);
}
}];
[self showLoading];
}
@end
...@@ -333,6 +333,7 @@ ...@@ -333,6 +333,7 @@
checkout.billingAddress = self.address; checkout.billingAddress = self.address;
} }
checkout.email = self.customer.email; checkout.email = self.customer.email;
checkout.customerId = self.customer.identifier;
// self.client.urlScheme = @"CemaroseApp://"; // self.client.urlScheme = @"CemaroseApp://";
// 走session的情况下应该不存在update 只是update cart自动会update到checkout // 走session的情况下应该不存在update 只是update cart自动会update到checkout
// if(checkoutCache){ // if(checkoutCache){
...@@ -719,13 +720,15 @@ ...@@ -719,13 +720,15 @@
[self.navigationController pushViewController:successVC animated:YES]; [self.navigationController pushViewController:successVC animated:YES];
} }
-(void) clearCheckout { -(void) clearCheckout {
self.cartCookie = nil; self.cartCookie = nil;
[[KWMShoppingCart sharedInstance] clearCartWithCallback:^(NSError *error, KWMCartResult *cart) { [KWMHttpUtil deleteCookie:@"cart"];
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // [[KWMShoppingCart sharedInstance] clearCartWithCallback:^(NSError *error, KWMCartResult *cart) {
[KWMHttpUtil deleteCookie:@"cart"]; //// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// }); // [KWMHttpUtil deleteCookie:@"cart"];
}]; //// });
// }];
// [KWMHttpUtil deleteCookie:@"cart"]; // [KWMHttpUtil deleteCookie:@"cart"];
// [[KWMShopCartData alloc] removeAllItems]; // [[KWMShopCartData alloc] removeAllItems];
[self.userDao deleteCheckoutCache]; [self.userDao deleteCheckoutCache];
......
...@@ -145,6 +145,7 @@ ...@@ -145,6 +145,7 @@
}else{ }else{
requestAddress = [[BUYAddress alloc] initWithModelManager:self.client.modelManager JSONDictionary:nil]; requestAddress = [[BUYAddress alloc] initWithModelManager:self.client.modelManager JSONDictionary:nil];
} }
NSString *country = [self.tfCountry.text trim];
requestAddress.lastName = [self.tfName.text trim]; requestAddress.lastName = [self.tfName.text trim];
requestAddress.phone = [self.tfPhone.text trim]; requestAddress.phone = [self.tfPhone.text trim];
requestAddress.province = [self.tfProvince.text trim]; requestAddress.province = [self.tfProvince.text trim];
...@@ -152,7 +153,7 @@ ...@@ -152,7 +153,7 @@
requestAddress.city = [self.tfCity.text trim]; requestAddress.city = [self.tfCity.text trim];
requestAddress.address1 = [self.tfAddress.text trim]; requestAddress.address1 = [self.tfAddress.text trim];
requestAddress.address2 = [self.tfAddressDetail.text trim]; requestAddress.address2 = [self.tfAddressDetail.text trim];
requestAddress.country = [self.tfCountry.text trim]; requestAddress.country = [country isEqualToString:@"中国"] ? @"China" : country;
requestAddress.countryCode = @""; requestAddress.countryCode = @"";
requestAddress.zip = [self.tfZip.text trim]; requestAddress.zip = [self.tfZip.text trim];
requestAddress.firstName = [(requestAddress.firstName?requestAddress.firstName:@"") trim]; requestAddress.firstName = [(requestAddress.firstName?requestAddress.firstName:@"") trim];
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#import "KWMUserModel.h" #import "KWMUserModel.h"
#import "KWMLoginVC.h" #import "KWMLoginVC.h"
#import "KWMShopCartData.h" #import "KWMShopCartData.h"
#import "KWMNewVC.h" //#import "KWMNewVC.h"
#import "KWMCategoryVC.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
#import "KWMShoppingCart.h" #import "KWMShoppingCart.h"
...@@ -93,9 +94,10 @@ ...@@ -93,9 +94,10 @@
//点击随意逛逛 //点击随意逛逛
- (IBAction)onClickRandomBtn:(id)sender { - (IBAction)onClickRandomBtn:(id)sender {
NSLog(@"点击了随意逛逛"); NSLog(@"点击了随意逛逛");
KWMNewVC *newVC = (KWMNewVC *)[KWMBaseVC findControllerBy:[KWMNewVC kwmTag] fromStoryboard:@"Main"]; // KWMNewVC *newVC = (KWMNewVC *)[KWMBaseVC findControllerBy:[KWMNewVC kwmTag] fromStoryboard:@"Main"];
self.hidesBottomBarWhenPushed = NO; self.hidesBottomBarWhenPushed = NO;
[self.navigationController pushViewController:newVC animated:YES]; KWMCategoryVC *vc = [KWMCategoryVC getNewInstance];
[self.navigationController pushViewController:vc animated:YES];
} }
- (void)onClickComplete:(id)sender{ - (void)onClickComplete:(id)sender{
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.5.0</string> <string>1.5.1</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2017071812</string> <string>2017071910</string>
<key>LSApplicationQueriesSchemes</key> <key>LSApplicationQueriesSchemes</key>
<array> <array>
<string>weixin</string> <string>weixin</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