Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ios1x
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
ios1x
Commits
81145eba
Commit
81145eba
authored
Jul 14, 2017
by
lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
u
parent
4ae110f7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
477 additions
and
472 deletions
+477
-472
AppDelegate+Deeplink.m
iCemarose/Class/AppDelegate+Deeplink.m
+4
-1
KWMOrderVC.m
iCemarose/Class/UI/Mine/KWMOrderVC.m
+3
-2
KWMNewHomeVC.m
iCemarose/Class/UI/NewHome/KWMNewHomeVC.m
+1
-1
KWMNewVC.m
iCemarose/Class/UI/Product/KWMNewVC.m
+3
-2
KWMProductDetailVC.h
iCemarose/Class/UI/Product/KWMProductDetailVC.h
+19
-19
KWMProductDetailVC.m
iCemarose/Class/UI/Product/KWMProductDetailVC.m
+446
-446
KWMSelectedGoodsVC.m
iCemarose/Class/UI/Product/KWMSelectedGoodsVC.m
+1
-1
No files found.
iCemarose/Class/AppDelegate+Deeplink.m
View file @
81145eba
...
...
@@ -27,6 +27,7 @@
KWMSelectedGoodsVC
*
selectedGoodsVC
=
(
KWMSelectedGoodsVC
*
)[
KWMBaseVC
findControllerBy
:[
KWMSelectedGoodsVC
kwmTag
]
fromStoryboard
:
@"New"
];
selectedGoodsVC
.
handle
=
parameters
[
@"handle"
];
selectedGoodsVC
.
ctags
=
tags
;
selectedGoodsVC
.
title
=
parameters
[
@"title"
];
[[
AppDelegate
mainViewController
].
selectedViewController
pushViewController
:
selectedGoodsVC
animated
:
YES
];
return
YES
;
}];
...
...
@@ -43,7 +44,8 @@
[
routes
addRoute
:
@"/blogs/:blog/:handle"
handler
:
^
BOOL
(
NSDictionary
<
NSString
*
,
id
>
*
_Nonnull
parameters
)
{
KWMBlogDetailVC
*
blogDetailVC
=
(
KWMBlogDetailVC
*
)[
KWMBlogDetailVC
findControllerBy
:
@"KWMBlogDetailVC"
fromStoryboard
:
@"Home"
];
blogDetailVC
.
handle
=
parameters
[
@"handle"
];
blogDetailVC
.
type
=
KWMContentTypeBlog
;
blogDetailVC
.
type
=
KWMContentTypeBlog
;;
blogDetailVC
.
title
=
parameters
[
@"title"
];
[[
AppDelegate
mainViewController
].
selectedViewController
pushViewController
:
blogDetailVC
animated
:
YES
];
return
YES
;
}];
...
...
@@ -51,6 +53,7 @@
KWMBlogDetailVC
*
blogDetailVC
=
(
KWMBlogDetailVC
*
)[
KWMBlogDetailVC
findControllerBy
:
@"KWMBlogDetailVC"
fromStoryboard
:
@"Home"
];
blogDetailVC
.
handle
=
parameters
[
@"handle"
];
blogDetailVC
.
type
=
KWMContentTypePage
;
blogDetailVC
.
title
=
parameters
[
@"title"
];
[[
AppDelegate
mainViewController
].
selectedViewController
pushViewController
:
blogDetailVC
animated
:
YES
];
return
YES
;
}];
...
...
iCemarose/Class/UI/Mine/KWMOrderVC.m
View file @
81145eba
...
...
@@ -8,7 +8,7 @@
#import "KWMOrderVC.h"
#import "KWMOrderCell.h"
#import "KWM
ProductDetail
VC.h"
#import "KWM
NewProduct
VC.h"
#import "KWMImageUtil.h"
#import "KWMStringUtil.h"
...
...
@@ -141,7 +141,8 @@
}
-
(
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
;
[
self
.
navigationController
pushViewController
:
productDetailVC
animated
:
YES
];
}
...
...
iCemarose/Class/UI/NewHome/KWMNewHomeVC.m
View file @
81145eba
...
...
@@ -154,7 +154,7 @@ typedef enum{
#pragma mark - KWMMenuDelegate
-
(
void
)
kwm_onClickHotMenu
{
[
self
openURLWithString
:
@"https://cemarose.myshopify.com/collections/new"
];
[
self
openURLWithString
:
@"https://cemarose.myshopify.com/collections/new
?title=%E6%9C%80%E6%96%B0%E5%8D%95%E5%93%81
"
];
}
-
(
void
)
kwm_onClickNewMenu
{
...
...
iCemarose/Class/UI/Product/KWMNewVC.m
View file @
81145eba
...
...
@@ -18,7 +18,7 @@
#import "KWMSelectedGoodsVC.h"
#import "KWMBrandCaramelVC.h"
#import "UIColor+SAMAdditions.h"
#import "KWM
ProductDetail
VC.h"
#import "KWM
NewProduct
VC.h"
#import "KWMShoppingCart.h"
...
...
@@ -281,7 +281,8 @@ static NSString * idStr = @"KWMNewGoodsCell";
if
(
product
==
nil
)
{
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
;
[
self
.
navigationController
pushViewController
:
goodsDetailvc
animated
:
YES
];
}
...
...
iCemarose/Class/UI/Product/KWMProductDetailVC.h
View file @
81145eba
////
//// KWMProductDetailVC.h
//// iCemarose
////
//// Created by HouWeiBin on 2017/1/11.
//// Copyright © 2017年 kollway. All rights reserved.
////
//
// KWMProductDetailVC.h
// iCemarose
//#import "KWMBaseVC.h"
//
// Created by HouWeiBin on 2017/1/11.
// Copyright © 2017年 kollway. All rights reserved.
//@interface KWMProductDetailVC : KWMBaseVC
//
#import "KWMBaseVC.h"
@interface
KWMProductDetailVC
:
KWMBaseVC
@property
(
nonatomic
)
BUYProduct
*
product
;
@property
(
nonatomic
)
NSNumber
*
productId
;
/**
* SKU 人为定义的SKU
*/
@property
(
nonatomic
)
NSString
*
handle
;
@end
//@property (nonatomic) BUYProduct *product;
//
//@property (nonatomic) NSNumber *productId;
//
///**
// * SKU 人为定义的SKU
// */
//@property (nonatomic) NSString *handle;
//
//@end
iCemarose/Class/UI/Product/KWMProductDetailVC.m
View file @
81145eba
////
//// KWMProductDetailVC.m
//// iCemarose
////
//// Created by HouWeiBin on 2017/1/11.
//// Copyright © 2017年 kollway. All rights reserved.
////
//
// KWMProductDetailVC.m
// iCemarose
//
// Created by HouWeiBin on 2017/1/11.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMProductDetailVC.h"
#import "KWMProductDetailView.h"
#import "KWMBottomView.h"
#import "KWMUserModel.h"
#import "PhotoBroswerVC.h"
#import "KWMStringUtil.h"
#import "KWMShopCartData.h"
#import "KWMInformationVC.h"
#import "KWMBrandCaramelVC.h"
#import "KWMSelectSizeVC.h"
#import "KWMShopCartVC.h"
#import "KWMBeforePayVC.h"
#import "KWMLoginVC.h"
#import "MZFormSheetPresentationViewController.h"
#import "KWMShareVC.h"
#import "KWMImageUtil.h"
#import "KWMShoppingCart.h"
#import <RegexKitLite/RegexKitLite.h>
#import <TOWebViewController/TOWebViewController.h>
#import <AFNetworking/AFNetworking.h>
#import <TOWebViewController/NJKWebViewProgress.h>
#import <PPNetworkHelper/PPNetworkHelper.h>
@interface
KWMProductDetailVC
()
<
KWMBottomViewDelegate
,
KWMProductDetailViewDelegate
,
KWMSelectSizeVCDelegate
,
UIScrollViewDelegate
>
@property
(
weak
,
nonatomic
)
IBOutlet
UIScrollView
*
svContent
;
@property
(
nonatomic
)
KWMProductDetailView
*
productDetailView
;
@property
(
nonatomic
)
KWMBottomView
*
recommendView
;
@property
(
nonatomic
)
BUYCollection
*
collectionSameType
;
@property
(
nonatomic
)
BUYCollection
*
collectionSameBrand
;
@property
(
nonatomic
)
NSString
*
typeTag
;
@property
(
weak
,
nonatomic
)
IBOutlet
UIButton
*
btnShopCart
;
@property
(
weak
,
nonatomic
)
IBOutlet
UIButton
*
btnShare
;
-
(
IBAction
)
onClickBackBtn
:(
id
)
sender
;
-
(
IBAction
)
onClickShopCartBtn
:(
id
)
sender
;
-
(
IBAction
)
onClickShare
:(
id
)
sender
;
@end
@implementation
KWMProductDetailVC
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
self
initScrollView
];
[
self
initRecommendProduct
];
//#import "KWMProductDetailVC.h"
//#import "KWMProductDetailView.h"
//#import "KWMBottomView.h"
//#import "KWMUserModel.h"
//#import "PhotoBroswerVC.h"
//#import "KWMStringUtil.h"
//#import "KWMShopCartData.h"
//#import "KWMInformationVC.h"
//#import "KWMBrandCaramelVC.h"
//#import "KWMSelectSizeVC.h"
//#import "KWMShopCartVC.h"
//#import "KWMBeforePayVC.h"
//#import "KWMLoginVC.h"
//#import "MZFormSheetPresentationViewController.h"
//#import "KWMShareVC.h"
//#import "KWMImageUtil.h"
//#import "KWMShoppingCart.h"
//#import <RegexKitLite/RegexKitLite.h>
//#import <TOWebViewController/TOWebViewController.h>
//#import <AFNetworking/AFNetworking.h>
//#import <TOWebViewController/NJKWebViewProgress.h>
//#import <PPNetworkHelper/PPNetworkHelper.h>
//
//
//@interface KWMProductDetailVC ()<KWMBottomViewDelegate,KWMProductDetailViewDelegate,KWMSelectSizeVCDelegate,UIScrollViewDelegate>
//
//@property (weak, nonatomic) IBOutlet UIScrollView *svContent;
//
//@property (nonatomic) KWMProductDetailView *productDetailView;
//
//@property (nonatomic) KWMBottomView *recommendView;
//
//@property (nonatomic) BUYCollection *collectionSameType;
//
//@property (nonatomic) BUYCollection *collectionSameBrand;
//
//@property (nonatomic) NSString *typeTag;
//
//@property (weak, nonatomic) IBOutlet UIButton *btnShopCart;
//
//@property (weak, nonatomic) IBOutlet UIButton *btnShare;
//
//- (IBAction)onClickBackBtn:(id)sender;
//
//- (IBAction)onClickShopCartBtn:(id)sender;
//
//- (IBAction)onClickShare:(id)sender;
//
//@end
//
//@implementation KWMProductDetailVC
//
//- (void)viewDidLoad {
// [super viewDidLoad];
// [self initScrollView];
// [self initRecommendProduct];
//// [self initShopCartCount];
// //刷新product,如果是缓存的product,因为没有字典,所以会发生错误,需要重新请求一个有字典的product
// if(self.handle || (self.product && self.product.identifier && !self.product.JSONDictionary)){
// [self getProductBy:nil product:self.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;
// }
// }
// 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];
//刷新product,如果是缓存的product,因为没有字典,所以会发生错误,需要重新请求一个有字典的product
if
(
self
.
handle
||
(
self
.
product
&&
self
.
product
.
identifier
&&
!
self
.
product
.
JSONDictionary
)){
[
self
getProductBy
:
nil
product
:
self
.
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
;
}
}
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
];
}
-
(
void
)
viewWillDisappear
:
(
BOOL
)
animated
{
[
super
viewWillDisappear
:
animated
];
[
self
.
navigationController
setNavigationBarHidden
:
NO
animated
:
YES
];
}
-
(
void
)
initScrollView
{
CGFloat
w
=
UI_SCREEN_WIDTH
;
CGFloat
h
=
UI_SCREEN_HEITHT
-
60
;
for
(
int
i
=
0
;
i
<
2
;
i
++
){
if
(
i
==
0
){
self
.
productDetailView
=
[[
KWMProductDetailView
alloc
]
init
];
self
.
productDetailView
.
frame
=
CGRectMake
(
i
*
w
,
0
,
w
,
h
);
self
.
productDetailView
.
delegate
=
self
;
[
self
.
svContent
addSubview
:
self
.
productDetailView
];
[
self
.
productDetailView
setData
:
self
.
product
];
}
else
{
self
.
recommendView
=
[[
KWMBottomView
alloc
]
init
];
self
.
recommendView
.
frame
=
CGRectMake
(
i
*
w
,
0
,
w
,
h
);
self
.
recommendView
.
delegate
=
self
;
[
self
.
svContent
addSubview
:
self
.
recommendView
];
}
}
self
.
svContent
.
delegate
=
self
;
self
.
svContent
.
contentSize
=
CGSizeMake
(
w
*
2
,
0
);
self
.
svContent
.
pagingEnabled
=
YES
;
if
(
self
.
product
&&
self
.
product
.
imagesArray
&&
self
.
product
.
imagesArray
.
count
>
0
){
NSInteger
imageCount
=
self
.
product
.
imagesArray
.
count
;
[
self
.
recommendView
setCount
:
imageCount
];
}
}
-
(
void
)
kwm_onClickSizeGuide
{
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];
//}
//
//- (void)viewWillDisappear:(BOOL)animated{
// [super viewWillDisappear:animated];
// [self.navigationController setNavigationBarHidden:NO animated:YES];
//}
//
//- (void)initScrollView{
// CGFloat w = UI_SCREEN_WIDTH;
// CGFloat h = UI_SCREEN_HEITHT-60;
// for (int i = 0;i < 2;i++){
// if(i == 0){
// self.productDetailView = [[KWMProductDetailView alloc] init];
// self.productDetailView.frame = CGRectMake(i*w, 0, w, h);
// self.productDetailView.delegate = self;
// [self.svContent addSubview:self.productDetailView];
// [self.productDetailView setData:self.product];
// }else{
// self.recommendView = [[KWMBottomView alloc] init];
// self.recommendView.frame = CGRectMake(i*w, 0, w, h);
// self.recommendView.delegate = self;
// [self.svContent addSubview:self.recommendView];
// }
// }
// self.svContent.delegate = self;
// self.svContent.contentSize = CGSizeMake(w*2,0);
// self.svContent.pagingEnabled = YES;
// if(self.product && self.product.imagesArray && self.product.imagesArray.count>0){
// NSInteger imageCount = self.product.imagesArray.count;
// [self.recommendView setCount:imageCount];
// }
//}
//
//- (void)kwm_onClickSizeGuide {
//
// 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:@""];
...
...
@@ -150,319 +166,303 @@
// @".rte.text-content td{padding-left:10px;}"
// @"</style>"];
// [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];
// }];
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];
// [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)
kwm_fastBuy:(BUYCart *)fastBuyCart
{
// if(
fastBuyCart == nil
){
//-(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) {
// KWMBeforePayVC *beforePayVC = (KWMBeforePayVC *)[KWMBaseVC findControllerBy:[KWMBeforePayVC kwmTag] fromStoryboard:@"ShopCart"];
// beforePayVC.fastPayCart = fastBuyCart;
// [self.navigationController pushViewController:beforePayVC animated:YES];}
// //用户未登录
// else{
// 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{
//// 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];
// }
//}
//
////获取相同类型商品collection/相同品牌商品collection
//-(void)requestCollection:(NSString *)handle isSameBrand:(BOOL)isSameBrand{
// __weak KWMProductDetailVC *weakSelf = self;
// [self.client getCollectionByHandle:handle completion:^(BUYCollection *collection, NSError *error) {
// if(!error && collection!=nil){
// if(isSameBrand){
// [weakSelf hideLoading];
// weakSelf.collectionSameBrand = collection;
// }else{
// weakSelf.collectionSameType = collection;
// }
// [self requestProducts:collection.identifier isSameBrand:isSameBrand];
// }else if(error != nil){
// [self showError:error];
// }
// }];
//}
//
////获取某个商品集合,并将其设置到猜你喜欢view中
//-(void)requestProducts:(NSNumber *)collectionId isSameBrand:(BOOL)isSameBrand{
// __weak KWMProductDetailVC *weakSelf = self;
// NSInteger targetPage;
// if(isSameBrand){
// if(self.recommendView.isLoadingSameBrand){
// return;
// }
// targetPage = self.recommendView.pageSameBrand + 1;
// self.recommendView.isLoadingSameBrand = YES;
// }else{
// if(self.recommendView.isLoadingSameType){
// return;
// }
// 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) {
// if(isSameBrand){
// self.recommendView.isLoadingSameBrand = NO;
// }else{
// self.recommendView.isLoadingSameType = NO;
// }
// if(!error && products!=nil){
// if(isSameBrand){
// weakSelf.recommendView.pageSameBrand += 1;
// }else{
// weakSelf.recommendView.pageSameType += 1;
// }
// [weakSelf.recommendView setData:products isSameBrand:isSameBrand];
// }else if(error != nil){
// [self showError:error];
// }
// }];
//}
#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
];
}
}
//获取相同类型商品collection/相同品牌商品collection
-
(
void
)
requestCollection
:
(
NSString
*
)
handle
isSameBrand
:
(
BOOL
)
isSameBrand
{
__weak
KWMProductDetailVC
*
weakSelf
=
self
;
[
self
.
client
getCollectionByHandle
:
handle
completion
:
^
(
BUYCollection
*
collection
,
NSError
*
error
)
{
if
(
!
error
&&
collection
!=
nil
){
if
(
isSameBrand
){
[
weakSelf
hideLoading
];
weakSelf
.
collectionSameBrand
=
collection
;
}
else
{
weakSelf
.
collectionSameType
=
collection
;
}
[
self
requestProducts
:
collection
.
identifier
isSameBrand
:
isSameBrand
];
}
else
if
(
error
!=
nil
){
[
self
showError
:
error
];
}
}];
}
//获取某个商品集合,并将其设置到猜你喜欢view中
-
(
void
)
requestProducts
:
(
NSNumber
*
)
collectionId
isSameBrand
:
(
BOOL
)
isSameBrand
{
__weak
KWMProductDetailVC
*
weakSelf
=
self
;
NSInteger
targetPage
;
if
(
isSameBrand
){
if
(
self
.
recommendView
.
isLoadingSameBrand
){
return
;
}
targetPage
=
self
.
recommendView
.
pageSameBrand
+
1
;
self
.
recommendView
.
isLoadingSameBrand
=
YES
;
}
else
{
if
(
self
.
recommendView
.
isLoadingSameType
){
return
;
}
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
)
{
if
(
isSameBrand
){
self
.
recommendView
.
isLoadingSameBrand
=
NO
;
}
else
{
self
.
recommendView
.
isLoadingSameType
=
NO
;
}
if
(
!
error
&&
products
!=
nil
){
if
(
isSameBrand
){
weakSelf
.
recommendView
.
pageSameBrand
+=
1
;
}
else
{
weakSelf
.
recommendView
.
pageSameType
+=
1
;
}
[
weakSelf
.
recommendView
setData
:
products
isSameBrand
:
isSameBrand
];
}
else
if
(
error
!=
nil
){
[
self
showError
:
error
];
}
}];
}
//查找商品API
-
(
void
)
getProductBy
:
(
NSNumber
*
)
productId
product
:
(
BUYProduct
*
)
product
{
if
(
productId
==
nil
&&
product
==
nil
&&
!
self
.
handle
){
return
;
}
[
self
showLoading
];
void
(
^
completion
)(
BUYProduct
*
,
NSError
*
)
=
^
(
BUYProduct
*
_Nullable
product
,
NSError
*
_Nullable
error
)
{
[
self
hideLoading
];
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
//
////查找商品API
//- (void)getProductBy:(NSNumber *)productId product:(BUYProduct *)product{
// if(productId == nil && product == nil && !self.handle){
// return;
// }
// [self showLoading];
// void(^completion)(BUYProduct *, NSError *) = ^(BUYProduct * _Nullable product, NSError * _Nullable error) {
// [self hideLoading];
// 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
iCemarose/Class/UI/Product/KWMSelectedGoodsVC.m
View file @
81145eba
...
...
@@ -53,7 +53,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
self
.
hasNextPage
=
NO
;
self
.
collectionSort
=
BUYCollectionSortCreatedDescending
;
if
(
self
.
handle
)
{
if
(
self
.
handle
&&
!
self
.
title
)
{
self
.
title
=
self
.
handle
.
capitalizedString
;
}
else
if
(
self
.
productType
!=
nil
){
//初始化双行标题栏
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment