Commit adcdd5a1 by lee

mrege

parents 7edd04d3 93111181
......@@ -79,6 +79,9 @@
9BE61CFE1ECD66BC0031D21E /* KWMShoppingCart.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE61CFD1ECD66BC0031D21E /* KWMShoppingCart.m */; };
9BE61D011ECD71610031D21E /* KWMCartResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE61D001ECD71610031D21E /* KWMCartResult.m */; };
C001BA5C1EB2ED5500B366A8 /* KWMImageBlurUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = C001BA5B1EB2ED5500B366A8 /* KWMImageBlurUtil.m */; };
C0028EC51F0DD19C00744C14 /* KWMAdditionalResult.m in Sources */ = {isa = PBXBuildFile; fileRef = C0028EC41F0DD19C00744C14 /* KWMAdditionalResult.m */; };
C0028EC81F0DE80500744C14 /* KWMWish.m in Sources */ = {isa = PBXBuildFile; fileRef = C0028EC71F0DE80500744C14 /* KWMWish.m */; };
C0028ECB1F0E2B3500744C14 /* KWMAdditionalListResult.m in Sources */ = {isa = PBXBuildFile; fileRef = C0028ECA1F0E2B3500744C14 /* KWMAdditionalListResult.m */; };
C0219A951DF53EB200711099 /* KWMExchangeRateResult.m in Sources */ = {isa = PBXBuildFile; fileRef = C0219A941DF53EB200711099 /* KWMExchangeRateResult.m */; };
C0243BBD1EFBD5A10013CFA7 /* Category.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0243BAF1EFBD5A10013CFA7 /* Category.storyboard */; };
C0243BBE1EFBD5A10013CFA7 /* KWMLeftCategoryCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C0243BB21EFBD5A10013CFA7 /* KWMLeftCategoryCell.m */; };
......@@ -90,6 +93,9 @@
C0243BC41EFBD5A10013CFA7 /* KWMProductFilterVC.m in Sources */ = {isa = PBXBuildFile; fileRef = C0243BBC1EFBD5A10013CFA7 /* KWMProductFilterVC.m */; };
C0243BC81EFBD6060013CFA7 /* KWMCategoryFilterTab.m in Sources */ = {isa = PBXBuildFile; fileRef = C0243BC61EFBD6060013CFA7 /* KWMCategoryFilterTab.m */; };
C0243BC91EFBD6060013CFA7 /* KWMCategoryFilterTab.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0243BC71EFBD6060013CFA7 /* KWMCategoryFilterTab.xib */; };
C02986881F0F249D002EB25F /* KWMWishListVC.m in Sources */ = {isa = PBXBuildFile; fileRef = C02986871F0F249D002EB25F /* KWMWishListVC.m */; };
C029868F1F0F2663002EB25F /* KWMWishCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C029868D1F0F2663002EB25F /* KWMWishCell.m */; };
C02986901F0F2663002EB25F /* KWMWishCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C029868E1F0F2663002EB25F /* KWMWishCell.xib */; };
C02C7D801E640D82008DC29C /* libWeChatSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C02C7D7B1E640D82008DC29C /* libWeChatSDK.a */; };
C02C7D811E640D82008DC29C /* README.txt in Resources */ = {isa = PBXBuildFile; fileRef = C02C7D7C1E640D82008DC29C /* README.txt */; };
C02C7D831E640FBF008DC29C /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C02C7D821E640FBF008DC29C /* SystemConfiguration.framework */; };
......@@ -469,6 +475,12 @@
B5C3F0326028FE5E2F51B4C1 /* Pods-iCemarose.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iCemarose.release.xcconfig"; path = "Pods/Target Support Files/Pods-iCemarose/Pods-iCemarose.release.xcconfig"; sourceTree = "<group>"; };
C001BA5A1EB2ED5500B366A8 /* KWMImageBlurUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMImageBlurUtil.h; sourceTree = "<group>"; };
C001BA5B1EB2ED5500B366A8 /* KWMImageBlurUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMImageBlurUtil.m; sourceTree = "<group>"; };
C0028EC31F0DD19C00744C14 /* KWMAdditionalResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMAdditionalResult.h; sourceTree = "<group>"; };
C0028EC41F0DD19C00744C14 /* KWMAdditionalResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMAdditionalResult.m; sourceTree = "<group>"; };
C0028EC61F0DE80500744C14 /* KWMWish.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMWish.h; sourceTree = "<group>"; };
C0028EC71F0DE80500744C14 /* KWMWish.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMWish.m; sourceTree = "<group>"; };
C0028EC91F0E2B3500744C14 /* KWMAdditionalListResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMAdditionalListResult.h; sourceTree = "<group>"; };
C0028ECA1F0E2B3500744C14 /* KWMAdditionalListResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMAdditionalListResult.m; sourceTree = "<group>"; };
C0219A931DF53EB200711099 /* KWMExchangeRateResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMExchangeRateResult.h; sourceTree = "<group>"; };
C0219A941DF53EB200711099 /* KWMExchangeRateResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMExchangeRateResult.m; sourceTree = "<group>"; };
C0243BAF1EFBD5A10013CFA7 /* Category.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Category.storyboard; sourceTree = "<group>"; };
......@@ -487,6 +499,11 @@
C0243BC51EFBD6060013CFA7 /* KWMCategoryFilterTab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMCategoryFilterTab.h; sourceTree = "<group>"; };
C0243BC61EFBD6060013CFA7 /* KWMCategoryFilterTab.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMCategoryFilterTab.m; sourceTree = "<group>"; };
C0243BC71EFBD6060013CFA7 /* KWMCategoryFilterTab.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMCategoryFilterTab.xib; sourceTree = "<group>"; };
C02986861F0F249D002EB25F /* KWMWishListVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMWishListVC.h; sourceTree = "<group>"; };
C02986871F0F249D002EB25F /* KWMWishListVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMWishListVC.m; sourceTree = "<group>"; };
C029868C1F0F2663002EB25F /* KWMWishCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMWishCell.h; sourceTree = "<group>"; };
C029868D1F0F2663002EB25F /* KWMWishCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMWishCell.m; sourceTree = "<group>"; };
C029868E1F0F2663002EB25F /* KWMWishCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMWishCell.xib; sourceTree = "<group>"; };
C02C7D7B1E640D82008DC29C /* libWeChatSDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libWeChatSDK.a; sourceTree = "<group>"; };
C02C7D7C1E640D82008DC29C /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = "<group>"; };
C02C7D7D1E640D82008DC29C /* WechatAuthSDK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WechatAuthSDK.h; sourceTree = "<group>"; };
......@@ -1243,6 +1260,10 @@
C03846931DB89EEB008C3BAB /* KWMCemaroseResult.m */,
C03120AB1EF2AC6700E49EFA /* KWMCheckoutPayResult.h */,
C03120AC1EF2AC6700E49EFA /* KWMCheckoutPayResult.m */,
C0028EC31F0DD19C00744C14 /* KWMAdditionalResult.h */,
C0028EC41F0DD19C00744C14 /* KWMAdditionalResult.m */,
C0028EC91F0E2B3500744C14 /* KWMAdditionalListResult.h */,
C0028ECA1F0E2B3500744C14 /* KWMAdditionalListResult.m */,
);
path = Api;
sourceTree = "<group>";
......@@ -1297,6 +1318,8 @@
9B18C11E1EF1270A001DD59B /* BUYProductVariant+Currency.m */,
C08870E91F03481C00C9C1C8 /* KWMCustomsClearance.h */,
C08870EA1F03481C00C9C1C8 /* KWMCustomsClearance.m */,
C0028EC61F0DE80500744C14 /* KWMWish.h */,
C0028EC71F0DE80500744C14 /* KWMWish.m */,
);
path = Model;
sourceTree = "<group>";
......@@ -1859,6 +1882,8 @@
C0A6B3BA1F01FC5300D85673 /* KWMNewProductVC.m */,
C0A6B3BB1F01FC5300D85673 /* KWMVariantsVC.h */,
C0A6B3BC1F01FC5300D85673 /* KWMVariantsVC.m */,
C02986861F0F249D002EB25F /* KWMWishListVC.h */,
C02986871F0F249D002EB25F /* KWMWishListVC.m */,
C0A6B3BD1F01FC5300D85673 /* NewProduct.storyboard */,
);
path = NewProduct;
......@@ -1882,6 +1907,9 @@
C0A6B3B61F01FC5300D85673 /* KWMThirdDetailView.h */,
C0A6B3B71F01FC5300D85673 /* KWMThirdDetailView.m */,
C0A6B3B81F01FC5300D85673 /* KWMThirdDetailView.xib */,
C029868C1F0F2663002EB25F /* KWMWishCell.h */,
C029868D1F0F2663002EB25F /* KWMWishCell.m */,
C029868E1F0F2663002EB25F /* KWMWishCell.xib */,
);
path = Cell;
sourceTree = "<group>";
......@@ -2201,6 +2229,7 @@
buildActionMask = 2147483647;
files = (
C0243BBF1EFBD5A10013CFA7 /* KWMLeftCategoryCell.xib in Resources */,
C02986901F0F2663002EB25F /* KWMWishCell.xib in Resources */,
C0F5867B1E24F820001248E2 /* KWMDoubleTitleView.xib in Resources */,
C034E8561D6B10A0006EE129 /* CoreSVP.bundle in Resources */,
C034E8591D6B10A0006EE129 /* SVProgressHUD.bundle in Resources */,
......@@ -2379,6 +2408,8 @@
9B8298E31EF22BE200743438 /* KWMCurrencyUtil.m in Sources */,
C034E6951D6AEB12006EE129 /* ViewController.m in Sources */,
C0DD53231EE55062002D1E0C /* KWMCarCountView.m in Sources */,
C02986881F0F249D002EB25F /* KWMWishListVC.m in Sources */,
C0028EC51F0DD19C00744C14 /* KWMAdditionalResult.m in Sources */,
C03943C01DD1FCE900141475 /* KWMProductType.m in Sources */,
C0CC140C1D7829FC007B5986 /* KWMSelectSizeVC.m in Sources */,
C034E7B31D6AFC3B006EE129 /* KWMMainVC.m in Sources */,
......@@ -2398,6 +2429,7 @@
C0392DB91DCC38450051AC8E /* KWMShippingCell.m in Sources */,
C02C7DA31E66AA97008DC29C /* KWMFilterVC.m in Sources */,
C034E8681D6B10A0006EE129 /* PhotoBroswerVC.m in Sources */,
C0028EC81F0DE80500744C14 /* KWMWish.m in Sources */,
C0CCB3D31EEA765B00BC2FB8 /* KWMNormalFilterView.m in Sources */,
8091DFB31D6EADE60020519C /* KWMSecondView.m in Sources */,
C034E8501D6B10A0006EE129 /* UIView+Extend.m in Sources */,
......@@ -2485,6 +2517,7 @@
C034E8431D6B10A0006EE129 /* NSDate+Extend.m in Sources */,
C091EE331DDB1FC500A382B9 /* KWMAppVersion.m in Sources */,
C0CC14041D7823B0007B5986 /* KWMDeleteView.m in Sources */,
C0028ECB1F0E2B3500744C14 /* KWMAdditionalListResult.m in Sources */,
8091DFA11D6E878C0020519C /* KWMGuideVC.m in Sources */,
C034E84A1D6B10A0006EE129 /* UIImage+Color.m in Sources */,
801230F21DD30704008C7904 /* KWMSearchBrandsCell.m in Sources */,
......@@ -2518,6 +2551,7 @@
9B53D5D71EE94739005BA6F7 /* KWMValidateUtil.m in Sources */,
9B0F56B81ECD3424009FC5FE /* UIViewController+AppearLog.m in Sources */,
C034E8451D6B10A0006EE129 /* NSString+Extend.m in Sources */,
C029868F1F0F2663002EB25F /* KWMWishCell.m in Sources */,
805C04381DD1FA7100ACC071 /* KWMBrandsTypeResult.m in Sources */,
C034E6DA1D6AEF1B006EE129 /* KWMTextFieldUtil.m in Sources */,
C0F5868D1E24F821001248E2 /* SHorizontalView.m in Sources */,
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_add@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_add@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_like_unable@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_like_unable@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -30,8 +30,11 @@
#import "KWMExchangeRateResult.h"
#import "KWMCartResult.h"
#import "KWMCheckoutPayResult.h"
#import "KWMAdditionalResult.h"
#import "KWMAdditionalListResult.h"
#import "KWMWechatPayData.h"
#import "KWMOrderPaid.h"
#import "KWMWish.h"
......@@ -273,4 +276,36 @@
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
/**
* 用户添加 wish API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) saveWish:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
/**
* 获取用户 wishlist API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getWishList:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
/**
* 移除指定 wish API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) removeWish:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
/**
* 清空愿望单 API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) clearWishList:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
@end
......@@ -206,7 +206,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
NSAssert((result == [KWMRequestResult class] || result == [KWMRequestListResult class]
|| result == [KWMCheckoutPayResult class]
|| result == [KWMCheckoutPayResult class]
|| result == [KWMCemaroseResult class] || [result isSubclassOfClass:[KWMCemaroseResult class]]),
@"result class must either be KWMRequestResult or KWMRequestListResult!");
NSAssert((!model || (model && [model isSubclassOfClass:[JSONModel class]])),
......@@ -425,10 +425,8 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 手机登录API
* @param parameters {mobile=?手机号,code=?收到的短信验证码}
* @param success 成功callback
* @param failure 失败callback
* @return NSURLSessionDataTask
* @param mobile 手机号
* @param code 收到的短信验证码
*/
- (NSURLSessionDataTask *) phoneLogin:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCustomerResult *result))success
......@@ -495,10 +493,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 手机登录-获取短信API
* @param parameters {mobile=?手机号}
* @param success 成功callback
* @param failure 失败callback
* @return NSURLSessionDataTask
* @param mobile 手机号
*/
- (NSURLSessionDataTask *) phoneSms:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCemaroseResult *result))success
......@@ -519,7 +514,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 获取所有品牌
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getAllBrand:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMBrandsResult *result))success
......@@ -538,8 +532,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 搜索API
* @param parameters {keyword=?搜索内容}
* @return NSURLSessionDataTask
* @param keyword 搜索内容
*/
- (NSURLSessionDataTask *) searchProduct:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMSearchResult *result))success
......@@ -556,7 +549,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 博客API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getAllBlog:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMBlogResult *result))success
......@@ -573,7 +565,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 商品——新品API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getNewProducts:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMNewProducts *result))success
......@@ -595,7 +586,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 商品——打折API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getDiscountProducts:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMNewProducts *result))success
......@@ -616,7 +606,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 获取商品分类API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getProductTypes:(NSDictionary *)parameters type:(NSInteger)type
success:(void(^)(NSURLSessionDataTask *task,KWMProductTypeResult *result))success
......@@ -649,7 +638,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 品牌类型--API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getBrandsType:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMBrandsTypeResult *result))success
......@@ -672,7 +660,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 汇率--API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getExchangeRate:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMExchangeRateResult *result))success
......@@ -696,7 +683,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 获取相关图片api
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getProductImages:(NSDictionary *)parameters productId:(NSNumber *)productId
success:(void(^)(NSURLSessionDataTask *task,KWMImagesResult *result))success
......@@ -715,7 +701,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 获取获取某个订单api
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getAdminOrder:(NSDictionary *)parameters orderId:(NSNumber *)orderId
success:(void(^)(NSURLSessionDataTask *task,KWMOrdersResult *result))success
......@@ -734,7 +719,6 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 获取商品api,因為admin商品有剩余库存数量字段,所以商品詳細還需要請求此api。
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) getAdminProduct:(NSDictionary *)parameters productId:(NSNumber *)productId
success:(void(^)(NSURLSessionDataTask *task,KWMProductResult *result))success
......@@ -753,12 +737,11 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 取消订单api
* amount 退款金额 (default: false)(十进制:21.20)If set, Shopify will attempt to void/refund the payment depending on the status.
* restock 是否将此订单商品重新包装会商店 (default: false)
* reason 订单取消原因 (用户customer, 库存inventory, 假货fraud, 其他other)(default: other)
* email 发送邮箱通知用户 (default: false)
* refund 更复杂的退款方式 As specified in the Refund documentation. Required for some more complex refund situations.
* @return NSURLSessionDataTask
* @param amount 退款金额 (default: false)(十进制:21.20)If set, Shopify will attempt to void/refund the payment depending on the status.
* @param restock 是否将此订单商品重新包装会商店 (default: false)
* @param reason 订单取消原因 (用户customer, 库存inventory, 假货fraud, 其他other)(default: other)
* @param email 发送邮箱通知用户 (default: false)
* @param refund 更复杂的退款方式 As specified in the Refund documentation. Required for some more complex refund situations.
*/
- (NSURLSessionDataTask *) cancelOrder:(NSDictionary *)parameters orderId:(NSNumber *)orderId
success:(void(^)(NSURLSessionDataTask *task,KWMProductResult *result))success
......@@ -777,16 +760,14 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 微信统一下单API
* checkout_token shopify订单token
* total_price 订单总金额
* ip_address 手机IP
* subject 订单描述
* sign 签名验证
* @param checkout_token shopify订单token
* @param total_price 订单总金额
* @param ip_address 手机IP
* @param subject 订单描述
* @param sign 签名验证
* 签名规则
* str_sign = "ip_address=127.0.0.1&checkout_token=5173547165345&subject=test&total_price=23423&key=bd3f58f5cd3d7a217ac8c8e655ab52f8";
* sign = md5(base64_encode($str_sign));
*
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) wechatPayUnifiedOrder:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
......@@ -803,15 +784,13 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 支付宝统一下单API
* checkout_token shopify订单token
* total_price 订单总金额
* subject 订单描述
* sign 签名验证
* 签名规则
* @param checkout_token shopify订单token
* @param total_price 订单总金额
* @param subject 订单描述
* @param sign 签名验证
* 签名规则
* str_sign = checkout_token=5173547165345&subject=test&total_price=23423&key=bd3f58f5cd3d7a217ac8c8e655ab52f8";
* sign = md5(base64_encode($str_sign));
*
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) aliPayUnifiedOrder:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
......@@ -856,13 +835,11 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 通过checkout_token查询shopify订单API
* checkout_token shopify订单token
* sign 签名验证
* 签名规则
* @param checkout_token shopify订单token
* @param sign 签名验证
* 签名规则
* str_sign = checkout_token=5173547165345&key=bd3f58f5cd3d7a217ac8c8e655ab52f8";
* sign = md5(base64_encode($str_sign));
*
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) appOrderQuery:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
......@@ -877,8 +854,90 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
failure:failure];
}
/**
* 用户添加 wish API
* @param customer_id 用户ID
* @param customer_email 用户邮箱
* @param customer_name 用户名
* @param product_title 产品标题
* @param prodcut_id 产品ID
* @param variant_id 变体ID
* @param variant_sku sku
* @param variant_title 变体标题
* @param product_handle 产品handle
* @param shop 店铺名(cemarose-test.myshopify.com)
*/
- (NSURLSessionDataTask *) saveWish:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist-save",@"chris.tofnews.com"];
return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath
parameters:parameters
result:[KWMAdditionalListResult class]
model:nil
success:success
failure:failure];
}
/**
* 获取用户 wishlist API
* @param customer_id 用户ID
* @param customer_email 用户邮箱
* @param variant_id 变体ID(用于获取单个愿望商品)
* @param shop 店铺名(cemarose-test.myshopify.com)
*/
- (NSURLSessionDataTask *) getWishList:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist",@"chris.tofnews.com"];
return [self startSessionTask:KWMHTTPMethodGET
apiPath:apiPath
parameters:parameters
result:[KWMAdditionalListResult class]
model:[KWMWish class]
success:success
failure:failure];
}
/**
* 移除指定 wish API
* @param customer_id 用户ID
* @param customer_email 用户邮箱
* @param variant_id 变体ID
* @param shop 店铺名(cemarose-test.myshopify.com)
*/
- (NSURLSessionDataTask *) removeWish:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist-prune",@"chris.tofnews.com"];
return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath
parameters:parameters
result:[KWMAdditionalListResult class]
model:[KWMWish class]
success:success
failure:failure];
}
/**
* 清空愿望单 API
* @param customer_id 用户ID
* @param customer_email 用户邮箱
* @param shop 店铺名(cemarose-test.myshopify.com)
*/
- (NSURLSessionDataTask *) clearWishList:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist-delete",@"chris.tofnews.com"];
return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath
parameters:parameters
result:[KWMAdditionalListResult class]
model:[KWMWish class]
success:success
failure:failure];
}
......
//
// KWMAdditionalListResult.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/6.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <JSONModel/JSONModel.h>
@interface KWMAdditionalListResult : KWMCemaroseResult
//结果状态。success:正常;fail:错误
@property (nonatomic) NSString<Optional> *status;
//结果详情
@property (nonatomic) NSString<Optional> *message;
@property (nonatomic) id<Optional> data;
@end
//
// KWMAdditionalListResult.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/6.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMAdditionalListResult.h"
@implementation KWMAdditionalListResult
- (instancetype)initWithDictionary:(NSDictionary *)dict
modelClass:(Class)modelClass
error:(NSError **)err {
self = [super initWithDictionary:dict error:err];
if (self) {
NSArray *dataArray = dict[@"data"];
if(dataArray){
self.data = [self buildListData:modelClass jsonDictionary:dataArray];
}
}
return self;
}
- (NSArray *)buildListData:(Class)modelClass jsonDictionary:(NSArray *)dataArray {
if(modelClass == nil){
NSString *reason = [[NSString alloc] initWithFormat:@"class with name:%@ doesn't exists!!", NSStringFromClass(modelClass)];
@throw [[NSException alloc] initWithName:NSInvalidArgumentException reason:reason userInfo:nil];
}
if(! [dataArray isKindOfClass:[NSArray class]]){
NSString *reason = [[NSString alloc] initWithFormat:@"dataArray object is not a NSArray instance"];
@throw [[NSException alloc] initWithName:NSInvalidArgumentException reason:reason userInfo:nil];
}
NSMutableArray *mutableArray = [[NSMutableArray alloc] init];
for(NSDictionary *itemJson in dataArray){
NSError *error;
id result = [[modelClass alloc] initWithDictionary:itemJson error:&error];
if(error){
NSLog(@"buildListData error: %@", [error localizedDescription]);
}else{
[mutableArray addObject:result];
}
}
return [[NSArray alloc] initWithArray:mutableArray];
}
@end
//
// KWMAdditionalResult.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/6.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <JSONModel/JSONModel.h>
@interface KWMAdditionalResult : KWMCemaroseResult
//结果状态。success:正常;fail:错误
@property (nonatomic) NSString<Optional> *status;
//结果详情
@property (nonatomic) NSString<Optional> *message;
@property (nonatomic) id<Optional> data;
@end
//
// KWMAdditionalResult.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/6.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMAdditionalResult.h"
@implementation KWMAdditionalResult
@end
//
// KWMWishProduct.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/6.
// Copyright © 2017年 . All rights reserved.
//
#import "KWMBaseModel.h"
@interface KWMWish : KWMBaseModel
@property (nonatomic) NSNumber *_id;
//用户id
@property (nonatomic) NSNumber *customerId;
//用户名
@property (nonatomic) NSString *customerName;
//用户邮箱
@property (nonatomic) NSString *customerEmail;
//商品id
@property (nonatomic) NSNumber *productId;
//商品名
@property (nonatomic) NSString *productTitle;
//变体id
@property (nonatomic) NSNumber *variantId;
//变体名
@property (nonatomic) NSString *variantTitle;
//变体sku
@property (nonatomic) NSString *variantSku;
//店铺地址 eg:liang2018.myshopify.com
@property (nonatomic) NSString *shop;
//创建时间 eg:2017-07-05 10:41:52
@property (nonatomic) NSString *createdAt;
//更新时间
@property (nonatomic) NSString *updatedAt;
@end
//
// KWMWishProduct.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/6.
// Copyright © 2017年 kollway. All rights reserved.
// 愿望model
//
#import "KWMWish.h"
@implementation KWMWish
@end
......@@ -10,6 +10,7 @@
#import "KWMOrderCell.h"
#import "KWMProductDetailVC.h"
#import "KWMImageUtil.h"
#import "KWMStringUtil.h"
@interface KWMOrderVC ()
@property (nonatomic) NSMutableArray<BUYOrder *> *orderList;//订单列表
......@@ -163,10 +164,6 @@
for(BUYProduct *product in self.productList){
if([product.identifier isEqualToNumber:productId]){
productImage = [KWMImageUtil getProductImageUrl:product ImageSize:LowImage];
if([product.identifier isEqualToNumber:@9690154060]){
NSLog(@"11111111%@",@"lalal");
}
}
}
}
......@@ -182,30 +179,6 @@
return NO;
}
-(NSArray *)splitArray:(NSArray *)array withSubSize:(NSInteger)subSize{
//拆分后的数组个数
NSInteger count = array.count % subSize == 0?(array.count /subSize): (array.count / subSize + 1);
NSMutableArray *arr = [NSMutableArray array];
for (int i = 0; i < count; i ++) {
//数组下标
NSInteger index = i * subSize;
//保存拆分的固定长度的数组元素的可变数组
NSMutableArray *arr1 = [[NSMutableArray alloc] init];
//移除子数组的所有元素
[arr1 removeAllObjects];
NSInteger j = index;
//将数组下标乘以1、2、3,得到拆分时数组的最大下标值,但最大不能超过数组的总大小
while (j < subSize*(i + 1) && j < array.count) {
[arr1 addObject:[array objectAtIndex:j]];
j += 1;
}
//将子数组添加到保存子数组的数组中
[arr addObject:[arr1 copy]];
}
return [arr copy];
}
//获取订单API
- (void)requestOrderAPI{
[self showLoading];
......@@ -246,7 +219,7 @@
return;
}
__weak KWMOrderVC *weakSelf = self;
NSArray *productIdsArray = [self splitArray:productIds withSubSize:50];
NSArray *productIdsArray = [KWMStringUtil splitArray:productIds withSubSize:50];
for(NSArray *mProductIds in productIdsArray){
//经过测试,该api一次最多返回50个product,所以如果有100个商品,需要分成两次请求
[self.client getProductsByIds:mProductIds completion:^(NSArray<BUYProduct *> * _Nullable products, NSError * _Nullable error) {
......
......@@ -20,6 +20,10 @@
@property (weak, nonatomic) id<KWMFirstDetailViewDelegate>delegate;
@property (nonatomic) BUYProductVariant *variant;
-(void)setData:(BUYProduct *)product;
@end
......@@ -28,6 +28,8 @@
@property(nonatomic,weak) IBOutlet UILabel *lbDetail;
@property(nonatomic,weak) IBOutlet UILabel *lbVariant;
//单位label
@property(nonatomic,weak) IBOutlet UILabel *lbUnit;
......@@ -257,6 +259,12 @@
}
}
-(void)setVariant:(BUYProductVariant *)variant{
_variant = variant;
if(variant){
self.lbVariant.text = variant.title;
}
}
......
......@@ -18,6 +18,7 @@
<outlet property="lbOldPrice" destination="Mql-V1-hiE" id="Sh1-Fz-sfU"/>
<outlet property="lbPrice" destination="gpT-Sg-ghu" id="FGd-AA-Yiv"/>
<outlet property="lbUnit" destination="wfT-JC-g9d" id="MSn-kd-aQ2"/>
<outlet property="lbVariant" destination="o3P-oH-Xcb" id="i3M-ae-jhH"/>
<outlet property="pageControl" destination="M6v-TN-2WE" id="QPe-TI-LdG"/>
<outlet property="vView" destination="iN0-l3-epB" id="TQD-W9-jEg"/>
</connections>
......
//
// KWMWishCell.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Buy/Buy.h>
#import "KWMWish.h"
@class KWMWishCell;
@protocol KWMWishCellDelegate <NSObject>
-(void)kwm_onClickRemove:(KWMWishCell *)wishCell;
-(void)kwm_onClickEdit:(KWMWishCell *)wishCell;
-(void)kwm_onClickAddToShopCart:(KWMWishCell *)wishCell;
@end
@interface KWMWishCell : UITableViewCell
@property (weak, nonatomic) id<KWMWishCellDelegate>delegate;
@property (nonatomic) KWMWish *wish;
@property (nonatomic) BUYProduct *product;
@property (nonatomic) BUYProductVariant *variant;
@end
//
// KWMWishCell.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMWishCell.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "KWMStringUtil.h"
#import "KWMImageUtil.h"
@interface KWMWishCell()
@property (weak, nonatomic) IBOutlet UIImageView *ivProduct;
@property (weak, nonatomic) IBOutlet UILabel *lbTitle;
@property (weak, nonatomic) IBOutlet UILabel *lbBrand;
@property (weak, nonatomic) IBOutlet UILabel *lbVariant;
@property (weak, nonatomic) IBOutlet UILabel *lbPrice;
@end
@implementation KWMWishCell
- (void)awakeFromNib {
[super awakeFromNib];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
- (IBAction)onClickEdit:(id)sender{
if(self.delegate){
[self.delegate kwm_onClickEdit:self];
}
}
- (IBAction)onClickRemove:(id)sender{
if(self.delegate){
[self.delegate kwm_onClickRemove:self];
}
}
- (IBAction)onClickAddToShopCart:(id)sender{
if(self.delegate){
[self.delegate kwm_onClickAddToShopCart:self];
}
}
-(void)setWish:(KWMWish *)wish{
_wish = wish;
if(_wish){
self.lbTitle.text = wish.productTitle;
self.lbVariant.text = wish.variantTitle;
}
}
-(void)setProduct:(BUYProduct *)product{
_product = product;
if(_product){
self.lbBrand.text = product.vendor;
if(product.imagesArray.count >0){
BUYImageLink *link = product.imagesArray.firstObject;
NSString *imageString = [KWMImageUtil getProductImageUrlByOriginalUrl:link.sourceURL.absoluteString ImageSize:NormalImage];
NSURL *imageURL = [NSURL URLWithString:imageString];
[self.ivProduct sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
}
}
}
-(void)setVariant:(BUYProductVariant *)variant{
_variant = variant;
if(_variant){
self.lbPrice.text = _variant.price.stringValue;
}
}
@end
<?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">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="KWMWishCell">
<rect key="frame" x="0.0" y="0.0" width="375" height="179"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="375" height="178.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UhZ-gR-v2o" userLabel="商品详细">
<rect key="frame" x="0.0" y="0.0" width="375" height="140"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_loading" translatesAutoresizingMaskIntoConstraints="NO" id="YKX-cf-Y6c">
<rect key="frame" x="20" y="20" width="100" height="100"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="HZx-IC-ouP"/>
<constraint firstAttribute="height" constant="100" id="VCs-Fe-0gq"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fkv-Fb-e1b">
<rect key="frame" x="335" y="15" width="25" height="25"/>
<constraints>
<constraint firstAttribute="height" constant="25" id="Dxa-8E-eQY"/>
<constraint firstAttribute="width" constant="25" id="ZCV-Qs-Dhm"/>
</constraints>
<state key="normal" image="ic_shopcar_delete"/>
<connections>
<action selector="onClickRemove:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="b3k-Er-bYc"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lwu-GC-T13">
<rect key="frame" x="150" y="32" width="185" height="31"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="22"/>
<color key="textColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pGi-mt-A0F">
<rect key="frame" x="150" y="63" width="185" height="21"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="15"/>
<color key="textColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="b4r-kH-eDR">
<rect key="frame" x="150" y="87" width="185" height="21"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="15"/>
<color key="textColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Slw-9e-X3r">
<rect key="frame" x="335" y="86" width="25" height="25"/>
<constraints>
<constraint firstAttribute="width" constant="25" id="Sss-m3-Hhh"/>
<constraint firstAttribute="height" constant="25" id="re3-EQ-63C"/>
</constraints>
<state key="normal" image="ic_shopcart_edit"/>
<connections>
<action selector="onClickEdit:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="sVp-AP-tP2"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="YKX-cf-Y6c" firstAttribute="top" secondItem="UhZ-gR-v2o" secondAttribute="top" constant="20" id="I3N-Q5-Qhi"/>
<constraint firstAttribute="trailing" secondItem="fkv-Fb-e1b" secondAttribute="trailing" constant="15" id="Kis-6h-Lcw"/>
<constraint firstAttribute="trailing" secondItem="pGi-mt-A0F" secondAttribute="trailing" constant="40" id="MEn-Ak-Gqj"/>
<constraint firstAttribute="trailing" secondItem="b4r-kH-eDR" secondAttribute="trailing" constant="40" id="OcI-Rp-7Zu"/>
<constraint firstItem="lwu-GC-T13" firstAttribute="top" secondItem="fkv-Fb-e1b" secondAttribute="bottom" constant="-8" id="OkJ-Q5-7e6"/>
<constraint firstItem="YKX-cf-Y6c" firstAttribute="leading" secondItem="UhZ-gR-v2o" secondAttribute="leading" constant="20" id="Shk-aZ-Z7S"/>
<constraint firstItem="fkv-Fb-e1b" firstAttribute="top" secondItem="UhZ-gR-v2o" secondAttribute="top" constant="15" id="UZ3-NR-Po3"/>
<constraint firstAttribute="trailing" secondItem="lwu-GC-T13" secondAttribute="trailing" constant="40" id="ZyI-Ke-DVh"/>
<constraint firstItem="b4r-kH-eDR" firstAttribute="top" secondItem="pGi-mt-A0F" secondAttribute="bottom" constant="3" id="cIP-eI-xVz"/>
<constraint firstItem="lwu-GC-T13" firstAttribute="leading" secondItem="YKX-cf-Y6c" secondAttribute="trailing" constant="30" id="gUm-YZ-7Xs"/>
<constraint firstItem="pGi-mt-A0F" firstAttribute="top" secondItem="lwu-GC-T13" secondAttribute="bottom" id="gwn-2y-s9B"/>
<constraint firstItem="Slw-9e-X3r" firstAttribute="bottom" secondItem="b4r-kH-eDR" secondAttribute="bottom" constant="3" id="mRV-6R-84c"/>
<constraint firstItem="pGi-mt-A0F" firstAttribute="leading" secondItem="YKX-cf-Y6c" secondAttribute="trailing" constant="30" id="oeN-bN-Be9"/>
<constraint firstAttribute="trailing" secondItem="Slw-9e-X3r" secondAttribute="trailing" constant="15" id="u5X-sy-mT9"/>
<constraint firstAttribute="height" constant="140" id="vnx-Hl-FlH"/>
<constraint firstItem="b4r-kH-eDR" firstAttribute="leading" secondItem="YKX-cf-Y6c" secondAttribute="trailing" constant="30" id="xy1-o6-oxN"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SGa-zN-fJF" userLabel="加入购物车">
<rect key="frame" x="0.0" y="140" width="375" height="28.5"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Y7k-T4-RT7">
<rect key="frame" x="0.0" y="0.0" width="114" height="28.5"/>
<constraints>
<constraint firstAttribute="width" constant="114" id="kix-hp-cCO"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/>
<inset key="titleEdgeInsets" minX="10" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="加入购物车" image="ic_add">
<color key="titleColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="onClickAddToShopCart:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="rfa-Kz-7uw"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RAF-IE-sba" userLabel="line">
<rect key="frame" x="0.0" y="0.0" width="375" height="1"/>
<color key="backgroundColor" red="0.84705882352941175" green="0.85882352941176465" blue="0.87058823529411766" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="jhk-NZ-t6U"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kY3-u6-T1c">
<rect key="frame" x="349.5" y="3.5" width="5.5" height="22.5"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="16"/>
<color key="textColor" red="0.94509803921568625" green="0.5725490196078431" blue="0.60392156862745094" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="kY3-u6-T1c" secondAttribute="trailing" constant="20" id="9aL-8y-0a5"/>
<constraint firstItem="RAF-IE-sba" firstAttribute="leading" secondItem="SGa-zN-fJF" secondAttribute="leading" id="BEd-41-Cuv"/>
<constraint firstItem="RAF-IE-sba" firstAttribute="top" secondItem="SGa-zN-fJF" secondAttribute="top" id="Pfb-gw-KXt"/>
<constraint firstItem="Y7k-T4-RT7" firstAttribute="top" secondItem="SGa-zN-fJF" secondAttribute="top" id="Z46-xI-kjk"/>
<constraint firstItem="kY3-u6-T1c" firstAttribute="centerY" secondItem="SGa-zN-fJF" secondAttribute="centerY" id="aUm-El-pRk"/>
<constraint firstItem="Y7k-T4-RT7" firstAttribute="leading" secondItem="SGa-zN-fJF" secondAttribute="leading" id="nfq-jr-9Zy"/>
<constraint firstAttribute="bottom" secondItem="Y7k-T4-RT7" secondAttribute="bottom" id="p7z-Ig-h9Z"/>
<constraint firstAttribute="trailing" secondItem="RAF-IE-sba" secondAttribute="trailing" id="tGn-Sd-eIq"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.95686274509803915" green="0.96078431372549022" blue="0.96862745098039216" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="SGa-zN-fJF" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="5mm-Vz-SLd"/>
<constraint firstAttribute="trailing" secondItem="UhZ-gR-v2o" secondAttribute="trailing" id="DDk-Pb-fyg"/>
<constraint firstItem="UhZ-gR-v2o" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="OwJ-jQ-YFX"/>
<constraint firstAttribute="bottom" secondItem="SGa-zN-fJF" secondAttribute="bottom" constant="10" id="Q23-QQ-qZG"/>
<constraint firstItem="UhZ-gR-v2o" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="VTQ-Y6-8kg"/>
<constraint firstAttribute="trailing" secondItem="SGa-zN-fJF" secondAttribute="trailing" id="Vat-v6-Dmw"/>
<constraint firstItem="SGa-zN-fJF" firstAttribute="top" secondItem="UhZ-gR-v2o" secondAttribute="bottom" id="d33-Vf-Ddx"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="ivProduct" destination="YKX-cf-Y6c" id="v5k-1d-VnN"/>
<outlet property="lbBrand" destination="lwu-GC-T13" id="p4A-GH-W15"/>
<outlet property="lbPrice" destination="kY3-u6-T1c" id="ZzR-qI-0sg"/>
<outlet property="lbTitle" destination="pGi-mt-A0F" id="a57-gH-6WD"/>
<outlet property="lbVariant" destination="b4r-kH-eDR" id="3L7-c6-XjH"/>
</connections>
</tableViewCell>
</objects>
<resources>
<image name="ic_add" width="14" height="14"/>
<image name="ic_loading" width="114" height="118"/>
<image name="ic_shopcar_delete" width="13" height="13"/>
<image name="ic_shopcart_edit" width="12" height="13"/>
</resources>
</document>
......@@ -11,6 +11,7 @@
#import "KWMBeforePayVC.h"
#import "KWMBrandCaramelVC.h"
#import "KWMShareVC.h"
#import "KWMWishListVC.h"
#import "PhotoBroswerVC.h"
#import "KWMUserModel.h"
#import "KWMShoppingCart.h"
......@@ -23,6 +24,14 @@
@property (weak, nonatomic) IBOutlet KWMSecondDetailView *detailView2;
@property (weak, nonatomic) IBOutlet UIButton *btnLike;
@property (weak, nonatomic) IBOutlet UIImageView *ivShare;
@property (nonatomic) BUYProductVariant *variant;
@property (nonatomic) BOOL isLikeVariant;
@end
@implementation KWMNewProductVC
......@@ -47,6 +56,7 @@
}
-(void)initView{
[self.btnLike setImage:[UIImage imageNamed:@"ic_like_unable"] forState:UIControlStateNormal];
self.productId = @(4746085766);
self.detailView1.delegate = self;
[self requestProductDetail];
......@@ -59,6 +69,12 @@
}
-(IBAction)onClickShare:(id)sender{
KWMWishListVC *wishVC = (KWMWishListVC *)[KWMBaseVC findControllerBy:[KWMWishListVC kwmTag] fromStoryboard:@"NewProduct"];
[self.navigationController pushViewController:wishVC animated:YES];
return;
if(self.product){
KWMShareVC *shareVC = (KWMShareVC *)[KWMBaseVC findControllerBy:[KWMShareVC kwmTag] fromStoryboard:@"New"];
shareVC.shareUrl = [NSString stringWithFormat:@"https://www.cemarose.com/products/%@",self.product.handle];
......@@ -70,7 +86,11 @@
}
-(IBAction)onClickLike:(id)sender{
[self showToast:@"LIKE"];
if(self.isLikeVariant){
[self requestRemoveWish];
}else{
[self requestAddWish];
}
}
#pragma mark -- KWMFirstDetailViewDelegate
......@@ -113,6 +133,15 @@
}
#pragma mark - KWMVariantsVCDelegate
-(void)kwm_setVariant:(KWMVariantsVC *)variantsVC variant:(BUYProductVariant *)variant{
self.detailView1.variant = variant;
self.variant = variant;
[self.btnLike setImage:[UIImage imageNamed:@"ic_like"] forState:UIControlStateNormal];
self.isLikeVariant = NO;
[self requestWishList];
}
- (void)kwm_addShopWithVariantId:(NSNumber *)identifier quantity:(NSInteger)quantity variant:(BUYProductVariant *) variant buyNow:(BOOL)buyNow callback:(void (^)(BOOL))callback {
__weak KWMNewProductVC *this = self;
if (!buyNow) {
......@@ -213,16 +242,115 @@
weakSelf.detailView2.isLoadingSameType = NO;
[weakSelf.detailView2 setData:products isSameBrand:NO];
}];
}else{
weakSelf.detailView2.isLoadingSameType = NO;
}
}];
}
-(void)requestWishList{
__weak KWMNewProductVC *weakSelf = self;
NSDictionary *customerDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"customer"];
BUYCustomer *customer = [[BUYCustomer alloc] initWithModelManager:self.client.modelManager JSONDictionary:customerDict];
BUYProductVariant *variant = self.detailView1.variant;
if(!customer || !variant){
return;
}
NSDictionary *parament = @{
@"customer_id":customer.identifier.stringValue,
@"customer_email":customer.email,
@"varaint_id":variant.identifier.stringValue,
@"shop":Shopify_SHOP_DOMAIN
};
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
[weakSelf hideLoading];
[weakSelf showError:error];
};
void(^success)(NSURLSessionDataTask *,KWMAdditionalListResult *) = ^(NSURLSessionDataTask *task,KWMAdditionalListResult *result){
[weakSelf hideLoading];
if(result && result.data){
NSArray *wishArray = (NSArray *)result.data;
if(wishArray.count >0){
UIImage *image = [UIImage imageNamed:@"ic_like_1"];
[weakSelf.btnLike setImage:image forState:UIControlStateNormal];
weakSelf.isLikeVariant = YES;
}
}
};
[self.api getWishList:parament success:success failure:failure];
}
-(void)requestRemoveWish{
__weak KWMNewProductVC *weakSelf = self;
NSDictionary *customerDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"customer"];
BUYCustomer *customer = [[BUYCustomer alloc] initWithModelManager:self.client.modelManager JSONDictionary:customerDict];
BUYProductVariant *variant = self.detailView1.variant;
if(!customer || !variant){
return;
}
NSDictionary *parament = @{
@"customer_id":customer.identifier.stringValue,
@"customer_email":customer.email,
@"variant_id":variant.identifier.stringValue,
@"shop":Shopify_SHOP_DOMAIN
};
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
[weakSelf hideLoading];
[weakSelf showError:error];
};
void(^success)(NSURLSessionDataTask *,KWMAdditionalListResult *) = ^(NSURLSessionDataTask *task,KWMAdditionalListResult *result){
[weakSelf hideLoading];
if(result && result.message){
if([result.message isEqualToString:@"success"] || [result.message isEqualToString:@"wishlist does not exist"]){
UIImage *image = [UIImage imageNamed:@"ic_like"];
[weakSelf.btnLike setImage:image forState:UIControlStateNormal];
weakSelf.isLikeVariant = NO;
}
}
};
[self.api removeWish:parament success:success failure:failure];
[self showLoading];
}
-(void)requestAddWish{
__weak KWMNewProductVC *weakSelf = self;
NSDictionary *customerDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"customer"];
BUYCustomer *customer = [[BUYCustomer alloc] initWithModelManager:self.client.modelManager JSONDictionary:customerDict];
if(!customer || !self.variant){
return;
}
NSDictionary *parament = @{
@"customer_id":customer.identifier.stringValue,
@"customer_email":customer.email,
@"customer_name":customer.lastName,
@"product_title":self.product.title,
@"product_id":self.product.identifier.stringValue,
@"variant_id":self.variant.identifier.stringValue,
@"variant_sku":self.variant.sku,
@"variant_title":self.variant.title,
@"product_handle":self.product.handle,
@"shop":Shopify_SHOP_DOMAIN
};
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
[weakSelf hideLoading];
[weakSelf showError:error];
};
void(^success)(NSURLSessionDataTask *,KWMAdditionalListResult *) = ^(NSURLSessionDataTask *task,KWMAdditionalListResult *result){
[weakSelf hideLoading];
if(result && result.message && [result.message isEqualToString:@"success"]){
if([result.message isEqualToString:@"success"] || [result.message isEqualToString:@"wishlist already exist"]){
UIImage *image = [UIImage imageNamed:@"ic_like_1"];
[weakSelf.btnLike setImage:image forState:UIControlStateNormal];
weakSelf.isLikeVariant = YES;
}
}
};
[self.api saveWish:parament success:success failure:failure];
[self showLoading];
}
@end
......@@ -12,11 +12,15 @@
#import "KWMSizeCell.h"
#import "KWMShopCartData.h"
#import "KWMVariants.h"
#import "KWMWish.h"
@class KWMVariantsVC;
@protocol KWMVariantsVCDelegate <NSObject>
- (void)kwm_addShopWithVariantId:(NSNumber *) identifier quantity:(NSInteger) quantity variant:(BUYProductVariant *) variant buyNow:(BOOL) buyNow callback:(void(^)(BOOL)) callback;
- (void)kwm_setVariant:(KWMVariantsVC *)variantsVC variant:(BUYProductVariant *)variant;
@end
@interface KWMVariantsVC : KWMBaseVC<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
......@@ -31,5 +35,6 @@
@property (nonatomic) BUYProduct *product;
@property (nonatomic) KWMWish *wish;
@end
......@@ -179,21 +179,24 @@
[self showToast:@"请选择您想要的规格"];
return;
}
if (self.product && !self.product.JSONDictionary){
[self showToast:@"该商品信息缺失"];
return;
}
BOOL buyNow = sender.tag == 1;
__weak id this = self;
[self showLoading];
if (self.delegate) {
[self.delegate kwm_addShopWithVariantId:self.selectVariant.identifier quantity:self.count variant:self.selectVariant buyNow:buyNow callback:^(BOOL success) {
[self hideLoading];
if(success) {
[this dismissViewControllerAnimated:YES completion:nil];
}
}];
}
// if (self.product && !self.product.JSONDictionary){
// [self showToast:@"该商品信息缺失"];
// return;
// }
// BOOL buyNow = sender.tag == 1;
// __weak id this = self;
// [self showLoading];
// if (self.delegate) {
// [self.delegate kwm_addShopWithVariantId:self.selectVariant.identifier quantity:self.count variant:self.selectVariant buyNow:buyNow callback:^(BOOL success) {
// [self hideLoading];
// if(success) {
// [this dismissViewControllerAnimated:YES completion:nil];
// }
// }];
// }
//现在不是添加到购物车了,而是显示在商品详情页。
[self.delegate kwm_setVariant:self variant:self.selectVariant];
[self dismissViewControllerAnimated:YES completion:nil];
}
-(IBAction)onClickBg:(id)sender{
......
//
// KWMWishListVC.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseVC.h"
#import "KWMWishCell.h"
#import "KWMVariantsVC.h"
@interface KWMWishListVC : KWMBaseVC<UITableViewDelegate,UITableViewDataSource,KWMWishCellDelegate,KWMVariantsVCDelegate>
@end
//
// KWMWishListVC.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMWishListVC.h"
#import "KWMShoppingCart.h"
#import "KWMImageUtil.h"
#import "KWMStringUtil.h"
#import "KWMShopCartModel.h"
@interface KWMWishListVC ()
@property (weak,nonatomic) IBOutlet UILabel *lbTotalPrice;
@property (weak,nonatomic) IBOutlet UITableView *tbvWish;
@property(nonatomic) NSMutableArray *wishArray;
@property(nonatomic) NSMutableArray *productArray;
@end
@implementation KWMWishListVC
+(NSString *)kwmTag{
return @"KWMWishListVC";
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initView];
[self requestWishList];
}
- (void)initView{
self.title = @"我喜欢的";
[self.tbvWish registerNib:[UINib nibWithNibName:NSStringFromClass([KWMWishCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([KWMWishCell class])];
self.wishArray = [NSMutableArray array];
self.productArray = [NSMutableArray array];
[self setTotalPrice];
}
-(void)removeWish:(NSNumber *)variantId{
for(KWMWish *wish in self.wishArray){
if([wish.variantId isEqualToNumber:variantId]){
[self.wishArray removeObject:wish];
}
}
}
//计算总价格
- (void) setTotalPrice{
NSArray *shopCartList = (NSMutableArray *)[[KWMShoppingCart sharedInstance] items];
NSDecimalNumber *total = [NSDecimalNumber decimalNumberWithDecimal:@(0).decimalValue];
for (KWMShopCartModel *model in shopCartList) {
if (model.line_price) {
total = [total decimalNumberByAdding:model.line_price.priceValue];
}else{
total = [total decimalNumberByAdding:[model.price.priceValue decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithString:@(model.quantity).stringValue]]];
}
}
self.lbTotalPrice.text = total.priceFormatted;
}
#pragma mark --KWMVariantsVCDelegate
-(void)kwm_setVariant:(KWMVariantsVC *)variantsVC variant:(BUYProductVariant *)variant{
for(KWMWish *wish in self.wishArray){
if([wish.variantId isEqualToNumber:variantsVC.wish.variantId]){
wish.variantId = variant.identifier;
wish.variantSku = variant.sku;
wish.variantTitle = variant.title;
[self.tbvWish reloadData];
}
}
}
#pragma mark --KWMWishCellDelegate
-(void)kwm_onClickEdit:(KWMWishCell *)wishCell{
//此edit并没有请求API,而只是暂时的在本页面修改wish,参考网页端cemarose。
KWMVariantsVC *variantsVC = (KWMVariantsVC *)[KWMVariantsVC findControllerBy:[KWMVariantsVC kwmTag] fromStoryboard:@"NewProduct"];
variantsVC.wish = wishCell.wish;
variantsVC.product = wishCell.product;
variantsVC.delegate = self;
CGSize size = [UIScreen mainScreen].bounds.size;
[self showPresentation:variantsVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade];
}
-(void)kwm_onClickRemove:(KWMWishCell *)wishCell{
[self requestRemoveWish:wishCell.wish.variantId];
}
-(void)kwm_onClickAddToShopCart:(KWMWishCell *)wishCell{
if(!self.productArray){
[self requestProductsApi];
return;
}
NSNumber *variantId = wishCell.wish.variantId;
BUYProduct *product = wishCell.product;
BUYProductVariant *variant = wishCell.variant;
if(!product || !variant){
return;
}
__weak KWMWishListVC *this = self;
[[KWMShoppingCart sharedInstance] increaseProductWithVariantId:variantId quantity:1 callback:^(NSError *error, KWMCartResult *cart) {
if (cart.items.firstObject && !cart.items.firstObject.product_id) {
KWMShopCartModel *model = cart.items.firstObject;
BUYImageLink *il = product.images.firstObject;
model.imageStr = [KWMImageUtil getProductImageUrlByOriginalUrl:il.sourceURL.absoluteString ImageSize:NormalImage];
model.name = product.title;
model.brand = product.vendor;
model.size = variant.title;
model.price = variant.price;
model.product_id = product.identifier;
}
if (!error) {
// [this showToast:@"添加成功"];
[this setTotalPrice];
//[this.btnShopCart setTitle:cart.item_count.stringValue forState:UIControlStateNormal];
//callback(YES);
}else{
[this showError:error];
//callback(NO);
}
}];
}
#pragma mark --UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.wishArray ? self.wishArray.count:0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
KWMWishCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([KWMWishCell class]) forIndexPath:indexPath];
KWMWish *wish = [self.wishArray objectAtIndex:indexPath.row];
BUYProduct *product;
BUYProductVariant *variant;
if(self.productArray){
for(BUYProduct *mProduct in self.productArray){
if([mProduct.identifier isEqualToNumber:wish.productId]){
product = mProduct;
}
}
}
if(product){
for(BUYProductVariant *mVariant in product.variantsArray){
if([mVariant.identifier isEqualToNumber:wish.variantId]){
variant = mVariant;
break;
}
}
}
cell.wish = wish;
cell.variant = variant;
cell.product = product;
cell.delegate = self;
return cell;
}
#pragma mark-- KWMAPIManager
-(void)requestWishList{
__weak KWMWishListVC *weakSelf = self;
NSDictionary *customerDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"customer"];
BUYCustomer *customer = [[BUYCustomer alloc] initWithModelManager:self.client.modelManager JSONDictionary:customerDict];
if(!customer){
return;
}
NSDictionary *parament = @{
@"customer_id":customer.identifier.stringValue,
@"customer_email":customer.email,
@"shop":Shopify_SHOP_DOMAIN
};
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
[weakSelf hideLoading];
[weakSelf showError:error];
};
void(^success)(NSURLSessionDataTask *,KWMAdditionalListResult *) = ^(NSURLSessionDataTask *task,KWMAdditionalListResult *result){
[weakSelf hideLoading];
if(result && result.data){
NSMutableArray *wishArray = (NSMutableArray *)result.data;
weakSelf.wishArray = wishArray;
[weakSelf.tbvWish reloadData];
[weakSelf requestProductsApi];
}
};
[self.api getWishList:parament success:success failure:failure];
[self showLoading];
}
-(void)requestRemoveWish:(NSNumber *)variantId{
__weak KWMWishListVC *weakSelf = self;
NSDictionary *customerDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"customer"];
BUYCustomer *customer = [[BUYCustomer alloc] initWithModelManager:self.client.modelManager JSONDictionary:customerDict];
if(!customer || !variantId){
return;
}
NSDictionary *parament = @{
@"customer_id":customer.identifier.stringValue,
@"customer_email":customer.email,
@"variant_id":variantId.stringValue,
@"shop":Shopify_SHOP_DOMAIN
};
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
[weakSelf hideLoading];
[weakSelf showError:error];
};
void(^success)(NSURLSessionDataTask *,KWMAdditionalListResult *) = ^(NSURLSessionDataTask *task,KWMAdditionalListResult *result){
[weakSelf hideLoading];
if(result && result.message){
if([result.message isEqualToString:@"success"] || [result.message isEqualToString:@"wishlist does not exist"]){
[weakSelf removeWish:variantId];
}
}
};
[self.api removeWish:parament success:success failure:failure];
[self showLoading];
}
#pragma mark-- BuyClient+storefront.h
-(void)requestProductsApi{
NSMutableArray *productIds = [NSMutableArray array];
for(KWMWish *wish in self.wishArray){
[productIds addObject:wish.productId];
}
if(productIds.count == 0){
return;
}
__weak KWMWishListVC *weakSelf = self;
NSArray *productIdsArray = [KWMStringUtil splitArray:productIds withSubSize:50];
for(NSArray *mProductIds in productIdsArray){
//经过测试,该api一次最多返回50个product,所以如果有100个商品,需要分成两次请求
[self.client getProductsByIds:mProductIds completion:^(NSArray<BUYProduct *> * _Nullable products, NSError * _Nullable error) {
[weakSelf hideLoading];
if (!error && products && products.count>0) {
[weakSelf.productArray addObjectsFromArray:products];
[weakSelf.tbvWish reloadData];
weakSelf.tbvWish.hidden = NO;
}else if (error){
[weakSelf showError:error];
}
}];
}
[self showLoading];
}
@end
......@@ -210,6 +210,7 @@
</constraints>
</view>
<connections>
<outlet property="btnLike" destination="jLv-Vv-7Vi" id="sep-kb-Y2L"/>
<outlet property="detailView1" destination="2KH-pA-K5l" id="ynO-by-UfZ"/>
<outlet property="detailView2" destination="pyO-1P-iAa" id="scJ-Iv-fnz"/>
</connections>
......@@ -500,7 +501,128 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="MKE-1G-zhs" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="885.60000000000002" y="164.16791604197903"/>
<point key="canvasLocation" x="1034" y="90"/>
</scene>
<!--我喜欢的-->
<scene sceneID="D2D-DR-hOl">
<objects>
<viewController storyboardIdentifier="KWMWishListVC" hidesBottomBarWhenPushed="YES" useStoryboardIdentifierAsRestorationIdentifier="YES" id="fOt-KO-9Ov" userLabel="我喜欢的" customClass="KWMWishListVC" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="KQ2-7z-UzJ"/>
<viewControllerLayoutGuide type="bottom" id="Dfj-Ng-EjS"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="UGP-zP-RNr">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView hidden="YES" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="174" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="Gm0-oI-7rN">
<rect key="frame" x="0.0" y="10" width="375" height="539"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<connections>
<outlet property="dataSource" destination="fOt-KO-9Ov" id="Bcs-TC-UeS"/>
<outlet property="delegate" destination="fOt-KO-9Ov" id="zUC-zC-t5H"/>
</connections>
</tableView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kFe-LP-nvv" userLabel="vPrice">
<rect key="frame" x="0.0" y="549" width="375" height="118"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥ 0.00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SFr-ds-7t9">
<rect key="frame" x="157.5" y="15" width="60.5" height="28"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="20"/>
<color key="textColor" red="0.94509803920000002" green="0.57254901960000004" blue="0.60392156860000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="b33-Xg-vbc">
<rect key="frame" x="40" y="53" width="295" height="50"/>
<subviews>
<button opaque="NO" tag="1" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5Rk-6T-lK0">
<rect key="frame" x="0.0" y="0.0" width="118" height="50"/>
<state key="normal" title="快速购买">
<color key="titleColor" red="0.22352941179999999" green="0.22352941179999999" blue="0.22352941179999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uc2-hz-nIz">
<rect key="frame" x="118" y="0.0" width="177" height="50"/>
<color key="backgroundColor" red="0.14117647059999999" green="0.14117647059999999" blue="0.14117647059999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="15"/>
<state key="normal" title="加入购物车">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="uc2-hz-nIz" firstAttribute="width" secondItem="5Rk-6T-lK0" secondAttribute="width" multiplier="1.5" id="Dp4-gn-Ic1"/>
<constraint firstAttribute="trailing" secondItem="uc2-hz-nIz" secondAttribute="trailing" id="IlD-Oa-JxK"/>
<constraint firstAttribute="height" constant="50" id="JPb-LF-Swj"/>
<constraint firstAttribute="bottom" secondItem="uc2-hz-nIz" secondAttribute="bottom" id="ObQ-bk-z6W"/>
<constraint firstItem="5Rk-6T-lK0" firstAttribute="top" secondItem="b33-Xg-vbc" secondAttribute="top" id="Tqm-xC-wWw"/>
<constraint firstAttribute="bottom" secondItem="5Rk-6T-lK0" secondAttribute="bottom" id="XFg-8n-6SS"/>
<constraint firstItem="5Rk-6T-lK0" firstAttribute="leading" secondItem="b33-Xg-vbc" secondAttribute="leading" id="cH2-y9-NT5"/>
<constraint firstItem="uc2-hz-nIz" firstAttribute="top" secondItem="b33-Xg-vbc" secondAttribute="top" id="nUo-Bu-QeP"/>
<constraint firstItem="uc2-hz-nIz" firstAttribute="leading" secondItem="5Rk-6T-lK0" secondAttribute="trailing" id="xkK-SZ-cVd"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KME-g8-0dp">
<rect key="frame" x="40" y="53" width="295" height="50"/>
<color key="backgroundColor" red="0.14117647059999999" green="0.14117647059999999" blue="0.14117647059999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="5Wx-pY-Hib"/>
</constraints>
<state key="normal" title="结算">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="b66-L6-qYh" userLabel="line">
<rect key="frame" x="0.0" y="0.0" width="375" height="1"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.85882352939999995" blue="0.87058823529999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="y89-fj-aLL"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="b33-Xg-vbc" secondAttribute="bottom" constant="15" id="25Q-5u-k6H"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="118" id="5lP-r0-Suh"/>
<constraint firstItem="SFr-ds-7t9" firstAttribute="centerX" secondItem="kFe-LP-nvv" secondAttribute="centerX" id="7va-KE-hxf"/>
<constraint firstItem="b66-L6-qYh" firstAttribute="top" secondItem="kFe-LP-nvv" secondAttribute="top" id="AJX-Ay-uGf"/>
<constraint firstItem="b66-L6-qYh" firstAttribute="leading" secondItem="kFe-LP-nvv" secondAttribute="leading" id="HbJ-cy-ROs"/>
<constraint firstAttribute="height" constant="118" id="L0W-aN-7LN"/>
<constraint firstItem="SFr-ds-7t9" firstAttribute="top" secondItem="kFe-LP-nvv" secondAttribute="top" constant="15" id="No5-OE-AqH"/>
<constraint firstAttribute="trailing" secondItem="KME-g8-0dp" secondAttribute="trailing" constant="40" id="TUa-ke-dHk"/>
<constraint firstAttribute="bottom" secondItem="KME-g8-0dp" secondAttribute="bottom" constant="15" id="nJO-b2-P19"/>
<constraint firstAttribute="trailing" secondItem="b66-L6-qYh" secondAttribute="trailing" id="oHD-39-dga"/>
<constraint firstItem="KME-g8-0dp" firstAttribute="leading" secondItem="kFe-LP-nvv" secondAttribute="leading" constant="40" id="ofB-zy-yf5"/>
<constraint firstAttribute="trailing" secondItem="b33-Xg-vbc" secondAttribute="trailing" constant="40" id="qX5-9n-DbR"/>
<constraint firstItem="b33-Xg-vbc" firstAttribute="leading" secondItem="kFe-LP-nvv" secondAttribute="leading" constant="40" id="rSA-eO-SYD"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="5lP-r0-Suh"/>
</mask>
</variation>
</view>
</subviews>
<color key="backgroundColor" red="0.95686274509803915" green="0.96078431372549022" blue="0.96862745098039216" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="kFe-LP-nvv" firstAttribute="leading" secondItem="UGP-zP-RNr" secondAttribute="leading" id="9TG-wq-MX9"/>
<constraint firstItem="Gm0-oI-7rN" firstAttribute="leading" secondItem="UGP-zP-RNr" secondAttribute="leading" id="K3h-xm-oGl"/>
<constraint firstItem="Gm0-oI-7rN" firstAttribute="top" secondItem="UGP-zP-RNr" secondAttribute="top" constant="10" id="R3B-xM-pgh"/>
<constraint firstAttribute="trailing" secondItem="kFe-LP-nvv" secondAttribute="trailing" id="RR3-mH-23B"/>
<constraint firstAttribute="trailing" secondItem="Gm0-oI-7rN" secondAttribute="trailing" id="Ybf-hR-Ibz"/>
<constraint firstItem="kFe-LP-nvv" firstAttribute="top" secondItem="Gm0-oI-7rN" secondAttribute="bottom" id="yvS-NU-8xK"/>
<constraint firstAttribute="bottom" secondItem="kFe-LP-nvv" secondAttribute="bottom" id="zBx-sm-Y8E"/>
</constraints>
</view>
<connections>
<outlet property="lbTotalPrice" destination="SFr-ds-7t9" id="MJr-m5-hj9"/>
<outlet property="tbvWish" destination="Gm0-oI-7rN" id="gcz-oK-W6j"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="rrc-zM-ZFg" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="337" y="58"/>
</scene>
</scenes>
<resources>
......
......@@ -51,9 +51,10 @@
+ (NSString *)price:(NSNumber *)price;
//欧元转人民币
//+ (NSString *)getEUR2CNYstring:(NSNumber *)price;
+ (NSArray *)splitArray:(NSArray *)array withSubSize:(NSInteger)subSize;
@end
......@@ -507,4 +507,28 @@ static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu
return [NSString stringWithFormat:@"¥ %@",CNYstring];
}
+ (NSArray *)splitArray:(NSArray *)array withSubSize:(NSInteger)subSize{
//拆分后的数组个数
NSInteger count = array.count % subSize == 0?(array.count /subSize): (array.count / subSize + 1);
NSMutableArray *arr = [NSMutableArray array];
for (int i = 0; i < count; i ++) {
//数组下标
NSInteger index = i * subSize;
//保存拆分的固定长度的数组元素的可变数组
NSMutableArray *arr1 = [[NSMutableArray alloc] init];
//移除子数组的所有元素
[arr1 removeAllObjects];
NSInteger j = index;
//将数组下标乘以1、2、3,得到拆分时数组的最大下标值,但最大不能超过数组的总大小
while (j < subSize*(i + 1) && j < array.count) {
[arr1 addObject:[array objectAtIndex:j]];
j += 1;
}
//将子数组添加到保存子数组的数组中
[arr addObject:[arr1 copy]];
}
return [arr copy];
}
@end
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