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
fdfa3996
Commit
fdfa3996
authored
7 years ago
by
lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物车修改完成
parent
6c9ff8a5
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
55 deletions
+119
-55
KWMAPIManager.h
iCemarose/Class/Api/KWMAPIManager.h
+4
-1
KWMAPIManager.m
iCemarose/Class/Api/KWMAPIManager.m
+10
-1
KWMShoppingCart.h
iCemarose/Class/Model/KWMShoppingCart.h
+3
-1
KWMShoppingCart.m
iCemarose/Class/Model/KWMShoppingCart.m
+25
-9
KWMProductDetailVC.m
iCemarose/Class/UI/Product/KWMProductDetailVC.m
+31
-23
KWMSelectSizeVC.h
iCemarose/Class/UI/ShopCart/KWMSelectSizeVC.h
+4
-4
KWMSelectSizeVC.m
iCemarose/Class/UI/ShopCart/KWMSelectSizeVC.m
+1
-1
KWMShopCartVC.m
iCemarose/Class/UI/ShopCart/KWMShopCartVC.m
+41
-15
No files found.
iCemarose/Class/Api/KWMAPIManager.h
View file @
fdfa3996
...
@@ -103,7 +103,10 @@
...
@@ -103,7 +103,10 @@
*
*
* @return <#return value description#>
* @return <#return value description#>
*/
*/
-
(
NSURLSessionDataTask
*
)
updateProductWithVariantId
:(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
success
:
(
void
(
^
)(
NSURLSessionDataTask
*
task
,
KWMCartResult
*
result
))
success
failure
:
(
void
(
^
)(
NSURLSessionDataTask
*
task
,
NSError
*
error
))
failure
;
-
(
NSURLSessionDataTask
*
)
changeProductWithVariantId
:(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
success
:
(
void
(
^
)(
NSURLSessionDataTask
*
task
,
KWMCartResult
*
result
))
success
failure
:
(
void
(
^
)(
NSURLSessionDataTask
*
task
,
NSError
*
error
))
failure
;
-
(
NSURLSessionDataTask
*
)
updateProductWithVariantIds
:(
NSArray
<
NSNumber
*>
*
)
variantIds
quantities
:
(
NSArray
<
NSNumber
*>
*
)
quantities
success
:
(
void
(
^
)(
NSURLSessionDataTask
*
task
,
KWMCartResult
*
result
))
success
failure
:
(
void
(
^
)(
NSURLSessionDataTask
*
task
,
NSError
*
error
))
failure
;
/**
/**
* 获取系统购物车
* 获取系统购物车
*
*
...
...
This diff is collapsed.
Click to expand it.
iCemarose/Class/Api/KWMAPIManager.m
View file @
fdfa3996
...
@@ -419,12 +419,21 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
...
@@ -419,12 +419,21 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
failure
:
failure
];
failure
:
failure
];
}
}
-
(
NSURLSessionDataTask
*
)
updat
eProductWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
success
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
KWMCartResult
*
))
success
failure
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
NSError
*
))
failure
{
-
(
NSURLSessionDataTask
*
)
chang
eProductWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
success
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
KWMCartResult
*
))
success
failure
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
NSError
*
))
failure
{
NSString
*
apiPath
=
[
NSString
stringWithFormat
:
@"https://%@/cart/change/%@.js"
,
Shopify_SHOP_DOMAIN
,
variantId
];
NSString
*
apiPath
=
[
NSString
stringWithFormat
:
@"https://%@/cart/change/%@.js"
,
Shopify_SHOP_DOMAIN
,
variantId
];
id
params
=
@{
@"quantity"
:
@
(
quantity
)
};
id
params
=
@{
@"quantity"
:
@
(
quantity
)
};
return
[
self
startSessionTask
:
KWMHTTPMethodGET
apiPath
:
apiPath
parameters
:
params
result
:
[
KWMCartResult
class
]
model
:
nil
success
:
success
failure
:
failure
];
return
[
self
startSessionTask
:
KWMHTTPMethodGET
apiPath
:
apiPath
parameters
:
params
result
:
[
KWMCartResult
class
]
model
:
nil
success
:
success
failure
:
failure
];
}
}
-
(
NSURLSessionDataTask
*
)
updateProductWithVariantIds
:
(
NSArray
<
NSNumber
*>
*
)
variantIds
quantities
:
(
NSArray
<
NSNumber
*>
*
)
quantities
success
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
KWMCartResult
*
))
success
failure
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
NSError
*
))
failure
{
NSString
*
apiPath
=
[
NSString
stringWithFormat
:
@"https://%@/cart/update.js"
,
Shopify_SHOP_DOMAIN
];
NSMutableDictionary
*
params
=
[
NSMutableDictionary
new
];
for
(
int
i
=
0
;
i
<
quantities
.
count
;
i
++
)
{
[
params
setObject
:
quantities
[
i
]
forKey
:[
NSString
stringWithFormat
:
@"updates[%@]"
,
variantIds
[
i
]]];
}
return
[
self
startSessionTask
:
KWMHTTPMethodPOST
apiPath
:
apiPath
parameters
:
params
result
:
[
KWMCartResult
class
]
model
:
nil
success
:
success
failure
:
failure
];
}
-
(
NSURLSessionDataTask
*
)
addProductWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
success
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
KWMRequestResult
*
))
success
failure
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
NSError
*
))
failure
{
-
(
NSURLSessionDataTask
*
)
addProductWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
success
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
KWMRequestResult
*
))
success
failure
:
(
void
(
^
)(
NSURLSessionDataTask
*
,
NSError
*
))
failure
{
NSString
*
apiPath
=
[
NSString
stringWithFormat
:
@"https://%@/cart/add.js"
,
Shopify_SHOP_DOMAIN
];
NSString
*
apiPath
=
[
NSString
stringWithFormat
:
@"https://%@/cart/add.js"
,
Shopify_SHOP_DOMAIN
];
id
params
=
@{
id
params
=
@{
...
...
This diff is collapsed.
Click to expand it.
iCemarose/Class/Model/KWMShoppingCart.h
View file @
fdfa3996
...
@@ -24,7 +24,9 @@ typedef void(^ShoppingCartCallBack) (NSError *error,KWMCartResult *cart);
...
@@ -24,7 +24,9 @@ typedef void(^ShoppingCartCallBack) (NSError *error,KWMCartResult *cart);
-
(
void
)
increaseProductWithVariantId
:(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
callback
:
(
ShoppingCartCallBack
)
callback
;
-
(
void
)
increaseProductWithVariantId
:(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
callback
:
(
ShoppingCartCallBack
)
callback
;
-
(
void
)
updateProductWithVariantId
:(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
callback
:
(
ShoppingCartCallBack
)
callback
;
-
(
void
)
changeProductWithVariantId
:(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
callback
:
(
ShoppingCartCallBack
)
callback
;
-
(
void
)
updateProductWithVariantIds
:(
NSArray
<
NSNumber
*>
*
)
variantIds
quantitties
:
(
NSArray
<
NSNumber
*>
*
)
quantites
callback
:
(
ShoppingCartCallBack
)
callback
;
-
(
void
)
deleteProductWithVariantId
:(
NSNumber
*
)
variantId
callback
:
(
ShoppingCartCallBack
)
callback
;
-
(
void
)
deleteProductWithVariantId
:(
NSNumber
*
)
variantId
callback
:
(
ShoppingCartCallBack
)
callback
;
...
...
This diff is collapsed.
Click to expand it.
iCemarose/Class/Model/KWMShoppingCart.m
View file @
fdfa3996
...
@@ -63,40 +63,55 @@
...
@@ -63,40 +63,55 @@
}
}
-
(
void
)
increaseProductWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
callback
:
(
ShoppingCartCallBack
)
callback
{
-
(
void
)
increaseProductWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
callback
:
(
ShoppingCartCallBack
)
callback
{
callback
(
nil
,[
self
changeLocalCartWithVariantId
:
variantId
quantity
:
quantity
flag
:
1
]);
[[
KWMAPIManager
sharedManager
]
addProductWithVariantId
:
variantId
quantity
:
quantity
success
:^
(
NSURLSessionDataTask
*
task
,
KWMRequestResult
*
result
)
{
[[
KWMAPIManager
sharedManager
]
addProductWithVariantId
:
variantId
quantity
:
quantity
success
:^
(
NSURLSessionDataTask
*
task
,
KWMRequestResult
*
result
)
{
[[
KWMShoppingCart
sharedInstance
]
allItemsWithCallback
:
^
(
NSError
*
error
,
KWMCartResult
*
cart
)
{
[[
KWMShoppingCart
sharedInstance
]
allItemsWithCallback
:
^
(
NSError
*
error
,
KWMCartResult
*
cart
)
{
//
callback(error,cart);
callback
(
error
,
cart
);
}];
}];
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
// callback(error,nil);
// callback(error,nil);
}];
}];
callback
(
nil
,[
self
changeLocalCartWithVariantId
:
variantId
quantity
:
quantity
flag
:
1
]);
}
}
-
(
void
)
updateProductWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
callback
:
(
ShoppingCartCallBack
)
callback
{
-
(
void
)
changeProductWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
callback
:
(
ShoppingCartCallBack
)
callback
{
[[
KWMAPIManager
sharedManager
]
changeProductWithVariantId
:
variantId
quantity
:
quantity
success
:^
(
NSURLSessionDataTask
*
task
,
KWMCartResult
*
result
)
{
[[
KWMShoppingCart
sharedInstance
]
setResult
:
result
];
callback
(
nil
,
result
);
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
// callback(error,nil);
}];
callback
(
nil
,[
self
changeLocalCartWithVariantId
:
variantId
quantity
:
quantity
flag
:
quantity
?
2
:
0
]);
callback
(
nil
,[
self
changeLocalCartWithVariantId
:
variantId
quantity
:
quantity
flag
:
quantity
?
2
:
0
]);
[[
KWMAPIManager
sharedManager
]
updateProductWithVariantId
:
variantId
quantity
:
quantity
success
:^
(
NSURLSessionDataTask
*
task
,
KWMCartResult
*
result
)
{
}
-
(
void
)
updateProductWithVariantIds
:
(
NSArray
<
NSNumber
*>
*
)
variantIds
quantitties
:
(
NSArray
<
NSNumber
*>
*
)
quantites
callback
:
(
ShoppingCartCallBack
)
callback
{
[[
KWMAPIManager
sharedManager
]
updateProductWithVariantIds
:
variantIds
quantities
:
quantites
success
:^
(
NSURLSessionDataTask
*
task
,
KWMCartResult
*
result
)
{
[[
KWMShoppingCart
sharedInstance
]
setResult
:
result
];
[[
KWMShoppingCart
sharedInstance
]
setResult
:
result
];
//
callback(nil,result);
callback
(
nil
,
result
);
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
}
failure
:^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
)
{
// callback(error,nil);
// callback(error,nil);
}];
}];
for
(
int
i
=
0
;
i
<
quantites
.
count
;
i
++
)
{
[
self
changeLocalCartWithVariantId
:
variantIds
[
i
]
quantity
:
quantites
[
i
].
integerValue
flag
:
quantites
[
i
].
integerValue
?
2
:
0
];
}
callback
(
nil
,
self
.
result
);
}
}
-
(
void
)
deleteProductWithVariantId
:
(
NSNumber
*
)
variantId
callback
:
(
ShoppingCartCallBack
)
callback
{
-
(
void
)
deleteProductWithVariantId
:
(
NSNumber
*
)
variantId
callback
:
(
ShoppingCartCallBack
)
callback
{
[
self
updat
eProductWithVariantId
:
variantId
quantity
:
0
callback
:
callback
];
[
self
chang
eProductWithVariantId
:
variantId
quantity
:
0
callback
:
callback
];
}
}
-
(
KWMCartResult
*
)
changeLocalCartWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
flag
:
(
NSInteger
)
flag
{
-
(
KWMCartResult
*
)
changeLocalCartWithVariantId
:
(
NSNumber
*
)
variantId
quantity
:
(
NSInteger
)
quantity
flag
:
(
NSInteger
)
flag
{
NSMutableArray
<
KWMShopCartModel
*>
*
items
=
self
.
items
;
NSMutableArray
<
KWMShopCartModel
*>
*
items
=
self
.
items
;
NSInteger
count
=
self
.
result
.
item_count
.
integerValue
;
NSInteger
count
=
self
.
result
.
item_count
.
integerValue
;
BOOL
processed
=
NO
;
BOOL
processed
=
NO
;
for
(
KWMShopCartModel
*
item
in
items
)
{
NSUInteger
size
=
items
.
count
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
KWMShopCartModel
*
item
=
items
[
i
];
if
(
item
.
identifier
.
integerValue
==
variantId
.
integerValue
)
{
if
(
item
.
identifier
.
integerValue
==
variantId
.
integerValue
)
{
switch
(
flag
)
{
switch
(
flag
)
{
case
0
:
case
0
:
count
-=
item
.
quantity
;
count
-=
item
.
quantity
;
[
items
removeObject
:
item
];
[
self
.
items
removeObjectAtIndex
:
i
];
break
;
break
;
case
1
:
case
1
:
count
+=
quantity
;
count
+=
quantity
;
...
@@ -115,7 +130,8 @@
...
@@ -115,7 +130,8 @@
model
.
identifier
=
variantId
.
stringValue
;
model
.
identifier
=
variantId
.
stringValue
;
model
.
quantity
=
quantity
;
model
.
quantity
=
quantity
;
count
+=
quantity
;
count
+=
quantity
;
[
items
addObject
:
model
];
// [items addObject:model];
[
items
insertObject
:
model
atIndex
:
0
];
}
}
self
.
result
.
item_count
=
@
(
count
);
self
.
result
.
item_count
=
@
(
count
);
return
self
.
result
;
return
self
.
result
;
...
...
This diff is collapsed.
Click to expand it.
iCemarose/Class/UI/Product/KWMProductDetailVC.m
View file @
fdfa3996
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
[
super
viewDidLoad
];
[
super
viewDidLoad
];
[
self
initScrollView
];
[
self
initScrollView
];
[
self
initRecommendProduct
];
[
self
initRecommendProduct
];
[
self
initShopCartCount
];
//
[self initShopCartCount];
//刷新product,如果是缓存的product,因为没有字典,所以会发生错误,需要重新请求一个有字典的product
//刷新product,如果是缓存的product,因为没有字典,所以会发生错误,需要重新请求一个有字典的product
if
(
self
.
product
&&
self
.
product
.
identifier
&&
!
self
.
product
.
JSONDictionary
){
if
(
self
.
product
&&
self
.
product
.
identifier
&&
!
self
.
product
.
JSONDictionary
){
[
self
getProductBy
:
nil
product
:
self
.
product
];
[
self
getProductBy
:
nil
product
:
self
.
product
];
...
@@ -71,6 +71,7 @@
...
@@ -71,6 +71,7 @@
-
(
void
)
viewWillAppear
:
(
BOOL
)
animated
{
-
(
void
)
viewWillAppear
:
(
BOOL
)
animated
{
[
super
viewWillAppear
:
animated
];
[
super
viewWillAppear
:
animated
];
[
self
.
navigationController
setNavigationBarHidden
:
YES
animated
:
YES
];
[
self
.
navigationController
setNavigationBarHidden
:
YES
animated
:
YES
];
[
self
initShopCartCount
];
}
}
-
(
void
)
viewWillDisappear
:
(
BOOL
)
animated
{
-
(
void
)
viewWillDisappear
:
(
BOOL
)
animated
{
...
@@ -213,10 +214,17 @@
...
@@ -213,10 +214,17 @@
#pragma mark - KWMSelectSizeVCDelegate
#pragma mark - KWMSelectSizeVCDelegate
-
(
void
)
kwm_addShopWithVariantId
:
(
NSNumber
*
)
identifier
quantity
:
(
NSInteger
)
quantity
buyNow
:
(
BOOL
)
buyNow
callback
:
(
void
(
^
)(
BOOL
))
callback
{
-
(
void
)
kwm_addShopWithVariantId
:
(
NSNumber
*
)
identifier
quantity
:
(
NSInteger
)
quantity
variant
:
(
BUYProductVariant
*
)
variant
buyNow
:
(
BOOL
)
buyNow
callback
:
(
void
(
^
)(
BOOL
))
callback
{
__weak
KWMProductDetailVC
*
this
=
self
;
__weak
KWMProductDetailVC
*
this
=
self
;
if
(
!
buyNow
)
{
if
(
!
buyNow
)
{
[[
KWMShoppingCart
sharedInstance
]
increaseProductWithVariantId
:
identifier
quantity
:
quantity
callback
:^
(
NSError
*
error
,
KWMCartResult
*
cart
)
{
[[
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
;
model
.
imageStr
=
[
KWMImageUtil
getProductImageUrl
:
this
.
product
.
identifier
ImageSize
:
NormalImage
];
model
.
name
=
this
.
product
.
title
;
model
.
size
=
variant
.
title
;
model
.
price
=
variant
.
price
.
floatValue
;
}
if
(
!
error
)
{
if
(
!
error
)
{
[
this
showToast
:
@"添加成功"
];
[
this
showToast
:
@"添加成功"
];
[
this
.
btnShopCart
setTitle
:
cart
.
item_count
.
stringValue
forState
:
UIControlStateNormal
];
[
this
.
btnShopCart
setTitle
:
cart
.
item_count
.
stringValue
forState
:
UIControlStateNormal
];
...
@@ -249,27 +257,27 @@
...
@@ -249,27 +257,27 @@
}
}
//KWMSelectSizeVCDelegate
//
//
KWMSelectSizeVCDelegate
-
(
void
)
kwm_addShopCartItem
:
(
KWMShopCartModel
*
)
shopCartModel
{
//
-(void)kwm_addShopCartItem:(KWMShopCartModel *)shopCartModel{
[
self
initShopCartCount
];
//
[self initShopCartCount];
}
//
}
//
-
(
void
)
kwm_fastBuy
:
(
BUYCart
*
)
fastBuyCart
{
//
-(void)kwm_fastBuy:(BUYCart *)fastBuyCart{
if
(
fastBuyCart
==
nil
){
//
if(fastBuyCart == nil){
return
;
//
return;
}
//
}
KWMUserModel
*
useModel
=
[
KWMUserModel
shareUser
];
//
KWMUserModel *useModel = [KWMUserModel shareUser];
if
(
useModel
.
status
)
{
//
if (useModel.status) {
KWMBeforePayVC
*
beforePayVC
=
(
KWMBeforePayVC
*
)[
KWMBaseVC
findControllerBy
:[
KWMBeforePayVC
kwmTag
]
fromStoryboard
:
@"ShopCart"
];
//
KWMBeforePayVC *beforePayVC = (KWMBeforePayVC *)[KWMBaseVC findControllerBy:[KWMBeforePayVC kwmTag] fromStoryboard:@"ShopCart"];
beforePayVC
.
fastPayCart
=
fastBuyCart
;
//
beforePayVC.fastPayCart = fastBuyCart;
[
self
.
navigationController
pushViewController
:
beforePayVC
animated
:
YES
];}
//
[self.navigationController pushViewController:beforePayVC animated:YES];}
//用户未登录
//
//用户未登录
else
{
//
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];
}
//
}
}
//
}
#pragma mark - KWMSelectSizeVCDelegate End
#pragma mark - KWMSelectSizeVCDelegate End
...
...
This diff is collapsed.
Click to expand it.
iCemarose/Class/UI/ShopCart/KWMSelectSizeVC.h
View file @
fdfa3996
...
@@ -15,11 +15,11 @@
...
@@ -15,11 +15,11 @@
@protocol
KWMSelectSizeVCDelegate
<
NSObject
>
@protocol
KWMSelectSizeVCDelegate
<
NSObject
>
-
(
void
)
kwm_addShopCartItem
:
(
KWMShopCartModel
*
)
shopCartModel
;
//
- (void)kwm_addShopCartItem:(KWMShopCartModel *)shopCartModel;
//
-
(
void
)
kwm_fastBuy
:(
BUYCart
*
)
fastBuyCart
;
//
- (void)kwm_fastBuy:(BUYCart *)fastBuyCart;
-
(
void
)
kwm_addShopWithVariantId
:(
NSNumber
*
)
identifier
quantity
:
(
NSInteger
)
quantity
buyNow
:
(
BOOL
)
buyNow
callback
:
(
void
(
^
)(
BOOL
))
callback
;
-
(
void
)
kwm_addShopWithVariantId
:
(
NSNumber
*
)
identifier
quantity
:
(
NSInteger
)
quantity
variant
:
(
BUYProductVariant
*
)
variant
buyNow
:
(
BOOL
)
buyNow
callback
:
(
void
(
^
)(
BOOL
))
callback
;
@end
@end
@interface
KWMSelectSizeVC
:
KWMBaseVC
<
UICollectionViewDataSource
,
UICollectionViewDelegate
,
UICollectionViewDelegateFlowLayout
,
KWMSizeDelegate
>
@interface
KWMSelectSizeVC
:
KWMBaseVC
<
UICollectionViewDataSource
,
UICollectionViewDelegate
,
UICollectionViewDelegateFlowLayout
,
KWMSizeDelegate
>
...
...
This diff is collapsed.
Click to expand it.
iCemarose/Class/UI/ShopCart/KWMSelectSizeVC.m
View file @
fdfa3996
...
@@ -200,7 +200,7 @@
...
@@ -200,7 +200,7 @@
__weak
id
this
=
self
;
__weak
id
this
=
self
;
[
self
showLoading
];
[
self
showLoading
];
if
(
self
.
delegate
)
{
if
(
self
.
delegate
)
{
[
self
.
delegate
kwm_addShopWithVariantId
:
_selectSize
.
identifier
quantity
:
_count
buyNow
:
buyNow
callback
:^
(
BOOL
success
)
{
[
self
.
delegate
kwm_addShopWithVariantId
:
_selectSize
.
identifier
quantity
:
_count
variant
:
_selectSize
buyNow
:
buyNow
callback
:^
(
BOOL
success
)
{
[
self
hideLoading
];
[
self
hideLoading
];
if
(
success
)
{
if
(
success
)
{
[
this
dismissViewControllerAnimated
:
YES
completion
:
nil
];
[
this
dismissViewControllerAnimated
:
YES
completion
:
nil
];
...
...
This diff is collapsed.
Click to expand it.
iCemarose/Class/UI/ShopCart/KWMShopCartVC.m
View file @
fdfa3996
...
@@ -156,7 +156,7 @@
...
@@ -156,7 +156,7 @@
#pragma mark -- KWMSelectSizeVCDelegate
#pragma mark -- KWMSelectSizeVCDelegate
-
(
void
)
kwm_addShopWithVariantId
:
(
NSNumber
*
)
identifier
quantity
:
(
NSInteger
)
quantity
buyNow
:
(
BOOL
)
buyNow
callback
:
(
void
(
^
)(
BOOL
))
callback
{
-
(
void
)
kwm_addShopWithVariantId
:
(
NSNumber
*
)
identifier
quantity
:
(
NSInteger
)
quantity
variant
:
(
BUYProductVariant
*
)
variant
buyNow
:
(
BOOL
)
buyNow
callback
:
(
void
(
^
)(
BOOL
))
callback
{
__weak
KWMShopCartVC
*
this
=
self
;
__weak
KWMShopCartVC
*
this
=
self
;
void
(
^
success
)(
NSError
*
,
KWMCartResult
*
)
=
^
(
NSError
*
error
,
KWMCartResult
*
cart
){
void
(
^
success
)(
NSError
*
,
KWMCartResult
*
)
=
^
(
NSError
*
error
,
KWMCartResult
*
cart
){
if
(
!
error
)
{
if
(
!
error
)
{
...
@@ -168,27 +168,53 @@
...
@@ -168,27 +168,53 @@
}
}
};
};
if
(
_changeModel
.
identifier
.
integerValue
==
identifier
.
integerValue
)
{
if
(
_changeModel
.
identifier
.
integerValue
==
identifier
.
integerValue
)
{
[[
KWMShoppingCart
sharedInstance
]
updat
eProductWithVariantId
:
identifier
quantity
:
quantity
callback
:
success
];
[[
KWMShoppingCart
sharedInstance
]
chang
eProductWithVariantId
:
identifier
quantity
:
quantity
callback
:
success
];
}
else
{
}
else
{
NSNumber
*
oldId
=
@
(
_changeModel
.
identifier
.
integerValue
);
NSNumber
*
oldId
=
@
(
_changeModel
.
identifier
.
integerValue
);
KWMShopCartModel
*
model
=
_changeModel
;
_changeModel
=
nil
;
_changeModel
=
nil
;
[[
KWMShoppingCart
sharedInstance
]
deleteProductWithVariantId
:
oldId
callback
:
^
(
NSError
*
error
,
KWMCartResult
*
cart
)
{
NSArray
<
NSNumber
*>
*
variantIds
=
@[
oldId
,
identifier
];
[[
KWMShoppingCart
sharedInstance
]
increaseProductWithVariantId
:
identifier
quantity
:
quantity
callback
:
success
];
NSArray
<
NSNumber
*>
*
quantities
=
@[
@0
,
@
(
quantity
)];
[[
KWMShoppingCart
sharedInstance
]
updateProductWithVariantIds
:
variantIds
quantitties
:
quantities
callback
:^
(
NSError
*
error
,
KWMCartResult
*
cart
)
{
if
(
!
cart
.
items
.
firstObject
.
product_id
)
{
KWMShopCartModel
*
tmp
=
cart
.
items
.
firstObject
;
tmp
.
imageStr
=
model
.
imageStr
;
tmp
.
size
=
variant
.
title
;
tmp
.
brand
=
model
.
brand
;
tmp
.
name
=
model
.
name
;
tmp
.
price
=
variant
.
price
.
floatValue
;
tmp
.
product_id
=
model
.
product_id
;
}
success
(
error
,
cart
);
}];
}];
// [[KWMShoppingCart sharedInstance] deleteProductWithVariantId:oldId callback:^(NSError *error, KWMCartResult *cart) {
// [[KWMShoppingCart sharedInstance] increaseProductWithVariantId:identifier quantity:quantity callback:^(NSError *error, KWMCartResult *cart) {
// if (!cart.items.lastObject.product_id) {
// KWMShopCartModel *tmp = cart.items.lastObject;
// tmp.imageStr = model.imageStr;
// tmp.size = variant.title;
// tmp.brand = model.brand;
// tmp.name = model.name;
// tmp.price = variant.price.floatValue;
// tmp.product_id = model.product_id;
// }
// success(error,cart);
// }];
// }];
}
}
}
}
-
(
void
)
kwm_addShopCartItem
:
(
KWMShopCartModel
*
)
shopCartModel
{
//
- (void)kwm_addShopCartItem:(KWMShopCartModel *)shopCartModel{
//
[
_shopCartList
removeAllObjects
];
//
[_shopCartList removeAllObjects];
[
_shopCartList
addObjectsFromArray
:[[
KWMShopCartData
alloc
]
getALLItems
]];
//
[_shopCartList addObjectsFromArray:[[KWMShopCartData alloc] getALLItems]];
[
self
.
tbvCart
reloadData
];
//
[self.tbvCart reloadData];
[
self
setTotalPrice
];
//
[self setTotalPrice];
}
//
}
//
-
(
void
)
kwm_fastBuy
:
(
BUYCart
*
)
fastBuyCart
{
//
-(void)kwm_fastBuy:(BUYCart *)fastBuyCart{
//
}
//
}
-
(
void
)
kwm_deleteProduct
{
-
(
void
)
kwm_deleteProduct
{
// BOOL isHas = NO;
// BOOL isHas = NO;
...
...
This diff is collapsed.
Click to expand it.
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