Commit 71b03f5d by houweibin

1,新主页面-分类页面。(未完成-未接入正式数据,该页面暂不显示出来,仍显示旧主页面-商品主页面。)

parent ecf2e870
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "test_category@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "test_category@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "test_category_s@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "test_category_s@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -106,7 +106,8 @@
self.currentPage = 0;
if(self.collection!=nil && self.collection.identifier!=nil){
[self getProcduct:self.collection.identifier];
}}
}
}
- (void)initHeaderView{
......
//
// KWMLeftCategoryCell.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface KWMLeftCategoryCell : UITableViewCell
@end
//
// KWMLeftCategoryCell.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMLeftCategoryCell.h"
#import "UIColor+SAMAdditions.h"
@interface KWMLeftCategoryCell()
@property (nonatomic,weak) IBOutlet UIImageView *ivCategory;
@property (nonatomic,weak) IBOutlet UILabel *lbTitle;
@end
@implementation KWMLeftCategoryCell
- (void)awakeFromNib {
[super awakeFromNib];
self.selectedBackgroundView = [[UIView alloc] initWithFrame:self.frame];
self.selectedBackgroundView.backgroundColor = [UIColor sam_colorWithHex:@"#F4F5F7"];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
UIColor *textColor = selected?[UIColor sam_colorWithHex:@"#F1929A"]:[UIColor sam_colorWithHex:@"#545454"];
UIImage *image = selected?[UIImage imageNamed:@"test_category_s"]:[UIImage imageNamed:@"test_category"];
self.ivCategory.image = image;
self.lbTitle.textColor = textColor;
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="KWMLeftCategoryCell">
<rect key="frame" x="0.0" y="0.0" width="90" height="60"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="90" height="59.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JCm-bX-LN5">
<rect key="frame" x="0.0" y="0.0" width="90" height="59.5"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="test_category" translatesAutoresizingMaskIntoConstraints="NO" id="AgB-Gc-x75">
<rect key="frame" x="30" y="5" width="30" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="30" id="Cwa-7S-AOw"/>
<constraint firstAttribute="height" constant="30" id="bVj-hu-0u2"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="上衣" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="O2z-nf-pqq">
<rect key="frame" x="32" y="35" width="26.5" height="18.5"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/>
<color key="textColor" red="0.32941176470588235" green="0.32941176470588235" blue="0.32941176470588235" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="AgB-Gc-x75" firstAttribute="centerX" secondItem="JCm-bX-LN5" secondAttribute="centerX" id="MZN-8r-ep6"/>
<constraint firstItem="O2z-nf-pqq" firstAttribute="centerX" secondItem="JCm-bX-LN5" secondAttribute="centerX" id="kO3-bC-3qr"/>
<constraint firstItem="AgB-Gc-x75" firstAttribute="top" secondItem="JCm-bX-LN5" secondAttribute="top" constant="5" id="x1h-iO-rkU"/>
<constraint firstItem="O2z-nf-pqq" firstAttribute="top" secondItem="AgB-Gc-x75" secondAttribute="bottom" id="xmQ-Sk-Eo7"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="JCm-bX-LN5" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="7zW-e0-FaU"/>
<constraint firstAttribute="trailing" secondItem="JCm-bX-LN5" secondAttribute="trailing" id="8bp-ge-oM8"/>
<constraint firstItem="JCm-bX-LN5" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="MZm-fF-F9Q"/>
<constraint firstAttribute="bottom" secondItem="JCm-bX-LN5" secondAttribute="bottom" id="umZ-4B-2Rg"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="ivCategory" destination="AgB-Gc-x75" id="DN6-Iw-76m"/>
<outlet property="lbTitle" destination="O2z-nf-pqq" id="Rzs-IN-Kho"/>
</connections>
</tableViewCell>
</objects>
<resources>
<image name="test_category" width="28" height="21"/>
</resources>
</document>
//
// KWMRightProductCell.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Buy/Buy.h>
@interface KWMRightProductCell : UICollectionViewCell
@property(nonatomic) BUYProduct *product;
@end
//
// KWMRightProductCell.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMRightProductCell.h"
#import "KWMStringUtil.h"
#import "KWMImageUtil.h"
#import "UIImageView+WebCache.h"
#import "UIView+Prettify.h"
@interface KWMRightProductCell()
@property(nonatomic,weak) IBOutlet UIImageView *ivProduct;
@property(nonatomic,weak) IBOutlet UILabel *lbTitle;
@property(nonatomic,weak) IBOutlet UILabel *lbSinglePrice;
@property(nonatomic,weak) IBOutlet UILabel *lbPrice;
@property(nonatomic,weak) IBOutlet UILabel *lbCompareAtPrice;
@end
@implementation KWMRightProductCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
[self initDefaultShadow];
}
-(void)setProduct:(BUYProduct *)product{
if(!product){
return;
}
_product = product;
NSArray *variantsArray = product.variantsArray;
if(variantsArray && variantsArray.count > 0){
BUYProductVariant *variant = variantsArray.firstObject;
self.lbPrice.text = [KWMStringUtil price:variant.price];
self.lbSinglePrice.text = [KWMStringUtil price:variant.price];
self.lbCompareAtPrice.text = [KWMStringUtil price:variant.compareAtPrice];
}
NSString *imageUrl = [KWMImageUtil getProductImageUrl:product ImageSize:SmallImage];
NSURL *imageURL = [NSURL URLWithString:imageUrl];
[self.ivProduct sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
}
@end
//
// KWMBrandFilterVC.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/20.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseVC.h"
@protocol KWMBrandFilterDelegate <NSObject>
- (void)kwm_onCancelBrandFilter;
- (void)kwm_onCompleteBrandFilter:(NSString *)selectBrand;
@end
@interface KWMBrandFilterVC : KWMBaseVC<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic) NSArray *brandArray;
@property (nonatomic) NSString *selectBrand;
@property(nonatomic,weak) id<KWMBrandFilterDelegate> delegate;
@end
//
// KWMBrandFilterVC.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/20.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBrandFilterVC.h"
#import "KWMSearchBrandsCell.h"
#import "UIColor+SAMAdditions.h"
#import "KWMStringUtil.h"
#import "NSString+PinYin.h"
@interface KWMBrandFilterVC ()
@property (nonatomic) NSArray *firstLetterArray;
@property (weak, nonatomic) IBOutlet UITableView *tbvBrand;
@end
@implementation KWMBrandFilterVC
- (void)viewDidLoad {
[super viewDidLoad];
[self.tbvBrand registerNib:[UINib nibWithNibName:NSStringFromClass([KWMSearchBrandsCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([KWMSearchBrandsCell class])];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(NSString *)selectBrand{
return _selectBrand?_selectBrand:@"";
}
-(void)setBrandArray:(NSArray *)brandArray{
if(brandArray){
_brandArray = brandArray;
self.firstLetterArray = [brandArray arrayWithPinYinFirstLetterFormat];
}
}
-(IBAction)onClickComplete:(id)sender{
if(self.delegate){
[self.delegate kwm_onCompleteBrandFilter:self.selectBrand];
}
[self dismissViewControllerAnimated:YES completion:^{
}];
}
-(IBAction)onClickBlank:(id)sender{
if(self.delegate){
[self.delegate kwm_onCancelBrandFilter];
}
[self dismissViewControllerAnimated:YES completion:^{
}];
}
#pragma mark - UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return self.firstLetterArray?self.firstLetterArray.count:0;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if(self.firstLetterArray){
NSDictionary *dict = self.firstLetterArray[section];
NSMutableArray *array = dict[@"content"];
return array.count;
}
return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
KWMSearchBrandsCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([KWMSearchBrandsCell class])];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
NSDictionary *dict = self.firstLetterArray[indexPath.section];
NSMutableArray *array = dict[@"content"];
NSString *brand = array[indexPath.row];
cell.lbBrand.text = brand;
cell.lbBrand.textColor = [brand isEqualToString:self.selectBrand]?[UIColor sam_colorWithHex:@"#F1929A"]:[UIColor sam_colorWithHex:@"#545454"];
return cell;
}
#pragma mark - UITableViewDelegate
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIView *view = [[UIView alloc]init];
view.backgroundColor = [UIColor whiteColor];
UILabel *lbTitle = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 90, 40)];;
lbTitle.text = self.firstLetterArray[section][@"firstLetter"];
lbTitle.font = [UIFont systemFontOfSize:24];
[view addSubview:lbTitle];
UIView *vLine = [[UIView alloc] initWithFrame:CGRectMake(20, 39, UI_SCREEN_WIDTH - 40, 1)];
vLine.backgroundColor = [UIColor sam_colorWithHex:@"#F4F5F7"];
[view addSubview:vLine];
return view;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH ,5)];
view.backgroundColor = [UIColor sam_colorWithHex:@"#F4F5F7"];
return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 40;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 5;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSDictionary *dict = self.firstLetterArray[indexPath.section];
NSString *brand = [dict[@"content"] objectAtIndex:indexPath.row];
NSString *str = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand];
self.selectBrand = [brand isEqualToString:self.selectBrand]?@"":brand;
[self.tbvBrand reloadData];
}
#pragma mark - 索引
//添加TableView头视图标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSDictionary *dict = self.firstLetterArray[section];
NSString *title = dict[@"firstLetter"];
return title;
}
//添加索引栏标题数组
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
NSMutableArray *resultArray = [NSMutableArray array];
for (NSDictionary *dict in self.firstLetterArray) {
NSString *title = dict[@"firstLetter"];
[resultArray addObject:title];
}
return resultArray;
}
//点击索引栏标题时执行
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:index]atScrollPosition:UITableViewScrollPositionTop animated:YES];
return index;
}
@end
//
// KWMCategoryVC.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseVC.h"
#import "KWMCollectionRefreshUtil.h"
#import "KWMCategoryFilterTab.h"
#import "KWMProductFilterVC.h"
#import "KWMBrandFilterVC.h"
@interface KWMCategoryVC : KWMBaseVC<UICollectionViewDataSource,UICollectionViewDelegate,UITableViewDataSource,UITableViewDelegate,KWMCollectionRefreshDelegate,CategoryFilterTabDelegate,KWMProductFilterDelegate,KWMBrandFilterDelegate>
@end
//
// KWMCategoryVC.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMCategoryVC.h"
#import "KWMProductDetailVC.h"
#import "KWMLeftCategoryCell.h"
#import "KWMRightProductCell.h"
#import "KWMBrandsTypeModel.h"
#import "KWMSearchBar.h"
#import "KWMStringUtil.h"
#import "KWMFilterUtil.h"
#import "MJRefresh.h"
//#import <RXCollections/RXCollection.h>
@interface KWMCategoryVC ()
@property (nonatomic,weak) IBOutlet KWMCategoryFilterTab *filterTab;
@property (nonatomic,weak) IBOutlet UITableView *tbvLeftCategory;
@property (nonatomic,weak) IBOutlet UICollectionView *cvRightProduct;
@property(nonatomic) KWMCollectionRefreshUtil *refreshUtil;
@property (nonatomic) KWMSearchBar *searchBar;
@property (nonatomic) NSArray *allBrands;
@property(nonatomic) BUYCollectionSort sort;
@property(nonatomic) NSMutableArray<KWMFilter *> *selectFilters;
@property(nonatomic) NSString *selectBrands;
@end
@implementation KWMCategoryVC
- (void)awakeFromNib{
[super awakeFromNib];
self.title = @"分类";
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initView];
[self requestAllBrandsApi];
[self.refreshUtil reLoadData];
[self.cvRightProduct.mj_header beginRefreshing];
}
-(KWMCollectionRefreshUtil *)refreshUtil{
if(!_refreshUtil){
_refreshUtil = [KWMCollectionRefreshUtil new];
_refreshUtil.collectionView = self.cvRightProduct;
_refreshUtil.delegate = self;
_refreshUtil.emptyMsg = @" ";
}
return _refreshUtil;
}
-(void)initView{
[self initTitleView];
[self initTbvLeft];
[self initCvRight];
self.sort = BUYCollectionSortCreatedAscending;
self.selectBrands = @"";
}
-(void)initTbvLeft{
self.automaticallyAdjustsScrollViewInsets = NO;
[self.tbvLeftCategory registerNib:[UINib nibWithNibName:NSStringFromClass([KWMLeftCategoryCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([KWMLeftCategoryCell class])];
}
-(void)initCvRight{
[self.cvRightProduct registerNib:[UINib nibWithNibName:NSStringFromClass([KWMRightProductCell class]) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass([KWMRightProductCell class])];
self.filterTab.delegate = self;
}
- (void)initTitleView{
[self.navigationController setNavigationBarHidden:YES];
//添加頭部header
self.searchBar = [[KWMSearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
// self.searchBar.delegate = self;
[self.view addSubview:_searchBar];
}
#pragma mark - UITableViewDataSource
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
KWMLeftCategoryCell *categoryCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([KWMLeftCategoryCell class]) forIndexPath:indexPath];
return categoryCell;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 20;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.01;
}
#pragma mark - UICollectionViewDataSource
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
KWMRightProductCell *productCell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([KWMRightProductCell class]) forIndexPath:indexPath];
productCell.product = (BUYProduct *)[self.refreshUtil.dataList objectAtIndex:indexPath.row];
return productCell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
NSInteger width = ( (UI_SCREEN_WIDTH - 90) - (18*3) )/2;
NSInteger height = width * 160 / 114 ;
CGSize size = CGSizeMake(width, height);
return size;
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.refreshUtil.dataList.count;
}
#pragma mark - UICollectionViewDelegate
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC *)[KWMProductDetailVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"];
BUYProduct *product = (BUYProduct *)[self.refreshUtil.dataList objectAtIndex:indexPath.row];
productDetailVC.product = product;
[self.navigationController pushViewController:productDetailVC animated:YES];
}
#pragma mark - KWMCollectionRefreshDelegate
-(void)refreshUtil:(KWMCollectionRefreshUtil *)util onLoad:(NSInteger)page{
[self requestProducts:page];
}
#pragma mark - CategoryFilterTabDelegate
-(void)kwm_onClickTab:(KWMFilterMode)filterMode isExpandView:(BOOL)isExpand{
KWMBaseVC *tragetVC;
if(filterMode == ModeBrand){
KWMBrandFilterVC *brandFilterVC = (KWMBrandFilterVC *)[KWMBaseVC findControllerBy:[KWMBrandFilterVC kwmTag] fromStoryboard:@"Category"];
brandFilterVC.brandArray = self.allBrands;
brandFilterVC.delegate = self;
brandFilterVC.selectBrand = self.selectBrands;
tragetVC = brandFilterVC;
}else{
KWMProductFilterVC *productFilterVC = (KWMProductFilterVC *)[KWMBaseVC findControllerBy:[KWMProductFilterVC kwmTag] fromStoryboard:@"Category"];
productFilterVC.filterMode = filterMode;
productFilterVC.delegate = self;
productFilterVC.selectedSort = self.sort;
productFilterVC.selectedTags = self.selectFilters;
tragetVC = productFilterVC;
}
CGSize size = [UIScreen mainScreen].bounds.size;
[self showPresentation:tragetVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade];
}
#pragma mark -
-(void)kwm_onCompleProductFilter:(KWMFilterView *)filterView{
self.selectFilters = filterView.selectedTags;
self.sort = filterView.selectedSort;
[self.filterTab close];
[self.refreshUtil reLoadData];
[self.cvRightProduct.mj_header beginRefreshing];
[self.cvRightProduct setContentOffset:CGPointMake(0,0) animated:YES];
}
-(void)kwm_onCancelProductFilter:(KWMFilterView *)filterView{
[self.filterTab close];
}
#pragma mark -
-(void)kwm_onCompleteBrandFilter:(NSString *)selectBrand{
self.selectBrands = selectBrand;
[self.filterTab close];
[self.refreshUtil reLoadData];
[self.cvRightProduct.mj_header beginRefreshing];
[self.cvRightProduct setContentOffset:CGPointMake(0,0) animated:YES];
}
-(void)kwm_onCancelBrandFilter{
[self.filterTab close];
}
#pragma mark - API KWMAPIManager.h
-(void)requestAllBrandsApi{
__weak KWMCategoryVC *weakSelf = self;
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
[weakSelf showError:error];
};
void(^success)(NSURLSessionDataTask *,KWMBrandsResult *) = ^(NSURLSessionDataTask *task,KWMBrandsResult *result){
if([weakSelf hasCemaroseError:result]){
return ;
}
self.allBrands = result.brands;
};
[self.api getAllBrand:nil success:success failure:failure];
}
#pragma mark - API BUYClient+Storefront.h
-(void)requestProducts:(NSInteger)page{
__weak KWMCategoryVC *weakSelf = self;
self.filterTab.userInteractionEnabled = false;
NSMutableArray *tags = [KWMFilterUtil getTagsByFilterArray:self.selectFilters];
if(![KWMStringUtil isEmpty:self.selectBrands]){
[tags addObject:self.selectBrands];
}
[self.client getProductsPage:page inCollection:@(171596038) withTags:tags sortOrder:self.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
[weakSelf.refreshUtil hideLoading];
weakSelf.filterTab.userInteractionEnabled = true;
if(error){
[weakSelf showError:error];
}
else{
weakSelf.refreshUtil.page = page;
weakSelf.refreshUtil.hasNextPage = !reachedEnd;
[weakSelf.refreshUtil appendDataList:products];
}
}];
}
@end
//
// KWMCategoryFilterVC.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/19.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseVC.h"
#import "KWMFilterView.h"
@protocol KWMProductFilterDelegate <NSObject>
- (void)kwm_onCancelProductFilter:(KWMFilterView *)filterView;
- (void)kwm_onCompleProductFilter:(KWMFilterView *)filterView;
@end
@interface KWMProductFilterVC : KWMBaseVC<KWMFilterDelegate>
@property(nonatomic) KWMFilterMode filterMode;
@property(nonatomic,weak) id<KWMProductFilterDelegate> delegate;
@property(nonatomic) NSMutableArray<KWMFilter *> *selectedTags;
@property(nonatomic) BUYCollectionSort selectedSort;
@end
//
// KWMCategoryFilterVC.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/19.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMProductFilterVC.h"
#import "KWMCategoryFilterTab.h"
#import "KWMFilter.h"
@interface KWMProductFilterVC ()
@property(weak,nonatomic) IBOutlet UIView *bg;
@property(weak,nonatomic) IBOutlet KWMFilterView *filterView;
@property(weak,nonatomic) IBOutlet NSLayoutConstraint *heightFilter;
@end
@implementation KWMProductFilterVC
- (void)viewDidLoad {
[super viewDidLoad];
self.filterView.delegate = self;
self.filterView.selectedTags = _selectedTags;
self.filterView.selectedSortPosition = [self getSelectSortPosition:_selectedSort];
self.filterView.filterMode = self.filterMode;
self.heightFilter.constant = self.filterMode == ModeFilter?UI_SCREEN_HEITHT * 0.85:210;
}
-(NSInteger)getSelectSortPosition:(BUYCollectionSort)sort{
switch (sort) {
case BUYCollectionSortCreatedAscending:
return 0;
case BUYCollectionSortCreatedDescending:
return 1;
case BUYCollectionSortPriceAscending:
return 2;
case BUYCollectionSortPriceDescending:
return 3;
default:
return 0;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(void)setFilterMode:(KWMFilterMode)filterMode{
_filterMode = filterMode;
}
-(void)setDelegate:(id<KWMProductFilterDelegate>)delegate{
_delegate = delegate;
}
-(BUYCollectionSort)selectedSort{
return self.filterView.selectedSort;
}
-(NSMutableArray<KWMFilter *> *)selectedTags{
return self.filterView.selectedTags;
}
-(void)kwm_onClickFilter:(KWMFilterView *)filterView{
if(self.delegate){
[self.delegate kwm_onCompleProductFilter:filterView];
}
[self dismissViewControllerAnimated:YES completion:^{
}];
}
-(IBAction)onClickBlank:(id)sender{
if(self.delegate){
[self.delegate kwm_onCancelProductFilter:self.filterView];
}
[self dismissViewControllerAnimated:YES completion:^{
}];
}
@end
......@@ -13,6 +13,7 @@
//#import <AMapLocationKit/AMapLocationKit.h>
#import "AppDelegate.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "MZFormSheetPresentationViewController.h"
#import "Buy/Buy.h"
......@@ -60,6 +61,8 @@
image:(UIImage *)image
action:(SEL)action;
- (void)showPresentation:(UIViewController *)vc size:(CGSize)size tapOutsideClose:(BOOL)tapOutsideClose style:(MZFormSheetPresentationTransitionStyle)style;
/**将URL转成UIImage*/
- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;
@end
......@@ -508,6 +508,21 @@
return [[UIBarButtonItem alloc] initWithCustomView:btnView];
}
- (void)showPresentation:(UIViewController *)vc size:(CGSize)size tapOutsideClose:(BOOL)tapOutsideClose style:(MZFormSheetPresentationTransitionStyle)style {
MZFormSheetPresentationViewController *mz = [[MZFormSheetPresentationViewController alloc] initWithContentViewController:vc];
mz.presentationController.shouldDismissOnBackgroundViewTap = tapOutsideClose;
mz.presentationController.movementActionWhenKeyboardAppears = MZFormSheetActionWhenKeyboardAppearsCenterVertically;
mz.contentViewControllerTransitionStyle = style;
if (size.width > 0 && size.height > 0) {
mz.presentationController.contentViewSize = size;
}
mz.presentationController.shouldCenterVertically = YES;
[self presentViewController:mz
animated:YES
completion:nil];
}
/**将URL转成UIImage*/
- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
......
......@@ -459,19 +459,5 @@
}];
}
- (void)showPresentation:(UIViewController *)vc size:(CGSize)size tapOutsideClose:(BOOL)tapOutsideClose style:(MZFormSheetPresentationTransitionStyle)style {
MZFormSheetPresentationViewController *mz = [[MZFormSheetPresentationViewController alloc] initWithContentViewController:vc];
mz.presentationController.shouldDismissOnBackgroundViewTap = tapOutsideClose;
mz.presentationController.movementActionWhenKeyboardAppears = MZFormSheetActionWhenKeyboardAppearsCenterVertically;
mz.contentViewControllerTransitionStyle = style;
if (size.width > 0 && size.height > 0) {
mz.presentationController.contentViewSize = size;
}
mz.presentationController.shouldCenterVertically = YES;
[self presentViewController:mz
animated:YES
completion:nil];
}
@end
......@@ -682,6 +682,8 @@
-(void)goToWebPay{
KWMCheckoutWebViewVC *checkoutVC = (KWMCheckoutWebViewVC *)[KWMBaseVC findControllerBy:[KWMCheckoutWebViewVC kwmTag] fromStoryboard:@"ShopCart"];
checkoutVC.payURL = self.checkout.webCheckoutURL;
// checkoutVC.payURL = [NSURL URLWithString:@"http://wxpay.wxutil.com/mch/pay/h5.v2.php"];
[self.navigationController pushViewController:checkoutVC animated:YES];
}
......
......@@ -61,11 +61,6 @@
if (result) {
[self.dataList addObjectsFromArray:result];
}
if (!self.hasNextPage) {
self.collectionView.mj_footer.hidden = YES;
}else{
self.collectionView.mj_footer.hidden = NO;
}
[self.collectionView reloadData];
BOOL hide = self.dataList.count > 0;
self.emptyView.hidden = hide;
......@@ -134,6 +129,11 @@
return self.page == 1;
}
-(void)setHasNextPage:(BOOL)hasNextPage{
_hasNextPage = hasNextPage;
self.collectionView.mj_footer.hidden = !hasNextPage;
}
-(void)setCollectionView:(UICollectionView *)collectionView{
_collectionView = collectionView;
if (!self.hideHeader || !collectionView.mj_header) {
......@@ -168,12 +168,8 @@
}
- (void)reLoadData {
if(self.hideHeader){
self.lastResult = nil;
[self loadData];
}else{
[self.collectionView.mj_header beginRefreshing];
}
self.page = 0;
[self loadData];
}
-(void)clearData{
......@@ -183,7 +179,7 @@
}
- (void)loadData {
[self.delegate refreshUtil:self onLoad:self.page];
[self.delegate refreshUtil:self onLoad:self.page+1];
}
......
......@@ -49,6 +49,9 @@
//中文转拼音
+ (NSString *)transform:(NSString *)chinese;
+ (NSString *)price:(NSNumber *)price;
//欧元转人民币
//+ (NSString *)getEUR2CNYstring:(NSNumber *)price;
......
......@@ -502,4 +502,9 @@ static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu
return CNYstring;
}
+ (NSString *)price:(NSNumber *)price{
NSString *CNYstring = [self getEUR2CNYstring:price];
return [NSString stringWithFormat:@"¥ %@",CNYstring];
}
@end
//
// KWMCategoryFilterView.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "KWMFilterTabItem.h"
@protocol CategoryFilterTabDelegate <NSObject>
- (void)kwm_onClickTab:(KWMFilterMode)filterMode isExpandView:(BOOL) isExpand;
@end
@interface KWMCategoryFilterTab : UIView<FilterTabItemDelegate>
@property(nonatomic,weak) id<CategoryFilterTabDelegate> delegate;
-(void)close;
@end
//
// KWMCategoryFilterView.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMCategoryFilterTab.h"
#import "KWMFilterTabItem.h"
@interface KWMCategoryFilterTab()
@property(nonatomic,weak) IBOutlet UIView *containerView;
@property(nonatomic,weak) IBOutlet KWMFilterTabItem *vLeft;
@property(nonatomic,weak) IBOutlet KWMFilterTabItem *vMid;
@property(nonatomic,weak) IBOutlet KWMFilterTabItem *vRight;
@end
@implementation KWMCategoryFilterTab
-(void)awakeFromNib{
[super awakeFromNib];
[self initView];
}
-(void)initView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.containerView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.containerView];
self.vLeft.filterMode = ModeFilter;
self.vMid.filterMode = ModeSort;
self.vRight.filterMode = ModeBrand;
self.vLeft.delegate = self;
self.vMid.delegate = self;
self.vRight.delegate = self;
}
-(void)kwm_onClickTabItem:(KWMFilterTabItem *)item isExpandView:(BOOL)isExpand{
self.vLeft.isExpand = item.filterMode == ModeFilter? isExpand: NO;
self.vMid.isExpand = item.filterMode == ModeSort? isExpand: NO;
self.vRight.isExpand = item.filterMode == ModeBrand? isExpand: NO;
if(self.delegate){
[self.delegate kwm_onClickTab:item.filterMode isExpandView:isExpand];
}
}
-(void)close{
self.vLeft.isExpand = NO;
self.vMid.isExpand = NO;
self.vRight.isExpand = NO;
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12121"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMCategoryFilterTab">
<connections>
<outlet property="containerView" destination="iN0-l3-epB" id="rga-XU-nmT"/>
<outlet property="vLeft" destination="pIt-FR-2d3" id="aJD-Te-qNW"/>
<outlet property="vMid" destination="BgV-Cs-T93" id="689-Y8-fc9"/>
<outlet property="vRight" destination="bMh-we-mKf" id="Cch-qd-rcw"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hky-Yx-Jv0">
<rect key="frame" x="0.0" y="0.0" width="280" height="40"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pIt-FR-2d3" userLabel="筛选" customClass="KWMFilterTabItem">
<rect key="frame" x="5" y="0.0" width="60" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="orx-Hm-zrc"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BgV-Cs-T93" userLabel="排序" customClass="KWMFilterTabItem">
<rect key="frame" x="75" y="0.0" width="60" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="KA6-f5-9H0"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bMh-we-mKf" userLabel="品牌" customClass="KWMFilterTabItem">
<rect key="frame" x="145" y="0.0" width="60" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="uQF-4r-QOK"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="pIt-FR-2d3" secondAttribute="bottom" id="5tl-08-vXE"/>
<constraint firstAttribute="bottom" secondItem="BgV-Cs-T93" secondAttribute="bottom" id="TgD-cE-Rcd"/>
<constraint firstItem="bMh-we-mKf" firstAttribute="top" secondItem="hky-Yx-Jv0" secondAttribute="top" id="UBx-8z-nlt"/>
<constraint firstAttribute="bottom" secondItem="bMh-we-mKf" secondAttribute="bottom" id="XVz-A3-InN"/>
<constraint firstItem="BgV-Cs-T93" firstAttribute="leading" secondItem="pIt-FR-2d3" secondAttribute="trailing" constant="10" id="dwH-1Q-9rb"/>
<constraint firstItem="pIt-FR-2d3" firstAttribute="leading" secondItem="hky-Yx-Jv0" secondAttribute="leading" constant="5" id="hGj-ZC-cRc"/>
<constraint firstItem="BgV-Cs-T93" firstAttribute="top" secondItem="hky-Yx-Jv0" secondAttribute="top" id="r2d-Wg-kMm"/>
<constraint firstItem="bMh-we-mKf" firstAttribute="leading" secondItem="BgV-Cs-T93" secondAttribute="trailing" constant="10" id="w6Z-Jv-HNW"/>
<constraint firstItem="pIt-FR-2d3" firstAttribute="top" secondItem="hky-Yx-Jv0" secondAttribute="top" id="zhJ-7s-W0q"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="hky-Yx-Jv0" secondAttribute="trailing" id="6e7-sj-Ttl"/>
<constraint firstAttribute="bottom" secondItem="hky-Yx-Jv0" secondAttribute="bottom" id="Dmt-4T-UCD"/>
<constraint firstItem="hky-Yx-Jv0" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="WLB-Et-7EG"/>
<constraint firstItem="hky-Yx-Jv0" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="xe5-cH-vhG"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="-16" y="71"/>
</view>
</objects>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -37,7 +37,7 @@
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="tintColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<gestureRecognizers/>
<constraints>
......@@ -50,7 +50,7 @@
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="X29-gf-6cs" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="Ghd-H3-FZ6"/>
<constraint firstAttribute="trailing" secondItem="X29-gf-6cs" secondAttribute="trailing" id="UPA-c4-Vvd"/>
......
......@@ -36,6 +36,9 @@ typedef NS_ENUM(NSInteger, KWMFilterMode) {
@property(nonatomic) BUYCollectionSort selectedSort;
//默认为0 新-旧款 1-3依次对应 旧-新款 高-低价 低-高价
@property(nonatomic) NSInteger selectedSortPosition;
@property(nonatomic,weak) id<KWMFilterDelegate> delegate;
@end
......@@ -20,8 +20,6 @@ static NSString *filterDataString = @"[{\"group\":\"SEASON\",\"tags\":[\"Spring/
@property(weak,nonatomic) IBOutlet UICollectionView *cvFilter;
//默认为0 新-旧款 1-3依次对应 旧-新款 高-低价 低-高价
@property(nonatomic) NSInteger selectedSortPosition;
-(IBAction)onClickFilter:(id)sender;
......
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