Commit 803ed47b by lee

u

parent 85b6a274
...@@ -348,6 +348,7 @@ ...@@ -348,6 +348,7 @@
C0FC278E1D9B73B000C5CFFE /* KWMGiftCardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C0FC278D1D9B73B000C5CFFE /* KWMGiftCardCell.m */; }; C0FC278E1D9B73B000C5CFFE /* KWMGiftCardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C0FC278D1D9B73B000C5CFFE /* KWMGiftCardCell.m */; };
DA4E36921F1613C70007E4D0 /* KWMHomeDataResult.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E36911F1613C70007E4D0 /* KWMHomeDataResult.m */; }; DA4E36921F1613C70007E4D0 /* KWMHomeDataResult.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E36911F1613C70007E4D0 /* KWMHomeDataResult.m */; };
DA4E36951F1726B80007E4D0 /* UIViewController+HTTP.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E36941F1726B80007E4D0 /* UIViewController+HTTP.m */; }; DA4E36951F1726B80007E4D0 /* UIViewController+HTTP.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E36941F1726B80007E4D0 /* UIViewController+HTTP.m */; };
DA4E36981F17729C0007E4D0 /* KWMCategoryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4E36971F17729C0007E4D0 /* KWMCategoryModel.m */; };
DAB6431A1F04CFE5002CD7FE /* AppDelegate+Deeplink.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */; }; DAB6431A1F04CFE5002CD7FE /* AppDelegate+Deeplink.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
...@@ -968,6 +969,8 @@ ...@@ -968,6 +969,8 @@
DA4E36911F1613C70007E4D0 /* KWMHomeDataResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMHomeDataResult.m; sourceTree = "<group>"; }; DA4E36911F1613C70007E4D0 /* KWMHomeDataResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMHomeDataResult.m; sourceTree = "<group>"; };
DA4E36931F1726B80007E4D0 /* UIViewController+HTTP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+HTTP.h"; sourceTree = "<group>"; }; DA4E36931F1726B80007E4D0 /* UIViewController+HTTP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+HTTP.h"; sourceTree = "<group>"; };
DA4E36941F1726B80007E4D0 /* UIViewController+HTTP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+HTTP.m"; sourceTree = "<group>"; }; DA4E36941F1726B80007E4D0 /* UIViewController+HTTP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+HTTP.m"; sourceTree = "<group>"; };
DA4E36961F17729C0007E4D0 /* KWMCategoryModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMCategoryModel.h; sourceTree = "<group>"; };
DA4E36971F17729C0007E4D0 /* KWMCategoryModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMCategoryModel.m; sourceTree = "<group>"; };
DAB643181F04CFE5002CD7FE /* AppDelegate+Deeplink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+Deeplink.h"; sourceTree = "<group>"; }; DAB643181F04CFE5002CD7FE /* AppDelegate+Deeplink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+Deeplink.h"; sourceTree = "<group>"; };
DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+Deeplink.m"; sourceTree = "<group>"; }; DAB643191F04CFE5002CD7FE /* AppDelegate+Deeplink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+Deeplink.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
...@@ -1395,6 +1398,8 @@ ...@@ -1395,6 +1398,8 @@
C043927F1F0F9A3D0027ABA3 /* KWMHotSales.m */, C043927F1F0F9A3D0027ABA3 /* KWMHotSales.m */,
C07267831F1616E500C5A869 /* KWMColor.h */, C07267831F1616E500C5A869 /* KWMColor.h */,
C07267841F1616E500C5A869 /* KWMColor.m */, C07267841F1616E500C5A869 /* KWMColor.m */,
DA4E36961F17729C0007E4D0 /* KWMCategoryModel.h */,
DA4E36971F17729C0007E4D0 /* KWMCategoryModel.m */,
); );
path = Model; path = Model;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2525,6 +2530,7 @@ ...@@ -2525,6 +2530,7 @@
9BE61CFB1ECD56E70031D21E /* KWMDictioaryResult.m in Sources */, 9BE61CFB1ECD56E70031D21E /* KWMDictioaryResult.m in Sources */,
C034E6D81D6AEF1B006EE129 /* KWMImageUtil.m in Sources */, C034E6D81D6AEF1B006EE129 /* KWMImageUtil.m in Sources */,
C0A6B3BE1F01FC5300D85673 /* KWMFirstDetailView.m in Sources */, C0A6B3BE1F01FC5300D85673 /* KWMFirstDetailView.m in Sources */,
DA4E36981F17729C0007E4D0 /* KWMCategoryModel.m in Sources */,
C048B8E21EF3C04B000DA7AF /* KWMBeforePayData.m in Sources */, C048B8E21EF3C04B000DA7AF /* KWMBeforePayData.m in Sources */,
C03846941DB89EEB008C3BAB /* KWMCemaroseResult.m in Sources */, C03846941DB89EEB008C3BAB /* KWMCemaroseResult.m in Sources */,
C04834411F13350F00A5BFB4 /* KWMRecommendHeader.m in Sources */, C04834411F13350F00A5BFB4 /* KWMRecommendHeader.m in Sources */,
......
//
// KWMCategoryModel.h
// iCemarose
//
// Created by Sanchew on 2017/7/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Mobile-Buy-SDK/Buy/BUYClient+Storefront.h>
@interface KWMCategoryModel : NSObject
@property (nonatomic) NSString* title;
@property (nonatomic) NSNumber* collection_id;
@property (nonatomic) NSString* image;
@property (nonatomic) NSInteger page;
@property (nonatomic) NSMutableArray *products;
@property (nonatomic) BUYCollectionSort sort;
@end
//
// KWMCategoryModel.m
// iCemarose
//
// Created by Sanchew on 2017/7/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMCategoryModel.h"
@implementation KWMCategoryModel
@end
...@@ -7,7 +7,10 @@ ...@@ -7,7 +7,10 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "KWMCategoryModel.h"
@interface KWMLeftCategoryCell : UITableViewCell @interface KWMLeftCategoryCell : UITableViewCell
- (void) fillData:(KWMCategoryModel *) model;
@end @end
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
self.selectedBackgroundView.backgroundColor = [UIColor sam_colorWithHex:@"#F4F5F7"]; self.selectedBackgroundView.backgroundColor = [UIColor sam_colorWithHex:@"#F4F5F7"];
} }
- (void)fillData:(KWMCategoryModel *)model {
_lbTitle.text = model.title;
_ivCategory.image = [UIImage imageNamed:model.image];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated]; [super setSelected:selected animated:animated];
UIColor *textColor = selected?[UIColor sam_colorWithHex:@"#F1929A"]:[UIColor sam_colorWithHex:@"#545454"]; UIColor *textColor = selected?[UIColor sam_colorWithHex:@"#F1929A"]:[UIColor sam_colorWithHex:@"#545454"];
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#import "KWMFilterUtil.h" #import "KWMFilterUtil.h"
#import "MJRefresh.h" #import "MJRefresh.h"
//#import <RXCollections/RXCollection.h> //#import <RXCollections/RXCollection.h>
@interface KWMCategoryVC () @interface KWMCategoryVC ()
...@@ -39,6 +41,10 @@ ...@@ -39,6 +41,10 @@
@property(nonatomic) NSString *selectBrands; @property(nonatomic) NSString *selectBrands;
@property(nonatomic) NSArray<KWMCategoryModel *>* categories;
@property (nonatomic) KWMCategoryModel *selectedCategory;
@end @end
@implementation KWMCategoryVC @implementation KWMCategoryVC
...@@ -50,10 +56,11 @@ ...@@ -50,10 +56,11 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self initData];
[self initView]; [self initView];
[self requestAllBrandsApi]; [self requestAllBrandsApi];
[self.refreshUtil reLoadData]; // [self.refreshUtil reLoadData];
[self.cvRightProduct.mj_header beginRefreshing]; // [self.cvRightProduct.mj_header beginRefreshing];
} }
-(KWMCollectionRefreshUtil *)refreshUtil{ -(KWMCollectionRefreshUtil *)refreshUtil{
...@@ -66,12 +73,42 @@ ...@@ -66,12 +73,42 @@
return _refreshUtil; return _refreshUtil;
} }
-(void) initData {
self.categories = [@[
@{@"title":@"上装",@"collection_id":@"192437702",@"image":@""},
@{@"title":@"连体衣",@"collection_id":@"192438342",@"image":@""},
@{@"title":@"外套",@"collection_id":@"192438790",@"image":@""},
@{@"title":@"裙子",@"collection_id":@"191377286",@"image":@""},
@{@"title":@"裤子",@"collection_id":@"333026630",@"image":@""},
@{@"title":@"短裙",@"collection_id":@"192434950",@"image":@""},
@{@"title":@"套装",@"collection_id":@"192438150",@"image":@""},
@{@"title":@"泳衣",@"collection_id":@"333026438",@"image":@""},
@{@"title":@"连裤袜",@"collection_id":@"192437830",@"image":@""},
@{@"title":@"打底裤",@"collection_id":@"192435334",@"image":@""},
@{@"title":@"内衣",@"collection_id":@"333026694",@"image":@""},
@{@"title":@"雨衣",@"collection_id":@"423509068",@"image":@""},
@{@"title":@"鞋子",@"collection_id":@"171856134",@"image":@""},
@{@"title":@"玩具",@"collection_id":@"332990918",@"image":@""},
@{@"title":@"饰品",@"collection_id":@"191376966",@"image":@""},
] rx_mapWithBlock:^id(id each) {
KWMCategoryModel *m = [KWMCategoryModel new];
m.title = each[@"title"];
m.collection_id = @([each[@"collection_id"] integerValue]);
m.image = each[@"image"];
m.page = 1;
m.products = [NSMutableArray new];
m.sort = BUYCollectionSortCollectionDefault;
return m;
}];
self.selectedCategory = self.categories.firstObject;
}
-(void)initView{ -(void)initView{
[self initTitleView]; [self initTitleView];
[self initTbvLeft]; [self initTbvLeft];
[self initCvRight]; [self initCvRight];
self.sort = BUYCollectionSortCreatedDescending; self.sort = BUYCollectionSortCollectionDefault;
self.selectBrands = @""; self.selectBrands = @"";
} }
...@@ -96,17 +133,22 @@ ...@@ -96,17 +133,22 @@
#pragma mark - UITableViewDataSource #pragma mark - UITableViewDataSource
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
KWMLeftCategoryCell *categoryCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([KWMLeftCategoryCell class]) forIndexPath:indexPath]; KWMLeftCategoryCell *categoryCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([KWMLeftCategoryCell class]) forIndexPath:indexPath];
[categoryCell fillData:self.categories[indexPath.item]];
return categoryCell; return categoryCell;
} }
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 20; return self.categories.count;
} }
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.01; return 0.01;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.selectedCategory = self.categories[indexPath.row];
}
#pragma mark - UICollectionViewDataSource #pragma mark - UICollectionViewDataSource
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
KWMRightProductCell *productCell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([KWMRightProductCell class]) forIndexPath:indexPath]; KWMRightProductCell *productCell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([KWMRightProductCell class]) forIndexPath:indexPath];
...@@ -139,7 +181,11 @@ ...@@ -139,7 +181,11 @@
#pragma mark - KWMCollectionRefreshDelegate #pragma mark - KWMCollectionRefreshDelegate
-(void)refreshUtil:(KWMCollectionRefreshUtil *)util onLoad:(NSInteger)page{ -(void)refreshUtil:(KWMCollectionRefreshUtil *)util onLoad:(NSInteger)page{
[self requestProducts:page]; if (page == 0) {
[self requestProducts:1];
}else{
[self requestProducts:self.selectedCategory.page + 1];
}
} }
#pragma mark - CategoryFilterTabDelegate #pragma mark - CategoryFilterTabDelegate
...@@ -167,6 +213,7 @@ ...@@ -167,6 +213,7 @@
-(void)kwm_onCompleProductFilter:(KWMFilterView *)filterView{ -(void)kwm_onCompleProductFilter:(KWMFilterView *)filterView{
self.selectFilters = filterView.selectedTags; self.selectFilters = filterView.selectedTags;
self.sort = filterView.selectedSort; self.sort = filterView.selectedSort;
self.selectedCategory.sort = filterView.selectedSort;
[self.filterTab close]; [self.filterTab close];
[self.refreshUtil reLoadData]; [self.refreshUtil reLoadData];
[self.cvRightProduct.mj_header beginRefreshing]; [self.cvRightProduct.mj_header beginRefreshing];
...@@ -206,7 +253,7 @@ ...@@ -206,7 +253,7 @@
} }
#pragma mark - API BUYClient+Storefront.h #pragma mark - API BUYClient+Storefront.h
-(void)requestProducts:(NSInteger)page{ -(void)requestProducts:(NSInteger)cpage{
__weak KWMCategoryVC *weakSelf = self; __weak KWMCategoryVC *weakSelf = self;
self.filterTab.userInteractionEnabled = false; self.filterTab.userInteractionEnabled = false;
...@@ -214,22 +261,53 @@ ...@@ -214,22 +261,53 @@
if(![KWMStringUtil isEmpty:self.selectBrands]){ if(![KWMStringUtil isEmpty:self.selectBrands]){
[tags addObject:self.selectBrands]; [tags addObject:self.selectBrands];
} }
KWMCategoryModel *cmodel = self.selectedCategory;
[self.client getProductsPage:page inCollection:@(Collection_All_ID) withTags:tags sortOrder:self.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){ [self.client getProductsPage:cpage inCollection:cmodel.collection_id withTags:tags sortOrder:self.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
[weakSelf.refreshUtil hideLoading]; if (cmodel == self.selectedCategory) {
[weakSelf.refreshUtil hideLoading];
}
weakSelf.filterTab.userInteractionEnabled = true; weakSelf.filterTab.userInteractionEnabled = true;
if(error){ if(error){
[weakSelf showError:error]; [weakSelf showError:error];
} }
else{ else{
weakSelf.refreshUtil.page = page; // weakSelf.refreshUtil.page = page;
weakSelf.refreshUtil.hasNextPage = !reachedEnd; cmodel.page = page;
[weakSelf.refreshUtil appendDataList:products]; // weakSelf.refreshUtil.hasNextPage = !reachedEnd;
// [weakSelf.refreshUtil appendDataList:products];
if (cpage == 1) {
[cmodel.products removeAllObjects];
}
[cmodel.products addObjectsFromArray:products];
if (cmodel == weakSelf.selectedCategory) {
[weakSelf.cvRightProduct reloadData];
}
} }
}]; }];
} }
#pragma mark - setter
- (void)setSelectedCategory:(KWMCategoryModel *)selectedCategory {
_selectedCategory = selectedCategory;
self.refreshUtil.page = _selectedCategory.page;
self.sort = _selectedCategory.sort;
self.refreshUtil.hasNextPage = YES;
self.refreshUtil.dataList = _selectedCategory.products;
[self.cvRightProduct reloadData];
if (_selectedCategory.products.count == 0) {
// [self requestProducts:1];
// [self.refreshUtil reLoadData];
if ([self.cvRightProduct.mj_header isRefreshing]) {
[self requestProducts:1];
}else{
[self.cvRightProduct.mj_header beginRefreshing];
}
}else if([self.cvRightProduct.mj_header isRefreshing]) {
[self.cvRightProduct.mj_header endRefreshing];
}
// [self.cvRightProduct reloadData];
}
@end @end
...@@ -168,8 +168,9 @@ ...@@ -168,8 +168,9 @@
} }
- (void)reLoadData { - (void)reLoadData {
self.page = 0; // self.page = 0;
[self loadData]; // [self loadData];
[self.delegate refreshUtil:self onLoad:0];
} }
-(void)clearData{ -(void)clearData{
...@@ -179,7 +180,7 @@ ...@@ -179,7 +180,7 @@
} }
- (void)loadData { - (void)loadData {
[self.delegate refreshUtil:self onLoad:self.page+1]; [self.delegate refreshUtil:self onLoad:1];
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#import <MagicalRecord/MagicalRecord.h> #import <MagicalRecord/MagicalRecord.h>
#import "NSDecimalNumber+Currency.h" #import "NSDecimalNumber+Currency.h"
#import "UIViewController+HTTP.h" #import "UIViewController+HTTP.h"
#import <RXCollections/RXCollection.h>
#ifndef Header_Prefix_h #ifndef Header_Prefix_h
#define Header_Prefix_h #define Header_Prefix_h
......
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