Commit 70bc6c29 by lee

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

parents 9f44a471 a16a259b
......@@ -99,6 +99,8 @@
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 */; };
C02C5A931FD54C7D00E32290 /* KWMRecommendView.m in Sources */ = {isa = PBXBuildFile; fileRef = C02C5A901FD54C7C00E32290 /* KWMRecommendView.m */; };
C02C5A941FD54C7D00E32290 /* KWMRecommendView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C02C5A911FD54C7C00E32290 /* KWMRecommendView.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 */; };
......@@ -221,10 +223,8 @@
C04834371F1325CB00A5BFB4 /* KWMHotSalesHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = C04834361F1325CB00A5BFB4 /* KWMHotSalesHeader.m */; };
C048343B1F13274300A5BFB4 /* KWMNewHomeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = C04834391F13274300A5BFB4 /* KWMNewHomeVC.m */; };
C048343E1F13288F00A5BFB4 /* KWMMenuHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = C048343D1F13288F00A5BFB4 /* KWMMenuHeader.xib */; };
C04834411F13350F00A5BFB4 /* KWMRecommendHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = C04834401F13350F00A5BFB4 /* KWMRecommendHeader.m */; };
C04834451F1337A800A5BFB4 /* KWMNewHomeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C04834431F1337A800A5BFB4 /* KWMNewHomeCell.m */; };
C04834461F1337A800A5BFB4 /* KWMNewHomeCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C04834441F1337A800A5BFB4 /* KWMNewHomeCell.xib */; };
C04834481F1338F200A5BFB4 /* KWMRecommendHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = C04834471F1338F200A5BFB4 /* KWMRecommendHeader.xib */; };
C048344A1F13391A00A5BFB4 /* KWMClothingSetsHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = C04834491F13391A00A5BFB4 /* KWMClothingSetsHeader.xib */; };
C048344C1F13393D00A5BFB4 /* KWMHotSalesHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = C048344B1F13393D00A5BFB4 /* KWMHotSalesHeader.xib */; };
C04834531F13590500A5BFB4 /* KWMProductBannerItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = C048344E1F13590500A5BFB4 /* KWMProductBannerItemView.m */; };
......@@ -544,6 +544,9 @@
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>"; };
C02C5A901FD54C7C00E32290 /* KWMRecommendView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMRecommendView.m; sourceTree = "<group>"; };
C02C5A911FD54C7C00E32290 /* KWMRecommendView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMRecommendView.xib; sourceTree = "<group>"; };
C02C5A921FD54C7D00E32290 /* KWMRecommendView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMRecommendView.h; 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>"; };
......@@ -768,12 +771,9 @@
C04834381F13274300A5BFB4 /* KWMNewHomeVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMNewHomeVC.h; sourceTree = "<group>"; };
C04834391F13274300A5BFB4 /* KWMNewHomeVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMNewHomeVC.m; sourceTree = "<group>"; };
C048343D1F13288F00A5BFB4 /* KWMMenuHeader.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMMenuHeader.xib; sourceTree = "<group>"; };
C048343F1F13350F00A5BFB4 /* KWMRecommendHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMRecommendHeader.h; sourceTree = "<group>"; };
C04834401F13350F00A5BFB4 /* KWMRecommendHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMRecommendHeader.m; sourceTree = "<group>"; };
C04834421F1337A800A5BFB4 /* KWMNewHomeCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMNewHomeCell.h; sourceTree = "<group>"; };
C04834431F1337A800A5BFB4 /* KWMNewHomeCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMNewHomeCell.m; sourceTree = "<group>"; };
C04834441F1337A800A5BFB4 /* KWMNewHomeCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMNewHomeCell.xib; sourceTree = "<group>"; };
C04834471F1338F200A5BFB4 /* KWMRecommendHeader.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMRecommendHeader.xib; sourceTree = "<group>"; };
C04834491F13391A00A5BFB4 /* KWMClothingSetsHeader.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMClothingSetsHeader.xib; sourceTree = "<group>"; };
C048344B1F13393D00A5BFB4 /* KWMHotSalesHeader.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMHotSalesHeader.xib; sourceTree = "<group>"; };
C048344D1F13590500A5BFB4 /* KWMProductBannerItemView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMProductBannerItemView.h; sourceTree = "<group>"; };
......@@ -1514,6 +1514,9 @@
C0DD53261EE55190002D1E0C /* Loading */,
C034E7C31D6B10A0006EE129 /* CorePhotoBroswer */,
C034E8381D6B10A0006EE129 /* EGO */,
C02C5A921FD54C7D00E32290 /* KWMRecommendView.h */,
C02C5A901FD54C7C00E32290 /* KWMRecommendView.m */,
C02C5A911FD54C7C00E32290 /* KWMRecommendView.xib */,
C0AF03981DD5BFB20060623F /* UIViewController+BackButtonHandler.h */,
C0AF03991DD5BFB20060623F /* UIViewController+BackButtonHandler.m */,
C04834211F13215500A5BFB4 /* KWMBannerView.h */,
......@@ -2004,9 +2007,6 @@
C048343D1F13288F00A5BFB4 /* KWMMenuHeader.xib */,
C048342C1F13254200A5BFB4 /* KWMMenuHeader.h */,
C048342D1F13254200A5BFB4 /* KWMMenuHeader.m */,
C04834471F1338F200A5BFB4 /* KWMRecommendHeader.xib */,
C048343F1F13350F00A5BFB4 /* KWMRecommendHeader.h */,
C04834401F13350F00A5BFB4 /* KWMRecommendHeader.m */,
C04834491F13391A00A5BFB4 /* KWMClothingSetsHeader.xib */,
C04834321F1325A000A5BFB4 /* KWMClothingSetsHeader.h */,
C04834331F1325A000A5BFB4 /* KWMClothingSetsHeader.m */,
......@@ -2436,7 +2436,7 @@
C0F586771E24F820001248E2 /* KWMCollectionCell.xib in Resources */,
C0243BBD1EFBD5A10013CFA7 /* Category.storyboard in Resources */,
C0F586791E24F820001248E2 /* KWMDetailCell.xib in Resources */,
C04834481F1338F200A5BFB4 /* KWMRecommendHeader.xib in Resources */,
C02C5A941FD54C7D00E32290 /* KWMRecommendView.xib in Resources */,
C0F5867F1E24F820001248E2 /* KWMNewGoodsCell.xib in Resources */,
C0DD53101EE54A9E002D1E0C /* KWMBarandSelectView.xib in Resources */,
C066650C1D75A2E500F02EF4 /* Mine.storyboard in Resources */,
......@@ -2592,7 +2592,6 @@
DA4E36981F17729C0007E4D0 /* KWMCategoryModel.m in Sources */,
C048B8E21EF3C04B000DA7AF /* KWMBeforePayData.m in Sources */,
C03846941DB89EEB008C3BAB /* KWMCemaroseResult.m in Sources */,
C04834411F13350F00A5BFB4 /* KWMRecommendHeader.m in Sources */,
C0F586871E24F820001248E2 /* KWMNewTypeSelectedVC.m in Sources */,
80598D471D99193400BF0F97 /* KWMInformationVC.m in Sources */,
C034E7B91D6B0A8D006EE129 /* KWMHomeVC.m in Sources */,
......@@ -2663,6 +2662,7 @@
C0F586781E24F820001248E2 /* KWMDetailCell.m in Sources */,
C03120AD1EF2AC6700E49EFA /* KWMCheckoutPayResult.m in Sources */,
801F87BF1DD1D6850038FA4C /* KWMLoadStatus.m in Sources */,
C02C5A931FD54C7D00E32290 /* KWMRecommendView.m in Sources */,
C03943C31DD1FD3F00141475 /* KWMProductTypeResult.m in Sources */,
804771851D6D585B0086B4DC /* KWMValidationVC.m in Sources */,
80ED0A4F1D93BD0E00B28DF2 /* KWMShopCartModel.m in Sources */,
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_choose_nor@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_choose_nor@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_choose_sel@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_choose_sel@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" 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="13174"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
......
......@@ -11,7 +11,7 @@
#import <CHTCollectionViewWaterfallLayout.h>
#import "KWMAdHeader.h"
#import "KWMMenuHeader.h"
#import "KWMRecommendHeader.h"
#import "KWMRecommendView.h"
#import "KWMClothingSetsHeader.h"
#import "KWMHotSalesHeader.h"
......
......@@ -45,7 +45,7 @@ typedef enum{
@property(nonatomic,strong) KWMMenuHeader *menuHeader;
@property(nonatomic,strong) KWMRecommendHeader *recommendHeader;
@property(nonatomic,strong) KWMRecommendView *recommendHeader;
@property(nonatomic,strong) KWMClothingSetsHeader *clothingSetsHeader;
......@@ -110,7 +110,7 @@ typedef enum{
heightHotSale = UI_SCREEN_WIDTH * 190 / 375 + 60;//60为图片外的布局高度
self.adHeader = [[KWMAdHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, heightAdHeader)];
self.menuHeader = [[KWMMenuHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 100)];
self.recommendHeader = [[KWMRecommendHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 230)];
self.recommendHeader = [[KWMRecommendView alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 230)];
self.clothingSetsHeader = [[KWMClothingSetsHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, heightClothingSets)];
self.hotSalesHeader = [[KWMHotSalesHeader alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, heightHotSale)];
......@@ -145,7 +145,7 @@ typedef enum{
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMAdHeader kwmTag]];
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMHotSalesHeader kwmTag]];
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMRecommendHeader kwmTag]];
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMRecommendView kwmTag]];
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMClothingSetsHeader kwmTag]];
[self.cvHome registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMMenuHeader kwmTag]];
......@@ -194,7 +194,7 @@ typedef enum{
}
#pragma mark - KWMRecommendDelegate
-(void)kwm_gotoRecommendPage{
-(void)kwm_gotoRecommendPage:(KWMRecommendView *)recommendView{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/hot-sell-app?title=主推单品"];
}
......@@ -264,7 +264,7 @@ typedef enum{
}
break;
case HeaderRecommend:
headerView = [collectionView dequeueReusableSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMRecommendHeader kwmTag] forIndexPath:indexPath];
headerView = [collectionView dequeueReusableSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withReuseIdentifier:[KWMRecommendView kwmTag] forIndexPath:indexPath];
if(headerView.subviews.count == 0){
[headerView addSubview:self.recommendHeader];
}
......@@ -341,7 +341,7 @@ typedef enum{
- (void) requestProductWithHandle:(NSString *) handle tags:(NSArray *) tags valueKeyPath:(NSString *) valueKeyPath {
BOOL isHome = [handle isEqualToString:@"products-list-app-homepage"];
NSInteger cpage = isHome ? self.page : 1;
NSDictionary *parameters = [self getProductCacheKeyDictionary:cpage tags:tags handle:handle];
NSDictionary *parameters = [KWMPPCacheUtil getProductCacheKeyDictionary:cpage tags:tags handle:handle];
if(!self.isRefreshUI){
BOOL useProductDataCache = [self useProductDataCache:parameters valueKeyPath:valueKeyPath page:cpage isHome:isHome];
}
......@@ -439,23 +439,6 @@ typedef enum{
}
}
//初始化缓存parameters key
- (NSDictionary *)getProductCacheKeyDictionary:(NSUInteger)page
tags:(nullable NSArray <NSString *> *)tags
handle:(nullable NSString *)handle{
NSMutableDictionary *params = @{
@"limit" : @(self.client.pageSize),
@"page" : @(page)
}.mutableCopy;
if (tags) {
params[@"tag"] = [tags componentsJoinedByString:@","];
}
if (handle) {
params[@"handle"] = handle;
}
return params;
}
//缓存规则:网络请求数据照常,如果没网络,并且缓存有数据,会拿缓存的数据显示。
-(BOOL)useProductDataCache:(NSDictionary *)cacheKeyDictionary valueKeyPath:(NSString *)valueKeyPath page:(NSUInteger)page isHome:(BOOL)isHome{
if(!kIsNetwork || page == 1){
......
......@@ -16,7 +16,7 @@
#import "KWMPayTypeVC.h"
#import "KWMBeforePayData.h"
@interface KWMBeforePayVC : KWMBaseVC<KWMGiftCardDelegate,KWMDiscountDelegate,KWMSelectAddressDelegate,KWMSelectShippingRateDelegate,KWMPayTypeDelegate>
@interface KWMBeforePayVC : KWMBaseVC<KWMGiftCardDelegate,KWMSelectAddressDelegate,KWMSelectShippingRateDelegate,UITextFieldDelegate>
//沒有默認地址時,高度為37,有地址時,高度為90
@property(nonatomic,weak) IBOutlet NSLayoutConstraint *vAddressHeight;
......@@ -33,13 +33,28 @@
@property (weak, nonatomic) IBOutlet UIView *vHasAddress;
@property (weak, nonatomic) IBOutlet UILabel *lbPayType;
//支付方式
@property (weak, nonatomic) IBOutlet UIView *vPayType;
//折扣
@property (weak, nonatomic) IBOutlet UILabel *lbDiscount;
@property (weak, nonatomic) IBOutlet UIImageView *ivAliPay;
@property (weak, nonatomic) IBOutlet UIImageView *ivWechatPay;
//折扣
@property (weak, nonatomic) IBOutlet UILabel *lbGiftCard;
@property (weak, nonatomic) IBOutlet UIButton *btnDiscountCancel;
@property (weak, nonatomic) IBOutlet UIButton *btnDiscountConfirm;
@property (weak, nonatomic) IBOutlet UIButton *btnDiscountEdit;
@property (weak, nonatomic) IBOutlet UITextField *tfDiscount;
@property (weak, nonatomic) IBOutlet UIButton *btnBg;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *marginTopContent;
//价格
@property (weak, nonatomic) IBOutlet UILabel *lbTotalPrice;
@property (weak, nonatomic) IBOutlet UILabel *lbShippingRate;
......@@ -47,8 +62,6 @@
//清关信息
@property (weak, nonatomic) IBOutlet UILabel *lbCustomsClearance;
@property (weak, nonatomic) IBOutlet UIView *vPayType;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightPayType;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightCustomsClearance;
......@@ -87,6 +100,9 @@
- (IBAction)onClickCustomsClearance:(id)sender;
- (IBAction)onClickDiscountConfirm:(id)sender;
- (IBAction)onClickDiscountCancel:(id)sender;
@end
......@@ -25,9 +25,9 @@
#import "KWMShoppingCart.h"
@interface KWMBeforePayVC ()
@property (nonatomic) BOOL isEditingDiscount;
@property (nonatomic) BUYCustomer *customer;
@property (weak, nonatomic) IBOutlet UIButton *submit;
@end
@implementation KWMBeforePayVC
......@@ -49,6 +49,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self initDiscountHintText];
self.title = @"提交订单";
self.payType = [self.userDao.currencyCode isEqualToString:@"EUR"]?TypeWebpay:TypeAlipay;
self.beforePayData = [KWMBeforePayData new];
......@@ -77,8 +78,6 @@
if(payType == TypeWebpay){
self.heightPayType.constant = 0;
self.vPayType.hidden = YES;
}else{
self.lbPayType.text = [KWMPayUtil payTypeString:payType];
}
}
......@@ -118,6 +117,7 @@
if (error == nil && checkout) {
this.address = address;
this.checkout = checkout;
[this showToast:@"更新地址成功"];
[this flushCheckout:dictionary];
// [this initData];
......@@ -150,11 +150,6 @@
[self initData];
}
- (void)kwm_addedDiscount:(BUYCheckout *)checkout{
self.checkout = checkout;
[self initData];
}
- (void)kwm_addedGiftCard:(BUYCheckout *)checkout{
self.checkout = checkout;
[self initData];
......@@ -167,6 +162,22 @@
-(void)kwm_onSelectPayType:(KWMPayType)payType{
self.payType = payType;
if(payType == TypeWechatPay){
self.ivAliPay.image = [UIImage imageNamed:@"ic_choose_nor"];
self.ivWechatPay.image = [UIImage imageNamed:@"ic_choose_sel"];
}else if(payType == TypeAlipay){
self.ivAliPay.image = [UIImage imageNamed:@"ic_choose_sel"];
self.ivWechatPay.image = [UIImage imageNamed:@"ic_choose_nor"];
}
}
-(void)initDiscountHintText{
NSString *holderText = @"请输入优惠码";
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:holderText];
[placeholder addAttribute:NSForegroundColorAttributeName
value:[UIColor sam_colorWithHex:@"393939"]
range:NSMakeRange(0, holderText.length)];
self.tfDiscount.attributedPlaceholder = placeholder;
}
- (void)initData{
......@@ -201,11 +212,17 @@
}
//优惠码
if(self.checkout.discount!=nil){
self.lbDiscount.text = self.checkout.discount.code;
if(self.checkout.discount){
self.tfDiscount.text = self.checkout.discount.code;
}else{
self.lbDiscount.text = @"请输入优惠码";
}
self.tfDiscount.text = @"";
}
//优惠码编辑相关
self.tfDiscount.enabled = self.isEditingDiscount;
[self.tfDiscount endEditing:!self.isEditingDiscount];
[self.btnDiscountCancel setHidden:!self.isEditingDiscount];
[self.btnDiscountConfirm setHidden:!self.isEditingDiscount];
[self.btnDiscountEdit setHidden:self.isEditingDiscount];
//礼品卡
if(self.checkout.giftCardsArray!=nil && self.checkout.giftCardsArray.count>0){
BUYGiftCard *giftCard = [self.checkout.giftCardsArray objectAtIndex:0];
......@@ -375,9 +392,13 @@
[self showToast:@"未成功创建订单"];
return;
}
KWMPayTypeVC *typeVC = (KWMPayTypeVC *)[KWMBaseVC findControllerBy:[KWMPayTypeVC kwmTag] fromStoryboard:@"ShopCart"];
typeVC.delegate = self;
[self.navigationController pushViewController:typeVC animated:YES];
UITapGestureRecognizer *tapType = sender;
UIView *vType = tapType.view;
if(vType.tag == 1){
[self kwm_onSelectPayType:TypeAlipay];
}else if(vType.tag == 2){
[self kwm_onSelectPayType:TypeWechatPay];
}
}
//优惠码页面
......@@ -386,10 +407,42 @@
[self showToast:@"未成功创建订单"];
return;
}
KWMDiscountVC *discountVC = (KWMDiscountVC *)[KWMBaseVC findControllerBy:[KWMDiscountVC kwmTag] fromStoryboard:@"ShopCart"];
discountVC.checkout = self.checkout;
discountVC.delegate = self;
[self.navigationController pushViewController:discountVC animated:YES];
self.isEditingDiscount = YES;
[self initData];
[self.tfDiscount becomeFirstResponder];
}
-(void)onClickDiscountCancel:(id)sender{
self.isEditingDiscount = NO;
[self initData];
[self.tfDiscount resignFirstResponder];
}
-(void)onClickDiscountConfirm:(id)sender{
if(self.checkout == nil){
[self showToast:@"未成功创建订单"];
return;
}
if([KWMStringUtil isBlank:self.tfDiscount.text]){
[self showToast:@"优惠码不能为空"];
return;
}
[self.tfDiscount resignFirstResponder];
[self showLoading];
__weak typeof(self) this = self;
[self.client updateCheckout:self.checkout completion:^(NSDictionary *dictionary, BUYCheckout *checkout, NSError *error) {
[this hideLoading];
if (error == nil && checkout && checkout.discount) {
this.checkout = checkout;
[this showToast:@"添加优惠码成功"];
[this flushCheckout:dictionary];
this.isEditingDiscount = NO;
[this initData];
}else {
[this showToast:@"添加优惠码失败"];
[this showError:error];
}
}];
}
//礼品卡页面
......@@ -429,6 +482,24 @@
[self startCheckout];
}
#pragma mark - UITextFieldDelegate
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
self.marginTopContent.constant = 22 - 200;
[UIView animateWithDuration:0.5 animations:^{
[self.view layoutIfNeeded];
}];
return YES;
}
//键盘弹出
-(void)keyboardWillHide:(NSNotification *)notification{
self.marginTopContent.constant = 22;
[UIView animateWithDuration:0.5 animations:^{
[self.view layoutIfNeeded];
}];
}
-(void)startCheckout{
if(self.checkout == nil){
[self showToast:@"未成功初始化订单"];
......@@ -485,23 +556,6 @@
[self showToast:errorMsg];
}
return errorMsg != nil;
// if(address == nil){
// [self showToast:@"您的地址尚未有任何地址,请前往选择地址"];
// return YES;
// }else if([KWMStringUtil isEmpty:address.firstName] && [KWMStringUtil isEmpty:address.lastName]){
// [self showToast:@"您的地址缺少收件人姓名,请前往完善地址"];
// return YES;
// }else if([KWMStringUtil isEmpty:address.city]){
// [self showToast:@"您的地址缺少所在城市,请前往完善地址"];
// return YES;
// }else if([KWMStringUtil isEmpty:address.zip]){
// [self showToast:@"您的地址缺少邮政编码,请前往完善地址"];
// return YES;
// }else if([KWMStringUtil isEmpty:address.phone]){
// [self showToast:@"您的地址缺少收件人电话号码,请前往完善地址"];
// return YES;
// }
// return NO;
}
......
......@@ -7,6 +7,8 @@
//
#import "KWMBaseVC.h"
#import "KWMRecommendView.h"
#import "KWMPPCacheUtil.h"
@interface KWMPaySuccessVC : KWMBaseVC
......@@ -16,12 +18,19 @@
@property (weak, nonatomic) IBOutlet UIButton *btnMyOrder;
@property (weak, nonatomic) IBOutlet UIButton *btnBackHome;
@property (weak, nonatomic) IBOutlet KWMRecommendView *hotRecommendView;
- (IBAction)onClickStartTime:(id)sender;
- (IBAction)onClickGetTime:(id)sender;
- (IBAction)onClickMyOrder:(id)sender;
- (IBAction)onClickBackHome:(id)sender;
//用于在跳转后的订单列表页面生成即时订单(支付后的订单需要一定时间后才能从订单列表获取)
@property (nonatomic) BUYCheckout *paidCheckout;
......
......@@ -13,7 +13,7 @@
#import "UIViewController+BackButtonHandler.h"
#import "KWMOrderVC.h"
@interface KWMPaySuccessVC ()
@interface KWMPaySuccessVC ()<KWMRecommendDelegate>
@end
......@@ -24,6 +24,9 @@
self.title = @"支付成功";
[self initButton];
[self requestProductWithHandle:@"products-list-app-homepage" tags:nil valueKeyPath:@"productArray"];
self.hotRecommendView.title = @"热卖单品";
self.hotRecommendView.delegate = self;
}
+(NSString *)kwmTag{
......@@ -45,6 +48,9 @@
self.btnMyOrder.layer.masksToBounds = YES;
self.btnMyOrder.layer.borderColor = [UIColor sam_colorWithHex:@"979797"].CGColor; //要设置的颜色
self.btnMyOrder.layer.borderWidth = 1; //要设置的描边宽
self.btnBackHome.layer.masksToBounds = YES;
self.btnBackHome.layer.borderColor = [UIColor sam_colorWithHex:@"979797"].CGColor; //要设置的颜色
self.btnBackHome.layer.borderWidth = 1; //要设置的描边宽
}
......@@ -70,11 +76,80 @@
[self.navigationController pushViewController:orderVC animated:YES];
}
-(void)onClickBackHome:(id)sender{
[self.navigationController popToRootViewControllerAnimated:YES];
}
-(BOOL) navigationShouldPopOnBackButton {
[self.navigationController popToRootViewControllerAnimated:YES];
return NO; // Ignore 'Back' button this time
}
#pragma mark KWMRecommendDelegate
-(void)kwm_gotoRecommendPage:(KWMRecommendView *)recommendView{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/products-list-app-homepage?title=热卖单品"];
}
-(void)kwm_onClickProduct:(BUYProduct *)product{
[self openURLWithString:[NSString stringWithFormat:@"https://cemarose.myshopify.com/products/%@",product.handle]];
}
#pragma makr - api
- (void) requestProductWithHandle:(NSString *) handle tags:(NSArray *) tags valueKeyPath:(nonnull NSString *) valueKeyPath {
NSDictionary *parameters = [KWMPPCacheUtil getProductCacheKeyDictionary:1 tags:tags handle:handle];
BOOL useProductDataCache = [self useProductDataCache:parameters valueKeyPath:valueKeyPath page:1];
__weak KWMPaySuccessVC *weakSelf = self;
[self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
if (!error) {
[weakSelf.client getProductsPage:1 inCollection:collection.identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) {
if (!error) {
[KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage products:products];
if(products){
NSArray *productIds;
@try {
if(self.paidCheckout && self.paidCheckout.lineItemsArray){
productIds = [[self.paidCheckout.lineItems array] rx_mapWithBlock:^id(BUYLineItem* each) {
NSNumber *a = each.productId ?: @(0);
return a;
}];
}
}
@catch (NSException *exception) {
// 捕获到的异常exception
}
self.hotRecommendView.productArray = products;
self.hotRecommendView.boughtProductIdArray = productIds;
}
}
}];
}
}];
}
-(BOOL)useProductDataCache:(NSDictionary *)cacheKeyDictionary valueKeyPath:(NSString *)valueKeyPath page:(NSUInteger)page{
if(!kIsNetwork || page == 1){
NSArray *productIds;
NSArray *products = [KWMPPCacheUtil getProductDataByCache:cacheKeyDictionary urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage];
if(products && products.count > 0){
@try {
if(self.paidCheckout && self.paidCheckout.lineItemsArray){
productIds = [[self.paidCheckout.lineItems array] rx_mapWithBlock:^id(BUYLineItem* each) {
NSNumber *a = each.productId ?: @(0);
return a;
}];
}
}
@catch (NSException *exception) {
// 捕获到的异常exception
}
self.hotRecommendView.productArray = products;
self.hotRecommendView.boughtProductIdArray = productIds;
}else{
return false;
}
}
return !kIsNetwork;
}
@end
......@@ -17,8 +17,12 @@
#import "KWMCategoryVC.h"
#import "KWMStringUtil.h"
#import "KWMShoppingCart.h"
#import "KWMRecommendView.h"
#import "KWMPPCacheUtil.h"
@interface KWMShopCartVC ()<UIAlertViewDelegate>
@interface KWMShopCartVC ()<UIAlertViewDelegate,KWMRecommendDelegate>
@property (nonatomic, weak) IBOutlet KWMRecommendView *newestRecommendView;
@property (nonatomic, weak) IBOutlet KWMRecommendView *mainRecommendView;
@property (nonatomic) NSMutableArray *shopCartList;
@property (nonatomic, strong) NSMutableArray *soldout;
@end
......@@ -53,6 +57,10 @@
[self setTotalPrice];
[self checkInStockAndRefresh];
self.newestRecommendView.title = @"最新单品";
self.mainRecommendView.title = @"主推单品";
self.newestRecommendView.delegate = self;
self.mainRecommendView.delegate = self;
}
- (void) checkInStockAndRefresh {
......@@ -165,13 +173,9 @@
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (_shopCartList.count == 0) {
self.vBackground.hidden = NO;
}else{
self.vBackground.hidden = YES;
}
return _shopCartList.count;
NSInteger count = self.shopCartList ? self.shopCartList.count : 0;
self.vBackground.hidden = count != 0;
return count;
}
#pragma mark UITableViewDelegate
......@@ -225,6 +229,19 @@
}
}
#pragma mark KWMRecommendDelegate
-(void)kwm_gotoRecommendPage:(KWMRecommendView *)recommendView{
if(recommendView.tag == 1){
[self openURLWithString:@"https://cemarose.myshopify.com/collections/new?title=最新单品"];
}else{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/hot-sell-app?title=主推单品"];
}
}
-(void)kwm_onClickProduct:(BUYProduct *)product{
[self openURLWithString:[NSString stringWithFormat:@"https://cemarose.myshopify.com/products/%@",product.handle]];
}
- (void)kwm_onClickDelete:(KWMShopCartModel *)shopCartModel{
self.vDelete.hidden = NO;
self.vDelete.delegate = self;
......@@ -356,6 +373,11 @@
self.shopCartList = [[KWMShoppingCart sharedInstance] items];
[self.tbvCart reloadData];
[self setTotalPrice];
if(! self.shopCartList || self.shopCartList.count == 0){
//请求推荐商品数据
[self requestProductWithHandle:@"new" tags:nil valueKeyPath:@"newestRecommendView"];
[self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"mainRecommendView"];
}
// [self.client getProductsByIds:[self.shopCartList rx_mapWithBlock:^id(KWMShopCartModel *each) {
// return each.product_id;
// }] completion:^(NSArray<BUYProduct *> * _Nullable products, NSError * _Nullable error) {
......@@ -380,4 +402,44 @@
_lbTotalPrice.text = total.priceFormatted;
}
#pragma makr - api
- (void) requestProductWithHandle:(NSString *) handle tags:(NSArray *) tags valueKeyPath:(nonnull NSString *) valueKeyPath {
NSDictionary *parameters = [KWMPPCacheUtil getProductCacheKeyDictionary:1 tags:tags handle:handle];
BOOL useProductDataCache = [self useProductDataCache:parameters valueKeyPath:valueKeyPath page:1];
__weak KWMShopCartVC *weakSelf = self;
[self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
if (!error) {
[weakSelf.client getProductsPage:1 inCollection:collection.identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) {
if (!error) {
[KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage products:products];
if(products){
if([valueKeyPath isEqualToString:@"newestRecommendView"]){
weakSelf.newestRecommendView.productArray = products;
}else{
weakSelf.mainRecommendView.productArray = products;
}
}
}
}];
}
}];
}
-(BOOL)useProductDataCache:(NSDictionary *)cacheKeyDictionary valueKeyPath:(NSString *)valueKeyPath page:(NSUInteger)page{
if(!kIsNetwork || page == 1){
NSArray *products = [KWMPPCacheUtil getProductDataByCache:cacheKeyDictionary urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage];
if(products && products.count > 0){
if([valueKeyPath isEqualToString:@"newestRecommendView"]){
self.newestRecommendView.productArray = products;
}else{
self.mainRecommendView.productArray = products;
}
}else{
return false;
}
}
return !kIsNetwork;
}
@end
......@@ -20,6 +20,11 @@
tags:(nullable NSArray <NSString *> *)tags
inCollection:(nullable NSNumber *)collectionId;
//初始化缓存parameters key
+ (NSDictionary *)getProductCacheKeyDictionary:(NSUInteger)page
tags:(nullable NSArray <NSString *> *)tags
handle:(nullable NSString *)handle;
+ (void)saveDataToCache:(NSDictionary *)cacheKeyDictionary urlKey:(NSString *)urlKey products:(NSArray *)products;
+ (NSArray *)getProductDataByCache:(NSDictionary *)cacheKeyDictionary urlKey:(NSString *)urlKey;
......
......@@ -33,6 +33,23 @@
return params;
}
//初始化缓存parameters key
+ (NSDictionary *)getProductCacheKeyDictionary:(NSUInteger)page
tags:(nullable NSArray <NSString *> *)tags
handle:(nullable NSString *)handle{
NSMutableDictionary *params = @{
// @"limit" : @(self.client.pageSize),
@"page" : @(page)
}.mutableCopy;
if (tags) {
params[@"tag"] = [tags componentsJoinedByString:@","];
}
if (handle) {
params[@"handle"] = handle;
}
return params;
}
+ (void)saveDataToCache:(NSDictionary *)cacheKeyDictionary urlKey:(NSString *)urlKey products:(NSArray *)products{
NSMutableArray *dictArray = [NSMutableArray array];
......
......@@ -8,15 +8,16 @@
#import <UIKit/UIKit.h>
#import <Buy/Buy.h>
@class KWMRecommendView;
@protocol KWMRecommendDelegate <NSObject>
- (void)kwm_onClickProduct:(BUYProduct *)product;
- (void)kwm_gotoRecommendPage;
- (void)kwm_gotoRecommendPage:(KWMRecommendView *)recommendView;
@end
@interface KWMRecommendHeader : UIView<UICollectionViewDataSource,UICollectionViewDelegate>
@interface KWMRecommendView : UIView<UICollectionViewDataSource,UICollectionViewDelegate>
+ (NSString *)kwmTag;
......@@ -24,4 +25,9 @@
@property(nonatomic) NSArray *productArray;
@property(nonatomic) NSString *title;
//已购买商品,用于去重
@property(nonatomic) NSArray *boughtProductIdArray;
@end
......@@ -6,21 +6,23 @@
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMRecommendHeader.h"
#import "KWMRecommendView.h"
#import "KWMCollectionCell.h"
@interface KWMRecommendHeader()
@interface KWMRecommendView()
@property (nonatomic,weak) IBOutlet UIView *vView;
@property (nonatomic,weak) IBOutlet UICollectionView *cvRecommend;
@property (nonatomic,weak) IBOutlet UILabel *lbTitle;
@end
@implementation KWMRecommendHeader
@implementation KWMRecommendView
+(NSString *)kwmTag{
return @"KWMRecommendHeader";
return @"KWMRecommendView";
}
- (id)init{
......@@ -68,11 +70,33 @@
self.cvRecommend.collectionViewLayout = layout;
}
-(void)setTitle:(NSString *)title{
_title = title;
if(self.lbTitle){
[self.lbTitle setText:title];
}
}
-(void)setProductArray:(NSArray *)productArray{
_productArray = productArray;
[self removeSameProduct];
[self.cvRecommend reloadData];
}
-(void)setBoughtProductIdArray:(NSArray *)boughtProductIdArray{
_boughtProductIdArray = boughtProductIdArray;
[self removeSameProduct];
[self.cvRecommend reloadData];
}
-(void)removeSameProduct{
if(self.productArray && self.boughtProductIdArray){
_productArray = [self.productArray rx_filterWithBlock:^BOOL(BUYProduct *each){
return (![self.boughtProductIdArray containsObject:each.identifier]);
}];
}
}
#pragma mark - UICollectionViewDataSource
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
KWMCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([KWMCollectionCell class]) forIndexPath:indexPath];
......@@ -93,17 +117,26 @@
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
if(self.productArray && self.productArray.count > 9){
NSInteger productCount = self.productArray?self.productArray.count:0;
NSInteger boughtCount = self.boughtProductIdArray?self.boughtProductIdArray.count:0;
if(productCount > 9){
return 10;
}
if(productCount + boughtCount > 9){
return productCount+1;
}
return self.productArray?self.productArray.count:0;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
if(indexPath.row == 9){
NSInteger productCount = self.productArray?self.productArray.count:0;
NSInteger boughtCount = self.boughtProductIdArray?self.boughtProductIdArray.count:0;
BOOL hasMore = (productCount > 9) || (productCount + boughtCount > 9);
if([self collectionView:self.cvRecommend numberOfItemsInSection:0] == indexPath.row + 1
&& hasMore){
if(self.delegate){
[self.delegate kwm_gotoRecommendPage];
[self.delegate kwm_gotoRecommendPage:self];
}
}else{
BUYProduct *product = [self.productArray objectAtIndex:indexPath.row];
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" 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="13173"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
......@@ -14,9 +14,10 @@
</array>
</customFonts>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMRecommendHeader">
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMRecommendView">
<connections>
<outlet property="cvRecommend" destination="YkQ-i0-Pi8" id="k1I-3x-9pe"/>
<outlet property="lbTitle" destination="7Fq-VX-XvA" id="643-OU-gbL"/>
<outlet property="vView" destination="iN0-l3-epB" id="4mj-ET-3eS"/>
</connections>
</placeholder>
......
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