Commit 2bafe321 by lee

u

parents fb8d6345 64bfda26
...@@ -14,6 +14,7 @@ pod 'SAMKeychain' ...@@ -14,6 +14,7 @@ pod 'SAMKeychain'
pod 'RXCollections','~> 1.0' pod 'RXCollections','~> 1.0'
pod 'TOWebViewController' pod 'TOWebViewController'
pod 'SDCycleScrollView'
#pod 'AFNetworking','~> 3.1' #pod 'AFNetworking','~> 3.1'
pod 'PPNetworkHelper' pod 'PPNetworkHelper'
pod 'JSONModel','~> 1.7.0' pod 'JSONModel','~> 1.7.0'
......
...@@ -713,8 +713,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -713,8 +713,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *)getHomeDataWithSuccess:(void (^)(NSURLSessionDataTask *, KWMHomeDataResult *))success failure:(void (^)(NSURLSessionDataTask *, NSError *))failure { - (NSURLSessionDataTask *)getHomeDataWithSuccess:(void (^)(NSURLSessionDataTask *, KWMHomeDataResult *))success failure:(void (^)(NSURLSessionDataTask *, NSError *))failure {
NSInteger st = [[NSDate date] timeIntervalSince1970]; NSInteger st = [[NSDate date] timeIntervalSince1970];
// st = st - st % 86400 - 28800; // st = st - st % 86400 - 28800;
// FIXME: 这里改了再发版本 NSString *apiPath = [NSString stringWithFormat:@"https://ogbgohpla.qnssl.com/App.Home.test.json?st=%zi",st];
NSString *apiPath = [NSString stringWithFormat:@"https://ogbgohpla.qnssl.com/App.Home.json.bak?st=%ld",st];
return [self startSessionTask:KWMHTTPMethodGET apiPath:apiPath parameters:nil result:[KWMHomeDataResult class] model:nil success:success failure:failure]; return [self startSessionTask:KWMHTTPMethodGET apiPath:apiPath parameters:nil result:[KWMHomeDataResult class] model:nil success:success failure:failure];
} }
...@@ -875,9 +874,10 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -875,9 +874,10 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/** /**
* 通过checkout_token查询shopify订单API * 通过checkout_token查询shopify订单API
* @param checkout_token shopify订单token * @param checkout_token shopify订单token
* @param out_trade_no 订单支付编号
* @param sign 签名验证 * @param sign 签名验证
* 签名规则: * 签名规则:
* str_sign = checkout_token=5173547165345&key=bd3f58f5cd3d7a217ac8c8e655ab52f8"; * str_sign = checkout_token=5173547165345&out_trade_no=201708011602269375&key=bd3f58f5cd3d7a217ac8c8e655ab52f8";
* sign = md5(base64_encode($str_sign)); * sign = md5(base64_encode($str_sign));
*/ */
- (NSURLSessionDataTask *) appOrderQuery:(NSDictionary *)parameters - (NSURLSessionDataTask *) appOrderQuery:(NSDictionary *)parameters
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
|code|int|1006|订单已支付完成| |code|int|1006|订单已支付完成|
|code|int|1007|签名验证失败| |code|int|1007|签名验证失败|
|code|int|1008|订单查询失败| |code|int|1008|订单查询失败|
|code|int|1009|订单创建失败|
|code|int|1010|必要参数缺失|
|code|int|1012|商品数量不足|
*/ */
@property (nonatomic) NSNumber<Optional> *code; @property (nonatomic) NSNumber<Optional> *code;
...@@ -39,4 +42,7 @@ ...@@ -39,4 +42,7 @@
//数据--存放解析后的model。ps:只有当微信支付下单返回结果状态为成功时,message key里的数据才会是wechat pay model的数据,此时,会将message里的数据转换为对应的model并存放到data里。 //数据--存放解析后的model。ps:只有当微信支付下单返回结果状态为成功时,message key里的数据才会是wechat pay model的数据,此时,会将message里的数据转换为对应的model并存放到data里。
@property (nonatomic) id<Optional> data; @property (nonatomic) id<Optional> data;
//商品缺货时的variantId
@property (nonatomic) NSNumber<Optional> *variantId;
@end @end
...@@ -19,4 +19,6 @@ ...@@ -19,4 +19,6 @@
//链接 //链接
@property (nonatomic) NSString *url; @property (nonatomic) NSString *url;
@property (nonatomic) NSString <Optional> *action;
@end @end
...@@ -14,4 +14,6 @@ ...@@ -14,4 +14,6 @@
@property (nonatomic) KWMWechatPayData *wechatPayData; @property (nonatomic) KWMWechatPayData *wechatPayData;
@property (nonatomic) NSString *outTradeNo;
@end @end
...@@ -20,4 +20,6 @@ ...@@ -20,4 +20,6 @@
@property (nonatomic) KWMHotSales *hot_sales; @property (nonatomic) KWMHotSales *hot_sales;
@property (nonatomic) NSArray <KWMAdvertisement,Optional> *hot_sales_ads;
@end @end
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
@property (nonatomic) NSString * _Nullable package; @property (nonatomic) NSString * _Nullable package;
/**时间戳*/ /**时间戳*/
@property (nonatomic) NSInteger timestamp; @property (nonatomic) NSInteger timestamp;
/**微信订单编号*/
@property (nonatomic) NSString * _Nullable outTradeNo;
@end @end
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
return m; return m;
}]; }];
self.selectedCategory = self.categories.firstObject; self.selectedCategory = self.categories.firstObject;
NSIndexPath * path = [NSIndexPath indexPathForItem:1 inSection:0]; NSIndexPath * path = [NSIndexPath indexPathForItem:0 inSection:0];
[self.tbvLeftCategory selectRowAtIndexPath:path animated:YES scrollPosition:UITableViewScrollPositionTop]; [self.tbvLeftCategory selectRowAtIndexPath:path animated:YES scrollPosition:UITableViewScrollPositionTop];
} }
......
...@@ -276,6 +276,9 @@ ...@@ -276,6 +276,9 @@
} }
- (void)showDialog:(NSString *)message{ - (void)showDialog:(NSString *)message{
if([KWMStringUtil isEmpty:message]){
return;
}
PSPDFAlertView *alertView = [[PSPDFAlertView alloc] initWithTitle:message]; PSPDFAlertView *alertView = [[PSPDFAlertView alloc] initWithTitle:message];
[alertView addButtonWithTitle:@"确定" block:nil]; [alertView addButtonWithTitle:@"确定" block:nil];
[alertView show]; [alertView show];
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
// //
#import "KWMBaseModel.h" #import "KWMBaseModel.h"
#import "KWMBannerView.h"
#import "KWMAdvertisement.h" #import "KWMAdvertisement.h"
...@@ -17,13 +16,10 @@ ...@@ -17,13 +16,10 @@
@end @end
@interface KWMAdHeader : UIView<KWMBannerViewDelegate> @interface KWMAdHeader : UIView
+ (NSString *)kwmTag; + (NSString *)kwmTag;
-(void)startBannerTimer;
-(void)endBannerTimer;
@property (nonatomic) NSArray<KWMAdvertisement *> *adArray; @property (nonatomic) NSArray<KWMAdvertisement *> *adArray;
......
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
#import "KWMAdHeader.h" #import "KWMAdHeader.h"
#import "UIImageView+WebCache.h" #import "UIImageView+WebCache.h"
#import <SDCycleScrollView/SDCycleScrollView.h>
@interface KWMAdHeader() @interface KWMAdHeader()<SDCycleScrollViewDelegate>
@property (nonatomic,strong) KWMBannerView *bannerView; @property (nonatomic,strong) SDCycleScrollView *focusView;
@end @end
...@@ -45,54 +46,48 @@ ...@@ -45,54 +46,48 @@
} }
-(void)addView{ -(void)addView{
self.bannerView = [[KWMBannerView alloc]initWithFrame:self.frame]; // self.bannerView = [[KWMBannerView alloc]initWithFrame:self.frame];
self.bannerView.delegate = self; // self.bannerView.delegate = self;
[self addSubview:self.bannerView]; // [self addSubview:self.bannerView];
[self initFocusView];
} }
-(void)startBannerTimer{
[self.bannerView addTimer];
}
-(void)endBannerTimer{
[self.bannerView removeTimer];
}
-(void)setAdArray:(NSArray<KWMAdvertisement *> *)adArray{ -(void)setAdArray:(NSArray<KWMAdvertisement *> *)adArray{
_adArray = adArray; _adArray = adArray;
[self.bannerView reloadData]; // [self.bannerView reloadData];
_focusView.imageURLStringsGroup = [adArray rx_mapWithBlock:^id(KWMAdvertisement *each) {
return each.image;
}];
} }
-(void)initFocusView {
#pragma mark - KWMBannerViewDelegate if (!_focusView) {
-(UIView *)bannerView:(KWMBannerView *)bannerView reusingView:(UIView *)reusingView pageAtIndex:(NSInteger)index{ _focusView = [[SDCycleScrollView alloc] init];
UIView *itemView = reusingView?reusingView:nil; _focusView.delegate = self;
UIImageView *topBannerItem = nil; _focusView.translatesAutoresizingMaskIntoConstraints = NO;
if(!itemView){ _focusView.frame = CGRectMake(0, 0, 375, 190);
topBannerItem = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, bannerView.frame.size.width, bannerView.frame.size.height)]; _focusView.autoScrollTimeInterval = 3;
}else{ _focusView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
topBannerItem = (UIImageView *)itemView; _focusView.pageDotImage = [UIImage imageNamed:@"ic_page_1"];
_focusView.currentPageDotImage = [UIImage imageNamed:@"ic_page_2"];
_focusView.placeholderImage = [UIImage imageNamed:@"ic_loading"];
_focusView.backgroundColor = [UIColor whiteColor];
[self addSubview:_focusView];
NSDictionary *views = @{ @"v": _focusView };
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[v]|" options:0 metrics:nil views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[v]|" options:0 metrics:nil views:views]];
} }
KWMAdvertisement *ad = [self.adArray objectAtIndex:index];
NSURL *imageURL = [NSURL URLWithString:ad.image];
[topBannerItem sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
//topBannerItem.image = [UIImage imageNamed:@"test_banner_1"];
topBannerItem.contentMode=UIViewContentModeScaleAspectFill;
itemView = topBannerItem;
return itemView;
} }
-(NSInteger)numberOfPagesForBanner:(KWMBannerView *)bannerView{ -(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
return self.adArray?self.adArray.count:0; [self.delegate kwm_gotoWebView:self.adArray[index].url];
} }
-(void)bannerView:(KWMBannerView *)bannerView onClickPage:(NSInteger)index{ //-(void)bannerView:(KWMBannerView *)bannerView onClickPage:(NSInteger)index{
KWMAdvertisement *ad = [self.adArray objectAtIndex:index]; // KWMAdvertisement *ad = [self.adArray objectAtIndex:index];
if(self.delegate){ // if(self.delegate){
[self.delegate kwm_gotoWebView:ad.url]; // [self.delegate kwm_gotoWebView:ad.url];
} // }
} //}
@end @end
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
@protocol KWMClothingSetsDelegate <NSObject> @protocol KWMClothingSetsDelegate <NSObject>
- (void)kwm_onClickFocusImage;
- (void)kwm_onClickProduct:(BUYProduct *)product; - (void)kwm_onClickProduct:(BUYProduct *)product;
- (void)kwm_gotoClothingSetsPage; - (void)kwm_gotoClothingSetsPage;
......
...@@ -124,5 +124,11 @@ ...@@ -124,5 +124,11 @@
} }
} }
#pragma mark - action
-(IBAction) focusImageAction:(id)sender {
[self.delegate kwm_onClickFocusImage];
}
@end @end
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/> <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
...@@ -25,8 +25,12 @@ ...@@ -25,8 +25,12 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nBP-0Q-eKB" userLabel="推荐搭配title view"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nBP-0Q-eKB" userLabel="推荐搭配title view">
<rect key="frame" x="0.0" y="0.0" width="375" height="190"/> <rect key="frame" x="0.0" y="0.0" width="375" height="190"/>
<subviews> <subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Xzr-zM-E25"> <imageView clipsSubviews="YES" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Xzr-zM-E25">
<rect key="frame" x="0.0" y="0.0" width="375" height="190"/> <rect key="frame" x="0.0" y="0.0" width="375" height="190"/>
<gestureRecognizers/>
<connections>
<outletCollection property="gestureRecognizers" destination="wLm-4C-MJb" appends="YES" id="eW6-hN-Ap5"/>
</connections>
</imageView> </imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_triangle" translatesAutoresizingMaskIntoConstraints="NO" id="LvJ-FP-Yc1"> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_triangle" translatesAutoresizingMaskIntoConstraints="NO" id="LvJ-FP-Yc1">
<rect key="frame" x="177" y="181" width="20" height="10"/> <rect key="frame" x="177" y="181" width="20" height="10"/>
...@@ -84,6 +88,11 @@ ...@@ -84,6 +88,11 @@
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="34.5" y="107"/> <point key="canvasLocation" x="34.5" y="107"/>
</view> </view>
<tapGestureRecognizer id="wLm-4C-MJb">
<connections>
<action selector="focusImageAction:" destination="-1" id="ds0-ME-0oT"/>
</connections>
</tapGestureRecognizer>
</objects> </objects>
<resources> <resources>
<image name="ic_triangle" width="21" height="11"/> <image name="ic_triangle" width="21" height="11"/>
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "KWMBannerView.h"
#import <Buy/Buy.h> #import <Buy/Buy.h>
#import "KWMAdvertisement.h"
...@@ -16,21 +16,20 @@ ...@@ -16,21 +16,20 @@
- (void)kwm_onClickProduct:(BUYProduct *)product; - (void)kwm_onClickProduct:(BUYProduct *)product;
- (void)kwm_onClickHotSalesAd:(KWMAdvertisement *) ad;
@end @end
@interface KWMHotSalesHeader : UIView<KWMBannerViewDelegate> @interface KWMHotSalesHeader : UIView
+ (NSString *)kwmTag; + (NSString *)kwmTag;
-(void)startBannerTimer;
-(void)endBannerTimer;
@property(nonatomic,weak) id<KWMHotSalesDelegate> delegate; @property(nonatomic,weak) id<KWMHotSalesDelegate> delegate;
@property(nonatomic) NSArray<BUYProduct *> *singleShowArray; @property(nonatomic) NSArray<BUYProduct *> *singleShowArray;
@property(nonatomic) NSArray<BUYProduct *> *bannerArray; @property(nonatomic) NSArray<KWMAdvertisement *> *bannerArray;
@property(nonatomic,readonly) NSInteger actrualHeight; @property(nonatomic,readonly) NSInteger actrualHeight;
......
...@@ -10,12 +10,15 @@ ...@@ -10,12 +10,15 @@
#import "KWMProductBannerItemView.h" #import "KWMProductBannerItemView.h"
#import "UIImageView+WebCache.h" #import "UIImageView+WebCache.h"
#import "KWMNewHomeCell.h" #import "KWMNewHomeCell.h"
#import <SDCycleScrollView/SDCycleScrollView.h>
@interface KWMHotSalesHeader()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> @interface KWMHotSalesHeader()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,SDCycleScrollViewDelegate>
@property (nonatomic,weak) IBOutlet UIView *vView; @property (nonatomic,weak) IBOutlet UIView *vView;
@property (nonatomic,weak) IBOutlet KWMBannerView *bannerView; @property (nonatomic,weak) IBOutlet UIView *bannerView;
@property (nonatomic, strong) SDCycleScrollView *focusView;
@property (nonatomic,weak) IBOutlet UICollectionView *singleShowView; @property (nonatomic,weak) IBOutlet UICollectionView *singleShowView;
...@@ -71,30 +74,37 @@ ...@@ -71,30 +74,37 @@
-(void)initView{ -(void)initView{
UINib *nib = [UINib nibWithNibName:@"KWMNewHomeCell" bundle:nil]; UINib *nib = [UINib nibWithNibName:@"KWMNewHomeCell" bundle:nil];
[self.singleShowView registerNib:nib forCellWithReuseIdentifier:@"KWMNewHomeCell"]; [self.singleShowView registerNib:nib forCellWithReuseIdentifier:@"KWMNewHomeCell"];
// [self.singleShowView registerNib:nib forCellReuseIdentifier:@"KWMNewHomeCell"];
// [self.singleShowView registerNib:[[[NSBundle mainBundle]loadNibNamed:@"KWMNewHomeCell" owner:self options:nil] firstObject] forCellReuseIdentifier:@"KWMNewHomeCell"];
self.singleShowView.delegate = self; self.singleShowView.delegate = self;
self.singleShowView.dataSource = self; self.singleShowView.dataSource = self;
// self.singleShowView.collectionViewLayout.collectionViewContentSize = CGSizeMake(UI_SCREEN_WIDTH - 16, UI_SCREEN_WIDTH + 58);
// self.singleShowView.collectionViewLayout = [UICollectionViewLayout alloc]
self.bannerView.delegate = self;
self.heightBannerView.constant = 0; self.heightBannerView.constant = 0;
self.heightSingleShowView.constant = 0; self.heightSingleShowView.constant = 0;
} }
-(void)startBannerTimer{ -(void)initFocusView {
[self.bannerView addTimer]; if (!_focusView) {
} _focusView = [[SDCycleScrollView alloc] init];
_focusView.delegate = self;
-(void)endBannerTimer{ _focusView.translatesAutoresizingMaskIntoConstraints = NO;
[self.bannerView removeTimer]; _focusView.frame = CGRectMake(0, 0, 375, 190);
_focusView.autoScrollTimeInterval = 3;
_focusView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
_focusView.pageDotImage = [UIImage imageNamed:@"ic_page_1"];
_focusView.currentPageDotImage = [UIImage imageNamed:@"ic_page_2"];
[self.bannerView addSubview:_focusView];
NSDictionary *views = @{ @"v": _focusView };
[self.bannerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[v]|" options:0 metrics:nil views:views]];
[self.bannerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[v]|" options:0 metrics:nil views:views]];
}
} }
-(void)setBannerArray:(NSArray *)bannerArray{ -(void)setBannerArray:(NSArray *)bannerArray{
_bannerArray = bannerArray; _bannerArray = bannerArray;
if(bannerArray && bannerArray.count > 0){ if(bannerArray && bannerArray.count > 0){
[self initFocusView];
self.focusView.imageURLStringsGroup = [bannerArray rx_mapWithBlock:^id(KWMAdvertisement *each) {
return each.image;
}];
self.heightBannerView.constant = 190; self.heightBannerView.constant = 190;
[self.bannerView reloadData];
}else{ }else{
self.heightBannerView.constant = 0; self.heightBannerView.constant = 0;
} }
...@@ -103,7 +113,7 @@ ...@@ -103,7 +113,7 @@
-(void)setSingleShowArray:(NSArray *)singleShowArray{ -(void)setSingleShowArray:(NSArray *)singleShowArray{
_singleShowArray = singleShowArray ? singleShowArray : [NSArray array]; _singleShowArray = singleShowArray ? singleShowArray : [NSArray array];
NSInteger itemWidth = UI_SCREEN_WIDTH - 16; // NSInteger itemWidth = UI_SCREEN_WIDTH - 16;
NSInteger itemHeight = UI_SCREEN_WIDTH + 58; NSInteger itemHeight = UI_SCREEN_WIDTH + 58;
// for(int i=0;i<singleShowArray.count;i++){ // for(int i=0;i<singleShowArray.count;i++){
...@@ -143,28 +153,15 @@ ...@@ -143,28 +153,15 @@
} }
#pragma mark - KWMBannerViewDelegate #pragma mark - KWMBannerViewDelegate
-(UIView *)bannerView:(KWMBannerView *)bannerView reusingView:(UIView *)reusingView pageAtIndex:(NSInteger)index{
UIView *itemView = reusingView?reusingView:nil;
KWMProductBannerItemView *productBannerItem = nil;
if(!itemView){
productBannerItem = [[KWMProductBannerItemView alloc]initWithFrame:CGRectMake(0, 0, bannerView.frame.size.width, bannerView.frame.size.height)];
}else{
productBannerItem = (KWMProductBannerItemView *)itemView;
}
itemView = productBannerItem;
return itemView;
}
-(NSInteger)numberOfPagesForBanner:(KWMBannerView *)bannerView{ - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
return self.bannerArray?self.bannerArray.count:0; [self.delegate kwm_onClickHotSalesAd:self.bannerArray[index]];
} }
-(void)bannerView:(KWMBannerView *)bannerView onClickPage:(NSInteger)index{ //-(void)bannerView:(KWMBannerView *)bannerView onClickPage:(NSInteger)index{
BUYProduct *product = [self.bannerArray objectAtIndex:index]; // KWMAdvertisement *adv = [self.bannerArray objectAtIndex:index];
if(self.delegate){ // [self.delegate kwm_onClickFocusImage:adv];
[self.delegate kwm_onClickProduct:product]; //}
}
}
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<constraint firstItem="ILX-tg-IwY" firstAttribute="centerY" secondItem="d0n-L5-xP1" secondAttribute="centerY" id="r8p-Ru-bb6"/> <constraint firstItem="ILX-tg-IwY" firstAttribute="centerY" secondItem="d0n-L5-xP1" secondAttribute="centerY" id="r8p-Ru-bb6"/>
</constraints> </constraints>
</view> </view>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ruv-UI-DGw" userLabel="热卖单品Banner" customClass="KWMBannerView"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ruv-UI-DGw" userLabel="热卖单品Banner">
<rect key="frame" x="0.0" y="60" width="375" height="190"/> <rect key="frame" x="0.0" y="60" width="375" height="190"/>
<color key="backgroundColor" red="0.90588235289999997" green="0.81960784310000001" blue="0.74117647060000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.90588235289999997" green="0.81960784310000001" blue="0.74117647060000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
......
...@@ -79,12 +79,6 @@ typedef enum{ ...@@ -79,12 +79,6 @@ typedef enum{
- (void)viewWillAppear:(BOOL)animated{ - (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated]; [super viewWillAppear:animated];
if(self.adHeader){
[self.adHeader startBannerTimer];
}
if(self.hotSalesHeader){
[self.hotSalesHeader startBannerTimer];
}
[self.navigationController setNavigationBarHidden:YES]; [self.navigationController setNavigationBarHidden:YES];
if (self.titleView) { if (self.titleView) {
NSInteger count = [[KWMShoppingCart sharedInstance] count].integerValue; NSInteger count = [[KWMShoppingCart sharedInstance] count].integerValue;
...@@ -96,12 +90,6 @@ typedef enum{ ...@@ -96,12 +90,6 @@ typedef enum{
-(void)viewDidDisappear:(BOOL)animated{ -(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated]; [super viewDidDisappear:animated];
if(self.adHeader){
[self.adHeader endBannerTimer];
}
if(self.hotSalesHeader){
[self.hotSalesHeader endBannerTimer];
}
} }
...@@ -167,7 +155,11 @@ typedef enum{ ...@@ -167,7 +155,11 @@ typedef enum{
#pragma mark - KWMMenuDelegate #pragma mark - KWMMenuDelegate
-(void)kwm_onClickHotMenu{ -(void)kwm_onClickHotMenu{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/new?title=最新单品"]; if([TestModel isEqualToString:@"YES"]){
[self openURLWithString:[NSString stringWithFormat:@"https://cemarose.myshopify.com/products/%@",@"17618-01"]];
}else{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/new?title=最新单品"];
}
} }
-(void)kwm_onClickNewMenu{ -(void)kwm_onClickNewMenu{
...@@ -194,6 +186,16 @@ typedef enum{ ...@@ -194,6 +186,16 @@ typedef enum{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/hot-sell-app?title=主推单品"]; [self openURLWithString:@"https://cemarose.myshopify.com/collections/hot-sell-app?title=主推单品"];
} }
-(void)kwm_onClickHotSalesAd:(KWMAdvertisement *)ad {
[self openURLWithString:ad.url];
}
-(void)kwm_onClickFocusImage {
if (![KWMStringUtil isBlank:self.homeData.clothing_sets.action]) {
[self openURLWithString:self.homeData.clothing_sets.action];
}
}
-(void)kwm_gotoClothingSetsPage{ -(void)kwm_gotoClothingSetsPage{
// [self openURLWithString:[NSString stringWithFormat:@"https://cemarose.myshopify.com/collections/%@",self.clotingSetsHandle]]; // [self openURLWithString:[NSString stringWithFormat:@"https://cemarose.myshopify.com/collections/%@",self.clotingSetsHandle]];
[self openURLWithString:self.homeData.clothing_sets.url]; [self openURLWithString:self.homeData.clothing_sets.url];
...@@ -396,6 +398,7 @@ typedef enum{ ...@@ -396,6 +398,7 @@ typedef enum{
_homeData = homeData; _homeData = homeData;
// [self.homeData.ad_banner[0] setUrl:@"https://www.cemarose.cn/collections/skirts/girls"]; // [self.homeData.ad_banner[0] setUrl:@"https://www.cemarose.cn/collections/skirts/girls"];
self.adHeader.adArray = self.homeData.ad_banner; self.adHeader.adArray = self.homeData.ad_banner;
self.hotSalesHeader.bannerArray = self.homeData.hot_sales_ads;
// self.homeData.hot_sales.single_show_count = @(1); // self.homeData.hot_sales.single_show_count = @(1);
self.clothingSetsHeader.headerImage = self.homeData.clothing_sets.image; self.clothingSetsHeader.headerImage = self.homeData.clothing_sets.image;
// self.homeData.clothing_sets.url =@"https://www.cemarose.cn/collections/skirts/girls+spring-summer-2016?title=ml"; // self.homeData.clothing_sets.url =@"https://www.cemarose.cn/collections/skirts/girls+spring-summer-2016?title=ml";
...@@ -411,7 +414,6 @@ typedef enum{ ...@@ -411,7 +414,6 @@ typedef enum{
} }
} }
[self requestProductWithHandle:@"products-list-app-homepage" tags:nil valueKeyPath:@"productArray"]; [self requestProductWithHandle:@"products-list-app-homepage" tags:nil valueKeyPath:@"productArray"];
NSLog(@"path:%@",clothingParam);
} }
- (void)setProductArray:(NSArray<BUYProduct *> *)productArray { - (void)setProductArray:(NSArray<BUYProduct *> *)productArray {
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
-(void)viewWillAppear:(BOOL)animated { -(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO]; [self.navigationController setNavigationBarHidden:NO];
[self setTotalPrice];
} }
- (IBAction)onClickComplete:(id)sender{ - (IBAction)onClickComplete:(id)sender{
...@@ -52,7 +53,6 @@ ...@@ -52,7 +53,6 @@
[self.tbvWish registerNib:[UINib nibWithNibName:NSStringFromClass([KWMWishCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([KWMWishCell class])]; [self.tbvWish registerNib:[UINib nibWithNibName:NSStringFromClass([KWMWishCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([KWMWishCell class])];
self.wishArray = [NSMutableArray array]; self.wishArray = [NSMutableArray array];
self.productArray = [NSMutableArray array]; self.productArray = [NSMutableArray array];
[self setTotalPrice];
} }
-(void)removeWish:(NSNumber *)variantId{ -(void)removeWish:(NSNumber *)variantId{
...@@ -92,6 +92,7 @@ ...@@ -92,6 +92,7 @@
wish.variantSku = variant.sku; wish.variantSku = variant.sku;
wish.variantTitle = variant.title; wish.variantTitle = variant.title;
[self.tbvWish reloadData]; [self.tbvWish reloadData];
break;
} }
} }
} }
......
...@@ -570,8 +570,6 @@ ...@@ -570,8 +570,6 @@
if(this.checkout.shippingAddress && !this.checkout.shippingRate) { if(this.checkout.shippingAddress && !this.checkout.shippingRate) {
[this requestShippingData]; [this requestShippingData];
} }
//排除已被支付的checkout的可能性
[this requestOrderPayResult];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[this hideLoading]; [this hideLoading];
[this showError:error]; [this showError:error];
...@@ -622,13 +620,11 @@ ...@@ -622,13 +620,11 @@
} }
-(void)requestOrderPayResult{ -(void)requestOrderPayResult{
//微信支付,用户支付后,当用户没有点击完成按钮,而是直接使用home键,或者点击状态栏左上角返回APP订单页面时,微信的回调不会调用,而很容易出现订单结果丢失的情况,所以需要再确认一次订单是否完成。 //微信支付,用户支付后,当用户没有点击完成按钮,而是直接使用home键,或者点击状态栏左上角返回APP订单页面时,微信的回调不会调用,而很容易出现本地订单结果回调丢失的情况,所以需要再确认一次订单是否完成。
//支付宝暂时没有这种问题。 //支付宝暂时没有这种问题。
//另外用到的情况:上次被支付的订单,因某些突发原因没从缓存清除。 if(self.beforePayData && ![KWMStringUtil isEmpty:self.beforePayData.outTradeNo] && self.checkout){
//if(self.beforePayData && self.beforePayData.wechatPayData && self.checkout){ NSDictionary *parameters = [KWMPayUtil payResultParameters:self.checkout tradeNo:self.beforePayData.outTradeNo];
if(self.checkout){ self.beforePayData.outTradeNo = @"";
NSDictionary *parameters = [KWMPayUtil payResultParameters:self.checkout];
self.beforePayData.wechatPayData = nil;
__weak KWMBeforePayVC *weakSelf = self; __weak KWMBeforePayVC *weakSelf = self;
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){ void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
//[weakSelf showError:error]; //[weakSelf showError:error];
...@@ -641,7 +637,7 @@ ...@@ -641,7 +637,7 @@
return; return;
} }
if(result.data){ if(result.data){
KWMOrderPaid *data = (KWMOrderPaid *)result.data; //KWMOrderPaid *data = (KWMOrderPaid *)result.data;
[weakSelf paySuccess]; [weakSelf paySuccess];
} }
}; };
...@@ -659,11 +655,12 @@ ...@@ -659,11 +655,12 @@
}; };
void(^success)(NSURLSessionDataTask *,KWMCheckoutPayResult *) = ^(NSURLSessionDataTask *task,KWMCheckoutPayResult *result){ void(^success)(NSURLSessionDataTask *,KWMCheckoutPayResult *) = ^(NSURLSessionDataTask *task,KWMCheckoutPayResult *result){
[weakSelf hideLoading]; [weakSelf hideLoading];
if(!result){ if(!(result && result.code)){
return; return;
} }
if(!result.code || result.code.integerValue != 1000){ if(result.code.integerValue != 1000){
NSLog(@"error: %@",result.message); NSString *message = [KWMPayUtil payErrorMessage:weakSelf.checkout errorResult:result];
[weakSelf showDialog:message];
return; return;
} }
NSString *alipayData = (NSString *)result.message; NSString *alipayData = (NSString *)result.message;
...@@ -694,16 +691,18 @@ ...@@ -694,16 +691,18 @@
}; };
void(^success)(NSURLSessionDataTask *,KWMCheckoutPayResult *) = ^(NSURLSessionDataTask *task,KWMCheckoutPayResult *result){ void(^success)(NSURLSessionDataTask *,KWMCheckoutPayResult *) = ^(NSURLSessionDataTask *task,KWMCheckoutPayResult *result){
[weakSelf hideLoading]; [weakSelf hideLoading];
if(!result){ if(!(result && result.code)){
return; return;
} }
if(!result.code || result.code.integerValue != 1000){ if(result.code.integerValue != 1000){
NSString *message = [KWMPayUtil payErrorMessage:weakSelf.checkout errorResult:result];
[weakSelf showDialog:message];
return; return;
} }
if(result.data){ if(result.data){
KWMWechatPayData *data = (KWMWechatPayData *)result.data; KWMWechatPayData *data = (KWMWechatPayData *)result.data;
[KWMPayUtil weChatPay:data]; [KWMPayUtil weChatPay:data];
weakSelf.beforePayData.wechatPayData = data; weakSelf.beforePayData.outTradeNo = data.outTradeNo;
} }
}; };
[self.api wechatPayUnifiedOrder:parameters success:success failure:failure]; [self.api wechatPayUnifiedOrder:parameters success:success failure:failure];
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
+ (NSDictionary *) aliPayParameters:(BUYCheckout *)checkout; + (NSDictionary *) aliPayParameters:(BUYCheckout *)checkout;
//构建支付结果查询数据 //构建支付结果查询数据
+(NSDictionary *)payResultParameters:(BUYCheckout *)checkout; +(NSDictionary *)payResultParameters:(BUYCheckout *)checkout tradeNo:(NSString *)tradeNo;
//调用微信SDK //调用微信SDK
+ (void)weChatPay:(KWMWechatPayData *)wechatData; + (void)weChatPay:(KWMWechatPayData *)wechatData;
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
//调用支付宝SDK //调用支付宝SDK
+ (void)aliPay:(NSString *)alipayData callback:(CompletionBlock)callback; + (void)aliPay:(NSString *)alipayData callback:(CompletionBlock)callback;
//支付失败提示信息
+(NSString *)payErrorMessage:(BUYCheckout *)checkout errorResult:(KWMCheckoutPayResult *)errorResult;
@end @end
...@@ -81,22 +81,21 @@ ...@@ -81,22 +81,21 @@
return parameters; return parameters;
} }
//现在在两个地方会用到这条api //微信支付后直接切换回到APP会调用此方法
//1,支付后切换回到APP +(NSDictionary *)payResultParameters:(BUYCheckout *)checkout tradeNo:(NSString *)tradeNo{
//2,beforepay创建/复用旧checkout时,判断该checkout是否被支付了,但是之前没清空。
+(NSDictionary *)payResultParameters:(BUYCheckout *)checkout{
#if DEBUG #if DEBUG
NSString *checkout_token = checkout.token; NSString *checkout_token = checkout.token;
#else #else
NSString *checkout_token = checkout.token; NSString *checkout_token = checkout.token;
#endif #endif
NSString *before_sign = [NSString stringWithFormat:@"checkout_token=%@&key=%@", NSString *out_trade_no = tradeNo?:@"";
checkout_token,User_Pay_KEY]; NSString *before_sign = [NSString stringWithFormat:@"checkout_token=%@&out_trade_no=%@&key=%@",
checkout_token,out_trade_no,User_Pay_KEY];
NSString *base64String = [KWMStringUtil BASE64:before_sign]; NSString *base64String = [KWMStringUtil BASE64:before_sign];
NSString *sign = [KWMStringUtil MD5:base64String]; NSString *sign = [KWMStringUtil MD5:base64String];
NSDictionary *parameters = @{ NSDictionary *parameters = @{
@"checkout_token":checkout_token, @"checkout_token":checkout_token,
@"out_trade_no":out_trade_no,
@"sign":sign @"sign":sign
}; };
return parameters; return parameters;
...@@ -123,4 +122,63 @@ ...@@ -123,4 +122,63 @@
} }
} }
/*
|code|int|1000|正常响应|
|code|int|1001|订单检索失败,未找到相应的订单数据|
|code|int|1002|请求的总金额与订单中不一致|
|code|int|1003|货币转换失败|
|code|int|1004|服务器端未开通店铺|
|code|int|1005|支付网关参数未设置|
|code|int|1006|订单已支付完成|
|code|int|1007|签名验证失败|
|code|int|1008|订单查询失败|
|code|int|1009|订单创建失败|
|code|int|1010|必要参数缺失|
|code|int|1012|商品数量不足|
*/
+(NSString *)payErrorMessage:(BUYCheckout *)checkout errorResult:(KWMCheckoutPayResult *)errorResult{
if(!errorResult){
return @"";
}
if(errorResult.code){
switch (errorResult.code.integerValue) {
case 1000:
return @"";
case 1001:
return @"订单检索失败,未找到相应的订单数据";
case 1002:
return @"请求的总金额与订单中不一致";
case 1003:
return @"货币转换失败";
case 1004:
return @"服务器端未开通店铺";
case 1005:
return @"支付网关参数未设置";
case 1006:
return @"订单已支付完成";
case 1007:
return @"签名验证失败";
case 1008:
return @"订单查询失败";
case 1009:
return @"订单创建失败";
case 1010:
return @"必要参数缺失";
case 1012:
if(!(checkout && errorResult.variantId) ){
return @"";
}
for(BUYCartLineItem *item in checkout.lineItemsArray){
if([item.variantId isEqualToNumber:errorResult.variantId]){
NSString *message = [NSString stringWithFormat:@"商品“%@/%@”数量不足",item.title,item.variantTitle];
return message;
}
}
return @"商品数量不足";
}
}
return @"";
}
@end @end
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.5.2</string> <string>1.5.3</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2017072520</string> <string>2017080413</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LSApplicationQueriesSchemes</key> <key>LSApplicationQueriesSchemes</key>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment