Commit e0173bd6 by houweibin

1,支付验证调整

2,支付方式选择调整
3,其他
parent 42034f2a
......@@ -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 */,
......
......@@ -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 TypeCredit:
case TypeWebpay:
[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){
[weakSelf paySuccess];
}
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
......@@ -27,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];
......
......@@ -682,41 +682,67 @@
<constraint firstAttribute="height" constant="90" id="zO1-RN-x44"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="支付" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Afz-nz-wCb">
<rect key="frame" x="30" y="167" width="30" height="21"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="15"/>
<color key="textColor" red="0.21960784310000001" green="0.21960784310000001" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1ep-3i-rAZ" userLabel="v支付方式">
<rect key="frame" x="0.0" y="200" width="374" height="40"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Yux-Ro-p2d" userLabel="支付方式">
<rect key="frame" x="0.0" y="145" width="374" height="95"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="请选择一种付款方式" textAlignment="natural" lineBreakMode="characterWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Fr9-gU-u2X">
<rect key="frame" x="30" y="12" width="314" height="17"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.22352941179999999" green="0.22352941179999999" blue="0.22352941179999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3Ed-rJ-foG">
<rect key="frame" x="324" y="10" width="20" height="20"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="d3K-2Z-bMD" userLabel="支付">
<rect key="frame" x="0.0" y="0.0" width="374" height="55"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="支付" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Afz-nz-wCb">
<rect key="frame" x="30" y="22" width="30" height="21"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="15"/>
<color key="textColor" red="0.21960784310000001" green="0.21960784310000001" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="F3M-l6-kCX"/>
<constraint firstAttribute="width" constant="20" id="ULG-n2-05F"/>
<constraint firstItem="Afz-nz-wCb" firstAttribute="top" secondItem="d3K-2Z-bMD" secondAttribute="top" constant="22" id="2xA-lW-H3d"/>
<constraint firstAttribute="height" constant="55" id="HmE-W9-fPL"/>
<constraint firstItem="Afz-nz-wCb" firstAttribute="leading" secondItem="d3K-2Z-bMD" secondAttribute="leading" constant="30" id="UMX-hS-jD3"/>
</constraints>
<state key="normal" image="button_order_deit"/>
<connections>
<outletCollection property="gestureRecognizers" destination="aLt-AM-zGa" appends="YES" id="k32-ow-FRi"/>
</connections>
</button>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1ep-3i-rAZ" userLabel="v支付方式">
<rect key="frame" x="0.0" y="55" width="374" height="40"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="请选择一种付款方式" textAlignment="natural" lineBreakMode="characterWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Fr9-gU-u2X">
<rect key="frame" x="30" y="12" width="314" height="17"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.22352941179999999" green="0.22352941179999999" blue="0.22352941179999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3Ed-rJ-foG">
<rect key="frame" x="324" y="10" width="20" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="F3M-l6-kCX"/>
<constraint firstAttribute="width" constant="20" id="ULG-n2-05F"/>
</constraints>
<state key="normal" image="button_order_deit"/>
<connections>
<outletCollection property="gestureRecognizers" destination="aLt-AM-zGa" appends="YES" id="k32-ow-FRi"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.95686274510000002" green="0.96078431369999995" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="3Ed-rJ-foG" secondAttribute="trailing" constant="30" id="57V-oG-ci0"/>
<constraint firstAttribute="trailing" secondItem="Fr9-gU-u2X" secondAttribute="trailing" constant="30" id="M7U-Jv-ok2"/>
<constraint firstItem="3Ed-rJ-foG" firstAttribute="centerY" secondItem="1ep-3i-rAZ" secondAttribute="centerY" id="Ugt-Rl-La6"/>
<constraint firstItem="Fr9-gU-u2X" firstAttribute="leading" secondItem="1ep-3i-rAZ" secondAttribute="leading" constant="30" id="fcL-xz-nJH"/>
<constraint firstItem="Fr9-gU-u2X" firstAttribute="centerY" secondItem="1ep-3i-rAZ" secondAttribute="centerY" id="zUq-aP-qzD"/>
<constraint firstAttribute="height" constant="40" id="zbx-Pl-0TZ"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.95686274510000002" green="0.96078431369999995" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="3Ed-rJ-foG" secondAttribute="trailing" constant="30" id="57V-oG-ci0"/>
<constraint firstAttribute="trailing" secondItem="Fr9-gU-u2X" secondAttribute="trailing" constant="30" id="M7U-Jv-ok2"/>
<constraint firstItem="3Ed-rJ-foG" firstAttribute="centerY" secondItem="1ep-3i-rAZ" secondAttribute="centerY" id="Ugt-Rl-La6"/>
<constraint firstItem="Fr9-gU-u2X" firstAttribute="leading" secondItem="1ep-3i-rAZ" secondAttribute="leading" constant="30" id="fcL-xz-nJH"/>
<constraint firstItem="Fr9-gU-u2X" firstAttribute="centerY" secondItem="1ep-3i-rAZ" secondAttribute="centerY" id="zUq-aP-qzD"/>
<constraint firstAttribute="height" constant="40" id="zbx-Pl-0TZ"/>
<constraint firstItem="d3K-2Z-bMD" firstAttribute="leading" secondItem="Yux-Ro-p2d" secondAttribute="leading" id="4bm-GZ-rkF"/>
<constraint firstAttribute="height" constant="95" id="CG5-Ai-UwP"/>
<constraint firstItem="d3K-2Z-bMD" firstAttribute="top" secondItem="Yux-Ro-p2d" secondAttribute="top" id="QfR-4b-sNf"/>
<constraint firstAttribute="trailing" secondItem="d3K-2Z-bMD" secondAttribute="trailing" id="gDq-ll-USd"/>
<constraint firstItem="1ep-3i-rAZ" firstAttribute="leading" secondItem="Yux-Ro-p2d" secondAttribute="leading" id="lFv-Kv-G8N"/>
<constraint firstItem="1ep-3i-rAZ" firstAttribute="top" secondItem="d3K-2Z-bMD" secondAttribute="bottom" id="o84-jd-8ls"/>
<constraint firstAttribute="trailing" secondItem="1ep-3i-rAZ" secondAttribute="trailing" id="q6K-5w-m6s"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="配送方式" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hsl-7w-xKW" userLabel="配送">
......@@ -833,24 +859,21 @@
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Afz-nz-wCb" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" constant="30" id="2Xx-oM-W0c"/>
<constraint firstItem="MY5-C7-Kcb" firstAttribute="top" secondItem="BlA-Cz-DcE" secondAttribute="top" constant="22" id="58G-Ar-blr"/>
<constraint firstItem="3g3-iU-dSA" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" id="8vj-MG-Rwk"/>
<constraint firstAttribute="bottom" secondItem="Wga-vh-5gr" secondAttribute="bottom" id="9mb-Gf-9QV"/>
<constraint firstItem="LpT-uQ-5JS" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" constant="30" id="AJZ-cD-G5p"/>
<constraint firstItem="Hsl-7w-xKW" firstAttribute="top" secondItem="1ep-3i-rAZ" secondAttribute="bottom" constant="22" id="CJA-Sb-ajp"/>
<constraint firstItem="Afz-nz-wCb" firstAttribute="top" secondItem="qFl-Qx-3nj" secondAttribute="bottom" constant="22" id="Cop-l6-ap2"/>
<constraint firstItem="Wga-vh-5gr" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" id="Db6-Ap-r5f"/>
<constraint firstItem="BOf-h7-67C" firstAttribute="top" secondItem="Hsl-7w-xKW" secondAttribute="bottom" constant="12" id="Hsf-NW-m1u"/>
<constraint firstItem="BOf-h7-67C" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" id="JAc-2L-MKm"/>
<constraint firstItem="LpT-uQ-5JS" firstAttribute="top" secondItem="3g3-iU-dSA" secondAttribute="bottom" constant="22" id="LDa-RL-PlM"/>
<constraint firstAttribute="trailing" secondItem="1ep-3i-rAZ" secondAttribute="trailing" id="QPV-y4-sps"/>
<constraint firstItem="meM-14-BFw" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" constant="30" id="Rzq-h1-6xo"/>
<constraint firstItem="1ep-3i-rAZ" firstAttribute="top" secondItem="Afz-nz-wCb" secondAttribute="bottom" constant="12" id="Yzf-a1-PQ6"/>
<constraint firstItem="1ep-3i-rAZ" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" id="bOr-Re-U8w"/>
<constraint firstItem="Yux-Ro-p2d" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" id="alr-MV-DC8"/>
<constraint firstAttribute="trailing" secondItem="Wga-vh-5gr" secondAttribute="trailing" id="bib-a1-w42"/>
<constraint firstItem="qFl-Qx-3nj" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" id="dLM-dh-XZx"/>
<constraint firstAttribute="trailing" secondItem="Yux-Ro-p2d" secondAttribute="trailing" id="fCv-Vu-IYq"/>
<constraint firstItem="Hsl-7w-xKW" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" constant="30" id="fQy-rP-Nqj"/>
<constraint firstItem="Hsl-7w-xKW" firstAttribute="top" secondItem="Yux-Ro-p2d" secondAttribute="bottom" constant="22" id="io7-tf-nUD"/>
<constraint firstItem="qFl-Qx-3nj" firstAttribute="top" secondItem="MY5-C7-Kcb" secondAttribute="bottom" constant="12" id="kMy-Hh-QZG"/>
<constraint firstItem="MY5-C7-Kcb" firstAttribute="leading" secondItem="BlA-Cz-DcE" secondAttribute="leading" constant="30" id="kuG-ew-ToU"/>
<constraint firstAttribute="trailing" secondItem="3g3-iU-dSA" secondAttribute="trailing" id="pxn-17-mEF"/>
......@@ -858,6 +881,7 @@
<constraint firstItem="3g3-iU-dSA" firstAttribute="top" secondItem="meM-14-BFw" secondAttribute="bottom" constant="12" id="t17-FU-6R8"/>
<constraint firstItem="meM-14-BFw" firstAttribute="top" secondItem="BOf-h7-67C" secondAttribute="bottom" constant="22" id="w8n-u5-5vI"/>
<constraint firstAttribute="trailing" secondItem="BOf-h7-67C" secondAttribute="trailing" id="wJy-5Z-efP"/>
<constraint firstItem="Yux-Ro-p2d" firstAttribute="top" secondItem="qFl-Qx-3nj" secondAttribute="bottom" id="x2D-MI-WYi"/>
<constraint firstAttribute="trailing" secondItem="qFl-Qx-3nj" secondAttribute="trailing" id="yod-ha-SL4"/>
</constraints>
</view>
......@@ -937,6 +961,7 @@
</constraints>
</view>
<connections>
<outlet property="heightPayType" destination="CG5-Ai-UwP" id="QPf-PX-6P9"/>
<outlet property="lbAddress" destination="z0p-CX-h3t" id="Imu-6N-5GL"/>
<outlet property="lbAddressDetail" destination="pnS-J7-TEY" id="kvk-bc-pgl"/>
<outlet property="lbDiscount" destination="7E5-kf-ON8" id="fYS-Bf-nSI"/>
......@@ -949,6 +974,7 @@
<outlet property="lbTotalPrice" destination="fdr-W0-QCc" id="Cfi-P2-B3O"/>
<outlet property="vAddressHeight" destination="zO1-RN-x44" id="VIC-wQ-AuJ"/>
<outlet property="vHasAddress" destination="gba-z6-T82" id="syf-hx-7rS"/>
<outlet property="vPayType" destination="Yux-Ro-p2d" id="qih-Ka-xDX"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="sBO-ff-MpR" userLabel="First Responder" sceneMemberID="firstResponder"/>
......@@ -1529,11 +1555,6 @@
<action selector="onClickWechatPay:" destination="uib-Dg-Fok" id="V5W-EO-7v0"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer id="mLJ-OU-y8G" userLabel="tap信用卡">
<connections>
<action selector="onClickCreditPay:" destination="uib-Dg-Fok" id="kZu-br-edw"/>
</connections>
</tapGestureRecognizer>
</objects>
<point key="canvasLocation" x="1543" y="840"/>
</scene>
......
//
// 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