Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ios1x
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
ios1x
Commits
e0173bd6
Commit
e0173bd6
authored
Jun 16, 2017
by
houweibin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,支付验证调整
2,支付方式选择调整 3,其他
parent
42034f2a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
269 additions
and
45 deletions
+269
-45
project.pbxproj
iCemarose.xcodeproj/project.pbxproj
+6
-0
KWMBeforePayVC.m
iCemarose/Class/UI/ShopCart/KWMBeforePayVC.m
+14
-36
KWMPayTypeVC.h
iCemarose/Class/UI/ShopCart/KWMPayTypeVC.h
+0
-2
KWMPayTypeVC.m
iCemarose/Class/UI/ShopCart/KWMPayTypeVC.m
+0
-7
ShopCart.storyboard
iCemarose/Class/UI/ShopCart/ShopCart.storyboard
+0
-0
KWMCollectionRefreshUtil.h
iCemarose/Class/Util/KWMCollectionRefreshUtil.h
+57
-0
KWMCollectionRefreshUtil.m
iCemarose/Class/Util/KWMCollectionRefreshUtil.m
+192
-0
No files found.
iCemarose.xcodeproj/project.pbxproj
View file @
e0173bd6
...
...
@@ -193,6 +193,7 @@
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 */
;
};
...
...
@@ -650,6 +651,8 @@
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>"
;
};
...
...
@@ -1218,6 +1221,8 @@
C034E6C41D6AECF9006EE129
/* Util */
=
{
isa
=
PBXGroup
;
children
=
(
C048B8E31EF3F20B000DA7AF
/* KWMCollectionRefreshUtil.h */
,
C048B8E41EF3F20B000DA7AF
/* KWMCollectionRefreshUtil.m */
,
C077966D1EEAA2BE00CD6859
/* KWMFilterUtil.h */
,
C077966E1EEAA2BE00CD6859
/* KWMFilterUtil.m */
,
C02C7D991E642DED008DC29C
/* KWMWeChatUtil.h */
,
...
...
@@ -2185,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 */
,
...
...
iCemarose/Class/UI/ShopCart/KWMBeforePayVC.m
View file @
e0173bd6
...
...
@@ -40,12 +40,14 @@
-
(
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
];
...
...
@@ -433,7 +435,7 @@
}
//不同的支付方式
switch
(
self
.
payType
)
{
case
Type
Credit
:
case
Type
Webpay
:
[
self
goToWebPay
];
break
;
case
TypeAlipay
:
...
...
@@ -605,25 +607,14 @@
-
(
void
)
validateOrderPayResult
{
//微信支付,用户支付后,当用户没有点击完成按钮,而是直接使用home键,或者点击状态栏左上角返回APP订单页面时,微信的回调不会调用,而很容易出现订单结果丢失的情况,所以需要再确认一次订单是否完成。
//支付宝暂时没有这种问题。
__weak
KWMBeforePayVC
*
weakSelf
=
self
;
if
(
self
.
beforePayData
&&
self
.
beforePayData
.
wechatPayData
){
NSString
*
sign
=
@""
;
NSDictionary
*
parameters
=
@{
@"transaction_id"
:
self
.
beforePayData
.
wechatPayData
.
prepayid
,
@"sign"
:
sign
};
weakSelf
.
beforePayData
.
wechatPayData
=
nil
;
void
(
^
failure
)(
NSURLSessionDataTask
*
,
NSError
*
)
=
^
(
NSURLSessionDataTask
*
task
,
NSError
*
error
){
};
void
(
^
success
)(
NSURLSessionDataTask
*
,
KWMCheckoutPayResult
*
)
=
^
(
NSURLSessionDataTask
*
task
,
KWMCheckoutPayResult
*
result
){
if
(
result
)
if
(
result
&&
result
.
status
&&
[
result
.
status
isEqualToString
:
@"success"
]){
if
(
result
.
code
&&
result
.
code
.
integerValue
==
1000
){
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
];
}
}
};
[
self
.
api
wechatPayOrderQuery
:
parameters
success
:
success
failure
:
failure
];
}];
}
}
...
...
@@ -675,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
];
...
...
@@ -693,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
iCemarose/Class/UI/ShopCart/KWMPayTypeVC.h
View file @
e0173bd6
...
...
@@ -27,8 +27,6 @@ typedef NS_ENUM(NSInteger, KWMPayType) {
-
(
IBAction
)
onClickAliPay
:(
id
)
sender
;
-
(
IBAction
)
onClickCreditPay
:(
id
)
sender
;
@property
(
weak
,
nonatomic
)
id
<
KWMPayTypeDelegate
>
delegate
;
...
...
iCemarose/Class/UI/ShopCart/KWMPayTypeVC.m
View file @
e0173bd6
...
...
@@ -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
];
...
...
iCemarose/Class/UI/ShopCart/ShopCart.storyboard
View file @
e0173bd6
This diff is collapsed.
Click to expand it.
iCemarose/Class/Util/KWMCollectionRefreshUtil.h
0 → 100644
View file @
e0173bd6
//
// 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
iCemarose/Class/Util/KWMCollectionRefreshUtil.m
0 → 100644
View file @
e0173bd6
//
// 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
.
0
f
];
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
.
0
f
];
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment