Commit c3f046f7 by houweibin

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

# Conflicts:
#	iCemarose/Class/UI/NewHome/KWMNewHomeVC.m
parents 343bf742 a07e140b
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#import "AppDelegate+Deeplink.h" #import "AppDelegate+Deeplink.h"
#import <JLRoutes/JLRoutes.h> #import <JLRoutes/JLRoutes.h>
#import "AppDelegate.h" #import "AppDelegate.h"
#import "KWMProductDetailVC.h" #import "KWMNewProductVC.h"
#import "KWMSelectedGoodsVC.h" #import "KWMSelectedGoodsVC.h"
#import "KWMBlogDetailVC.h" #import "KWMBlogDetailVC.h"
#import "KWMNewProductVC.h" #import "KWMNewProductVC.h"
...@@ -27,13 +27,14 @@ ...@@ -27,13 +27,14 @@
KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"]; KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"];
selectedGoodsVC.handle = parameters[@"handle"]; selectedGoodsVC.handle = parameters[@"handle"];
selectedGoodsVC.ctags = tags; selectedGoodsVC.ctags = tags;
selectedGoodsVC.title = parameters[@"title"];
[[AppDelegate mainViewController].selectedViewController pushViewController:selectedGoodsVC animated:YES]; [[AppDelegate mainViewController].selectedViewController pushViewController:selectedGoodsVC animated:YES];
return YES; return YES;
}]; }];
[routes addRoute:@"/products/:id" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) { [routes addRoute:@"/products/:id" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
NSLog(@"product id %@",parameters[@"id"]); NSLog(@"product id %@",parameters[@"id"]);
KWMNewProductVC *vc = [KWMNewProductVC getNewInstance]; KWMNewProductVC *vc = [KWMNewProductVC getNewInstance];
// KWMProductDetailVC *productDetailVC = (KWMProductDetailVC*)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; // KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
// productDetailVC.product = brandCell.leftProduct; // productDetailVC.product = brandCell.leftProduct;
vc.handle = parameters[@"id"]; vc.handle = parameters[@"id"];
// NSLog(@"%@",[AppDelegate mainViewController].selectedViewController); // NSLog(@"%@",[AppDelegate mainViewController].selectedViewController);
...@@ -43,7 +44,8 @@ ...@@ -43,7 +44,8 @@
[routes addRoute:@"/blogs/:blog/:handle" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) { [routes addRoute:@"/blogs/:blog/:handle" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
KWMBlogDetailVC *blogDetailVC = (KWMBlogDetailVC *)[KWMBlogDetailVC findControllerBy:@"KWMBlogDetailVC" fromStoryboard:@"Home"]; KWMBlogDetailVC *blogDetailVC = (KWMBlogDetailVC *)[KWMBlogDetailVC findControllerBy:@"KWMBlogDetailVC" fromStoryboard:@"Home"];
blogDetailVC.handle = parameters[@"handle"]; blogDetailVC.handle = parameters[@"handle"];
blogDetailVC.type = KWMContentTypeBlog; blogDetailVC.type = KWMContentTypeBlog;;
blogDetailVC.title = parameters[@"title"];
[[AppDelegate mainViewController].selectedViewController pushViewController:blogDetailVC animated:YES]; [[AppDelegate mainViewController].selectedViewController pushViewController:blogDetailVC animated:YES];
return YES; return YES;
}]; }];
...@@ -51,6 +53,7 @@ ...@@ -51,6 +53,7 @@
KWMBlogDetailVC *blogDetailVC = (KWMBlogDetailVC *)[KWMBlogDetailVC findControllerBy:@"KWMBlogDetailVC" fromStoryboard:@"Home"]; KWMBlogDetailVC *blogDetailVC = (KWMBlogDetailVC *)[KWMBlogDetailVC findControllerBy:@"KWMBlogDetailVC" fromStoryboard:@"Home"];
blogDetailVC.handle = parameters[@"handle"]; blogDetailVC.handle = parameters[@"handle"];
blogDetailVC.type = KWMContentTypePage; blogDetailVC.type = KWMContentTypePage;
blogDetailVC.title = parameters[@"title"];
[[AppDelegate mainViewController].selectedViewController pushViewController:blogDetailVC animated:YES]; [[AppDelegate mainViewController].selectedViewController pushViewController:blogDetailVC animated:YES];
return YES; return YES;
}]; }];
......
...@@ -15,8 +15,15 @@ ...@@ -15,8 +15,15 @@
@implementation UIViewController (HTTP) @implementation UIViewController (HTTP)
- (void)openURLWithString:(NSString *)URLString { - (void)openURLWithString:(NSString *)URLString {
UIApplication *application = [UIApplication sharedApplication]; NSString *parten=@"[^%\\da-zA-Z:/.?&=]+";
NSURL *url = [[NSURL alloc] initWithString:[URLString stringByReplacingOccurrencesOfRegex:@"^https?" withString:@"cemarose"]]; NSRegularExpression *reg=[NSRegularExpression regularExpressionWithPattern:parten options:0 error:nil];
NSArray *matchs=[reg matchesInString:URLString options:0 range:NSMakeRange(0, [URLString length])];
NSString *encodeURL=[NSString stringWithString:URLString];
for (long i=matchs.count-1; i>=0; --i) {
NSTextCheckingResult *tcr=matchs[i];
encodeURL=[encodeURL stringByReplacingCharactersInRange:tcr.range withString:[[encodeURL substringWithRange:tcr.range] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
NSURL *url = [[NSURL alloc] initWithString:[encodeURL stringByReplacingOccurrencesOfRegex:@"^https?" withString:@"cemarose"]];
if ([JLRoutes canRouteURL:url]) { if ([JLRoutes canRouteURL:url]) {
[JLRoutes routeURL:url]; [JLRoutes routeURL:url];
// }else if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) { // }else if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#import "KWMBrandCaramelVC.h" #import "KWMBrandCaramelVC.h"
#import "KWMBrandCaramelCell.h" #import "KWMBrandCaramelCell.h"
#import "KWMBarandSelectView.h" #import "KWMBarandSelectView.h"
#import "KWMProductDetailVC.h" #import "KWMNewProductVC.h"
#import "KWMShopCartVC.h" #import "KWMShopCartVC.h"
#import "KWMShopCartData.h" #import "KWMShopCartData.h"
#import "UIImageView+WebCache.h" #import "UIImageView+WebCache.h"
...@@ -232,14 +232,14 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -232,14 +232,14 @@ static NSString *idStr = @"KWMBrandCaramelCell";
//点击左边商品回调 //点击左边商品回调
- (void)kwm_onClickLeftIamge:(KWMBrandCaramelCell *)brandCell{ - (void)kwm_onClickLeftIamge:(KWMBrandCaramelCell *)brandCell{
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC*)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
productDetailVC.product = brandCell.leftProduct; productDetailVC.product = brandCell.leftProduct;
[self.navigationController pushViewController:productDetailVC animated:YES]; [self.navigationController pushViewController:productDetailVC animated:YES];
} }
//点击右边商品回调 //点击右边商品回调
- (void)kwm_onClickRightIamge:(KWMBrandCaramelCell *)brandCell{ - (void)kwm_onClickRightIamge:(KWMBrandCaramelCell *)brandCell{
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC*)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
productDetailVC.product = brandCell.rightProduct; productDetailVC.product = brandCell.rightProduct;
[self.navigationController pushViewController:productDetailVC animated:YES]; [self.navigationController pushViewController:productDetailVC animated:YES];
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// //
#import "KWMCategoryVC.h" #import "KWMCategoryVC.h"
#import "KWMProductDetailVC.h" #import "KWMNewProductVC.h"
#import "KWMShopCartVC.h" #import "KWMShopCartVC.h"
#import "KWMNewProductVC.h" #import "KWMNewProductVC.h"
#import "KWMSearchFeedbackVC.h" #import "KWMSearchFeedbackVC.h"
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view // Do any additional setup after loading the view
self.title = @"正文"; if(!self.title) self.title = @"正文";
self.automaticallyAdjustsScrollViewInsets = NO; self.automaticallyAdjustsScrollViewInsets = NO;
if (!self.handle) { if (!self.handle) {
[self initData]; [self initData];
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#import "KWMOrderVC.h" #import "KWMOrderVC.h"
#import "KWMOrderCell.h" #import "KWMOrderCell.h"
#import "KWMProductDetailVC.h" #import "KWMNewProductVC.h"
#import "KWMImageUtil.h" #import "KWMImageUtil.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
...@@ -141,7 +141,8 @@ ...@@ -141,7 +141,8 @@
} }
- (void)kwm_onClickProduct:(NSNumber *)productId{ - (void)kwm_onClickProduct:(NSNumber *)productId{
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC *)[KWMProductDetailVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; // KWMProductDetailVC *productDetailVC = (KWMProductDetailVC *)[KWMProductDetailVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"];
KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
productDetailVC.productId = productId; productDetailVC.productId = productId;
[self.navigationController pushViewController:productDetailVC animated:YES]; [self.navigationController pushViewController:productDetailVC animated:YES];
} }
......
...@@ -156,7 +156,7 @@ typedef enum{ ...@@ -156,7 +156,7 @@ typedef enum{
#pragma mark - KWMMenuDelegate #pragma mark - KWMMenuDelegate
-(void)kwm_onClickHotMenu{ -(void)kwm_onClickHotMenu{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/new"]; [self openURLWithString:@"https://cemarose.myshopify.com/collections/new?title=最新单品"];
} }
-(void)kwm_onClickNewMenu{ -(void)kwm_onClickNewMenu{
...@@ -175,12 +175,12 @@ typedef enum{ ...@@ -175,12 +175,12 @@ typedef enum{
-(void)kwm_onClickDeliveryMenu{ -(void)kwm_onClickDeliveryMenu{
NSLog(@"deliverymenu"); NSLog(@"deliverymenu");
[self openURLWithString:@"https://www.cemarose.com/pages/service-description/"]; [self openURLWithString:@"https://www.cemarose.com/pages/service-description/?title=服务说明"];
} }
#pragma mark - KWMRecommendDelegate #pragma mark - KWMRecommendDelegate
-(void)kwm_gotoRecommendPage{ -(void)kwm_gotoRecommendPage{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/hot-sell-app"]; [self openURLWithString:@"https://cemarose.myshopify.com/collections/hot-sell-app?title=主推单品"];
} }
-(void)kwm_gotoClothingSetsPage{ -(void)kwm_gotoClothingSetsPage{
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
- (void)kwm_onClickImage:(NSMutableArray *)imageArr currentIndex:(NSInteger)currentIndex; - (void)kwm_onClickImage:(NSMutableArray *)imageArr currentIndex:(NSInteger)currentIndex;
- (void)kwm_onClickSizeBtn; - (void)kwm_onClickSizeBtn;
- (void)kwm_goToBrandVC; - (void)kwm_goToBrandVC;
- (void)kwm_sizeGuide;
@end @end
...@@ -31,6 +32,6 @@ ...@@ -31,6 +32,6 @@
-(void)setData:(BUYProduct *)product; -(void)setData:(BUYProduct *)product;
@property (nonatomic) BOOL sizeGuideHidden;
@end @end
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
@property(nonatomic,weak) IBOutlet KWMPageControl *pageControl; @property(nonatomic,weak) IBOutlet KWMPageControl *pageControl;
@property (weak, nonatomic) IBOutlet UIView *sizeGuideView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *sizeGuideViewHeightConstraint;
@property (nonatomic) BUYProduct *product; @property (nonatomic) BUYProduct *product;
@property (nonatomic) NSMutableArray *imageArr; @property (nonatomic) NSMutableArray *imageArr;
...@@ -254,6 +257,11 @@ ...@@ -254,6 +257,11 @@
} }
} }
- (IBAction)sizeGuideAction:(id)sender {
[self.delegate kwm_sizeGuide];
}
-(void)onClickBlandBtn:(id)sender{ -(void)onClickBlandBtn:(id)sender{
if(self.delegate){ if(self.delegate){
[self.delegate kwm_goToBrandVC]; [self.delegate kwm_goToBrandVC];
...@@ -273,10 +281,9 @@ ...@@ -273,10 +281,9 @@
} }
} }
- (void)setSizeGuideHidden:(BOOL)sizeGuideHidden {
self.sizeGuideView.hidden = sizeGuideHidden;
self.sizeGuideViewHeightConstraint.constant = sizeGuideHidden ? 0 : 50;
}
@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="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>
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
<outlet property="lbPrice" destination="gpT-Sg-ghu" id="FGd-AA-Yiv"/> <outlet property="lbPrice" destination="gpT-Sg-ghu" id="FGd-AA-Yiv"/>
<outlet property="lbVariant" destination="o3P-oH-Xcb" id="i3M-ae-jhH"/> <outlet property="lbVariant" destination="o3P-oH-Xcb" id="i3M-ae-jhH"/>
<outlet property="pageControl" destination="M6v-TN-2WE" id="QPe-TI-LdG"/> <outlet property="pageControl" destination="M6v-TN-2WE" id="QPe-TI-LdG"/>
<outlet property="sizeGuideView" destination="sRa-JA-uEq" id="D94-al-5dF"/>
<outlet property="sizeGuideViewHeightConstraint" destination="CLu-Pt-dGG" id="yih-xF-sL8"/>
<outlet property="vView" destination="iN0-l3-epB" id="TQD-W9-jEg"/> <outlet property="vView" destination="iN0-l3-epB" id="TQD-W9-jEg"/>
</connections> </connections>
</placeholder> </placeholder>
...@@ -246,16 +248,59 @@ ...@@ -246,16 +248,59 @@
<outletCollection property="gestureRecognizers" destination="Bn3-BY-NZm" appends="YES" id="5YW-Qp-ioO"/> <outletCollection property="gestureRecognizers" destination="Bn3-BY-NZm" appends="YES" id="5YW-Qp-ioO"/>
</connections> </connections>
</view> </view>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sRa-JA-uEq" userLabel="Size Guide" customClass="KWMItemView">
<rect key="frame" x="0.0" y="190" width="375" height="0.0"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="尺码参考" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TKI-ds-uBS">
<rect key="frame" x="21" y="-9" width="48" height="17"/>
<fontDescription key="fontDescription" name="PingFangSC-Light" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.1529411765" green="0.14901960780000001" blue="0.21176470589999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uPE-YR-dUl" userLabel="line">
<rect key="frame" x="20" y="-1" width="355" height="1"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.85882352939999995" blue="0.87058823529999996" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="aZ5-j8-htj"/>
</constraints>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="button_mine_more" translatesAutoresizingMaskIntoConstraints="NO" id="thi-C2-XsQ">
<rect key="frame" x="348" y="-7" width="7" height="14"/>
<constraints>
<constraint firstAttribute="width" constant="7" id="0AO-H1-1QW"/>
<constraint firstAttribute="height" constant="14" id="eYQ-zU-dNQ"/>
</constraints>
</imageView>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<constraints> <constraints>
<constraint firstAttribute="height" id="CLu-Pt-dGG"/>
<constraint firstItem="TKI-ds-uBS" firstAttribute="centerY" secondItem="sRa-JA-uEq" secondAttribute="centerY" id="MNr-f8-wK4"/>
<constraint firstItem="uPE-YR-dUl" firstAttribute="leading" secondItem="sRa-JA-uEq" secondAttribute="leading" constant="20" id="OdU-WY-fl8"/>
<constraint firstAttribute="bottom" secondItem="uPE-YR-dUl" secondAttribute="bottom" id="Rs7-5n-j55"/>
<constraint firstItem="TKI-ds-uBS" firstAttribute="leading" secondItem="sRa-JA-uEq" secondAttribute="leading" constant="21" id="fLf-3b-nJK"/>
<constraint firstAttribute="trailing" secondItem="thi-C2-XsQ" secondAttribute="trailing" constant="20" id="imC-XO-I0R"/>
<constraint firstItem="thi-C2-XsQ" firstAttribute="centerY" secondItem="sRa-JA-uEq" secondAttribute="centerY" id="vxn-93-Pge"/>
<constraint firstAttribute="trailing" secondItem="uPE-YR-dUl" secondAttribute="trailing" id="yPN-GE-gtc"/>
</constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="GPA-oO-7UP" appends="YES" id="idl-7c-IV1"/>
</connections>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="sRa-JA-uEq" firstAttribute="top" secondItem="wgu-cH-TXa" secondAttribute="bottom" id="0Tr-TT-0nX"/>
<constraint firstAttribute="trailing" secondItem="wgu-cH-TXa" secondAttribute="trailing" id="1BE-r2-etn"/> <constraint firstAttribute="trailing" secondItem="wgu-cH-TXa" secondAttribute="trailing" id="1BE-r2-etn"/>
<constraint firstItem="wgu-cH-TXa" firstAttribute="top" secondItem="iJa-Oj-Sd2" secondAttribute="bottom" constant="10" id="3E1-qY-lsE"/> <constraint firstItem="wgu-cH-TXa" firstAttribute="top" secondItem="iJa-Oj-Sd2" secondAttribute="bottom" constant="10" id="3E1-qY-lsE"/>
<constraint firstItem="sRa-JA-uEq" firstAttribute="leading" secondItem="Ymw-Cg-156" secondAttribute="leading" id="3dS-8p-JTq"/>
<constraint firstAttribute="bottom" secondItem="sRa-JA-uEq" secondAttribute="bottom" id="8LP-Bk-QII"/>
<constraint firstAttribute="trailing" secondItem="iJa-Oj-Sd2" secondAttribute="trailing" id="8a6-sG-pwj"/> <constraint firstAttribute="trailing" secondItem="iJa-Oj-Sd2" secondAttribute="trailing" id="8a6-sG-pwj"/>
<constraint firstItem="iJa-Oj-Sd2" firstAttribute="top" secondItem="Ymw-Cg-156" secondAttribute="top" id="Vl5-q8-AzT"/> <constraint firstItem="iJa-Oj-Sd2" firstAttribute="top" secondItem="Ymw-Cg-156" secondAttribute="top" id="Vl5-q8-AzT"/>
<constraint firstItem="iJa-Oj-Sd2" firstAttribute="leading" secondItem="Ymw-Cg-156" secondAttribute="leading" id="hhQ-sM-yEW"/> <constraint firstItem="iJa-Oj-Sd2" firstAttribute="leading" secondItem="Ymw-Cg-156" secondAttribute="leading" id="hhQ-sM-yEW"/>
<constraint firstAttribute="trailing" secondItem="sRa-JA-uEq" secondAttribute="trailing" id="jq7-29-LTi"/>
<constraint firstItem="wgu-cH-TXa" firstAttribute="leading" secondItem="Ymw-Cg-156" secondAttribute="leading" id="oIc-Ag-UZg"/> <constraint firstItem="wgu-cH-TXa" firstAttribute="leading" secondItem="Ymw-Cg-156" secondAttribute="leading" id="oIc-Ag-UZg"/>
<constraint firstAttribute="bottom" secondItem="wgu-cH-TXa" secondAttribute="bottom" id="uTa-HP-Rfa"/>
</constraints> </constraints>
</view> </view>
</subviews> </subviews>
...@@ -287,6 +332,11 @@ ...@@ -287,6 +332,11 @@
<action selector="onClickSizeBtn:" destination="-1" id="Xre-Rk-3w3"/> <action selector="onClickSizeBtn:" destination="-1" id="Xre-Rk-3w3"/>
</connections> </connections>
</tapGestureRecognizer> </tapGestureRecognizer>
<tapGestureRecognizer id="GPA-oO-7UP" userLabel="sizeGuide">
<connections>
<action selector="sizeGuideAction:" destination="-1" id="M2I-CX-KdI"/>
</connections>
</tapGestureRecognizer>
</objects> </objects>
<resources> <resources>
<image name="button_mine_more" width="7" height="14"/> <image name="button_mine_more" width="7" height="14"/>
......
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
#import "KWMImageUtil.h" #import "KWMImageUtil.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
#import "KWMShopCartVC.h" #import "KWMShopCartVC.h"
#import <TOWebViewController/TOWebViewController.h>
#import <PPNetworkHelper/PPNetworkHelper.h>
#import <TOWebViewController/NJKWebViewProgress.h>
@interface KWMNewProductVC () @interface KWMNewProductVC ()
...@@ -50,6 +53,8 @@ ...@@ -50,6 +53,8 @@
//选中的数量 //选中的数量
@property (nonatomic) NSInteger count; @property (nonatomic) NSInteger count;
@property (nonatomic) NSString *typeTag;
@property (nonatomic) BOOL isLikeVariant; @property (nonatomic) BOOL isLikeVariant;
...@@ -104,8 +109,12 @@ ...@@ -104,8 +109,12 @@
[self initShopCartCount]; [self initShopCartCount];
[self initMidViewHight]; [self initMidViewHight];
[self.btnLike setImage:[UIImage imageNamed:@"ic_like_unable"] forState:UIControlStateNormal]; [self.btnLike setImage:[UIImage imageNamed:@"ic_like_unable"] forState:UIControlStateNormal];
} }
- (void)initShopCartCount{ - (void)initShopCartCount{
NSNumber *count = [[KWMShoppingCart sharedInstance] count]; NSNumber *count = [[KWMShoppingCart sharedInstance] count];
[self.btnShopCart setTitle:count.stringValue forState:UIControlStateNormal]; [self.btnShopCart setTitle:count.stringValue forState:UIControlStateNormal];
...@@ -301,6 +310,68 @@ ...@@ -301,6 +310,68 @@
[self showPresentation:variantsVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade]; [self showPresentation:variantsVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade];
} }
- (void)kwm_sizeGuide {
NSString *brand = [self.product.vendor stringByReplacingOccurrencesOfRegex:@"\\s*\\W\\s*" withString:@"-"].lowercaseString;
NSString *baseUrl = @"http://www.cemarose.cn/pages/";
NSString *url= [NSString stringWithFormat:@"%@%@-size-guide-%@",baseUrl,brand,self.typeTag];
NSLog(@"size guide url: %@",url);
// TOWebViewController *wv = [[TOWebViewController alloc] initWithURLString:url];
TOWebViewController *wv = [[TOWebViewController alloc] init];
__unused id _ = wv.view;
wv.showPageTitles = NO;
wv.title = @"Size Guide";
wv.navigationButtonsHidden = YES;
// AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//// manager.responseSerializer = [AFXMLParserResponseSerializer serializer];
// manager.responseSerializer = [AFHTTPResponseSerializer serializer];
// manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
// [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//// NJKWebViewProgress *wvp = [vc valueForKeyPath:@"progressManager"];
//// [wvp.progressDelegate webViewProgress:wvp updateProgress:downloadProgress.fractionCompleted];
// } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// NSString *body = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
// body = [body stringByReplacingOccurrencesOfRegex:@"<meta[\\w\\W]*?/?>" withString:@""];
// body = [body stringByReplacingOccurrencesOfRegex:@"<script[\\w\\W]*?</script>" withString:@""];
// body = [body stringByReplacingOccurrencesOfRegex:@"<header[\\w\\W]*?</header>" withString:@""];
// body = [body stringByReplacingOccurrencesOfRegex:@"<footer[\\w\\W]*?</footer>" withString:@""];
// body = [body stringByReplacingOccurrencesOfRegex:@"<head>" withString:@"<head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no\" /><style type='text/css'>"
// @".page-title h1.label{font-size:17px;}"
// @".rte.text-content td{padding-left:10px;}"
// @"</style>"];
// [wv.webView loadHTMLString:body baseURL:[NSURL URLWithString:baseUrl]];
// } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// }];
void(^success)(id) = ^(id body){
if (!body) {
return;
}
body = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];
body = [body stringByReplacingOccurrencesOfRegex:@"<meta[\\w\\W]*?/?>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<script[\\w\\W]*?</script>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<header[\\w\\W]*?</header>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<footer[\\w\\W]*?</footer>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<head>" withString:@"<head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no\" /><style type='text/css'>"
@".page-title h1.label{font-size:17px;}"
@".rte.text-content td{padding-left:10px;}"
@"</style>"];
[wv.webView loadHTMLString:body baseURL:[NSURL URLWithString:baseUrl]];
};
__weak typeof(self) this = self;
[PPNetworkHelper setAFHTTPSessionManagerProperty:^(AFHTTPSessionManager *sessionManager) {
sessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
sessionManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
}];
[PPNetworkHelper GET:url parameters:nil responseCache:success success:success failure:^(NSError *error) {
[this showError:error];
}];
[self.navigationController pushViewController:wv animated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(200 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
NJKWebViewProgress *wvp = [wv valueForKeyPath:@"progressManager"];
[wvp.progressDelegate webViewProgress:wvp updateProgress:0.1];
});
}
-(void)kwm_goToBrandVC{ -(void)kwm_goToBrandVC{
if(self.product && self.product.vendor){ if(self.product && self.product.vendor){
...@@ -585,6 +656,19 @@ ...@@ -585,6 +656,19 @@
- (void)setProduct:(BUYProduct *)product {
_product = product;
NSArray *types = @[@"baby",@"girls",@"boys",@"shoes",@"newborn"];
for (NSString *tag in self.product.tags) {
if ([types containsObject:tag.lowercaseString]) {
self.typeTag = tag.lowercaseString;
break;
}
}
[self.detailView1 setSizeGuideHidden:!self.typeTag];
}
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#import "KWMSelectedGoodsVC.h" #import "KWMSelectedGoodsVC.h"
#import "KWMBrandCaramelVC.h" #import "KWMBrandCaramelVC.h"
#import "UIColor+SAMAdditions.h" #import "UIColor+SAMAdditions.h"
#import "KWMProductDetailVC.h" #import "KWMNewProductVC.h"
#import "KWMShoppingCart.h" #import "KWMShoppingCart.h"
...@@ -281,7 +281,8 @@ static NSString * idStr = @"KWMNewGoodsCell"; ...@@ -281,7 +281,8 @@ static NSString * idStr = @"KWMNewGoodsCell";
if (product == nil) { if (product == nil) {
return; return;
} }
KWMProductDetailVC *goodsDetailvc = (KWMProductDetailVC *)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; // KWMProductDetailVC *goodsDetailvc = (KWMProductDetailVC *)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"];
KWMNewProductVC *goodsDetailvc = [KWMNewProductVC getNewInstance];
goodsDetailvc.product = product; goodsDetailvc.product = product;
[self.navigationController pushViewController:goodsDetailvc animated:YES]; [self.navigationController pushViewController:goodsDetailvc animated:YES];
} }
......
////
//// KWMProductDetailVC.h
//// iCemarose
////
//// Created by HouWeiBin on 2017/1/11.
//// Copyright © 2017年 kollway. All rights reserved.
////
// //
// KWMProductDetailVC.h //#import "KWMBaseVC.h"
// iCemarose
// //
// Created by HouWeiBin on 2017/1/11. //@interface KWMProductDetailVC : KWMBaseVC
// Copyright © 2017年 kollway. All rights reserved.
// //
//@property (nonatomic) BUYProduct *product;
#import "KWMBaseVC.h" //
//@property (nonatomic) NSNumber *productId;
@interface KWMProductDetailVC : KWMBaseVC //
///**
@property (nonatomic) BUYProduct *product; // * SKU 人为定义的SKU
// */
@property (nonatomic) NSNumber *productId; //@property (nonatomic) NSString *handle;
//
/** //@end
* SKU 人为定义的SKU
*/
@property (nonatomic) NSString *handle;
@end
////
//// KWMProductDetailVC.m
//// iCemarose
////
//// Created by HouWeiBin on 2017/1/11.
//// Copyright © 2017年 kollway. All rights reserved.
////
// //
// KWMProductDetailVC.m //#import "KWMNewProductVC.h"
// iCemarose //#import "KWMProductDetailView.h"
// //#import "KWMBottomView.h"
// Created by HouWeiBin on 2017/1/11. //#import "KWMUserModel.h"
// Copyright © 2017年 kollway. All rights reserved. //#import "PhotoBroswerVC.h"
// //#import "KWMStringUtil.h"
//#import "KWMShopCartData.h"
#import "KWMProductDetailVC.h" //#import "KWMInformationVC.h"
#import "KWMProductDetailView.h" //#import "KWMBrandCaramelVC.h"
#import "KWMBottomView.h" //#import "KWMSelectSizeVC.h"
#import "KWMUserModel.h" //#import "KWMShopCartVC.h"
#import "PhotoBroswerVC.h" //#import "KWMBeforePayVC.h"
#import "KWMStringUtil.h" //#import "KWMLoginVC.h"
#import "KWMShopCartData.h" //#import "MZFormSheetPresentationViewController.h"
#import "KWMInformationVC.h" //#import "KWMShareVC.h"
#import "KWMBrandCaramelVC.h" //#import "KWMImageUtil.h"
#import "KWMSelectSizeVC.h" //#import "KWMShoppingCart.h"
#import "KWMShopCartVC.h" //#import <RegexKitLite/RegexKitLite.h>
#import "KWMBeforePayVC.h" //#import <TOWebViewController/TOWebViewController.h>
#import "KWMLoginVC.h" //#import <AFNetworking/AFNetworking.h>
#import "MZFormSheetPresentationViewController.h" //#import <TOWebViewController/NJKWebViewProgress.h>
#import "KWMShareVC.h" //#import <PPNetworkHelper/PPNetworkHelper.h>
#import "KWMImageUtil.h" //
#import "KWMShoppingCart.h" //
#import <RegexKitLite/RegexKitLite.h> //@interface KWMProductDetailVC ()<KWMBottomViewDelegate,KWMProductDetailViewDelegate,KWMSelectSizeVCDelegate,UIScrollViewDelegate>
#import <TOWebViewController/TOWebViewController.h> //
#import <AFNetworking/AFNetworking.h> //@property (weak, nonatomic) IBOutlet UIScrollView *svContent;
#import <TOWebViewController/NJKWebViewProgress.h> //
#import <PPNetworkHelper/PPNetworkHelper.h> //@property (nonatomic) KWMProductDetailView *productDetailView;
//
//@property (nonatomic) KWMBottomView *recommendView;
@interface KWMProductDetailVC ()<KWMBottomViewDelegate,KWMProductDetailViewDelegate,KWMSelectSizeVCDelegate,UIScrollViewDelegate> //
//@property (nonatomic) BUYCollection *collectionSameType;
@property (weak, nonatomic) IBOutlet UIScrollView *svContent; //
//@property (nonatomic) BUYCollection *collectionSameBrand;
@property (nonatomic) KWMProductDetailView *productDetailView; //
//@property (nonatomic) NSString *typeTag;
@property (nonatomic) KWMBottomView *recommendView; //
//@property (weak, nonatomic) IBOutlet UIButton *btnShopCart;
@property (nonatomic) BUYCollection *collectionSameType; //
//@property (weak, nonatomic) IBOutlet UIButton *btnShare;
@property (nonatomic) BUYCollection *collectionSameBrand; //
//- (IBAction)onClickBackBtn:(id)sender;
@property (nonatomic) NSString *typeTag; //
//- (IBAction)onClickShopCartBtn:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *btnShopCart; //
//- (IBAction)onClickShare:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *btnShare; //
//@end
- (IBAction)onClickBackBtn:(id)sender; //
//@implementation KWMProductDetailVC
- (IBAction)onClickShopCartBtn:(id)sender; //
//- (void)viewDidLoad {
- (IBAction)onClickShare:(id)sender; // [super viewDidLoad];
// [self initScrollView];
@end // [self initRecommendProduct];
//// [self initShopCartCount];
@implementation KWMProductDetailVC // //刷新product,如果是缓存的product,因为没有字典,所以会发生错误,需要重新请求一个有字典的product
// if(self.handle || (self.product && self.product.identifier && !self.product.JSONDictionary)){
- (void)viewDidLoad { // [self getProductBy:nil product:self.product];
[super viewDidLoad]; // }
[self initScrollView]; // NSArray *types = @[@"baby",@"girls",@"boys",@"shoes",@"newborn"];
[self initRecommendProduct]; // for (NSString *tag in self.product.tags) {
// if ([types containsObject:tag.lowercaseString]) {
// self.typeTag = tag.lowercaseString;
// break;
// }
// }
// if (!self.typeTag) {
// self.productDetailView.sizeGuide.hidden = YES;
// }
//}
//
//- (BOOL)prefersStatusBarHidden {
// return YES;
//}
//
//- (void)viewWillAppear:(BOOL)animated{
// [super viewWillAppear:animated];
// [self.navigationController setNavigationBarHidden:YES animated:YES];
// [self initShopCartCount]; // [self initShopCartCount];
//刷新product,如果是缓存的product,因为没有字典,所以会发生错误,需要重新请求一个有字典的product //}
if(self.handle || (self.product && self.product.identifier && !self.product.JSONDictionary)){ //
[self getProductBy:nil product:self.product]; //- (void)viewWillDisappear:(BOOL)animated{
} // [super viewWillDisappear:animated];
NSArray *types = @[@"baby",@"girls",@"boys",@"shoes",@"newborn"]; // [self.navigationController setNavigationBarHidden:NO animated:YES];
for (NSString *tag in self.product.tags) { //}
if ([types containsObject:tag.lowercaseString]) { //
self.typeTag = tag.lowercaseString; //- (void)initScrollView{
break; // CGFloat w = UI_SCREEN_WIDTH;
} // CGFloat h = UI_SCREEN_HEITHT-60;
} // for (int i = 0;i < 2;i++){
if (!self.typeTag) { // if(i == 0){
self.productDetailView.sizeGuide.hidden = YES; // self.productDetailView = [[KWMProductDetailView alloc] init];
} // self.productDetailView.frame = CGRectMake(i*w, 0, w, h);
} // self.productDetailView.delegate = self;
// [self.svContent addSubview:self.productDetailView];
- (BOOL)prefersStatusBarHidden { // [self.productDetailView setData:self.product];
return YES; // }else{
} // self.recommendView = [[KWMBottomView alloc] init];
// self.recommendView.frame = CGRectMake(i*w, 0, w, h);
- (void)viewWillAppear:(BOOL)animated{ // self.recommendView.delegate = self;
[super viewWillAppear:animated]; // [self.svContent addSubview:self.recommendView];
[self.navigationController setNavigationBarHidden:YES animated:YES]; // }
[self initShopCartCount]; // }
} // self.svContent.delegate = self;
// self.svContent.contentSize = CGSizeMake(w*2,0);
- (void)viewWillDisappear:(BOOL)animated{ // self.svContent.pagingEnabled = YES;
[super viewWillDisappear:animated]; // if(self.product && self.product.imagesArray && self.product.imagesArray.count>0){
[self.navigationController setNavigationBarHidden:NO animated:YES]; // NSInteger imageCount = self.product.imagesArray.count;
} // [self.recommendView setCount:imageCount];
// }
- (void)initScrollView{ //}
CGFloat w = UI_SCREEN_WIDTH; //
CGFloat h = UI_SCREEN_HEITHT-60; //- (void)kwm_onClickSizeGuide {
for (int i = 0;i < 2;i++){ //
if(i == 0){ // NSString *brand = [self.product.vendor stringByReplacingOccurrencesOfRegex:@"\\s*\\W\\s*" withString:@"-"].lowercaseString;
self.productDetailView = [[KWMProductDetailView alloc] init]; // NSString *baseUrl = @"http://www.cemarose.cn/pages/";
self.productDetailView.frame = CGRectMake(i*w, 0, w, h); // NSString *url= [NSString stringWithFormat:@"%@%@-size-guide-%@",baseUrl,brand,self.typeTag];
self.productDetailView.delegate = self; // NSLog(@"size guide url: %@",url);
[self.svContent addSubview:self.productDetailView]; //// TOWebViewController *wv = [[TOWebViewController alloc] initWithURLString:url];
[self.productDetailView setData:self.product]; // TOWebViewController *wv = [[TOWebViewController alloc] init];
}else{ // __unused id _ = wv.view;
self.recommendView = [[KWMBottomView alloc] init]; // wv.showPageTitles = NO;
self.recommendView.frame = CGRectMake(i*w, 0, w, h); // wv.title = @"Size Guide";
self.recommendView.delegate = self; // wv.navigationButtonsHidden = YES;
[self.svContent addSubview:self.recommendView]; //// AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
} ////// manager.responseSerializer = [AFXMLParserResponseSerializer serializer];
} //// manager.responseSerializer = [AFHTTPResponseSerializer serializer];
self.svContent.delegate = self; //// manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
self.svContent.contentSize = CGSizeMake(w*2,0); //// [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
self.svContent.pagingEnabled = YES; ////// NJKWebViewProgress *wvp = [vc valueForKeyPath:@"progressManager"];
if(self.product && self.product.imagesArray && self.product.imagesArray.count>0){ ////// [wvp.progressDelegate webViewProgress:wvp updateProgress:downloadProgress.fractionCompleted];
NSInteger imageCount = self.product.imagesArray.count; //// } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self.recommendView setCount:imageCount]; //// NSString *body = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
} //// body = [body stringByReplacingOccurrencesOfRegex:@"<meta[\\w\\W]*?/?>" withString:@""];
} //// body = [body stringByReplacingOccurrencesOfRegex:@"<script[\\w\\W]*?</script>" withString:@""];
//// body = [body stringByReplacingOccurrencesOfRegex:@"<header[\\w\\W]*?</header>" withString:@""];
- (void)kwm_onClickSizeGuide { //// body = [body stringByReplacingOccurrencesOfRegex:@"<footer[\\w\\W]*?</footer>" withString:@""];
//// body = [body stringByReplacingOccurrencesOfRegex:@"<head>" withString:@"<head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no\" /><style type='text/css'>"
NSString *brand = [self.product.vendor stringByReplacingOccurrencesOfRegex:@"\\s*\\W\\s*" withString:@"-"].lowercaseString; //// @".page-title h1.label{font-size:17px;}"
NSString *baseUrl = @"http://www.cemarose.cn/pages/"; //// @".rte.text-content td{padding-left:10px;}"
NSString *url= [NSString stringWithFormat:@"%@%@-size-guide-%@",baseUrl,brand,self.typeTag]; //// @"</style>"];
NSLog(@"size guide url: %@",url); //// [wv.webView loadHTMLString:body baseURL:[NSURL URLWithString:baseUrl]];
// TOWebViewController *wv = [[TOWebViewController alloc] initWithURLString:url]; //// } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
TOWebViewController *wv = [[TOWebViewController alloc] init]; //// }];
__unused id _ = wv.view; // void(^success)(id) = ^(id body){
wv.showPageTitles = NO; // if (!body) {
wv.title = @"Size Guide"; // return;
wv.navigationButtonsHidden = YES; // }
// AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; // body = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];
//// manager.responseSerializer = [AFXMLParserResponseSerializer serializer];
// manager.responseSerializer = [AFHTTPResponseSerializer serializer];
// manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
// [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//// NJKWebViewProgress *wvp = [vc valueForKeyPath:@"progressManager"];
//// [wvp.progressDelegate webViewProgress:wvp updateProgress:downloadProgress.fractionCompleted];
// } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// NSString *body = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
// body = [body stringByReplacingOccurrencesOfRegex:@"<meta[\\w\\W]*?/?>" withString:@""]; // body = [body stringByReplacingOccurrencesOfRegex:@"<meta[\\w\\W]*?/?>" withString:@""];
// body = [body stringByReplacingOccurrencesOfRegex:@"<script[\\w\\W]*?</script>" withString:@""]; // body = [body stringByReplacingOccurrencesOfRegex:@"<script[\\w\\W]*?</script>" withString:@""];
// body = [body stringByReplacingOccurrencesOfRegex:@"<header[\\w\\W]*?</header>" withString:@""]; // body = [body stringByReplacingOccurrencesOfRegex:@"<header[\\w\\W]*?</header>" withString:@""];
...@@ -150,319 +166,303 @@ ...@@ -150,319 +166,303 @@
// @".rte.text-content td{padding-left:10px;}" // @".rte.text-content td{padding-left:10px;}"
// @"</style>"]; // @"</style>"];
// [wv.webView loadHTMLString:body baseURL:[NSURL URLWithString:baseUrl]]; // [wv.webView loadHTMLString:body baseURL:[NSURL URLWithString:baseUrl]];
// } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { //
// };
//
// __weak typeof(self) this = self;
// [PPNetworkHelper setAFHTTPSessionManagerProperty:^(AFHTTPSessionManager *sessionManager) {
// sessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
// sessionManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
// }];
// [PPNetworkHelper GET:url parameters:nil responseCache:success success:success failure:^(NSError *error) {
// [this showError:error];
// }];
// [self.navigationController pushViewController:wv animated:YES];
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(200 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
// NJKWebViewProgress *wvp = [wv valueForKeyPath:@"progressManager"];
// [wvp.progressDelegate webViewProgress:wvp updateProgress:0.1];
// });
//
//
//}
//
//-(void)onClickBackBtn:(id)sender{
// [self.navigationController popViewControllerAnimated:YES];
//}
//
//-(void)onClickShopCartBtn:(id)sender{
// KWMShopCartVC *shopCartVC = (KWMShopCartVC *)[KWMBaseVC findControllerBy:[KWMShopCartVC kwmTag] fromStoryboard:@"ShopCart"];
// [self.navigationController pushViewController:shopCartVC animated:YES];
//}
//
//-(void)onClickShare:(id)sender{
// if(!self.product){
// return;
// }
// KWMShareVC *shareVC = (KWMShareVC *)[KWMBaseVC findControllerBy:[KWMShareVC kwmTag] fromStoryboard:@"New"];
// CGSize size = [UIScreen mainScreen].bounds.size;
// [self showPresentation:shareVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade];
// shareVC.shareUrl = [NSString stringWithFormat:@"https://www.cemarose.com/products/%@",self.product.handle];
// shareVC.imageUrl = [KWMImageUtil getProductImageUrl:self.product ImageSize:SmallImage];
// shareVC.productName = self.product.title;
//}
//
//- (void)initShopCartCount{
// NSNumber *count = [[KWMShoppingCart sharedInstance] count];
// [self.btnShopCart setTitle:count.stringValue forState:UIControlStateNormal];
//}
//
//- (void)setProductId:(NSNumber *)productId{
// _productId = productId;
// [self getProductBy:self.productId product:nil];
//}
//
////KWMProductDetailViewDelegate
//-(void)kwm_onClickImage:(NSMutableArray *)imageArr currentIndex:(NSInteger)currentIndex{
// //避免循环引用
// __weak KWMProductDetailVC *weakSelf=self;
// NSArray<NSString *> *imags = imageArr;
// [PhotoBroswerVC show:self type:PhotoBroswerVCTypePush index:currentIndex isShowSaveBtn:YES photoModelBlock:^NSArray *{
// NSArray *localImages = imags;
// NSMutableArray *modelsM = [NSMutableArray arrayWithCapacity:localImages.count];
// for (NSUInteger i = 0; i< localImages.count; i++) {
// PhotoModel *pbModel=[[PhotoModel alloc] init];
// pbModel.mid = i + 1;
// //源frame
// UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, weakSelf.view.frame.size.width, weakSelf.view.frame.size.height)];
// pbModel.sourceImageView = imageV;
// pbModel.image_HD_U = [[KWMAPIManager sharedManager] toAbsoluteUrl:localImages[i]];
// [modelsM addObject:pbModel];
// }
// return modelsM;
// }]; // }];
void(^success)(id) = ^(id body){
if (!body) {
return;
}
body = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];
body = [body stringByReplacingOccurrencesOfRegex:@"<meta[\\w\\W]*?/?>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<script[\\w\\W]*?</script>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<header[\\w\\W]*?</header>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<footer[\\w\\W]*?</footer>" withString:@""];
body = [body stringByReplacingOccurrencesOfRegex:@"<head>" withString:@"<head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no\" /><style type='text/css'>"
@".page-title h1.label{font-size:17px;}"
@".rte.text-content td{padding-left:10px;}"
@"</style>"];
[wv.webView loadHTMLString:body baseURL:[NSURL URLWithString:baseUrl]];
};
__weak typeof(self) this = self;
[PPNetworkHelper setAFHTTPSessionManagerProperty:^(AFHTTPSessionManager *sessionManager) {
sessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
sessionManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
}];
[PPNetworkHelper GET:url parameters:nil responseCache:success success:success failure:^(NSError *error) {
[this showError:error];
}];
[self.navigationController pushViewController:wv animated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(200 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
NJKWebViewProgress *wvp = [wv valueForKeyPath:@"progressManager"];
[wvp.progressDelegate webViewProgress:wvp updateProgress:0.1];
});
}
-(void)onClickBackBtn:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
}
-(void)onClickShopCartBtn:(id)sender{
KWMShopCartVC *shopCartVC = (KWMShopCartVC *)[KWMBaseVC findControllerBy:[KWMShopCartVC kwmTag] fromStoryboard:@"ShopCart"];
[self.navigationController pushViewController:shopCartVC animated:YES];
}
-(void)onClickShare:(id)sender{
if(!self.product){
return;
}
KWMShareVC *shareVC = (KWMShareVC *)[KWMBaseVC findControllerBy:[KWMShareVC kwmTag] fromStoryboard:@"New"];
CGSize size = [UIScreen mainScreen].bounds.size;
[self showPresentation:shareVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade];
shareVC.shareUrl = [NSString stringWithFormat:@"https://www.cemarose.com/products/%@",self.product.handle];
shareVC.imageUrl = [KWMImageUtil getProductImageUrl:self.product ImageSize:SmallImage];
shareVC.productName = self.product.title;
}
- (void)initShopCartCount{
NSNumber *count = [[KWMShoppingCart sharedInstance] count];
[self.btnShopCart setTitle:count.stringValue forState:UIControlStateNormal];
}
- (void)setProductId:(NSNumber *)productId{
_productId = productId;
[self getProductBy:self.productId product:nil];
}
//KWMProductDetailViewDelegate
-(void)kwm_onClickImage:(NSMutableArray *)imageArr currentIndex:(NSInteger)currentIndex{
//避免循环引用
__weak KWMProductDetailVC *weakSelf=self;
NSArray<NSString *> *imags = imageArr;
[PhotoBroswerVC show:self type:PhotoBroswerVCTypePush index:currentIndex isShowSaveBtn:YES photoModelBlock:^NSArray *{
NSArray *localImages = imags;
NSMutableArray *modelsM = [NSMutableArray arrayWithCapacity:localImages.count];
for (NSUInteger i = 0; i< localImages.count; i++) {
PhotoModel *pbModel=[[PhotoModel alloc] init];
pbModel.mid = i + 1;
//源frame
UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, weakSelf.view.frame.size.width, weakSelf.view.frame.size.height)];
pbModel.sourceImageView = imageV;
pbModel.image_HD_U = [[KWMAPIManager sharedManager] toAbsoluteUrl:localImages[i]];
[modelsM addObject:pbModel];
}
return modelsM;
}];
}
-(void)kwm_onClickInformation{
KWMInformationVC *informationVC = (KWMInformationVC *)[KWMBaseVC findControllerBy:[KWMInformationVC kwmTag] fromStoryboard:@"Main"];
informationVC.inforStr = NSLocalizedString(@"getAndReturnGoods",@"getAndReturnGoods");
informationVC.inforTitleStr = NSLocalizedString(@"getAndReturnGoodsTitle",@"getAndReturnGoodsTitle");
informationVC.titleStr = @"发货与退货";
[self.navigationController pushViewController:informationVC animated:YES];
}
-(void)kwm_onClickSizeBtn{
KWMSelectSizeVC *editVC = (KWMSelectSizeVC *)[KWMBaseVC findControllerBy:[KWMSelectSizeVC kwmTag] fromStoryboard:@"ShopCart"];
editVC.delegate = self;
editVC.product = self.product;
// NSDictionary *shopCartDict = self.product.JSONDictionary;
editVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
editVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
editVC.providesPresentationContextTransitionStyle = YES;
editVC.definesPresentationContext = YES;
[self presentViewController:editVC animated:YES completion:nil];
}
-(void)kwm_goToBrandVC{
if(self.product && self.product.vendor){
KWMBrandCaramelVC *brandCaramelVC = (KWMBrandCaramelVC *)[KWMBrandCaramelVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"];
NSString *brand = self.product.vendor;
brandCaramelVC.brand = brand;
brandCaramelVC.handle = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand];
brandCaramelVC.isSale = NO;
[self.navigationController pushViewController:brandCaramelVC animated:YES];
}
}
//KWMBottomViewDelegate
-(void)kwm_loadNewPage:(BOOL)isSameBrand{
if(isSameBrand && self.collectionSameBrand!=nil){
[self requestProducts:self.collectionSameBrand.identifier isSameBrand:isSameBrand];
}else if(self.collectionSameType!=nil){
[self requestProducts:self.collectionSameType.identifier isSameBrand:isSameBrand];
}
}
-(void)kwm_clickCollectionCell:(BUYProduct *)product{
if(product == nil){
return;
}
self.product = product;
[self.productDetailView setData:product];
[self.svContent setContentOffset:CGPointMake(0, 0) animated:YES];
if(self.product && self.product.imagesArray && self.product.imagesArray.count>0){
NSInteger imageCount = self.product.imagesArray.count;
[self.recommendView setCount:imageCount];
}
[self initRecommendProduct];
}
#pragma mark - KWMSelectSizeVCDelegate
- (void)kwm_addShopWithVariantId:(NSNumber *)identifier quantity:(NSInteger)quantity variant:(BUYProductVariant *) variant buyNow:(BOOL)buyNow callback:(void (^)(BOOL))callback {
__weak KWMProductDetailVC *this = self;
if (!buyNow) {
[[KWMShoppingCart sharedInstance] increaseProductWithVariantId:identifier quantity:quantity callback:^(NSError *error, KWMCartResult *cart) {
if (cart.items.firstObject && !cart.items.firstObject.product_id) {
KWMShopCartModel *model = cart.items.firstObject;
BUYImageLink *il = this.product.images.firstObject;
// model.imageStr = [KWMImageUtil getProductImageUrl:this.product.identifier ImageSize:NormalImage];
model.imageStr = [KWMImageUtil getProductImageUrlByOriginalUrl:il.sourceURL.absoluteString ImageSize:NormalImage];
model.name = this.product.title;
model.brand = this.product.vendor;
model.size = variant.title;
// model.price = variant.price.floatValue;
model.price = variant.price;
model.product_id = this.product.identifier;
}
if (!error) {
[this showToast:@"添加成功"];
[this.btnShopCart setTitle:cart.item_count.stringValue forState:UIControlStateNormal];
callback(YES);
}else{
[this showError:error];
callback(NO);
}
}];
return;
}
callback(YES);
KWMUserModel *useModel = [KWMUserModel shareUser];
if (!useModel.status) {
//登录
KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc];
[self presentViewController:nav animated:YES completion:nil];
return;
}
[self showLoading];
[self.api tmpCartWithVariantId:identifier quantity:quantity success:^(NSURLSessionDataTask *task, NSString *cartCookie) {
[this hideLoading];
KWMBeforePayVC *beforePayVC = (KWMBeforePayVC *)[KWMBaseVC findControllerBy:[KWMBeforePayVC kwmTag] fromStoryboard:@"ShopCart"];
beforePayVC.cartCookie = cartCookie;
[this.navigationController pushViewController:beforePayVC animated:YES];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
[this showError:error];
}];
}
////KWMSelectSizeVCDelegate
//-(void)kwm_addShopCartItem:(KWMShopCartModel *)shopCartModel{
// [self initShopCartCount];
//} //}
// //
//-(void)kwm_fastBuy:(BUYCart *)fastBuyCart{ //-(void)kwm_onClickInformation{
// if(fastBuyCart == nil){ // KWMInformationVC *informationVC = (KWMInformationVC *)[KWMBaseVC findControllerBy:[KWMInformationVC kwmTag] fromStoryboard:@"Main"];
// informationVC.inforStr = NSLocalizedString(@"getAndReturnGoods",@"getAndReturnGoods");
// informationVC.inforTitleStr = NSLocalizedString(@"getAndReturnGoodsTitle",@"getAndReturnGoodsTitle");
// informationVC.titleStr = @"发货与退货";
// [self.navigationController pushViewController:informationVC animated:YES];
//}
//
//-(void)kwm_onClickSizeBtn{
// KWMSelectSizeVC *editVC = (KWMSelectSizeVC *)[KWMBaseVC findControllerBy:[KWMSelectSizeVC kwmTag] fromStoryboard:@"ShopCart"];
// editVC.delegate = self;
// editVC.product = self.product;
//
//// NSDictionary *shopCartDict = self.product.JSONDictionary;
// editVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
// editVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
// editVC.providesPresentationContextTransitionStyle = YES;
// editVC.definesPresentationContext = YES;
// [self presentViewController:editVC animated:YES completion:nil];
//}
//
//-(void)kwm_goToBrandVC{
// if(self.product && self.product.vendor){
// KWMBrandCaramelVC *brandCaramelVC = (KWMBrandCaramelVC *)[KWMBrandCaramelVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"];
// NSString *brand = self.product.vendor;
// brandCaramelVC.brand = brand;
// brandCaramelVC.handle = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand];
// brandCaramelVC.isSale = NO;
// [self.navigationController pushViewController:brandCaramelVC animated:YES];
// }
//}
//
////KWMBottomViewDelegate
//-(void)kwm_loadNewPage:(BOOL)isSameBrand{
// if(isSameBrand && self.collectionSameBrand!=nil){
// [self requestProducts:self.collectionSameBrand.identifier isSameBrand:isSameBrand];
// }else if(self.collectionSameType!=nil){
// [self requestProducts:self.collectionSameType.identifier isSameBrand:isSameBrand];
// }
//}
//
//-(void)kwm_clickCollectionCell:(BUYProduct *)product{
// if(product == nil){
// return; // return;
// } // }
// self.product = product;
// [self.productDetailView setData:product];
// [self.svContent setContentOffset:CGPointMake(0, 0) animated:YES];
// if(self.product && self.product.imagesArray && self.product.imagesArray.count>0){
// NSInteger imageCount = self.product.imagesArray.count;
// [self.recommendView setCount:imageCount];
// }
// [self initRecommendProduct];
//}
//
//#pragma mark - KWMSelectSizeVCDelegate
//
//- (void)kwm_addShopWithVariantId:(NSNumber *)identifier quantity:(NSInteger)quantity variant:(BUYProductVariant *) variant buyNow:(BOOL)buyNow callback:(void (^)(BOOL))callback {
// __weak KWMProductDetailVC *this = self;
// if (!buyNow) {
// [[KWMShoppingCart sharedInstance] increaseProductWithVariantId:identifier quantity:quantity callback:^(NSError *error, KWMCartResult *cart) {
// if (cart.items.firstObject && !cart.items.firstObject.product_id) {
// KWMShopCartModel *model = cart.items.firstObject;
// BUYImageLink *il = this.product.images.firstObject;
//// model.imageStr = [KWMImageUtil getProductImageUrl:this.product.identifier ImageSize:NormalImage];
// model.imageStr = [KWMImageUtil getProductImageUrlByOriginalUrl:il.sourceURL.absoluteString ImageSize:NormalImage];
// model.name = this.product.title;
// model.brand = this.product.vendor;
// model.size = variant.title;
//// model.price = variant.price.floatValue;
// model.price = variant.price;
// model.product_id = this.product.identifier;
// }
// if (!error) {
// [this showToast:@"添加成功"];
// [this.btnShopCart setTitle:cart.item_count.stringValue forState:UIControlStateNormal];
// callback(YES);
// }else{
// [this showError:error];
// callback(NO);
// }
// }];
// return;
// }
// callback(YES);
// KWMUserModel *useModel = [KWMUserModel shareUser]; // KWMUserModel *useModel = [KWMUserModel shareUser];
// if (useModel.status) { // if (!useModel.status) {
// KWMBeforePayVC *beforePayVC = (KWMBeforePayVC *)[KWMBaseVC findControllerBy:[KWMBeforePayVC kwmTag] fromStoryboard:@"ShopCart"]; // //登录
// beforePayVC.fastPayCart = fastBuyCart;
// [self.navigationController pushViewController:beforePayVC animated:YES];}
// //用户未登录
// else{
// KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"]; // KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"];
// UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc]; // UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc];
// [self presentViewController:nav animated:YES completion:nil]; // [self presentViewController:nav animated:YES completion:nil];
// return;
// }
// [self showLoading];
// [self.api tmpCartWithVariantId:identifier quantity:quantity success:^(NSURLSessionDataTask *task, NSString *cartCookie) {
// [this hideLoading];
// KWMBeforePayVC *beforePayVC = (KWMBeforePayVC *)[KWMBaseVC findControllerBy:[KWMBeforePayVC kwmTag] fromStoryboard:@"ShopCart"];
// beforePayVC.cartCookie = cartCookie;
// [this.navigationController pushViewController:beforePayVC animated:YES];
// } failure:^(NSURLSessionDataTask *task, NSError *error) {
// [this showError:error];
// }];
//
//}
//
//////KWMSelectSizeVCDelegate
////-(void)kwm_addShopCartItem:(KWMShopCartModel *)shopCartModel{
//// [self initShopCartCount];
////}
////
////-(void)kwm_fastBuy:(BUYCart *)fastBuyCart{
//// if(fastBuyCart == nil){
//// return;
//// }
//// KWMUserModel *useModel = [KWMUserModel shareUser];
//// if (useModel.status) {
//// KWMBeforePayVC *beforePayVC = (KWMBeforePayVC *)[KWMBaseVC findControllerBy:[KWMBeforePayVC kwmTag] fromStoryboard:@"ShopCart"];
//// beforePayVC.fastPayCart = fastBuyCart;
//// [self.navigationController pushViewController:beforePayVC animated:YES];}
//// //用户未登录
//// else{
//// KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"];
//// UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc];
//// [self presentViewController:nav animated:YES completion:nil];
//// }
////}
//
//#pragma mark - KWMSelectSizeVCDelegate End
//
//-(void)initRecommendProduct{
// if(self.product == nil){
// return;
// }
// [self.recommendView clear];
// [self.recommendView setBrandString:self.product.vendor];
// NSString *handle = [KWMStringUtil deleteOtherCharExceptLetterWithLine:self.product.vendor];
// //该商品的品牌不为nil
// if(self.product.vendor){
// [self requestCollection:handle isSameBrand:YES];
// }
// //该商品的类型不为nil
// if(self.product.productType){
// [self requestCollection:self.product.productType isSameBrand:NO];
// } // }
//} //}
//
#pragma mark - KWMSelectSizeVCDelegate End ////获取相同类型商品collection/相同品牌商品collection
//-(void)requestCollection:(NSString *)handle isSameBrand:(BOOL)isSameBrand{
-(void)initRecommendProduct{ // __weak KWMProductDetailVC *weakSelf = self;
if(self.product == nil){ // [self.client getCollectionByHandle:handle completion:^(BUYCollection *collection, NSError *error) {
return; // if(!error && collection!=nil){
} // if(isSameBrand){
[self.recommendView clear]; // [weakSelf hideLoading];
[self.recommendView setBrandString:self.product.vendor]; // weakSelf.collectionSameBrand = collection;
NSString *handle = [KWMStringUtil deleteOtherCharExceptLetterWithLine:self.product.vendor]; // }else{
//该商品的品牌不为nil // weakSelf.collectionSameType = collection;
if(self.product.vendor){ // }
[self requestCollection:handle isSameBrand:YES]; // [self requestProducts:collection.identifier isSameBrand:isSameBrand];
} // }else if(error != nil){
//该商品的类型不为nil // [self showError:error];
if(self.product.productType){ // }
[self requestCollection:self.product.productType isSameBrand:NO]; // }];
} //}
} //
////获取某个商品集合,并将其设置到猜你喜欢view中
//获取相同类型商品collection/相同品牌商品collection //-(void)requestProducts:(NSNumber *)collectionId isSameBrand:(BOOL)isSameBrand{
-(void)requestCollection:(NSString *)handle isSameBrand:(BOOL)isSameBrand{ // __weak KWMProductDetailVC *weakSelf = self;
__weak KWMProductDetailVC *weakSelf = self; // NSInteger targetPage;
[self.client getCollectionByHandle:handle completion:^(BUYCollection *collection, NSError *error) { // if(isSameBrand){
if(!error && collection!=nil){ // if(self.recommendView.isLoadingSameBrand){
if(isSameBrand){ // return;
[weakSelf hideLoading]; // }
weakSelf.collectionSameBrand = collection; // targetPage = self.recommendView.pageSameBrand + 1;
}else{ // self.recommendView.isLoadingSameBrand = YES;
weakSelf.collectionSameType = collection; // }else{
} // if(self.recommendView.isLoadingSameType){
[self requestProducts:collection.identifier isSameBrand:isSameBrand]; // return;
}else if(error != nil){ // }
[self showError:error]; // targetPage = self.recommendView.pageSameType + 1;
} // self.recommendView.isLoadingSameType = YES;
}]; // }
} //
// [self.client getProductsPage:targetPage inCollection:collectionId withTags:nil sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {
//获取某个商品集合,并将其设置到猜你喜欢view中 // if(isSameBrand){
-(void)requestProducts:(NSNumber *)collectionId isSameBrand:(BOOL)isSameBrand{ // self.recommendView.isLoadingSameBrand = NO;
__weak KWMProductDetailVC *weakSelf = self; // }else{
NSInteger targetPage; // self.recommendView.isLoadingSameType = NO;
if(isSameBrand){ // }
if(self.recommendView.isLoadingSameBrand){ // if(!error && products!=nil){
return; // if(isSameBrand){
} // weakSelf.recommendView.pageSameBrand += 1;
targetPage = self.recommendView.pageSameBrand + 1; // }else{
self.recommendView.isLoadingSameBrand = YES; // weakSelf.recommendView.pageSameType += 1;
}else{ // }
if(self.recommendView.isLoadingSameType){ // [weakSelf.recommendView setData:products isSameBrand:isSameBrand];
return; // }else if(error != nil){
} // [self showError:error];
targetPage = self.recommendView.pageSameType + 1; // }
self.recommendView.isLoadingSameType = YES; // }];
} //}
//
[self.client getProductsPage:targetPage inCollection:collectionId withTags:nil sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) { ////查找商品API
if(isSameBrand){ //- (void)getProductBy:(NSNumber *)productId product:(BUYProduct *)product{
self.recommendView.isLoadingSameBrand = NO; // if(productId == nil && product == nil && !self.handle){
}else{ // return;
self.recommendView.isLoadingSameType = NO; // }
} // [self showLoading];
if(!error && products!=nil){ // void(^completion)(BUYProduct *, NSError *) = ^(BUYProduct * _Nullable product, NSError * _Nullable error) {
if(isSameBrand){ // [self hideLoading];
weakSelf.recommendView.pageSameBrand += 1; // if (product != nil && error == nil) {
}else{ // self.product = product;
weakSelf.recommendView.pageSameType += 1; // [self.productDetailView setData:product];
} // if(productId){
[weakSelf.recommendView setData:products isSameBrand:isSameBrand]; // [self kwm_clickCollectionCell:product];
}else if(error != nil){ // }
[self showError:error]; // }else{
} // self.product = nil;
}]; // [self showError:error];
} // }
// };
//查找商品API // if (self.handle) {
- (void)getProductBy:(NSNumber *)productId product:(BUYProduct *)product{ // [self.client getProductByHandle:self.handle completion:completion];
if(productId == nil && product == nil && !self.handle){ // }else{
return; // [self.client getProductById:productId?productId:product.identifier completion:completion];
} // }
[self showLoading]; //}
void(^completion)(BUYProduct *, NSError *) = ^(BUYProduct * _Nullable product, NSError * _Nullable error) { //
[self hideLoading]; //@end
if (product != nil && error == nil) {
self.product = product;
[self.productDetailView setData:product];
if(productId){
[self kwm_clickCollectionCell:product];
}
}else{
self.product = nil;
[self showError:error];
}
};
if (self.handle) {
[self.client getProductByHandle:self.handle completion:completion];
}else{
[self.client getProductById:productId?productId:product.identifier completion:completion];
}
}
@end
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#import "KWMSearchFeedbackVC.h" #import "KWMSearchFeedbackVC.h"
#import "KWMBrandCaramelCell.h" #import "KWMBrandCaramelCell.h"
#import "KWMSearchFeedBackView.h" #import "KWMSearchFeedBackView.h"
#import "KWMProductDetailVC.h" #import "KWMNewProductVC.h"
@interface KWMSearchFeedbackVC ()<UITableViewDelegate,UITableViewDataSource,KWMSearchFeedBackViewDelegate,KWMBrandCaramelCellDelegate> @interface KWMSearchFeedbackVC ()<UITableViewDelegate,UITableViewDataSource,KWMSearchFeedBackViewDelegate,KWMBrandCaramelCellDelegate>
@property (nonatomic) KWMSearchFeedBackView *vSearchFB; @property (nonatomic) KWMSearchFeedBackView *vSearchFB;
...@@ -90,14 +90,14 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -90,14 +90,14 @@ static NSString *idStr = @"KWMBrandCaramelCell";
#pragma mark -- KWMBrandCaramelCellDelegate #pragma mark -- KWMBrandCaramelCellDelegate
//点击左边商品回调 //点击左边商品回调
- (void)kwm_onClickLeftIamge:(KWMBrandCaramelCell *)brandCell{ - (void)kwm_onClickLeftIamge:(KWMBrandCaramelCell *)brandCell{
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC*)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
productDetailVC.productId = brandCell.leftDataProduct.id; productDetailVC.productId = brandCell.leftDataProduct.id;
[self.navigationController pushViewController:productDetailVC animated:YES]; [self.navigationController pushViewController:productDetailVC animated:YES];
} }
//点击右边商品回调 //点击右边商品回调
- (void)kwm_onClickRightIamge:(KWMBrandCaramelCell *)brandCell{ - (void)kwm_onClickRightIamge:(KWMBrandCaramelCell *)brandCell{
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC*)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
productDetailVC.productId = brandCell.rightDataProduct.id; productDetailVC.productId = brandCell.rightDataProduct.id;
[self.navigationController pushViewController:productDetailVC animated:YES]; [self.navigationController pushViewController:productDetailVC animated:YES];
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// //
#import "KWMSelectedGoodsVC.h" #import "KWMSelectedGoodsVC.h"
#import "KWMProductDetailVC.h" #import "KWMNewProductVC.h"
#import "KWMBeforePayVC.h" #import "KWMBeforePayVC.h"
#import "KWMMineTitleView.h" #import "KWMMineTitleView.h"
#import "MJRefresh.h" #import "MJRefresh.h"
...@@ -53,7 +53,7 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -53,7 +53,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
self.hasNextPage = NO; self.hasNextPage = NO;
self.collectionSort = BUYCollectionSortCreatedDescending; self.collectionSort = BUYCollectionSortCreatedDescending;
if (self.handle) { if (self.handle && !self.title) {
self.title = self.handle.capitalizedString; self.title = self.handle.capitalizedString;
}else if(self.productType != nil){ }else if(self.productType != nil){
//初始化双行标题栏 //初始化双行标题栏
...@@ -168,14 +168,14 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -168,14 +168,14 @@ static NSString *idStr = @"KWMBrandCaramelCell";
//点击左边商品回调 //点击左边商品回调
- (void)kwm_onClickLeftIamge:(KWMBrandCaramelCell *)brandCell{ - (void)kwm_onClickLeftIamge:(KWMBrandCaramelCell *)brandCell{
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC*)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
productDetailVC.product = brandCell.leftProduct; productDetailVC.product = brandCell.leftProduct;
[self.navigationController pushViewController:productDetailVC animated:YES]; [self.navigationController pushViewController:productDetailVC animated:YES];
} }
//点击右边商品回调 //点击右边商品回调
- (void)kwm_onClickRightIamge:(KWMBrandCaramelCell *)brandCell{ - (void)kwm_onClickRightIamge:(KWMBrandCaramelCell *)brandCell{
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC*)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"]; KWMNewProductVC *productDetailVC = [KWMNewProductVC getNewInstance];
productDetailVC.product = brandCell.rightProduct; productDetailVC.product = brandCell.rightProduct;
[self.navigationController pushViewController:productDetailVC animated:YES]; [self.navigationController pushViewController:productDetailVC animated:YES];
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#import "NSDecimalNumber+Currency.h" #import "NSDecimalNumber+Currency.h"
#import "UIViewController+HTTP.h" #import "UIViewController+HTTP.h"
#import <RXCollections/RXCollection.h> #import <RXCollections/RXCollection.h>
#import <RegexKitLite/RegexKitLite.h>
#ifndef Header_Prefix_h #ifndef Header_Prefix_h
#define Header_Prefix_h #define Header_Prefix_h
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.4.0</string> <string>1.5.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
......
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