Commit db4977fb by lee

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

parents ddae4359 e0173bd6
......@@ -192,6 +192,8 @@
C03943C01DD1FCE900141475 /* KWMProductType.m in Sources */ = {isa = PBXBuildFile; fileRef = C03943BF1DD1FCE900141475 /* KWMProductType.m */; };
C03943C31DD1FD3F00141475 /* KWMProductTypeResult.m in Sources */ = {isa = PBXBuildFile; fileRef = C03943C21DD1FD3F00141475 /* KWMProductTypeResult.m */; };
C03A05061E35DC5800BAA889 /* KWMNewGiftCardVC.m in Sources */ = {isa = PBXBuildFile; fileRef = C03A05051E35DC5800BAA889 /* KWMNewGiftCardVC.m */; };
C048B8E21EF3C04B000DA7AF /* KWMBeforePayData.m in Sources */ = {isa = PBXBuildFile; fileRef = C048B8E11EF3C04B000DA7AF /* KWMBeforePayData.m */; };
C048B8E51EF3F20B000DA7AF /* KWMCollectionRefreshUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = C048B8E41EF3F20B000DA7AF /* KWMCollectionRefreshUtil.m */; };
C05910941E34A729002990B3 /* KWMNewGiftCardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C05910921E34A729002990B3 /* KWMNewGiftCardCell.m */; };
C05910951E34A729002990B3 /* KWMNewGiftCardCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C05910931E34A729002990B3 /* KWMNewGiftCardCell.xib */; };
C06665091D75A2E500F02EF4 /* KWMOrderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C06665041D75A2E500F02EF4 /* KWMOrderCell.m */; };
......@@ -647,6 +649,10 @@
C03943C21DD1FD3F00141475 /* KWMProductTypeResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMProductTypeResult.m; sourceTree = "<group>"; };
C03A05041E35DC5800BAA889 /* KWMNewGiftCardVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMNewGiftCardVC.h; sourceTree = "<group>"; };
C03A05051E35DC5800BAA889 /* KWMNewGiftCardVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMNewGiftCardVC.m; sourceTree = "<group>"; };
C048B8E01EF3C04B000DA7AF /* KWMBeforePayData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMBeforePayData.h; sourceTree = "<group>"; };
C048B8E11EF3C04B000DA7AF /* KWMBeforePayData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMBeforePayData.m; sourceTree = "<group>"; };
C048B8E31EF3F20B000DA7AF /* KWMCollectionRefreshUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMCollectionRefreshUtil.h; sourceTree = "<group>"; };
C048B8E41EF3F20B000DA7AF /* KWMCollectionRefreshUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMCollectionRefreshUtil.m; sourceTree = "<group>"; };
C05910911E34A729002990B3 /* KWMNewGiftCardCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWMNewGiftCardCell.h; path = ../../ShopCart/Cell/KWMNewGiftCardCell.h; sourceTree = "<group>"; };
C05910921E34A729002990B3 /* KWMNewGiftCardCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWMNewGiftCardCell.m; path = ../../ShopCart/Cell/KWMNewGiftCardCell.m; sourceTree = "<group>"; };
C05910931E34A729002990B3 /* KWMNewGiftCardCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = KWMNewGiftCardCell.xib; path = ../../ShopCart/Cell/KWMNewGiftCardCell.xib; sourceTree = "<group>"; };
......@@ -1180,6 +1186,8 @@
9BE61CFD1ECD66BC0031D21E /* KWMShoppingCart.m */,
C0CCB3BB1EEA589200BC2FB8 /* KWMFilter.h */,
C0CCB3BC1EEA589200BC2FB8 /* KWMFilter.m */,
C048B8E01EF3C04B000DA7AF /* KWMBeforePayData.h */,
C048B8E11EF3C04B000DA7AF /* KWMBeforePayData.m */,
9B18C11D1EF1270A001DD59B /* BUYProductVariant+Currency.h */,
9B18C11E1EF1270A001DD59B /* BUYProductVariant+Currency.m */,
);
......@@ -1213,6 +1221,8 @@
C034E6C41D6AECF9006EE129 /* Util */ = {
isa = PBXGroup;
children = (
C048B8E31EF3F20B000DA7AF /* KWMCollectionRefreshUtil.h */,
C048B8E41EF3F20B000DA7AF /* KWMCollectionRefreshUtil.m */,
C077966D1EEAA2BE00CD6859 /* KWMFilterUtil.h */,
C077966E1EEAA2BE00CD6859 /* KWMFilterUtil.m */,
C02C7D991E642DED008DC29C /* KWMWeChatUtil.h */,
......@@ -2180,6 +2190,7 @@
C084F4531D6D8CA700A0625D /* KWMBlogCell.m in Sources */,
C0DD53361EE55190002D1E0C /* KWMLoadingHeader.m in Sources */,
807AF4A21DC984950000A326 /* KWMArticlesResult.m in Sources */,
C048B8E51EF3F20B000DA7AF /* KWMCollectionRefreshUtil.m in Sources */,
C034E6E41D6AEF73006EE129 /* KWMRequestResult.m in Sources */,
8019E9541DC89CF300CAD7BF /* KWMNewGoodsModel.m in Sources */,
C034E7B01D6AFBDA006EE129 /* KWMWebViewVC.m in Sources */,
......@@ -2193,6 +2204,7 @@
C03120B01EF2B26B00E49EFA /* KWMPayUtil.m in Sources */,
9BE61CFB1ECD56E70031D21E /* KWMDictioaryResult.m in Sources */,
C034E6D81D6AEF1B006EE129 /* KWMImageUtil.m in Sources */,
C048B8E21EF3C04B000DA7AF /* KWMBeforePayData.m in Sources */,
C03846941DB89EEB008C3BAB /* KWMCemaroseResult.m in Sources */,
C0F586951E25C17A001248E2 /* KWMProductDetailVC.m in Sources */,
C0F586871E24F820001248E2 /* KWMNewTypeSelectedVC.m in Sources */,
......
//
// KWMBeforePayData.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/16.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "KWMBaseModel.h"
#import "KWMWechatPayData.h"
@interface KWMBeforePayData : KWMBaseModel
@property (nonatomic) KWMWechatPayData *wechatPayData;
@end
//
// KWMBeforePayData.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/16.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBeforePayData.h"
@implementation KWMBeforePayData
@end
......@@ -7,8 +7,8 @@
//
// 筛选model
//
#import "KWMBaseModel.h"
#import <JSONModel/JSONModel.h>
#import <Foundation/Foundation.h>
@interface KWMFilter : KWMBaseModel
......
......@@ -14,7 +14,7 @@
#import "KWMAddGiftCardVC.h"
#import "KWMShippingVC.h"
#import "KWMPayTypeVC.h"
#import "KWMBeforePayData.h"
@interface KWMBeforePayVC : KWMBaseVC<KWMGiftCardDelegate,KWMDiscountDelegate,KWMSelectAddressDelegate,KWMSelectShippingRateDelegate,KWMPayTypeDelegate>
......@@ -44,6 +44,10 @@
@property (weak, nonatomic) IBOutlet UILabel *lbShippingRate;
@property (weak, nonatomic) IBOutlet UIView *vPayType;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightPayType;
@property (nonatomic) BUYAddress *address;
//创建订单异步请求
......@@ -60,6 +64,8 @@
@property (nonatomic) KWMPayType payType;
@property (nonatomic) KWMBeforePayData *beforePayData;
@property (strong, nonatomic) NSString *cartCookie;
- (IBAction)onClickPayType:(id)sender;
......
......@@ -40,12 +40,15 @@
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self validateOrderPayResult];
[self initDefaultData];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"提交订单";
self.payType = [self.userDao.currencyCode isEqualToString:@"EUR"]?TypeWebpay:TypeNone;
self.beforePayData = [KWMBeforePayData new];
//支付成功回调广播接收者 ##通过广播接受appdelegate中的支付回调。
NSNotificationCenter *notifi = [NSNotificationCenter defaultCenter];
[notifi addObserver:self selector:@selector(paySuccess) name:KWMPaySuccess object:nil];
......@@ -61,7 +64,13 @@
-(void)setPayType:(KWMPayType)payType{
_payType = payType;
self.lbPayType.text = [KWMPayUtil payTypeString:payType];
//web支付,隐藏选择支付栏
if(payType == TypeWebpay){
self.heightPayType.constant = 0;
self.vPayType.hidden = YES;
}else{
self.lbPayType.text = [KWMPayUtil payTypeString:payType];
}
}
-(void)initDefaultData{
......@@ -426,7 +435,7 @@
}
//不同的支付方式
switch (self.payType) {
case TypeCredit:
case TypeWebpay:
[self goToWebPay];
break;
case TypeAlipay:
......@@ -595,6 +604,20 @@
}];
}
-(void)validateOrderPayResult{
//微信支付,用户支付后,当用户没有点击完成按钮,而是直接使用home键,或者点击状态栏左上角返回APP订单页面时,微信的回调不会调用,而很容易出现订单结果丢失的情况,所以需要再确认一次订单是否完成。
//支付宝暂时没有这种问题。
if(self.beforePayData && self.beforePayData.wechatPayData){
self.beforePayData.wechatPayData = nil;
__weak KWMBeforePayVC *weakSelf = self;
[self.client getCompletionStatusOfCheckoutWithToken:self.checkout.token completion:^(BUYStatus status, NSError * _Nullable error) {
if (!error && status) {
[weakSelf paySuccess];
}
}];
}
}
//支付宝支付
-(void)requestAliPay{
NSDictionary *parameters = [KWMPayUtil aliPayParameters:self.checkout];
......@@ -643,6 +666,7 @@
if(result.data){
KWMWechatPayData *data = (KWMWechatPayData *)result.data;
[KWMPayUtil weChatPay:data];
weakSelf.beforePayData.wechatPayData = data;
}
};
[self.api wechatPayUnifiedOrder:parameters success:success failure:failure];
......@@ -661,25 +685,11 @@
}
////判断订单是否支付
//-(void)requestCheckPay:(BUYCheckout *)checkCache{
// [self showLoading];
// __weak KWMBeforePayVC *weakSelf = self;
// [self.client getCompletionStatusOfCheckoutWithToken:checkCache.token completion:^(BUYStatus status, NSError * _Nullable error) {
// [self hideLoading];
// if (error == nil && status) {
// if(status == BUYStatusProcessing){
// weakSelf.checkout = checkCache;
// //在原有缓存订单的基础上设置初始数据
// [weakSelf initDefaultData];
// return;
// }
// }
// [weakSelf.userDao deleteCheckoutCache];
// [weakSelf initDefaultData];
//
// }];
//}
//判断订单是否支付
-(void)requestCheckPay:(BUYCheckout *)checkout{
[self showLoading];
}
@end
......@@ -10,6 +10,7 @@
typedef NS_ENUM(NSInteger, KWMPayType) {
TypeNone = 0,
TypeWebpay,
TypeCredit,
TypeAlipay,
TypeWechatPay
......@@ -26,8 +27,6 @@ typedef NS_ENUM(NSInteger, KWMPayType) {
- (IBAction)onClickAliPay:(id)sender;
- (IBAction)onClickCreditPay:(id)sender;
@property (weak, nonatomic) id<KWMPayTypeDelegate>delegate;
......
......@@ -36,13 +36,6 @@
[[self navigationController] popViewControllerAnimated:YES];
}
-(void)onClickCreditPay:(id)sender{
if(self.delegate){
[self.delegate kwm_onSelectPayType:TypeCredit];
}
[[self navigationController] popViewControllerAnimated:YES];
}
-(void)onClickWechatPay:(id)sender{
if(self.delegate){
[self.delegate kwm_onSelectPayType:TypeWechatPay];
......
//
// KWMCollectionRefreshUtil.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/16.
// Copyright © 2017年 kollway. All rights reserved.
//
// 这个工具类只支持简单的collection样式,如果有更复杂的需要,后面会进行调整。
#import <Foundation/Foundation.h>
@class KWMCollectionRefreshUtil;
@protocol KWMCollectionRefreshDelegate
- (void)refreshUtil:(KWMCollectionRefreshUtil *)util onLoad:(NSInteger)page;
@end
@interface KWMCollectionRefreshUtil : NSObject
@property (nonatomic, weak) id<KWMCollectionRefreshDelegate> delegate;
@property (nonatomic, weak) UICollectionView *collectionView;
@property (nonatomic, weak) UIView *emptyView;
@property (nonatomic) NSString *emptyMsg;
@property (nonatomic) NSString *imageName;
@property (nonatomic) BOOL isShowEmptyImage;
@property (nonatomic) NSMutableArray *lastResult;
@property (nonatomic) NSMutableArray *dataList;
@property (nonatomic) BOOL hasNextPage;
@property (nonatomic) NSInteger page;
@property (nonatomic, copy) BOOL (^dataFilter)(id data);
@property (nonatomic) BOOL hideHeader;
-(void)setRefreshNull;
- (void)reLoadData;
- (void)clearData;
- (BOOL)isLoading;
- (void)hideLoading;
- (void)appendDataList:(NSArray *)result;
- (BOOL)isReload;
@end
//
// KWMCollectionRefreshUtil.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/16.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMCollectionRefreshUtil.h"
#import "KWMLoadingHeader.h"
#import "MJRefresh.h"
#import "KWMStringUtil.h"
#import "UIColor+SAMAdditions.h"
@interface KWMCollectionRefreshUtil()
@end
@implementation KWMCollectionRefreshUtil
-(NSMutableArray *)dataList{
if(!_dataList){
_dataList = [NSMutableArray new];
}
if (_dataList.count > 0) {
if (self.dataFilter) {
NSMutableArray *filted = [NSMutableArray new];
for (id data in _dataList) {
if (self.dataFilter(data)) {
[filted addObject:data];
}
}
return filted;
}
}
return _dataList;
}
- (BOOL)isLoading {
return [self.collectionView.mj_header isRefreshing] || [self.collectionView.mj_footer isRefreshing];
}
- (void)hideLoading {
[self.collectionView.mj_header endRefreshing];
[self.collectionView.mj_footer endRefreshing];
};
//隐藏上啦下啦刷新
-(void)setRefreshNull{
[self.collectionView setMj_header:nil];
[self.collectionView setMj_footer:nil];
}
- (void)appendDataList:(NSArray *)result {
if (self.page == 1) {
[self.dataList removeAllObjects];
}
if (result) {
[self.dataList addObjectsFromArray:result];
}
if (!self.hasNextPage) {
self.collectionView.mj_footer.hidden = YES;
}else{
self.collectionView.mj_footer.hidden = NO;
}
[self.collectionView reloadData];
BOOL hide = self.dataList.count > 0;
self.emptyView.hidden = hide;
self.lastResult = [NSMutableArray arrayWithArray:result];
}
- (UIView *)emptyView {
if (_emptyView == nil) {
UIView *emptyView = [[UIView alloc] init];
emptyView.backgroundColor = [UIColor clearColor];
emptyView.frame = CGRectMake(0, 0, CGRectGetWidth(self.collectionView.frame), CGRectGetHeight(self.collectionView.frame) );
NSString *msg = @"暂时没有数据";
if (![KWMStringUtil isEmpty:self.emptyMsg]) {
msg = self.emptyMsg;
}
if(self.isShowEmptyImage){
emptyView.backgroundColor = [UIColor whiteColor];
UIView *childView = [self getHasImageView:emptyView setTips:msg];
[emptyView addSubview:childView];
}else{
CGFloat labelHeight = 25;
NSInteger labelY = CGRectGetHeight(emptyView.frame)/2 - labelHeight;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, labelY, CGRectGetWidth(emptyView.frame), labelHeight)];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor darkGrayColor];
label.font = [UIFont systemFontOfSize:14.0f];
label.text = msg;
[emptyView addSubview:label];
}
[self.collectionView addSubview:emptyView];
[self.collectionView bringSubviewToFront:emptyView];
_emptyView = emptyView;
}
return _emptyView;
}
//有图片的提示view
-(UIView *)getHasImageView:(UIView *)emptyView setTips:(NSString *)tips{
NSInteger childViewY = CGRectGetHeight(emptyView.frame)/2-130;//130是空view高度的一半
NSInteger childViewX = CGRectGetWidth(emptyView.frame)/2-100;//100是空view宽度的一半
UIView *childView = [[UIView alloc] initWithFrame:CGRectMake(childViewX, childViewY, 200, 260)];
childView.backgroundColor = [UIColor clearColor];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(70, 100, 60, 60)];//70是空view的宽减去image的宽除2(100也是同理)
imageView.clipsToBounds = YES;
[imageView setImage:[UIImage imageNamed:self.imageName]];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[childView addSubview:imageView];
UILabel *lbFirst = [[UILabel alloc] initWithFrame:CGRectMake(0, 170,200, 20)];
lbFirst.textAlignment = NSTextAlignmentCenter;
lbFirst.textColor = [UIColor sam_colorWithHex:@"EAECEE"];
lbFirst.font = [UIFont systemFontOfSize:14.0f];
lbFirst.text = tips;
[childView addSubview:lbFirst];
return childView;
}
-(BOOL)isReload{
return self.page == 1;
}
-(void)setCollectionView:(UICollectionView *)collectionView{
_collectionView = collectionView;
if (!self.hideHeader || !collectionView.mj_header) {
collectionView.mj_header = [self createHeader];
}
if (collectionView.mj_footer == nil) {
collectionView.mj_footer = [self createFooter];
}
}
-(MJRefreshHeader *)createHeader{
__weak KWMCollectionRefreshUtil *weakSelf = self;
KWMLoadingHeader *header = [KWMLoadingHeader headerWithRefreshingBlock:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf reLoadData];
});
}];
return header;
}
- (MJRefreshAutoNormalFooter *)createFooter {
__weak KWMCollectionRefreshUtil *weakSelf = self;
MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf loadData];
});
}];
footer.hidden = YES;
return footer;
}
- (void)reLoadData {
if(self.hideHeader){
self.lastResult = nil;
[self loadData];
}else{
[self.collectionView.mj_header beginRefreshing];
}
}
-(void)clearData{
self.lastResult = nil;
[self.dataList removeAllObjects];
[self.collectionView reloadData];
}
- (void)loadData {
[self.delegate refreshUtil:self onLoad:self.page];
}
@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