Commit 89357459 by lee

uhome u default sort

parent 961869d1
......@@ -11,13 +11,13 @@
#import "UIImageView+WebCache.h"
#import "KWMNewHomeCell.h"
@interface KWMHotSalesHeader()
@interface KWMHotSalesHeader()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property (nonatomic,weak) IBOutlet UIView *vView;
@property (nonatomic,weak) IBOutlet KWMBannerView *bannerView;
@property (nonatomic,weak) IBOutlet UIView *singleShowView;
@property (nonatomic,weak) IBOutlet UICollectionView *singleShowView;
@property (nonatomic,weak) IBOutlet NSLayoutConstraint *heightBannerView;
......@@ -69,6 +69,14 @@
}
-(void)initView{
UINib *nib = [UINib nibWithNibName:@"KWMNewHomeCell" bundle:nil];
[self.singleShowView registerNib:nib forCellWithReuseIdentifier:@"KWMNewHomeCell"];
// [self.singleShowView registerNib:nib forCellReuseIdentifier:@"KWMNewHomeCell"];
// [self.singleShowView registerNib:[[[NSBundle mainBundle]loadNibNamed:@"KWMNewHomeCell" owner:self options:nil] firstObject] forCellReuseIdentifier:@"KWMNewHomeCell"];
self.singleShowView.delegate = self;
self.singleShowView.dataSource = self;
// self.singleShowView.collectionViewLayout.collectionViewContentSize = CGSizeMake(UI_SCREEN_WIDTH - 16, UI_SCREEN_WIDTH + 58);
// self.singleShowView.collectionViewLayout = [UICollectionViewLayout alloc]
self.bannerView.delegate = self;
self.heightBannerView.constant = 0;
self.heightSingleShowView.constant = 0;
......@@ -98,20 +106,42 @@
NSInteger itemWidth = UI_SCREEN_WIDTH - 16;
NSInteger itemHeight = UI_SCREEN_WIDTH + 58;
for(int i=0;i<singleShowArray.count;i++){
BUYProduct *product = [singleShowArray objectAtIndex:i];
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"KWMNewHomeCell" owner:self options:nil];
KWMNewHomeCell *homeCell = [nib objectAtIndex:0];
homeCell.frame = CGRectMake(8, itemHeight*i, itemWidth, itemHeight);
homeCell.singleShow = YES;
homeCell.tag = i;
homeCell.product = product;
[self.singleShowView addSubview:homeCell];
}
// for(int i=0;i<singleShowArray.count;i++){
// BUYProduct *product = [singleShowArray objectAtIndex:i];
// NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"KWMNewHomeCell" owner:self options:nil];
// KWMNewHomeCell *homeCell = [nib objectAtIndex:0];
// homeCell.frame = CGRectMake(8, itemHeight*i, itemWidth, itemHeight);
// homeCell.singleShow = YES;
// homeCell.tag = i;
// homeCell.product = product;
//
// [self.singleShowView addSubview:homeCell];
// }
self.heightSingleShowView.constant = itemHeight*singleShowArray.count;
}
#pragma mark - UICollectionViewDataSource & UICollectionViewDelegate
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.singleShowArray.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
KWMNewHomeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"KWMNewHomeCell" forIndexPath:indexPath];
cell.singleShow = YES;
cell.product = self.singleShowArray[indexPath.item];
return cell;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(UI_SCREEN_WIDTH - 16, UI_SCREEN_WIDTH + 58);
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[self.delegate kwm_onClickProduct:self.singleShowArray[indexPath.item]];
}
#pragma mark - KWMBannerViewDelegate
-(UIView *)bannerView:(KWMBannerView *)bannerView reusingView:(UIView *)reusingView pageAtIndex:(NSInteger)index{
UIView *itemView = reusingView?reusingView:nil;
......
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" 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"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -13,8 +13,8 @@
<connections>
<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="7LG-U7-451" id="9MA-ha-ZlO"/>
<outlet property="singleShowView" destination="Dwm-lO-Zce" id="DKc-lA-7U0"/>
<outlet property="heightSingleShowView" destination="SEw-Tw-g0a" id="PcT-Pv-gcm"/>
<outlet property="singleShowView" destination="UGY-II-IMu" id="wxp-gP-PDh"/>
<outlet property="vView" destination="iN0-l3-epB" id="bI2-U9-soo"/>
</connections>
</placeholder>
......@@ -67,25 +67,31 @@
<constraint firstAttribute="height" constant="190" id="NbW-Kh-s5O"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dwm-lO-Zce" userLabel="singleShowView">
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="UGY-II-IMu">
<rect key="frame" x="0.0" y="250" width="375" height="0.0"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" id="7LG-U7-451"/>
<constraint firstAttribute="height" id="SEw-Tw-g0a"/>
</constraints>
</view>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="Bjo-LO-kzZ">
<size key="itemSize" width="50" height="50"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
</collectionView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="UGY-II-IMu" secondAttribute="trailing" id="6ji-Iq-sFG"/>
<constraint firstItem="Ruv-UI-DGw" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="9fw-Ph-Q4P"/>
<constraint firstItem="Ruv-UI-DGw" firstAttribute="top" secondItem="d0n-L5-xP1" secondAttribute="bottom" id="BTm-DX-XK4"/>
<constraint firstAttribute="trailing" secondItem="Ruv-UI-DGw" secondAttribute="trailing" id="RLP-eB-Asb"/>
<constraint firstItem="UGY-II-IMu" firstAttribute="top" secondItem="Ruv-UI-DGw" secondAttribute="bottom" id="VJK-eY-4rm"/>
<constraint firstItem="d0n-L5-xP1" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="aWf-1E-iKC"/>
<constraint firstItem="d0n-L5-xP1" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="g82-sr-LTG"/>
<constraint firstAttribute="trailing" secondItem="d0n-L5-xP1" secondAttribute="trailing" id="iHt-uY-XiY"/>
<constraint firstAttribute="trailing" secondItem="Dwm-lO-Zce" secondAttribute="trailing" id="q59-1g-wOJ"/>
<constraint firstItem="Dwm-lO-Zce" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="vxZ-CO-Z64"/>
<constraint firstItem="Dwm-lO-Zce" firstAttribute="top" secondItem="Ruv-UI-DGw" secondAttribute="bottom" id="y5m-bf-H2m"/>
<constraint firstItem="UGY-II-IMu" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="whN-vO-ZIi"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
......
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" 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"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<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"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="1111" contentMode="center" id="gTV-IL-0wX" customClass="KWMNewHomeCell">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="1111" contentMode="center" reuseIdentifier="KWMNewHomeCell" id="gTV-IL-0wX" customClass="KWMNewHomeCell">
<rect key="frame" x="0.0" y="0.0" width="184" height="242"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
......
......@@ -15,6 +15,8 @@
#import <RegexKitLite/RegexKitLite.h>
#import <RXCollections/RXCollection.h>
#import "KWMHomeVC.h"
#import "KWMWishListVC.h"
#import <MJRefresh.h>
typedef enum{
......@@ -49,6 +51,8 @@ typedef enum{
@property(nonatomic) KWMHomeData *homeData;
@property(nonatomic) NSInteger page;
@property(nonatomic) NSMutableArray<BUYProduct *>* productArray;
@property(nonatomic) NSMutableDictionary *dataMapping;
......@@ -60,6 +64,7 @@ typedef enum{
- (void)viewDidLoad {
[super viewDidLoad];
[self initView];
self.page = 1;
// [self requestProduct:@""];
[self loadHomeData];
......@@ -91,29 +96,6 @@ typedef enum{
}
}
//- (void)initTestData{
// KWMHomeData *homeData = [KWMHomeData new];
//
// KWMHotSales *hotSales = [KWMHotSales new];
// hotSales.singleShowCount = @(3);
//
// KWMAdvertisement *clothingSets = [KWMAdvertisement new];
// clothingSets.image = @"http://o42yton8r.qnssl.com/s/files/1/1089/5284/collections/b_8d773a6f-6a70-4d15-a280-e4dd13a7a744_large.jpg?v=1464083899";
// clothingSets.url = @"http://www.baidu.com";
// clothingSets.title = @"boy";
//
// NSMutableArray *adBanner = [NSMutableArray array];
// [adBanner addObject:[clothingSets copy]];
// [adBanner addObject:[clothingSets copy]];
// [adBanner addObject:[clothingSets copy]];
//
// homeData.hotSales = hotSales;
// homeData.clothingSets = clothingSets;
// homeData.adBanner = adBanner;
//
// self.homeData = homeData;
// [self initData];
//}
- (void)initView{
// self.title = @"首页";
......@@ -156,6 +138,12 @@ typedef enum{
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMRecommendHeader kwmTag]];
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMClothingSetsHeader kwmTag]];
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMMenuHeader kwmTag]];
self.cvHome.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMore)];
}
- (void) loadMore {
[self requestProductWithHandle:@"products-list-app-homepage" tags:nil valueKeyPath:@"productArray"];
}
#pragma mark - KWMAdDelegate
......@@ -176,6 +164,8 @@ typedef enum{
-(void)kwm_onClickWishMenu{
NSLog(@"wishmenu");
KWMWishListVC* vc= (KWMWishListVC *)[KWMBaseVC findControllerBy:[KWMWishListVC kwmTag] fromStoryboard:@"NewProduct"];
[self.navigationController pushViewController:vc animated:YES];
}
-(void)kwm_onClickDeliveryMenu{
......@@ -275,7 +265,7 @@ typedef enum{
#pragma mark - CHTCollectionViewDelegateWaterfallLayout
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
[self kwm_onClickProduct:self.productArray[indexPath.item]];
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
......@@ -318,16 +308,23 @@ typedef enum{
- (void) requestProductWithHandle:(NSString *) handle tags:(NSArray *) tags valueKeyPath:(NSString *) valueKeyPath {
[self showLoading];
BOOL isHome = [handle isEqualToString:@"products-list-app-homepage"];
NSInteger cpage = isHome ? self.page : 1;
[self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
if (!error) {
[self.client getProductsPage:1 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) {
[self hideLoading];
if (!error) {
[self setValue:products forKeyPath:valueKeyPath];
[self.cvHome reloadData];
}else{
[self showError:error];
}
if (isHome) {
self.page = self.page + 1;
products.count ? [self.cvHome.mj_footer endRefreshing] : [self.cvHome.mj_footer endRefreshingWithNoMoreData];
}
}];
}else{
[self hideLoading];
......
......@@ -36,6 +36,11 @@
[self requestWishList];
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO];
}
- (void)initView{
self.title = @"我喜欢的";
[self.tbvWish registerNib:[UINib nibWithNibName:NSStringFromClass([KWMWishCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([KWMWishCell class])];
......
......@@ -45,7 +45,8 @@ static NSString *idStr = @"KWMBrandCaramelCell";
[super viewDidLoad];
[self initView];
[self reLoadData];
// [self reLoadData];
}
- (void)initView{
......
......@@ -86,6 +86,7 @@ static NSString *filterDataString = @"[{\"group\":\"SEASON\",\"tags\":[\"Spring/
}
-(void)initSortData{
self.selectedSortPosition = -1;
sortStringData = @[@"新-旧款",@"旧-新款",@"高-低价",@"低-高价"];
}
......@@ -100,7 +101,7 @@ static NSString *filterDataString = @"[{\"group\":\"SEASON\",\"tags\":[\"Spring/
case 3:
return BUYCollectionSortPriceAscending;
default:
return BUYCollectionSortCreatedDescending;
return BUYCollectionSortCollectionDefault;
}
}
......
......@@ -10,6 +10,7 @@
@protocol KWMSearchBarDelegate <NSObject>
@optional
- (void)kwm_startSearch;
- (void)kwm_onClickSearch:(NSString *)content;
- (void)kwm_onClickShopCar;
......
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