Commit 050f30f1 by houweibin
parents af1531be 1ed601f7
...@@ -16,7 +16,7 @@ pod 'TOWebViewController' ...@@ -16,7 +16,7 @@ pod 'TOWebViewController'
#pod 'AFNetworking','~> 3.1' #pod 'AFNetworking','~> 3.1'
pod 'PPNetworkHelper' pod 'PPNetworkHelper'
pod 'JSONModel','~> 1.2.0' pod 'JSONModel','~> 1.7.0'
pod 'SDWebImage','~> 3.7.1' pod 'SDWebImage','~> 3.7.1'
pod 'SAMCategories', '~> 0.5.1' pod 'SAMCategories', '~> 0.5.1'
pod 'SAMTextView', '~> 0.2.1' pod 'SAMTextView', '~> 0.2.1'
......
...@@ -346,6 +346,9 @@ ...@@ -346,6 +346,9 @@
C0F586AE1E279574001248E2 /* KWMBottomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0F586AD1E279574001248E2 /* KWMBottomView.xib */; }; C0F586AE1E279574001248E2 /* KWMBottomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0F586AD1E279574001248E2 /* KWMBottomView.xib */; };
C0FBD88E1F049D510009E375 /* KWMOrderPaid.m in Sources */ = {isa = PBXBuildFile; fileRef = C0FBD88D1F049D510009E375 /* KWMOrderPaid.m */; }; C0FBD88E1F049D510009E375 /* KWMOrderPaid.m in Sources */ = {isa = PBXBuildFile; fileRef = C0FBD88D1F049D510009E375 /* KWMOrderPaid.m */; };
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 */; };
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 */
...@@ -962,6 +965,12 @@ ...@@ -962,6 +965,12 @@
C0FBD88D1F049D510009E375 /* KWMOrderPaid.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMOrderPaid.m; sourceTree = "<group>"; }; C0FBD88D1F049D510009E375 /* KWMOrderPaid.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMOrderPaid.m; sourceTree = "<group>"; };
C0FC278C1D9B73B000C5CFFE /* KWMGiftCardCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMGiftCardCell.h; sourceTree = "<group>"; }; C0FC278C1D9B73B000C5CFFE /* KWMGiftCardCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMGiftCardCell.h; sourceTree = "<group>"; };
C0FC278D1D9B73B000C5CFFE /* KWMGiftCardCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMGiftCardCell.m; sourceTree = "<group>"; }; C0FC278D1D9B73B000C5CFFE /* KWMGiftCardCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMGiftCardCell.m; sourceTree = "<group>"; };
DA4E36901F1613C70007E4D0 /* KWMHomeDataResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMHomeDataResult.h; 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>"; };
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 */
...@@ -1056,6 +1065,8 @@ ...@@ -1056,6 +1065,8 @@
807806861D7566DD00FD2841 /* NSString+PinYin.m */, 807806861D7566DD00FD2841 /* NSString+PinYin.m */,
9B8298E41EF237FC00743438 /* NSDecimalNumber+Currency.h */, 9B8298E41EF237FC00743438 /* NSDecimalNumber+Currency.h */,
9B8298E51EF237FC00743438 /* NSDecimalNumber+Currency.m */, 9B8298E51EF237FC00743438 /* NSDecimalNumber+Currency.m */,
DA4E36931F1726B80007E4D0 /* UIViewController+HTTP.h */,
DA4E36941F1726B80007E4D0 /* UIViewController+HTTP.m */,
); );
path = Classify; path = Classify;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1387,6 +1398,8 @@ ...@@ -1387,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>";
...@@ -1914,6 +1927,8 @@ ...@@ -1914,6 +1927,8 @@
9BE61CFA1ECD56E70031D21E /* KWMDictioaryResult.m */, 9BE61CFA1ECD56E70031D21E /* KWMDictioaryResult.m */,
9BE61CFF1ECD71610031D21E /* KWMCartResult.h */, 9BE61CFF1ECD71610031D21E /* KWMCartResult.h */,
9BE61D001ECD71610031D21E /* KWMCartResult.m */, 9BE61D001ECD71610031D21E /* KWMCartResult.m */,
DA4E36901F1613C70007E4D0 /* KWMHomeDataResult.h */,
DA4E36911F1613C70007E4D0 /* KWMHomeDataResult.m */,
); );
path = Cemarose; path = Cemarose;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2515,6 +2530,7 @@ ...@@ -2515,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 */,
...@@ -2686,6 +2702,7 @@ ...@@ -2686,6 +2702,7 @@
805C04381DD1FA7100ACC071 /* KWMBrandsTypeResult.m in Sources */, 805C04381DD1FA7100ACC071 /* KWMBrandsTypeResult.m in Sources */,
C034E6DA1D6AEF1B006EE129 /* KWMTextFieldUtil.m in Sources */, C034E6DA1D6AEF1B006EE129 /* KWMTextFieldUtil.m in Sources */,
C0F5868D1E24F821001248E2 /* SHorizontalView.m in Sources */, C0F5868D1E24F821001248E2 /* SHorizontalView.m in Sources */,
DA4E36921F1613C70007E4D0 /* KWMHomeDataResult.m in Sources */,
C034E7041D6AF205006EE129 /* RTSpinKitView.m in Sources */, C034E7041D6AF205006EE129 /* RTSpinKitView.m in Sources */,
C0CCB3B91EEA579900BC2FB8 /* KWMFilterView.m in Sources */, C0CCB3B91EEA579900BC2FB8 /* KWMFilterView.m in Sources */,
C05910941E34A729002990B3 /* KWMNewGiftCardCell.m in Sources */, C05910941E34A729002990B3 /* KWMNewGiftCardCell.m in Sources */,
...@@ -2694,6 +2711,7 @@ ...@@ -2694,6 +2711,7 @@
C034E8411D6B10A0006EE129 /* CALayer+Transition.m in Sources */, C034E8411D6B10A0006EE129 /* CALayer+Transition.m in Sources */,
C077966F1EEAA2BE00CD6859 /* KWMFilterUtil.m in Sources */, C077966F1EEAA2BE00CD6859 /* KWMFilterUtil.m in Sources */,
C034E8631D6B10A0006EE129 /* PBSaveBtn.m in Sources */, C034E8631D6B10A0006EE129 /* PBSaveBtn.m in Sources */,
DA4E36951F1726B80007E4D0 /* UIViewController+HTTP.m in Sources */,
807AF4A71DC984950000A326 /* KWMProducts.m in Sources */, 807AF4A71DC984950000A326 /* KWMProducts.m in Sources */,
C0F5868A1E24F820001248E2 /* KWMSelectedGoodsVC.m in Sources */, C0F5868A1E24F820001248E2 /* KWMSelectedGoodsVC.m in Sources */,
C034E8661D6B10A0006EE129 /* PhotoItemView.m in Sources */, C034E8661D6B10A0006EE129 /* PhotoItemView.m in Sources */,
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="n8p-We-k4e"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="n8p-We-k4e">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/> <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<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>
...@@ -718,7 +718,7 @@ ...@@ -718,7 +718,7 @@
<scene sceneID="bOf-dv-ZzC"> <scene sceneID="bOf-dv-ZzC">
<objects> <objects>
<navigationController id="u8P-hB-9hk" userLabel="首页tab" sceneMemberID="viewController"> <navigationController id="u8P-hB-9hk" userLabel="首页tab" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Item" id="XwP-f8-O3G"/> <tabBarItem key="tabBarItem" title="首页" id="XwP-f8-O3G"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="RA9-LY-7Yg"> <navigationBar key="navigationBar" contentMode="scaleToFill" id="RA9-LY-7Yg">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/> <rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
...@@ -734,7 +734,7 @@ ...@@ -734,7 +734,7 @@
<!--首页--> <!--首页-->
<scene sceneID="iDT-Ta-igF"> <scene sceneID="iDT-Ta-igF">
<objects> <objects>
<viewController storyboardIdentifier="KWMHomeVC" automaticallyAdjustsScrollViewInsets="NO" useStoryboardIdentifierAsRestorationIdentifier="YES" id="NBO-61-l1q" userLabel="首页" customClass="KWMHomeVC" sceneMemberID="viewController"> <viewController storyboardIdentifier="KWMHomeVC" automaticallyAdjustsScrollViewInsets="NO" hidesBottomBarWhenPushed="YES" useStoryboardIdentifierAsRestorationIdentifier="YES" id="NBO-61-l1q" userLabel="首页" customClass="KWMHomeVC" sceneMemberID="viewController">
<layoutGuides> <layoutGuides>
<viewControllerLayoutGuide type="top" id="f00-jP-fyg"/> <viewControllerLayoutGuide type="top" id="f00-jP-fyg"/>
<viewControllerLayoutGuide type="bottom" id="etP-Nh-Q2m"/> <viewControllerLayoutGuide type="bottom" id="etP-Nh-Q2m"/>
...@@ -776,14 +776,13 @@ ...@@ -776,14 +776,13 @@
</mask> </mask>
</variation> </variation>
</view> </view>
<navigationItem key="navigationItem" id="2Ib-m2-1Tz"/>
<connections> <connections>
<outlet property="tbvBlog" destination="lb3-DY-TZq" id="t0G-sz-ZbP"/> <outlet property="tbvBlog" destination="lb3-DY-TZq" id="t0G-sz-ZbP"/>
</connections> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="GVM-zj-f6B" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="GVM-zj-f6B" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="-346" y="1361"/> <point key="canvasLocation" x="-1615" y="1361"/>
</scene> </scene>
<!--商品--> <!--商品-->
<scene sceneID="KxV-Rs-wmH"> <scene sceneID="KxV-Rs-wmH">
...@@ -1010,7 +1009,7 @@ ...@@ -1010,7 +1009,7 @@
</constraints> </constraints>
</view> </view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsVerticalScrollIndicator="NO" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="kMh-Eo-ATi"> <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsVerticalScrollIndicator="NO" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="kMh-Eo-ATi">
<rect key="frame" x="0.0" y="167" width="375" height="451"/> <rect key="frame" x="0.0" y="167" width="375" height="500"/>
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections> <connections>
<outlet property="dataSource" destination="jDD-sy-yjq" id="svg-5f-Kbf"/> <outlet property="dataSource" destination="jDD-sy-yjq" id="svg-5f-Kbf"/>
......
//
// KWMHomeDataResult.h
// iCemarose
//
// Created by Sanchew on 2017/7/12.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMCemaroseResult.h"
#import "KWMHomeData.h"
@interface KWMHomeDataResult : KWMCemaroseResult
@property (nonatomic, strong) KWMHomeData *data;
@end
//
// KWMHomeDataResult.m
// iCemarose
//
// Created by Sanchew on 2017/7/12.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMHomeDataResult.h"
@implementation KWMHomeDataResult
- (instancetype)initWithDictionary:(NSDictionary *)dict error:(NSError **)err {
if (self = [super init]) {
self.data = [[KWMHomeData alloc] initWithDictionary:dict error:nil];
// NSArray *dataArray = dict[@"items"];
// if(dataArray){
// self.items = [self buildListData:[KWMShopCartModel class] jsonDictionary:dataArray];
// }
}
return self;
}
- (instancetype)initWithDictionary:(NSDictionary *)dict modelClass:(Class)modelClass error:(NSError *__autoreleasing *)err {
if (self = [self initWithDictionary:dict error:err]) {
}
return self;
}
@end
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#import "KWMWechatPayData.h" #import "KWMWechatPayData.h"
#import "KWMOrderPaid.h" #import "KWMOrderPaid.h"
#import "KWMWish.h" #import "KWMWish.h"
#import "KWMHomeDataResult.h"
...@@ -161,6 +161,17 @@ ...@@ -161,6 +161,17 @@
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure; failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
/** /**
* 首页板块数据
*
* @param success <#success description#>
* @param failure <#failure description#>
*
* @return <#return value description#>
*/
- (NSURLSessionDataTask *) getHomeDataWithSuccess:(void(^)(NSURLSessionDataTask *task,KWMHomeDataResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
/**
* 商品——新品API * 商品——新品API
* @return NSURLSessionDataTask * @return NSURLSessionDataTask
*/ */
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#import <SAMKeychain/SAMKeychain.h> #import <SAMKeychain/SAMKeychain.h>
#import "KWMUserModel.h" #import "KWMUserModel.h"
#import "KWMHttpUtil.h" #import "KWMHttpUtil.h"
#import "KWMHomeDataResult.h"
#import <PPNetworkHelper/PPNetworkHelper.h>
...@@ -354,6 +356,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -354,6 +356,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
return task; return task;
} }
- (NSURLSessionDataTask *)startSessionTask:(KWMHTTPMethod)httpMethod - (NSURLSessionDataTask *)startSessionTask:(KWMHTTPMethod)httpMethod
apiPath:(NSString *)apiPath apiPath:(NSString *)apiPath
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
...@@ -679,6 +682,11 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -679,6 +682,11 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
failure:failure]; failure:failure];
} }
- (NSURLSessionDataTask *)getHomeDataWithSuccess:(void (^)(NSURLSessionDataTask *, KWMHomeDataResult *))success failure:(void (^)(NSURLSessionDataTask *, NSError *))failure {
NSString *apiPath = @"https://ogbgohpla.qnssl.com/App.Home.json?1";
return [self startSessionTask:KWMHTTPMethodGET apiPath:apiPath parameters:nil result:[KWMHomeDataResult class] model:nil success:success failure:failure];
}
/** /**
......
...@@ -11,15 +11,19 @@ ...@@ -11,15 +11,19 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#import "KWMProductDetailVC.h" #import "KWMProductDetailVC.h"
#import "KWMSelectedGoodsVC.h" #import "KWMSelectedGoodsVC.h"
#import "KWMBlogDetailVC.h"
@implementation AppDelegate (Deeplink) @implementation AppDelegate (Deeplink)
- (void)registerRouter { - (void)registerRouter {
JLRoutes *routes = [JLRoutes routesForScheme:@"cemarose"]; JLRoutes *routes = [JLRoutes routesForScheme:@"cemarose"];
[routes addRoute:@"/collections/*" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) { [routes addRoute:@"/collections/:handle/*" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
NSArray *tags = parameters[JLRouteWildcardComponentsKey]; NSArray *tags = parameters[JLRouteWildcardComponentsKey];
tags = tags.count > 0 ? [tags[0] componentsSeparatedByString:@"+"] : nil;
// NSArray *tags = [parameters[JLRouteWildcardComponentsKey] componentsSeparatedByString:@"+"];
NSLog(@"trace tags %@",[tags componentsJoinedByString:@","]); NSLog(@"trace tags %@",[tags componentsJoinedByString:@","]);
KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"]; KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"];
selectedGoodsVC.handle = parameters[@"handle"];
selectedGoodsVC.ctags = tags; selectedGoodsVC.ctags = tags;
[[AppDelegate mainViewController].selectedViewController pushViewController:selectedGoodsVC animated:YES]; [[AppDelegate mainViewController].selectedViewController pushViewController:selectedGoodsVC animated:YES];
return YES; return YES;
...@@ -33,6 +37,12 @@ ...@@ -33,6 +37,12 @@
[[AppDelegate mainViewController].selectedViewController pushViewController:productDetailVC animated:YES]; [[AppDelegate mainViewController].selectedViewController pushViewController:productDetailVC animated:YES];
return YES; return YES;
}]; }];
[routes addRoute:@"/blogs/:blog/:handle" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
KWMBlogDetailVC *blogDetailVC = (KWMBlogDetailVC *)[KWMBlogDetailVC findControllerBy:@"KWMBlogDetailVC" fromStoryboard:@"Home"];
blogDetailVC.handle = parameters[@"handle"];
[[AppDelegate mainViewController].selectedViewController pushViewController:blogDetailVC animated:YES];
return YES;
}];
} }
- (BOOL)handleURL:(NSURL *)url { - (BOOL)handleURL:(NSURL *)url {
......
//
// UIViewController+HTTP.h
// iCemarose
//
// Created by Sanchew on 2017/7/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIViewController (HTTP)
- (void) openURLWithString:(NSString *) URLString;
@end
//
// UIViewController+HTTP.m
// iCemarose
//
// Created by Sanchew on 2017/7/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "UIViewController+HTTP.h"
#import <JLRoutes/JLRoutes.h>
#import <RegexKitLite/RegexKitLite.h>
#import <TOWebViewController/TOWebViewController.h>
#import "AppDelegate.h"
@implementation UIViewController (HTTP)
- (void)openURLWithString:(NSString *)URLString {
UIApplication *application = [UIApplication sharedApplication];
NSURL *url = [[NSURL alloc] initWithString:[URLString stringByReplacingOccurrencesOfRegex:@"^https?" withString:@"cemarose"]];
if ([JLRoutes canRouteURL:url]) {
[JLRoutes routeURL:url];
// }else if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
// [application openURL:[NSURL URLWithString:URLString] options:@{} completionHandler:nil];
} else {
// [application openURL:[NSURL URLWithString:URLString]];
TOWebViewController *wv = [[TOWebViewController alloc] initWithURLString:URLString];
[[AppDelegate mainViewController].selectedViewController pushViewController:wv animated:YES];
}
}
@end
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#import "KWMBaseModel.h" #import "KWMBaseModel.h"
@interface KWMAdvertisement : KWMBaseModel @interface KWMAdvertisement :JSONModel
//标题 //标题
@property (nonatomic) NSString *title; @property (nonatomic) NSString *title;
......
//
// 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>
#import "KWMFilter.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;
@property (nonatomic) NSMutableArray<KWMFilter *> *filters;
@property (nonatomic) NSString *brand;
@end
//
// KWMCategoryModel.m
// iCemarose
//
// Created by Sanchew on 2017/7/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMCategoryModel.h"
@implementation KWMCategoryModel
@end
...@@ -10,12 +10,14 @@ ...@@ -10,12 +10,14 @@
#import "KWMAdvertisement.h" #import "KWMAdvertisement.h"
#import "KWMHotSales.h" #import "KWMHotSales.h"
@interface KWMHomeData : KWMBaseModel @protocol KWMAdvertisement;
@property (nonatomic) NSArray *adBanner; @interface KWMHomeData : JSONModel
@property (nonatomic) KWMAdvertisement *clothingSets; @property (nonatomic) NSArray <KWMAdvertisement> *ad_banner;
@property (nonatomic) KWMHotSales *hotSales; @property (nonatomic) KWMAdvertisement *clothing_sets;
@property (nonatomic) KWMHotSales *hot_sales;
@end @end
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
#import "KWMBaseModel.h" #import "KWMBaseModel.h"
@interface KWMHotSales : KWMBaseModel @interface KWMHotSales :JSONModel
//大图商品数量 //大图商品数量
@property (nonatomic) NSNumber *singleShowCount; @property (nonatomic) NSNumber *single_show_count;
@end @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 ()
...@@ -33,11 +35,15 @@ ...@@ -33,11 +35,15 @@
@property (nonatomic) NSArray *allBrands; @property (nonatomic) NSArray *allBrands;
@property(nonatomic) BUYCollectionSort sort; //@property(nonatomic) BUYCollectionSort sort;
//@property(nonatomic) NSMutableArray<KWMFilter *> *selectFilters;
@property(nonatomic) NSMutableArray<KWMFilter *> *selectFilters; //@property(nonatomic) NSString *selectBrands;
@property(nonatomic) NSString *selectBrands; @property(nonatomic) NSArray<KWMCategoryModel *>* categories;
@property (nonatomic) KWMCategoryModel *selectedCategory;
@end @end
...@@ -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,13 +73,43 @@ ...@@ -66,13 +73,43 @@
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 = @"";
} }
-(void)initTbvLeft{ -(void)initTbvLeft{
...@@ -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
...@@ -149,14 +195,14 @@ ...@@ -149,14 +195,14 @@
KWMBrandFilterVC *brandFilterVC = (KWMBrandFilterVC *)[KWMBaseVC findControllerBy:[KWMBrandFilterVC kwmTag] fromStoryboard:@"Category"]; KWMBrandFilterVC *brandFilterVC = (KWMBrandFilterVC *)[KWMBaseVC findControllerBy:[KWMBrandFilterVC kwmTag] fromStoryboard:@"Category"];
brandFilterVC.brandArray = self.allBrands; brandFilterVC.brandArray = self.allBrands;
brandFilterVC.delegate = self; brandFilterVC.delegate = self;
brandFilterVC.selectBrand = self.selectBrands; brandFilterVC.selectBrand = self.selectedCategory.brand;
tragetVC = brandFilterVC; tragetVC = brandFilterVC;
}else{ }else{
KWMProductFilterVC *productFilterVC = (KWMProductFilterVC *)[KWMBaseVC findControllerBy:[KWMProductFilterVC kwmTag] fromStoryboard:@"Category"]; KWMProductFilterVC *productFilterVC = (KWMProductFilterVC *)[KWMBaseVC findControllerBy:[KWMProductFilterVC kwmTag] fromStoryboard:@"Category"];
productFilterVC.filterMode = filterMode; productFilterVC.filterMode = filterMode;
productFilterVC.delegate = self; productFilterVC.delegate = self;
productFilterVC.selectedSort = self.sort; productFilterVC.selectedSort = self.selectedCategory.sort;
productFilterVC.selectedTags = self.selectFilters; productFilterVC.selectedTags = self.selectedCategory.filters;
tragetVC = productFilterVC; tragetVC = productFilterVC;
} }
CGSize size = [UIScreen mainScreen].bounds.size; CGSize size = [UIScreen mainScreen].bounds.size;
...@@ -165,8 +211,9 @@ ...@@ -165,8 +211,9 @@
#pragma mark - #pragma mark -
-(void)kwm_onCompleProductFilter:(KWMFilterView *)filterView{ -(void)kwm_onCompleProductFilter:(KWMFilterView *)filterView{
self.selectFilters = filterView.selectedTags; // self.selectFilters = filterView.selectedTags;
self.sort = filterView.selectedSort; self.selectedCategory.filters = filterView.selectedTags;
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];
...@@ -179,7 +226,8 @@ ...@@ -179,7 +226,8 @@
#pragma mark - #pragma mark -
-(void)kwm_onCompleteBrandFilter:(NSString *)selectBrand{ -(void)kwm_onCompleteBrandFilter:(NSString *)selectBrand{
self.selectBrands = selectBrand; // self.selectBrands = selectBrand;
self.selectedCategory.brand = selectBrand;
[self.filterTab close]; [self.filterTab close];
[self.refreshUtil reLoadData]; [self.refreshUtil reLoadData];
[self.cvRightProduct.mj_header beginRefreshing]; [self.cvRightProduct.mj_header beginRefreshing];
...@@ -206,30 +254,60 @@ ...@@ -206,30 +254,60 @@
} }
#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;
NSMutableArray *tags = [KWMFilterUtil getTagsByFilterArray:self.selectFilters]; KWMCategoryModel *cmodel = self.selectedCategory;
if(![KWMStringUtil isEmpty:self.selectBrands]){ NSMutableArray *tags = [KWMFilterUtil getTagsByFilterArray:cmodel.filters];
[tags addObject:self.selectBrands]; if(cmodel.brand){
[tags addObject:cmodel.brand];
} }
[self.client getProductsPage:cpage inCollection:cmodel.collection_id withTags:tags sortOrder:cmodel.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
[self.client getProductsPage:page inCollection:@(Collection_All_ID) withTags:tags sortOrder:self.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){ if (cmodel == self.selectedCategory) {
[weakSelf.refreshUtil hideLoading]; [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.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
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
case BUYCollectionSortPriceAscending: case BUYCollectionSortPriceAscending:
return 3; return 3;
default: default:
return 0; return -1;
} }
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12118" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.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"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<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>
<scenes> <scenes>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="648"/> <rect key="frame" x="0.0" y="0.0" width="375" height="648"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_ home_content_title" translatesAutoresizingMaskIntoConstraints="NO" id="6b3-4L-fqj"> <imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_ home_content_title" translatesAutoresizingMaskIntoConstraints="NO" id="6b3-4L-fqj">
<rect key="frame" x="20" y="10" width="14" height="9"/> <rect key="frame" x="20" y="10" width="14" height="9"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="9" id="SlC-wh-5e0"/> <constraint firstAttribute="height" constant="9" id="SlC-wh-5e0"/>
...@@ -40,17 +40,17 @@ ...@@ -40,17 +40,17 @@
</constraints> </constraints>
</imageView> </imageView>
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XjH-A0-ATq"> <webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XjH-A0-ATq">
<rect key="frame" x="0.0" y="83.5" width="375" height="564.5"/> <rect key="frame" x="0.0" y="34" width="375" height="614"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</webView> </webView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="35I-9E-t9l"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="35I-9E-t9l">
<rect key="frame" x="20" y="23" width="325" height="32.5"/> <rect key="frame" x="20" y="23" width="325" height="0.0"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="23"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="23"/>
<color key="textColor" red="0.29803921568627451" green="0.34901960784313724" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.29803921568627451" green="0.34901960784313724" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gjF-Th-7MU"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gjF-Th-7MU">
<rect key="frame" x="20" y="66.5" width="345" height="17"/> <rect key="frame" x="20" y="34" width="345" height="0.0"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.29803921570000003" green="0.34901960780000002" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.29803921570000003" green="0.34901960780000002" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
</constraints> </constraints>
</view> </view>
<connections> <connections>
<outlet property="flagImg" destination="6b3-4L-fqj" id="Zw9-1P-Fjp"/>
<outlet property="lbTitle" destination="35I-9E-t9l" id="zpt-Oq-Rhh"/> <outlet property="lbTitle" destination="35I-9E-t9l" id="zpt-Oq-Rhh"/>
<outlet property="publishTime" destination="gjF-Th-7MU" id="HE9-1B-5Yl"/> <outlet property="publishTime" destination="gjF-Th-7MU" id="HE9-1B-5Yl"/>
<outlet property="tbvArticle" destination="XdN-GP-LIS" id="3qw-6w-72k"/> <outlet property="tbvArticle" destination="XdN-GP-LIS" id="3qw-6w-72k"/>
......
...@@ -16,5 +16,8 @@ ...@@ -16,5 +16,8 @@
@property (weak, nonatomic) IBOutlet UILabel *lbTitle; @property (weak, nonatomic) IBOutlet UILabel *lbTitle;
@property (weak, nonatomic) IBOutlet UILabel *publishTime; @property (weak, nonatomic) IBOutlet UILabel *publishTime;
@property (weak, nonatomic) IBOutlet UIView *vHeader; @property (weak, nonatomic) IBOutlet UIView *vHeader;
@property (weak, nonatomic) IBOutlet UIImageView *flagImg;
@property (nonatomic) KWMArticlesResult *article; @property (nonatomic) KWMArticlesResult *article;
@property (nonatomic) NSString *handle;
@end @end
...@@ -23,15 +23,36 @@ ...@@ -23,15 +23,36 @@
// Do any additional setup after loading the view // Do any additional setup after loading the view
self.title = @"正文"; self.title = @"正文";
self.automaticallyAdjustsScrollViewInsets = NO; self.automaticallyAdjustsScrollViewInsets = NO;
if (!self.handle) {
[self initData];
}else{
[self requestData];
}
}
- (void) requestData {
[self showLoading];
[self.api getAllBlog:@{@"handle":self.handle} success:^(NSURLSessionDataTask *task, KWMBlogResult *result) {
[self hideLoading];
self.article = result.blogs.firstObject;
[self initData];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
[self showError:error];
NSLog(@"error:%@",error);
self.view.hidden = NO;
}];
}
- (void) initData {
self.flagImg.hidden = NO;
self.wbArticle.delegate = self; self.wbArticle.delegate = self;
self.wbArticle.scrollView.scrollEnabled = NO; self.wbArticle.scrollView.scrollEnabled = NO;
self.lbTitle.text = _article.title; self.lbTitle.text = _article.title;
self.publishTime.text = [self returnTimeStr:_article.published_at]; self.publishTime.text = [self returnTimeStr:_article.published_at];
self.tbvArticle.backgroundColor = [UIColor clearColor]; self.tbvArticle.backgroundColor = [UIColor clearColor];
self.tbvArticle.separatorStyle = UITableViewCellSeparatorStyleNone; self.tbvArticle.separatorStyle = UITableViewCellSeparatorStyleNone;
[self initWebView]; [self initWebView];
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
[super viewDidLoad]; [super viewDidLoad];
_dataArr = [NSArray array]; _dataArr = [NSArray array];
[self requestBlogAPI]; [self requestBlogAPI];
// FIXME: mo to main
[self.api loginWebSuccess:nil failure:nil]; [self.api loginWebSuccess:nil failure:nil];
} }
...@@ -70,19 +71,19 @@ ...@@ -70,19 +71,19 @@
- (void)viewWillAppear:(BOOL)animated{ - (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated]; [super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES]; [self.navigationController setNavigationBarHidden:NO];
[self initHeaderView]; // [self initHeaderView];
if (_searchBar) { // if (_searchBar) {
NSInteger count = [[KWMShoppingCart sharedInstance] count].integerValue; // NSInteger count = [[KWMShoppingCart sharedInstance] count].integerValue;
_searchBar.count = count; // _searchBar.count = count;
} // }
[_searchBar resumeView]; // [_searchBar resumeView];
} }
- (void)viewWillDisappear:(BOOL)animated{ - (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated]; [super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:YES]; // [self.navigationController setNavigationBarHidden:YES];
[_searchBar removeFromSuperview]; // [_searchBar removeFromSuperview];
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
...@@ -91,7 +92,7 @@ ...@@ -91,7 +92,7 @@
-(void)awakeFromNib{ -(void)awakeFromNib{
[super awakeFromNib]; [super awakeFromNib];
self.title = @"首页"; self.title = @"发现新鲜";
} }
//请求api //请求api
......
<?xml version="1.0" encoding="UTF-8"?> <?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="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="总计:¥" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="z8Q-AY-djl"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="总计:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="z8Q-AY-djl">
<rect key="frame" x="273" y="7" width="34.5" height="17"/> <rect key="frame" x="280" y="7" width="27.5" height="17"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.94509803920000002" green="0.57254901960000004" blue="0.60392156860000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.94509803920000002" green="0.57254901960000004" blue="0.60392156860000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
<outlet property="vContent" destination="ijW-ut-DIo" id="ibM-ZX-F0E"/> <outlet property="vContent" destination="ijW-ut-DIo" id="ibM-ZX-F0E"/>
<outlet property="vHeader" destination="9GU-8G-dS5" id="esp-Xp-6d3"/> <outlet property="vHeader" destination="9GU-8G-dS5" id="esp-Xp-6d3"/>
</connections> </connections>
<point key="canvasLocation" x="54" y="-116"/> <point key="canvasLocation" x="53.5" y="-116"/>
</tableViewCell> </tableViewCell>
</objects> </objects>
<resources> <resources>
......
...@@ -108,5 +108,9 @@ ...@@ -108,5 +108,9 @@
return self.productArray?self.productArray.count:0; return self.productArray?self.productArray.count:0;
} }
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[self.delegate kwm_onClickProduct:self.productArray[indexPath.item]];
}
@end @end
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
#import "UIImageView+WebCache.h" #import "UIImageView+WebCache.h"
#import "KWMNewHomeCell.h" #import "KWMNewHomeCell.h"
@interface KWMHotSalesHeader() @interface KWMHotSalesHeader()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property (nonatomic,weak) IBOutlet UIView *vView; @property (nonatomic,weak) IBOutlet UIView *vView;
@property (nonatomic,weak) IBOutlet KWMBannerView *bannerView; @property (nonatomic,weak) IBOutlet KWMBannerView *bannerView;
@property (nonatomic,weak) IBOutlet UIView *singleShowView; @property (nonatomic,weak) IBOutlet UICollectionView *singleShowView;
@property (nonatomic,weak) IBOutlet NSLayoutConstraint *heightBannerView; @property (nonatomic,weak) IBOutlet NSLayoutConstraint *heightBannerView;
...@@ -69,6 +69,14 @@ ...@@ -69,6 +69,14 @@
} }
-(void)initView{ -(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.bannerView.delegate = self;
self.heightBannerView.constant = 0; self.heightBannerView.constant = 0;
self.heightSingleShowView.constant = 0; self.heightSingleShowView.constant = 0;
...@@ -98,19 +106,42 @@ ...@@ -98,19 +106,42 @@
NSInteger itemWidth = UI_SCREEN_WIDTH - 16; NSInteger itemWidth = UI_SCREEN_WIDTH - 16;
NSInteger itemHeight = UI_SCREEN_WIDTH + 58; NSInteger itemHeight = UI_SCREEN_WIDTH + 58;
for(int i=0;i<singleShowArray.count;i++){ // for(int i=0;i<singleShowArray.count;i++){
BUYProduct *product = [singleShowArray objectAtIndex:i]; // BUYProduct *product = [singleShowArray objectAtIndex:i];
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"KWMNewHomeCell" owner:self options:nil]; // NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"KWMNewHomeCell" owner:self options:nil];
KWMNewHomeCell *homeCell = [nib objectAtIndex:0]; // KWMNewHomeCell *homeCell = [nib objectAtIndex:0];
homeCell.frame = CGRectMake(8, itemHeight*i, itemWidth, itemHeight); // homeCell.frame = CGRectMake(8, itemHeight*i, itemWidth, itemHeight);
homeCell.singleShow = YES; // homeCell.singleShow = YES;
homeCell.tag = i; // homeCell.tag = i;
homeCell.product = product; // homeCell.product = product;
[self.singleShowView addSubview:homeCell]; //
} // [self.singleShowView addSubview:homeCell];
// }
self.heightSingleShowView.constant = itemHeight*singleShowArray.count; 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 #pragma mark - KWMBannerViewDelegate
-(UIView *)bannerView:(KWMBannerView *)bannerView reusingView:(UIView *)reusingView pageAtIndex:(NSInteger)index{ -(UIView *)bannerView:(KWMBannerView *)bannerView reusingView:(UIView *)reusingView pageAtIndex:(NSInteger)index{
UIView *itemView = reusingView?reusingView:nil; UIView *itemView = reusingView?reusingView:nil;
......
<?xml version="1.0" encoding="UTF-8"?> <?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"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <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"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
<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="heightBannerView" destination="NbW-Kh-s5O" id="zdT-r2-QNE"/>
<outlet property="heightSingleShowView" destination="7LG-U7-451" id="9MA-ha-ZlO"/> <outlet property="heightSingleShowView" destination="SEw-Tw-g0a" id="PcT-Pv-gcm"/>
<outlet property="singleShowView" destination="Dwm-lO-Zce" id="DKc-lA-7U0"/> <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"/>
</connections> </connections>
</placeholder> </placeholder>
...@@ -67,25 +67,31 @@ ...@@ -67,25 +67,31 @@
<constraint firstAttribute="height" constant="190" id="NbW-Kh-s5O"/> <constraint firstAttribute="height" constant="190" id="NbW-Kh-s5O"/>
</constraints> </constraints>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dwm-lO-Zce" userLabel="singleShowView"> <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="UGY-II-IMu">
<rect key="frame" x="0.0" y="250" width="375" height="0.0"/> <rect key="frame" x="0.0" y="250" width="375" height="0.0"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstAttribute="height" id="7LG-U7-451"/> <constraint firstAttribute="height" id="SEw-Tw-g0a"/>
</constraints> </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> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <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="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 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 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="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 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="d0n-L5-xP1" secondAttribute="trailing" id="iHt-uY-XiY"/>
<constraint firstAttribute="trailing" secondItem="Dwm-lO-Zce" secondAttribute="trailing" id="q59-1g-wOJ"/> <constraint firstItem="UGY-II-IMu" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="whN-vO-ZIi"/>
<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"/>
</constraints> </constraints>
<nil key="simulatedStatusBarMetrics"/> <nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
......
...@@ -50,5 +50,17 @@ ...@@ -50,5 +50,17 @@
self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vView]; [self addSubview:self.vView];
} }
- (IBAction)newAction:(id)sender {
[self.delegate kwm_onClickHotMenu];
}
- (IBAction)discoverAction:(id)sender {
[self.delegate kwm_onClickNewMenu];
}
- (IBAction)likeAction:(id)sender {
[self.delegate kwm_onClickWishMenu];
}
- (IBAction)serverAction:(id)sender {
[self.delegate kwm_onClickDeliveryMenu];
}
@end @end
<?xml version="1.0" encoding="UTF-8"?> <?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"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <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"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
...@@ -40,12 +40,16 @@ ...@@ -40,12 +40,16 @@
</label> </label>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<constraints> <constraints>
<constraint firstItem="4Bg-sB-Fk4" firstAttribute="top" secondItem="Vyx-ed-YkS" secondAttribute="top" id="Qys-rx-muq"/> <constraint firstItem="4Bg-sB-Fk4" firstAttribute="top" secondItem="Vyx-ed-YkS" secondAttribute="top" id="Qys-rx-muq"/>
<constraint firstItem="4Bg-sB-Fk4" firstAttribute="centerX" secondItem="Vyx-ed-YkS" secondAttribute="centerX" id="WEr-ts-Nib"/> <constraint firstItem="4Bg-sB-Fk4" firstAttribute="centerX" secondItem="Vyx-ed-YkS" secondAttribute="centerX" id="WEr-ts-Nib"/>
<constraint firstItem="c40-0Y-Obt" firstAttribute="top" secondItem="4Bg-sB-Fk4" secondAttribute="bottom" constant="10" id="u96-ve-TeV"/> <constraint firstItem="c40-0Y-Obt" firstAttribute="top" secondItem="4Bg-sB-Fk4" secondAttribute="bottom" constant="10" id="u96-ve-TeV"/>
<constraint firstItem="c40-0Y-Obt" firstAttribute="centerX" secondItem="Vyx-ed-YkS" secondAttribute="centerX" id="vjx-GI-Sjs"/> <constraint firstItem="c40-0Y-Obt" firstAttribute="centerX" secondItem="Vyx-ed-YkS" secondAttribute="centerX" id="vjx-GI-Sjs"/>
</constraints> </constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="bXR-EM-KIH" appends="YES" id="kSp-hM-baR"/>
</connections>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="92D-Xx-Bd9" userLabel="火爆热卖"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="92D-Xx-Bd9" userLabel="火爆热卖">
<rect key="frame" x="99" y="0.0" width="88.5" height="80"/> <rect key="frame" x="99" y="0.0" width="88.5" height="80"/>
...@@ -57,7 +61,7 @@ ...@@ -57,7 +61,7 @@
<constraint firstAttribute="height" constant="40" id="m2N-Ea-82N"/> <constraint firstAttribute="height" constant="40" id="m2N-Ea-82N"/>
</constraints> </constraints>
</imageView> </imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="火爆热卖" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3sg-P6-odK"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="发现新鲜" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3sg-P6-odK">
<rect key="frame" x="20.5" y="50" width="48" height="17"/> <rect key="frame" x="20.5" y="50" width="48" height="17"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.13725490200000001" green="0.14117647059999999" blue="0.16078431369999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.13725490200000001" green="0.14117647059999999" blue="0.16078431369999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
...@@ -65,12 +69,16 @@ ...@@ -65,12 +69,16 @@
</label> </label>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<constraints> <constraints>
<constraint firstItem="JdT-c1-AgH" firstAttribute="top" secondItem="92D-Xx-Bd9" secondAttribute="top" id="4xb-8P-Bfq"/> <constraint firstItem="JdT-c1-AgH" firstAttribute="top" secondItem="92D-Xx-Bd9" secondAttribute="top" id="4xb-8P-Bfq"/>
<constraint firstItem="3sg-P6-odK" firstAttribute="top" secondItem="JdT-c1-AgH" secondAttribute="bottom" constant="10" id="SHS-AO-PBc"/> <constraint firstItem="3sg-P6-odK" firstAttribute="top" secondItem="JdT-c1-AgH" secondAttribute="bottom" constant="10" id="SHS-AO-PBc"/>
<constraint firstItem="3sg-P6-odK" firstAttribute="centerX" secondItem="92D-Xx-Bd9" secondAttribute="centerX" id="g4G-UD-0fN"/> <constraint firstItem="3sg-P6-odK" firstAttribute="centerX" secondItem="92D-Xx-Bd9" secondAttribute="centerX" id="g4G-UD-0fN"/>
<constraint firstItem="JdT-c1-AgH" firstAttribute="centerX" secondItem="92D-Xx-Bd9" secondAttribute="centerX" id="pGd-bq-ZI1"/> <constraint firstItem="JdT-c1-AgH" firstAttribute="centerX" secondItem="92D-Xx-Bd9" secondAttribute="centerX" id="pGd-bq-ZI1"/>
</constraints> </constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="cF7-BX-xa9" appends="YES" id="7rg-sB-lvS"/>
</connections>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PAq-6Z-msb" userLabel="我喜欢的"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PAq-6Z-msb" userLabel="我喜欢的">
<rect key="frame" x="187.5" y="0.0" width="89" height="80"/> <rect key="frame" x="187.5" y="0.0" width="89" height="80"/>
...@@ -90,12 +98,16 @@ ...@@ -90,12 +98,16 @@
</label> </label>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<constraints> <constraints>
<constraint firstItem="2Fh-Tj-POc" firstAttribute="centerX" secondItem="PAq-6Z-msb" secondAttribute="centerX" id="SWN-bO-gb1"/> <constraint firstItem="2Fh-Tj-POc" firstAttribute="centerX" secondItem="PAq-6Z-msb" secondAttribute="centerX" id="SWN-bO-gb1"/>
<constraint firstItem="Pfa-Sa-Cv9" firstAttribute="centerX" secondItem="PAq-6Z-msb" secondAttribute="centerX" id="bqR-bR-Fwr"/> <constraint firstItem="Pfa-Sa-Cv9" firstAttribute="centerX" secondItem="PAq-6Z-msb" secondAttribute="centerX" id="bqR-bR-Fwr"/>
<constraint firstItem="2Fh-Tj-POc" firstAttribute="top" secondItem="Pfa-Sa-Cv9" secondAttribute="bottom" constant="10" id="dJl-Bc-0PQ"/> <constraint firstItem="2Fh-Tj-POc" firstAttribute="top" secondItem="Pfa-Sa-Cv9" secondAttribute="bottom" constant="10" id="dJl-Bc-0PQ"/>
<constraint firstItem="Pfa-Sa-Cv9" firstAttribute="top" secondItem="PAq-6Z-msb" secondAttribute="top" id="szi-Li-o6n"/> <constraint firstItem="Pfa-Sa-Cv9" firstAttribute="top" secondItem="PAq-6Z-msb" secondAttribute="top" id="szi-Li-o6n"/>
</constraints> </constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="kA5-mN-m1r" appends="YES" id="wpR-al-fIV"/>
</connections>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fxs-MB-T7q" userLabel="直邮说明"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fxs-MB-T7q" userLabel="直邮说明">
<rect key="frame" x="276.5" y="0.0" width="88.5" height="80"/> <rect key="frame" x="276.5" y="0.0" width="88.5" height="80"/>
...@@ -107,7 +119,7 @@ ...@@ -107,7 +119,7 @@
<constraint firstAttribute="width" constant="40" id="n6V-12-EnZ"/> <constraint firstAttribute="width" constant="40" id="n6V-12-EnZ"/>
</constraints> </constraints>
</imageView> </imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="直邮说明" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Izf-6L-av5"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="服务说明" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Izf-6L-av5">
<rect key="frame" x="20.5" y="50" width="48" height="17"/> <rect key="frame" x="20.5" y="50" width="48" height="17"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.13725490200000001" green="0.14117647059999999" blue="0.16078431369999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.13725490200000001" green="0.14117647059999999" blue="0.16078431369999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
...@@ -115,12 +127,16 @@ ...@@ -115,12 +127,16 @@
</label> </label>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<constraints> <constraints>
<constraint firstItem="Izf-6L-av5" firstAttribute="top" secondItem="keV-Nx-QNu" secondAttribute="bottom" constant="10" id="2b4-9n-z6h"/> <constraint firstItem="Izf-6L-av5" firstAttribute="top" secondItem="keV-Nx-QNu" secondAttribute="bottom" constant="10" id="2b4-9n-z6h"/>
<constraint firstItem="keV-Nx-QNu" firstAttribute="top" secondItem="fxs-MB-T7q" secondAttribute="top" id="2dK-0c-oKe"/> <constraint firstItem="keV-Nx-QNu" firstAttribute="top" secondItem="fxs-MB-T7q" secondAttribute="top" id="2dK-0c-oKe"/>
<constraint firstItem="Izf-6L-av5" firstAttribute="centerX" secondItem="fxs-MB-T7q" secondAttribute="centerX" id="3rs-0K-XLv"/> <constraint firstItem="Izf-6L-av5" firstAttribute="centerX" secondItem="fxs-MB-T7q" secondAttribute="centerX" id="3rs-0K-XLv"/>
<constraint firstItem="keV-Nx-QNu" firstAttribute="centerX" secondItem="fxs-MB-T7q" secondAttribute="centerX" id="8go-Zp-Y2W"/> <constraint firstItem="keV-Nx-QNu" firstAttribute="centerX" secondItem="fxs-MB-T7q" secondAttribute="centerX" id="8go-Zp-Y2W"/>
</constraints> </constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="Nlw-ai-eZC" appends="YES" id="8rJ-FV-Jyr"/>
</connections>
</view> </view>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
...@@ -154,6 +170,26 @@ ...@@ -154,6 +170,26 @@
<nil key="simulatedStatusBarMetrics"/> <nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</view> </view>
<tapGestureRecognizer id="bXR-EM-KIH" userLabel="new">
<connections>
<action selector="newAction:" destination="-1" id="f8T-3h-3L3"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer id="cF7-BX-xa9" userLabel="discover">
<connections>
<action selector="discoverAction:" destination="-1" id="07g-uX-2pJ"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer id="kA5-mN-m1r" userLabel="like">
<connections>
<action selector="likeAction:" destination="-1" id="Zig-Z6-MQb"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer id="Nlw-ai-eZC" userLabel="server">
<connections>
<action selector="serverAction:" destination="-1" id="TvK-1P-BoK"/>
</connections>
</tapGestureRecognizer>
</objects> </objects>
<resources> <resources>
<image name="ic_home_about_shipping" width="40" height="40"/> <image name="ic_home_about_shipping" width="40" height="40"/>
......
<?xml version="1.0" encoding="UTF-8"?> <?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"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <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="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>
<objects> <objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> <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"/> <rect key="frame" x="0.0" y="0.0" width="184" height="242"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center"> <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
......
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
#import "KWMSearchBar.h" #import "KWMSearchBar.h"
#import "KWMHomeData.h" #import "KWMHomeData.h"
#import "KWMShoppingCart.h" #import "KWMShoppingCart.h"
#import <RegexKitLite/RegexKitLite.h>
#import <RXCollections/RXCollection.h>
#import "KWMHomeVC.h"
#import "KWMWishListVC.h"
#import <MJRefresh.h>
typedef enum{ typedef enum{
...@@ -46,7 +51,11 @@ typedef enum{ ...@@ -46,7 +51,11 @@ typedef enum{
@property(nonatomic) KWMHomeData *homeData; @property(nonatomic) KWMHomeData *homeData;
@property(nonatomic) NSArray<BUYProduct *>* productArray; @property(nonatomic) NSInteger page;
@property(nonatomic) NSMutableArray<BUYProduct *>* productArray;
@property(nonatomic) NSMutableDictionary *dataMapping;
@end @end
...@@ -55,7 +64,10 @@ typedef enum{ ...@@ -55,7 +64,10 @@ typedef enum{
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self initView]; [self initView];
[self requestProduct:@""]; self.page = 1;
// [self requestProduct:@""];
[self loadHomeData];
} }
- (void)viewWillAppear:(BOOL)animated{ - (void)viewWillAppear:(BOOL)animated{
...@@ -84,52 +96,9 @@ typedef enum{ ...@@ -84,52 +96,9 @@ 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)initData{
if(self.homeData){
self.adHeader.adArray = self.homeData.adBanner;
self.recommendHeader.productArray = self.productArray;
self.clothingSetsHeader.productArray = self.productArray;
self.clothingSetsHeader.headerImage = self.homeData.clothingSets.image;
NSMutableArray *testArray = [NSMutableArray array];
[testArray addObject:[self.productArray objectAtIndex:0]];
[testArray addObject:[self.productArray objectAtIndex:1]];
[testArray addObject:[self.productArray objectAtIndex:2]];
[testArray addObject:[self.productArray objectAtIndex:4]];
self.hotSalesHeader.singleShowArray = testArray;
self.hotSalesHeader.bannerArray = testArray;
[self.cvHome reloadData];
}
}
- (void)initView{ - (void)initView{
self.title = @"首页"; // self.title = @"首页";
self.adHeader = [[KWMAdHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 275)]; self.adHeader = [[KWMAdHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 275)];
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)];
...@@ -169,33 +138,44 @@ typedef enum{ ...@@ -169,33 +138,44 @@ typedef enum{
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMRecommendHeader kwmTag]]; [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:[KWMClothingSetsHeader kwmTag]];
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMMenuHeader 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 #pragma mark - KWMAdDelegate
-(void)kwm_gotoWebView:(NSString *)url{ -(void)kwm_gotoWebView:(NSString *)url{
// NSLog(@"click webview");
[self openURLWithString:url];
} }
#pragma mark - KWMMenuDelegate #pragma mark - KWMMenuDelegate
-(void)kwm_onClickHotMenu{ -(void)kwm_onClickHotMenu{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/new"];
} }
-(void)kwm_onClickNewMenu{ -(void)kwm_onClickNewMenu{
KWMHomeVC* selectedGoodsVC = (KWMHomeVC *)[KWMBaseVC findControllerBy:[KWMHomeVC kwmTag] fromStoryboard:@"Main"];
[self.navigationController pushViewController:selectedGoodsVC animated:YES];
} }
-(void)kwm_onClickWishMenu{ -(void)kwm_onClickWishMenu{
NSLog(@"wishmenu");
KWMWishListVC* vc= (KWMWishListVC *)[KWMBaseVC findControllerBy:[KWMWishListVC kwmTag] fromStoryboard:@"NewProduct"];
[self.navigationController pushViewController:vc animated:YES];
} }
-(void)kwm_onClickDeliveryMenu{ -(void)kwm_onClickDeliveryMenu{
NSLog(@"deliverymenu");
} }
#pragma makr - KWMRecommendDelegate KWMClothingSetsDelegate KWMHotSalesDelegate #pragma makr - KWMRecommendDelegate KWMClothingSetsDelegate KWMHotSalesDelegate
-(void)kwm_onClickProduct:(BUYProduct *)product{ -(void)kwm_onClickProduct:(BUYProduct *)product{
// NSLog(@"product");
[self openURLWithString:[NSString stringWithFormat:@"https://cemarose.myshopify.com/products/%@",product.handle]];
} }
...@@ -285,7 +265,7 @@ typedef enum{ ...@@ -285,7 +265,7 @@ typedef enum{
#pragma mark - CHTCollectionViewDelegateWaterfallLayout #pragma mark - CHTCollectionViewDelegateWaterfallLayout
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
[self kwm_onClickProduct:self.productArray[indexPath.item]];
} }
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
...@@ -304,28 +284,103 @@ typedef enum{ ...@@ -304,28 +284,103 @@ typedef enum{
} }
#pragma makr - api #pragma makr - api
- (void)requestProduct:(NSString *)tag{ //- (void)requestProduct:(NSString *)tag{
NSMutableArray *tags = nil; // NSMutableArray *tags = nil;
if(tag){ // if(tag){
tags = [NSMutableArray array]; // tags = [NSMutableArray array];
[tags addObject:tag]; // [tags addObject:tag];
} // }
//
__weak KWMNewHomeVC *weakSelf = self; // __weak KWMNewHomeVC *weakSelf = self;
// [self showLoading];
// [self.client getProductsPage:1 inCollection:@(Collection_All_ID) withTags:tags sortOrder:BUYCollectionSortBestSelling completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
// [weakSelf hideLoading];
// if(error){
// [weakSelf showError:error];
// }
// else if(products && products.count>0){
// weakSelf.productArray = products;
// [weakSelf.cvHome reloadData];
//// [weakSelf initTestData];
// }
// }];
//}
- (void) requestProductWithHandle:(NSString *) handle tags:(NSArray *) tags valueKeyPath:(NSString *) valueKeyPath {
[self showLoading]; [self showLoading];
[self.client getProductsPage:1 inCollection:@(Collection_All_ID) withTags:tags sortOrder:BUYCollectionSortBestSelling completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){ BOOL isHome = [handle isEqualToString:@"products-list-app-homepage"];
[weakSelf hideLoading]; NSInteger cpage = isHome ? self.page : 1;
if(error){ [self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
[weakSelf showError: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) {
else if(products && products.count>0){ [self hideLoading];
weakSelf.productArray = products;
[weakSelf.cvHome reloadData]; if (!error) {
[weakSelf initTestData]; [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];
[self showError:error];
} }
}]; }];
} }
- (void) loadHomeData {
[self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"];
[self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) {
self.homeData = result.data;
[self.cvHome reloadData];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
[self showError:error];
}];
}
- (void)setHomeData:(KWMHomeData *)homeData {
_homeData = homeData;
[homeData.ad_banner[0] setUrl:@"https://www.cemarose.com/blogs/news/article-1"];
self.adHeader.adArray = self.homeData.ad_banner;
// self.recommendHeader.productArray = self.productArray;
// self.clothingSetsHeader.productArray = self.productArray;
// self.homeData.hot_sales.single_show_count = @(3);
self.clothingSetsHeader.headerImage = self.homeData.clothing_sets.image;
// self.hotSalesHeader.singleShowArray = testArray;
// self.hotSalesHeader.bannerArray = testArray;
NSArray *clothingParam = [self.homeData.clothing_sets.url arrayOfCaptureComponentsMatchedByRegex:@"collections\\/(.*?)\\/(.*)"];
if (clothingParam.count) {
clothingParam = clothingParam.firstObject;
NSString *handle = clothingParam.count > 1 ? clothingParam[1] : nil;
NSArray *tags = clothingParam.count > 2 ? [clothingParam[2] componentsSeparatedByString:@"+"] : nil;
if (handle) {
[self requestProductWithHandle:handle tags:tags valueKeyPath:@"clothingSetsHeader.productArray"];
}
}
[self requestProductWithHandle:@"products-list-app-homepage" tags:nil valueKeyPath:@"productArray"];
NSLog(@"path:%@",clothingParam);
}
- (void)setProductArray:(NSArray<BUYProduct *> *)productArray {
if (!_productArray) {
NSInteger ssize = self.homeData.hot_sales.single_show_count.integerValue;
NSInteger count = productArray.count;
self.hotSalesHeader.singleShowArray = count <= ssize ? productArray : [productArray subarrayWithRange:NSMakeRange(0, ssize)];
_productArray = [[NSMutableArray alloc] init];
// [_productArray addObjectsFromArray:[productArray subarrayWithRange:NSMakeRange(self.homeData.hot_sales.single_show_count.integerValue, 99)]];
if (count > ssize) {
[_productArray addObjectsFromArray:[productArray subarrayWithRange:NSMakeRange(ssize, count - ssize)]];
}
}else{
[_productArray addObjectsFromArray:productArray];
}
// _productArray = productArray;
}
@end @end
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
[self requestWishList]; [self requestWishList];
} }
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO];
}
- (void)initView{ - (void)initView{
self.title = @"我喜欢的"; self.title = @"我喜欢的";
[self.tbvWish registerNib:[UINib nibWithNibName:NSStringFromClass([KWMWishCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([KWMWishCell class])]; [self.tbvWish registerNib:[UINib nibWithNibName:NSStringFromClass([KWMWishCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([KWMWishCell class])];
......
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
@property (nonatomic) BOOL isLoading; @property (nonatomic) BOOL isLoading;
/** /**
* deeplink handle
*/
@property (strong, nonatomic) NSString *handle;
/**
* deeplink tags * deeplink tags
*/ */
@property (strong, nonatomic) NSArray<NSString *>*ctags; @property (strong, nonatomic) NSArray<NSString *>*ctags;
......
...@@ -45,15 +45,16 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -45,15 +45,16 @@ static NSString *idStr = @"KWMBrandCaramelCell";
[super viewDidLoad]; [super viewDidLoad];
[self initView]; [self initView];
[self reLoadData];
// [self reLoadData];
} }
- (void)initView{ - (void)initView{
self.hasNextPage = NO; self.hasNextPage = NO;
self.collectionSort = BUYCollectionSortCreatedDescending; self.collectionSort = BUYCollectionSortCreatedDescending;
if (self.ctags) { if (self.handle) {
self.title = self.ctags.firstObject.capitalizedString; self.title = self.handle.capitalizedString;
}else if(self.productType != nil){ }else if(self.productType != nil){
//初始化双行标题栏 //初始化双行标题栏
NSString *mTitle; NSString *mTitle;
...@@ -266,8 +267,8 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -266,8 +267,8 @@ static NSString *idStr = @"KWMBrandCaramelCell";
NSLog(@"Error fetching products: %@", error); NSLog(@"Error fetching products: %@", error);
} }
}; };
if (self.ctags) { if (self.handle) {
[self.client getCollectionByHandle:self.ctags.lastObject completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) { [self.client getCollectionByHandle:self.handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
[self.client getProductsPage:tagetPage inCollection:collection.identifier withTags:self.ctags sortOrder:self.filterView.selectedSort completion:completion]; [self.client getProductsPage:tagetPage inCollection:collection.identifier withTags:self.ctags sortOrder:self.filterView.selectedSort completion:completion];
}]; }];
// [self.client getProductsPage:tagetPage inCollection:nil withTags:self.ctags sortOrder:self.filterView.selectedSort completion:completion]; // [self.client getProductsPage:tagetPage inCollection:nil withTags:self.ctags sortOrder:self.filterView.selectedSort completion:completion];
......
...@@ -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];
} }
......
...@@ -86,6 +86,7 @@ static NSString *filterDataString = @"[{\"group\":\"SEASON\",\"tags\":[\"Spring/ ...@@ -86,6 +86,7 @@ static NSString *filterDataString = @"[{\"group\":\"SEASON\",\"tags\":[\"Spring/
} }
-(void)initSortData{ -(void)initSortData{
self.selectedSortPosition = -1;
sortStringData = @[@"新-旧款",@"旧-新款",@"高-低价",@"低-高价"]; sortStringData = @[@"新-旧款",@"旧-新款",@"高-低价",@"低-高价"];
} }
...@@ -100,7 +101,7 @@ static NSString *filterDataString = @"[{\"group\":\"SEASON\",\"tags\":[\"Spring/ ...@@ -100,7 +101,7 @@ static NSString *filterDataString = @"[{\"group\":\"SEASON\",\"tags\":[\"Spring/
case 3: case 3:
return BUYCollectionSortPriceAscending; return BUYCollectionSortPriceAscending;
default: default:
return BUYCollectionSortCreatedDescending; return BUYCollectionSortCollectionDefault;
} }
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
@protocol KWMSearchBarDelegate <NSObject> @protocol KWMSearchBarDelegate <NSObject>
@optional
- (void)kwm_startSearch; - (void)kwm_startSearch;
- (void)kwm_onClickSearch:(NSString *)content; - (void)kwm_onClickSearch:(NSString *)content;
- (void)kwm_onClickShopCar; - (void)kwm_onClickShopCar;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#import "KWMAPIManager.h" #import "KWMAPIManager.h"
#import <MagicalRecord/MagicalRecord.h> #import <MagicalRecord/MagicalRecord.h>
#import "NSDecimalNumber+Currency.h" #import "NSDecimalNumber+Currency.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