Commit fbf76059 by lee

Merge branch 'master' of git.oschina.net:kollway-kollway/newcemarose

parents f7d30dd5 f52543d4
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#import "KWMBlogDetailVC.h" #import "KWMBlogDetailVC.h"
#import "KWMNewProductVC.h" #import "KWMNewProductVC.h"
#import "KWMBrandCaramelVC.h" #import "KWMBrandCaramelVC.h"
#import "KWMStringUtil.h"
static NSMutableDictionary *controllerCache = nil; static NSMutableDictionary *controllerCache = nil;
...@@ -47,11 +48,15 @@ static NSMutableDictionary *controllerCache = nil; ...@@ -47,11 +48,15 @@ static NSMutableDictionary *controllerCache = nil;
NSLog(@"trace tags %@",[tags componentsJoinedByString:@","]); NSLog(@"trace tags %@",[tags componentsJoinedByString:@","]);
NSArray *brands = @[@"amelie-wang",@"babywalker",@"beau-loves",@"billieblush",@"billybandit",@"bonpoint",@"burberry",@"caramel",@"chloe",@"collegien",@"dolce-gabbana",@"emile-et-ida",@"fendi",@"gucci",@"hucklebones",@"il-gufo",@"indikidual",@"karl-lagerfeld-kids",@"kenzo",@"lanvin",@"little-marc-jacobs",@"loud-apparel",@"louis-louise",@"louise-misha",@"marie-chantal",@"marni",@"mini-melissa",@"mini-rodini",@"mischka-aoki",@"moncler",@"moschino",@"msgm",@"nailmatic",@"nana-huchy",@"noukies",@"oeuf",@"patachou",@"paul-smith",@"pepe",@"sons-daughters-eyewear",@"stella-mccartney-kids",@"story-loris",@"tartine-et-chocolat",@"the-animals-observatory",@"tiny-cottons",@"veja",@"young-versace",@"zadig-voltaire"]; NSArray *brands = @[@"amelie-wang",@"babywalker",@"beau-loves",@"billieblush",@"billybandit",@"bonpoint",@"burberry",@"caramel",@"chloe",@"collegien",@"dolce-gabbana",@"emile-et-ida",@"fendi",@"gucci",@"hucklebones",@"il-gufo",@"indikidual",@"karl-lagerfeld-kids",@"kenzo",@"lanvin",@"little-marc-jacobs",@"loud-apparel",@"louis-louise",@"louise-misha",@"marie-chantal",@"marni",@"mini-melissa",@"mini-rodini",@"mischka-aoki",@"moncler",@"moschino",@"msgm",@"nailmatic",@"nana-huchy",@"noukies",@"oeuf",@"patachou",@"paul-smith",@"pepe",@"sons-daughters-eyewear",@"stella-mccartney-kids",@"story-loris",@"tartine-et-chocolat",@"the-animals-observatory",@"tiny-cottons",@"veja",@"young-versace",@"zadig-voltaire"];
NSDictionary *brandNames = @{@"amelie-wang":@"Amelie Wang",@"babywalker":@"Babywalker",@"beau-loves":@"Beau Loves",@"billieblush":@"Billieblush",@"billybandit":@"Billybandit",@"bonpoint":@"Bonpoint",@"burberry":@"Burberry",@"caramel":@"Caramel",@"chloe":@"Chloé",@"dolce-gabbana":@"Dolce & Gabbana",@"emile-et-ida":@"Emile et Ida",@"fendi":@"Fendi",@"givenchy":@"Givenchy",@"gucci":@"Gucci",@"hucklebones":@"Hucklebones",@"il-gufo":@"Il Gufo",@"indikidual":@"Indikidual",@"karl-lagerfeld-kids":@"Karl Lagerfeld Kids",@"kenzo":@"Kenzo",@"lanvin":@"Lanvin",@"little-marc-jacobs":@"Little Marc Jacobs",@"loud-apparel":@"Loud Apparel",@"louis-louise":@"Louis Louise",@"louise-misha":@"Louise Misha",@"marie-chantal":@"Marie-Chantal",@"marni":@"Marni",@"mini-melissa":@"Mini Melissa",@"mini-rodini":@"Mini Rodini",@"mischka-aoki":@"Mischka Aoki",@"moncler":@"Moncler",@"moschino":@"MOSCHINO",@"msgm":@"MSGM",@"nailmatic":@"Nailmatic",@"nana-huchy":@"Nana Huchy",@"noukies":@"Noukie's",@"oeuf":@"Oeuf",@"patachou":@"Patachou",@"paul-smith":@"Paul Smith",@"pepe":@"PèPè",@"sons-daughters-eyewear":@"Sons + Daughters Eyewear",@"stella-mccartney-kids":@"Stella McCartney Kids",@"story-loris":@"Story Loris",@"tartine-et-chocolat":@"Tartine et Chocolat",@"the-animals-observatory":@"The Animals Observatory",@"tiny-cottons":@"Tiny Cottons",@"tip-toey-joey":@"Tip Toey Joey",@"veja":@"Veja",@"young-versace":@"Young Versace",@"zadig-voltaire":@"Zadig & Voltaire"}; NSDictionary *brandNames = @{@"amelie-wang":@"Amelie Wang",@"babywalker":@"Babywalker",@"beau-loves":@"Beau Loves",@"billieblush":@"Billieblush",@"billybandit":@"Billybandit",@"bonpoint":@"Bonpoint",@"burberry":@"Burberry",@"caramel":@"Caramel",@"chloe":@"Chloé",@"dolce-gabbana":@"Dolce & Gabbana",@"emile-et-ida":@"Emile et Ida",@"fendi":@"Fendi",@"givenchy":@"Givenchy",@"gucci":@"Gucci",@"hucklebones":@"Hucklebones",@"il-gufo":@"Il Gufo",@"indikidual":@"Indikidual",@"karl-lagerfeld-kids":@"Karl Lagerfeld Kids",@"kenzo":@"Kenzo",@"lanvin":@"Lanvin",@"little-marc-jacobs":@"Little Marc Jacobs",@"loud-apparel":@"Loud Apparel",@"louis-louise":@"Louis Louise",@"louise-misha":@"Louise Misha",@"marie-chantal":@"Marie-Chantal",@"marni":@"Marni",@"mini-melissa":@"Mini Melissa",@"mini-rodini":@"Mini Rodini",@"mischka-aoki":@"Mischka Aoki",@"moncler":@"Moncler",@"moschino":@"MOSCHINO",@"msgm":@"MSGM",@"nailmatic":@"Nailmatic",@"nana-huchy":@"Nana Huchy",@"noukies":@"Noukie's",@"oeuf":@"Oeuf",@"patachou":@"Patachou",@"paul-smith":@"Paul Smith",@"pepe":@"PèPè",@"sons-daughters-eyewear":@"Sons + Daughters Eyewear",@"stella-mccartney-kids":@"Stella McCartney Kids",@"story-loris":@"Story Loris",@"tartine-et-chocolat":@"Tartine et Chocolat",@"the-animals-observatory":@"The Animals Observatory",@"tiny-cottons":@"Tiny Cottons",@"tip-toey-joey":@"Tip Toey Joey",@"veja":@"Veja",@"young-versace":@"Young Versace",@"zadig-voltaire":@"Zadig & Voltaire"};
//将handle的转化放到这里,转化之前将没转化过的handle存为标题
NSString *title = handle;
handle = [[KWMStringUtil deleteOtherCharExceptLetterWithLine:handle] lowercaseString];
if ([brands containsObject:[handle lowercaseString]]) { if ([brands containsObject:[handle lowercaseString]]) {
KWMBrandCaramelVC *brandCaramelVC = [KWMBrandCaramelVC getNewInstance]; KWMBrandCaramelVC *brandCaramelVC = [KWMBrandCaramelVC getNewInstance];
brandCaramelVC.isSale = NO; brandCaramelVC.isSale = NO;
brandCaramelVC.handle = handle; brandCaramelVC.handle = handle;
brandCaramelVC.brand = brandNames[[handle lowercaseString]]; //brandCaramelVC.brand = brandNames[[handle lowercaseString]];
brandCaramelVC.brand = title;
brandCaramelVC.title = brandCaramelVC.brand; brandCaramelVC.title = brandCaramelVC.brand;
[self pushViewController:brandCaramelVC]; [self pushViewController:brandCaramelVC];
[controllerCache setObject:brandCaramelVC forKey:url]; [controllerCache setObject:brandCaramelVC forKey:url];
...@@ -59,7 +64,8 @@ static NSMutableDictionary *controllerCache = nil; ...@@ -59,7 +64,8 @@ static NSMutableDictionary *controllerCache = nil;
KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"]; KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"];
selectedGoodsVC.handle = handle; selectedGoodsVC.handle = handle;
selectedGoodsVC.ctags = tags; selectedGoodsVC.ctags = tags;
selectedGoodsVC.title = parameters[@"title"]; //selectedGoodsVC.title = parameters[@"title"];
selectedGoodsVC.title = title;
[self pushViewController:selectedGoodsVC]; [self pushViewController:selectedGoodsVC];
[controllerCache setObject:selectedGoodsVC forKey:url]; [controllerCache setObject:selectedGoodsVC forKey:url];
} }
......
...@@ -65,9 +65,23 @@ ...@@ -65,9 +65,23 @@
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
[self initView]; [self initView];
[self initTableViewHeaderHidden];
[self getCollection:_handle]; [self getCollection:_handle];
} }
- (void)initTableViewHeaderHidden{
//判断是否有品牌图,有就显示
if(self.collection &&
self.collection.image && self.collection.image.sourceURL &&
![KWMStringUtil isEmpty:self.collection.image.sourceURL.absoluteString]){
self.tbvBrandCaramel.tableHeaderView.frame = CGRectMake(0, 0, UI_SCREEN_WIDTH, 210);
self.tbvBrandCaramel.tableHeaderView.hidden = NO;
return;
}
self.tbvBrandCaramel.tableHeaderView.frame = CGRectMake(0, 0, 0, 0);
self.tbvBrandCaramel.tableHeaderView.hidden = YES;
}
- (void)setBackColor{ - (void)setBackColor{
colorArr = [NSArray arrayWithObjects:@"#D8A88D",@"#A4C8C6",@"#E6C995",@"#718473",@"#D7B48B", nil]; colorArr = [NSArray arrayWithObjects:@"#D8A88D",@"#A4C8C6",@"#E6C995",@"#718473",@"#D7B48B", nil];
int num = arc4random_uniform(10); int num = arc4random_uniform(10);
...@@ -93,10 +107,10 @@ ...@@ -93,10 +107,10 @@
} }
- (void)initHeaderView{ - (void)initHeaderView{
self.barandSelectView = [[KWMBarandSelectView alloc]init]; self.barandSelectView = [[KWMBarandSelectView alloc]init];
self.barandSelectView.count = [[KWMShoppingCart sharedInstance] count].integerValue; self.barandSelectView.count = [[KWMShoppingCart sharedInstance] count].integerValue;
self.barandSelectView.lbBrand.text = [_brand uppercaseString]; //self.barandSelectView.lbBrand.text = [_brand uppercaseString];
self.barandSelectView.lbBrand.text = _brand;
self.barandSelectView.delegate = self; self.barandSelectView.delegate = self;
[self.view addSubview:_barandSelectView]; [self.view addSubview:_barandSelectView];
[self initCustomTitleBarConstarints:self.barandSelectView]; [self initCustomTitleBarConstarints:self.barandSelectView];
...@@ -313,6 +327,7 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -313,6 +327,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
} }
- (void)setBrandData{ - (void)setBrandData{
[self initTableViewHeaderHidden];
//图片 //图片
if(_collection!=nil && _collection.image!=nil){ if(_collection!=nil && _collection.image!=nil){
NSURL *url = [_collection.image sourceURL]; NSURL *url = [_collection.image sourceURL];
......
...@@ -191,7 +191,9 @@ static NSString *cellId = @"KWMBrandCell"; ...@@ -191,7 +191,9 @@ static NSString *cellId = @"KWMBrandCell";
// brandCaramelVC.backColor = [UIColor sam_colorWithHex:colorStr]; // brandCaramelVC.backColor = [UIColor sam_colorWithHex:colorStr];
// //
// [self.navigationController pushViewController:brandCaramelVC animated:YES]; // [self.navigationController pushViewController:brandCaramelVC animated:YES];
brand = [[KWMStringUtil deleteOtherCharExceptLetterWithLine:brand] lowercaseString];
// brand = [[KWMStringUtil deleteOtherCharExceptLetterWithLine:brand] lowercaseString];
[self openURLWithString:[NSString stringWithFormat:@"https://www.cemarose.cn/collections/%@",brand]]; [self openURLWithString:[NSString stringWithFormat:@"https://www.cemarose.cn/collections/%@",brand]];
}else{ }else{
//品牌搜索 //品牌搜索
......
...@@ -246,7 +246,9 @@ static NSString *identify = @"KWMSearchBrandsCell"; ...@@ -246,7 +246,9 @@ static NSString *identify = @"KWMSearchBrandsCell";
NSDictionary *dict = self.dataArray[indexPath.section]; NSDictionary *dict = self.dataArray[indexPath.section];
brand = [dict[@"content"] objectAtIndex:indexPath.row]; brand = [dict[@"content"] objectAtIndex:indexPath.row];
} }
NSString *str = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand]; //NSString *str = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand];
NSString *str = brand;
// NSLog(@"str: %@",str); // NSLog(@"str: %@",str);
// //品牌介绍 // //品牌介绍
// KWMBrandCaramelVC *brandCaramelVC = (KWMBrandCaramelVC *)[KWMBaseVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"]; // KWMBrandCaramelVC *brandCaramelVC = (KWMBrandCaramelVC *)[KWMBaseVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"];
...@@ -320,14 +322,16 @@ static NSString *identify = @"KWMSearchBrandsCell"; ...@@ -320,14 +322,16 @@ static NSString *identify = @"KWMSearchBrandsCell";
[weakSelf.tbvSearchBrand reloadData]; [weakSelf.tbvSearchBrand reloadData];
}; };
void(^cacheCallback)(KWMBrandsResult *) = ^(KWMBrandsResult *result){ void(^cacheCallback)(KWMBrandsResult *) = ^(KWMBrandsResult *result){
if([weakSelf hasCemaroseError:result]){ // if([weakSelf hasCemaroseError:result]){
return ; // return ;
// }
if(result && result.brands){
NSArray *indexArray= [[result.brands rx_filterWithBlock:^BOOL(id each) {
return each && each != [NSNull null];
}] arrayWithPinYinFirstLetterFormat];
_dataArray =[NSMutableArray arrayWithArray:indexArray];
[weakSelf.tbvSearchBrand reloadData];
} }
NSArray *indexArray= [[result.brands rx_filterWithBlock:^BOOL(id each) {
return each && each != [NSNull null];
}] arrayWithPinYinFirstLetterFormat];
_dataArray =[NSMutableArray arrayWithArray:indexArray];
[weakSelf.tbvSearchBrand reloadData];
}; };
[self.api getAllBrand:nil cacheCallback:cacheCallback success:success failure:failure]; [self.api getAllBrand:nil cacheCallback:cacheCallback success:success failure:failure];
// [self showLoading]; // [self showLoading];
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
@{@"title":@"连裤袜",@"collection_id":@"192437830",@"image":@"ic_type_pantyhose"}, @{@"title":@"连裤袜",@"collection_id":@"192437830",@"image":@"ic_type_pantyhose"},
@{@"title":@"打底裤",@"collection_id":@"192435334",@"image":@"ic_type_leggings"}, @{@"title":@"打底裤",@"collection_id":@"192435334",@"image":@"ic_type_leggings"},
@{@"title":@"内衣",@"collection_id":@"333026694",@"image":@"ic_type_underwear"}, @{@"title":@"内衣",@"collection_id":@"333026694",@"image":@"ic_type_underwear"},
@{@"title":@"雨衣",@"collection_id":@"423509068",@"image":@"ic_type_raincoat"}, // @{@"title":@"雨衣",@"collection_id":@"423509068",@"image":@"ic_type_raincoat"},
@{@"title":@"鞋子",@"collection_id":@"171856134",@"image":@"ic_type_shoe"}, @{@"title":@"鞋子",@"collection_id":@"171856134",@"image":@"ic_type_shoe"},
@{@"title":@"玩具",@"collection_id":@"332990918",@"image":@"ic_type_toy"}, @{@"title":@"玩具",@"collection_id":@"332990918",@"image":@"ic_type_toy"},
@{@"title":@"配件",@"collection_id":@"191376966",@"image":@"ic_type_Acc"}, @{@"title":@"配件",@"collection_id":@"191376966",@"image":@"ic_type_Acc"},
...@@ -300,10 +300,12 @@ ...@@ -300,10 +300,12 @@
} }
}; };
void(^cacheCallback)(KWMBrandsResult *) = ^(KWMBrandsResult *result){ void(^cacheCallback)(KWMBrandsResult *) = ^(KWMBrandsResult *result){
if([weakSelf hasCemaroseError:result]){ // if([weakSelf hasCemaroseError:result]){
return ; // return ;
// }
if(result && result.brands){
self.allBrands = result.brands;
} }
self.allBrands = result.brands;
}; };
[self.api getAllBrand:nil cacheCallback:cacheCallback success:success failure:failure]; [self.api getAllBrand:nil cacheCallback:cacheCallback success:success failure:failure];
} }
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13174"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<customFonts key="customFonts"> <customFonts key="customFonts">
...@@ -17,7 +18,6 @@ ...@@ -17,7 +18,6 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMHotSalesHeader"> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMHotSalesHeader">
<connections> <connections>
<outlet property="bannerView" destination="Ruv-UI-DGw" id="USH-xg-KHp"/> <outlet property="bannerView" destination="Ruv-UI-DGw" id="USH-xg-KHp"/>
<outlet property="heightBannerView" destination="NbW-Kh-s5O" id="zdT-r2-QNE"/>
<outlet property="heightSingleShowView" destination="SEw-Tw-g0a" id="PcT-Pv-gcm"/> <outlet property="heightSingleShowView" destination="SEw-Tw-g0a" id="PcT-Pv-gcm"/>
<outlet property="singleShowView" destination="UGY-II-IMu" id="wxp-gP-PDh"/> <outlet property="singleShowView" destination="UGY-II-IMu" id="wxp-gP-PDh"/>
<outlet property="vView" destination="iN0-l3-epB" id="bI2-U9-soo"/> <outlet property="vView" destination="iN0-l3-epB" id="bI2-U9-soo"/>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="190"/> <rect key="frame" x="0.0" y="0.0" width="375" height="190"/>
<color key="backgroundColor" red="0.90588235289999997" green="0.81960784310000001" blue="0.74117647060000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.90588235289999997" green="0.81960784310000001" blue="0.74117647060000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="190" id="NbW-Kh-s5O"/> <constraint firstAttribute="width" secondItem="Ruv-UI-DGw" secondAttribute="height" multiplier="375:190" id="wq7-qE-RyI"/>
</constraints> </constraints>
</view> </view>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="UGY-II-IMu"> <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="UGY-II-IMu">
......
...@@ -68,6 +68,7 @@ typedef enum{ ...@@ -68,6 +68,7 @@ typedef enum{
@implementation KWMNewHomeVC{ @implementation KWMNewHomeVC{
CGFloat heightAdHeader; CGFloat heightAdHeader;
CGFloat heightClothingSets; CGFloat heightClothingSets;
CGFloat heightHotSale;
} }
- (void)viewDidLoad { - (void)viewDidLoad {
...@@ -99,11 +100,12 @@ typedef enum{ ...@@ -99,11 +100,12 @@ typedef enum{
// self.title = @"首页"; // self.title = @"首页";
heightAdHeader = UI_SCREEN_WIDTH * 275 / 375; heightAdHeader = UI_SCREEN_WIDTH * 275 / 375;
heightClothingSets = UI_SCREEN_WIDTH * 190 / 375 + 127; //127为图片外的布局高度 heightClothingSets = UI_SCREEN_WIDTH * 190 / 375 + 127; //127为图片外的布局高度
heightHotSale = UI_SCREEN_WIDTH * 190 / 375 + 60;//60为图片外的布局高度
self.adHeader = [[KWMAdHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, heightAdHeader)]; self.adHeader = [[KWMAdHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, heightAdHeader)];
self.menuHeader = [[KWMMenuHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 100)]; self.menuHeader = [[KWMMenuHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 100)];
self.recommendHeader = [[KWMRecommendHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 230)]; self.recommendHeader = [[KWMRecommendHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 230)];
self.clothingSetsHeader = [[KWMClothingSetsHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, heightClothingSets)]; self.clothingSetsHeader = [[KWMClothingSetsHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, heightClothingSets)];
self.hotSalesHeader = [[KWMHotSalesHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 250)]; self.hotSalesHeader = [[KWMHotSalesHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, heightHotSale)];
self.adHeader.delegate = self; self.adHeader.delegate = self;
self.menuHeader.delegate = self; self.menuHeader.delegate = self;
...@@ -291,7 +293,7 @@ typedef enum{ ...@@ -291,7 +293,7 @@ typedef enum{
height = heightClothingSets; height = heightClothingSets;
break; break;
case HeaderHotSales: case HeaderHotSales:
height = self.hotSalesHeader.actrualHeight; height = heightHotSale;
break; break;
default: default:
break; break;
...@@ -352,19 +354,19 @@ typedef enum{ ...@@ -352,19 +354,19 @@ typedef enum{
BOOL isHome = [handle isEqualToString:@"products-list-app-homepage"]; BOOL isHome = [handle isEqualToString:@"products-list-app-homepage"];
NSInteger cpage = isHome ? self.page : 1; NSInteger cpage = isHome ? self.page : 1;
NSDictionary *parameters = [self getProductCacheKeyDictionary:cpage tags:tags handle:handle]; NSDictionary *parameters = [self getProductCacheKeyDictionary:cpage tags:tags handle:handle];
if([self isUseProductDataCache:parameters valueKeyPath:valueKeyPath page:cpage isHome:isHome]){ BOOL isUseCache = [self isUseProductDataCache:parameters valueKeyPath:valueKeyPath page:cpage isHome:isHome];
return;
}
[self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) { [self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
[self hideLoading]; [self hideLoading];
if (!error) { if (!error) {
[self.client getProductsPage:cpage inCollection:collection.identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) { [self.client getProductsPage:cpage inCollection:collection.identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) {
if (!error) { if (!error) {
[KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage products:products]; [KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage products:products];
[self setValue:products forKeyPath:valueKeyPath]; if(!isUseCache){
[self.cvHome reloadData]; [self setValue:products forKeyPath:valueKeyPath];
[self.cvHome reloadData];
}
}else{ }else{
[self showError:error]; // [self showError:error];
} }
if (isHome) { if (isHome) {
self.page = self.page + 1; self.page = self.page + 1;
...@@ -397,15 +399,15 @@ typedef enum{ ...@@ -397,15 +399,15 @@ typedef enum{
- (void) loadHomeData { - (void) loadHomeData {
[self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"]; [self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"];
if([self isUseHomeDataCache]){ BOOL isUseCache = [self isUseHomeDataCache];
return;
}
[self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) { [self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) {
[KWMPPCacheUtil saveDataToCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess homeData:result.data]; [KWMPPCacheUtil saveDataToCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess homeData:result.data];
self.homeData = result.data; if(!isUseCache){
[self.cvHome reloadData]; self.homeData = result.data;
[self.cvHome reloadData];
}
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
[self showError:error]; // [self showError:error];
}]; }];
} }
...@@ -453,6 +455,7 @@ typedef enum{ ...@@ -453,6 +455,7 @@ typedef enum{
#pragma mark -cache #pragma mark -cache
/** 因为homedata api的url是动态的,url上的时间戳随时间的改变,所以需要手动保存,和获取 **/ /** 因为homedata api的url是动态的,url上的时间戳随时间的改变,所以需要手动保存,和获取 **/
//缓存规则:网络请求数据照常,如果没网络,并且缓存有数据,会拿缓存的数据显示。
-(BOOL)isUseHomeDataCache{ -(BOOL)isUseHomeDataCache{
if(!kIsNetwork){ if(!kIsNetwork){
KWMHomeData *homeData = [KWMPPCacheUtil getHomeDataByCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess]; KWMHomeData *homeData = [KWMPPCacheUtil getHomeDataByCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess];
...@@ -460,7 +463,7 @@ typedef enum{ ...@@ -460,7 +463,7 @@ typedef enum{
self.homeData = homeData; self.homeData = homeData;
[self.cvHome reloadData]; [self.cvHome reloadData];
}else{ }else{
[self showToast:CACHE_KEY_FAIL_HINT]; return false;
} }
} }
return !kIsNetwork; return !kIsNetwork;
...@@ -483,6 +486,7 @@ typedef enum{ ...@@ -483,6 +486,7 @@ typedef enum{
return params; return params;
} }
//缓存规则:网络请求数据照常,如果没网络,并且缓存有数据,会拿缓存的数据显示。
-(BOOL)isUseProductDataCache:(NSDictionary *)cacheKeyDictionary valueKeyPath:(NSString *)valueKeyPath page:(NSUInteger)page isHome:(BOOL)isHome{ -(BOOL)isUseProductDataCache:(NSDictionary *)cacheKeyDictionary valueKeyPath:(NSString *)valueKeyPath page:(NSUInteger)page isHome:(BOOL)isHome{
if(!kIsNetwork){ if(!kIsNetwork){
[self hideLoading]; [self hideLoading];
...@@ -495,10 +499,7 @@ typedef enum{ ...@@ -495,10 +499,7 @@ typedef enum{
products.count ? [self.cvHome.mj_footer endRefreshing] : [self.cvHome.mj_footer endRefreshingWithNoMoreData]; products.count ? [self.cvHome.mj_footer endRefreshing] : [self.cvHome.mj_footer endRefreshingWithNoMoreData];
} }
}else{ }else{
[self showToast:CACHE_KEY_FAIL_HINT]; return false;
if (isHome) {
[self.cvHome.mj_footer endRefreshing];
}
} }
} }
return !kIsNetwork; return !kIsNetwork;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#import "KWMSearchFeedBackView.h" #import "KWMSearchFeedBackView.h"
#import "KWMNewProductVC.h" #import "KWMNewProductVC.h"
#import "MJRefresh.h" #import "MJRefresh.h"
#import "KWMStringUtil.h"
@interface KWMSearchFeedbackVC ()<UITableViewDelegate,UITableViewDataSource,KWMSearchFeedBackViewDelegate,KWMBrandCaramelCellDelegate> @interface KWMSearchFeedbackVC ()<UITableViewDelegate,UITableViewDataSource,KWMSearchFeedBackViewDelegate,KWMBrandCaramelCellDelegate>
@property (nonatomic) KWMSearchFeedBackView *vSearchFB; @property (nonatomic) KWMSearchFeedBackView *vSearchFB;
...@@ -52,8 +53,8 @@ ...@@ -52,8 +53,8 @@
} }
- (void)reLoadData{ - (void)reLoadData{
self.currentPage = @0;
// [self getSearchProduct]; [self getSearchProduct];
} }
static NSString *idStr = @"KWMBrandCaramelCell"; static NSString *idStr = @"KWMBrandCaramelCell";
- (void)viewDidLoad { - (void)viewDidLoad {
...@@ -189,7 +190,9 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -189,7 +190,9 @@ static NSString *idStr = @"KWMBrandCaramelCell";
//搜索API //搜索API
- (void)getSearchProduct{ - (void)getSearchProduct{
if([KWMStringUtil isEmpty:_searchText]){
return;
}
if ([[_searchText lowercaseString] isEqualToString:@"bonpoint"]) { if ([[_searchText lowercaseString] isEqualToString:@"bonpoint"]) {
self.vNoGoods.hidden = NO; self.vNoGoods.hidden = NO;
return; return;
......
...@@ -84,12 +84,17 @@ ...@@ -84,12 +84,17 @@
// NSDictionary *saveDict = collection.JSONDictionary; // NSDictionary *saveDict = collection.JSONDictionary;
// [PPNetworkCache setHttpCache:saveDict URL:urlKey parameters:cacheKeyDictionary]; // [PPNetworkCache setHttpCache:saveDict URL:urlKey parameters:cacheKeyDictionary];
// } // }
if(collection){ if(collection && collection.identifier){
NSString *imageString = collection.image.sourceURL.absoluteString; NSMutableDictionary *collectionData = @{@"identifier":collection.identifier.stringValue,
NSDictionary *collectionData = @{@"image":imageString,
@"identifier":collection.identifier.stringValue,
@"description":collection.htmlDescription, @"description":collection.htmlDescription,
}; }.mutableCopy;;
if (collection.image && collection.image.sourceURL) {
NSString *imageString = collection.image.sourceURL.absoluteString;
collectionData[@"image"] = imageString;
}
if(collection.htmlDescription){
collectionData[@"description"] = collection.htmlDescription;
}
[PPNetworkCache setHttpCache:collectionData URL:urlKey parameters:cacheKeyDictionary]; [PPNetworkCache setHttpCache:collectionData URL:urlKey parameters:cacheKeyDictionary];
} }
} }
...@@ -100,10 +105,16 @@ ...@@ -100,10 +105,16 @@
// BUYCollection *collection = (BUYCollection *)[[BUYModelManager modelManager] buy_objectWithEntityName:[BUYCollection entityName] JSONDictionary:cacheDictionary]; // BUYCollection *collection = (BUYCollection *)[[BUYModelManager modelManager] buy_objectWithEntityName:[BUYCollection entityName] JSONDictionary:cacheDictionary];
// return collection; // return collection;
BUYCollection *collection = [[BUYCollection alloc]init]; BUYCollection *collection = [[BUYCollection alloc]init];
collection.image = [[BUYImageLink alloc]init]; if(cacheDictionary[@"image"]){
NSString *imageString = cacheDictionary[@"image"]; collection.image = [[BUYImageLink alloc]init];
collection.image.sourceURL = [[NSURL alloc]initWithString:imageString]; NSString *imageString = cacheDictionary[@"image"];
collection.htmlDescription = cacheDictionary[@"description"]; collection.image.sourceURL = [[NSURL alloc]initWithString:imageString];
}
if(cacheDictionary[@"description"]){
collection.htmlDescription = cacheDictionary[@"description"];
}else{
collection.htmlDescription = @"";
}
NSString *idString = cacheDictionary[@"identifier"]; NSString *idString = cacheDictionary[@"identifier"];
collection.identifier = @([idString integerValue]); collection.identifier = @([idString integerValue]);
return collection; return collection;
......
...@@ -411,8 +411,8 @@ static NSDateFormatter *monthDayFormatter; ...@@ -411,8 +411,8 @@ static NSDateFormatter *monthDayFormatter;
return rect.size; return rect.size;
} }
//删除出字母以外的字符补充为@"-" //删除出字母以及“-”以外的字符补充为@"-"
static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
+ (NSString *)deleteOtherCharExceptLetterWithLine:(NSString *)str{ + (NSString *)deleteOtherCharExceptLetterWithLine:(NSString *)str{
NSString *changeStr = [str stringByReplacingOccurrencesOfString:@"é" withString:@"e"]; NSString *changeStr = [str stringByReplacingOccurrencesOfString:@"é" withString:@"e"];
......
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