Commit db4977fb by lee

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

No related merge requests found
......@@ -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];
......
......@@ -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"/>
......@@ -1496,65 +1522,6 @@
<outletCollection property="gestureRecognizers" destination="sVp-3n-Jr5" appends="YES" id="KDE-el-ula"/>
</connections>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SFF-e9-hE6" userLabel="信用卡">
<rect key="frame" x="0.0" y="135" width="375" height="55"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lne-LW-nPv">
<rect key="frame" x="0.0" y="0.0" width="75" height="55"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_pay_credit_card" translatesAutoresizingMaskIntoConstraints="NO" id="LRL-q6-ddo">
<rect key="frame" x="29" y="21" width="17" height="14"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="DzZ-qm-kZY"/>
<constraint firstAttribute="width" constant="17" id="ddV-GJ-MCj"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="LRL-q6-ddo" firstAttribute="centerX" secondItem="lne-LW-nPv" secondAttribute="centerX" id="0Qd-1I-nYc"/>
<constraint firstItem="LRL-q6-ddo" firstAttribute="centerY" secondItem="lne-LW-nPv" secondAttribute="centerY" id="EbE-8R-mfG"/>
<constraint firstAttribute="width" constant="75" id="p1y-5n-Tzy"/>
</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="FUc-8V-X5I">
<rect key="frame" x="75" y="18" width="70" height="20"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="14"/>
<color key="textColor" red="0.30588235289999999" green="0.30588235289999999" blue="0.30588235289999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7ow-Jk-Xtf" userLabel="line">
<rect key="frame" x="0.0" y="54" width="375" height="1"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.85882352939999995" blue="0.87058823529999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="rX2-Nt-VD6"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.95686274510000002" green="0.96078431369999995" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="7ow-Jk-Xtf" secondAttribute="bottom" id="5Vj-RK-Tbz"/>
<constraint firstItem="lne-LW-nPv" firstAttribute="leading" secondItem="SFF-e9-hE6" secondAttribute="leading" id="5tN-yN-UX7"/>
<constraint firstItem="FUc-8V-X5I" firstAttribute="top" secondItem="SFF-e9-hE6" secondAttribute="top" id="AKU-nX-Kty"/>
<constraint firstAttribute="bottom" secondItem="lne-LW-nPv" secondAttribute="bottom" id="HFb-Zg-Crc"/>
<constraint firstAttribute="height" constant="55" id="MKL-DZ-TKj"/>
<constraint firstAttribute="bottom" secondItem="FUc-8V-X5I" secondAttribute="bottom" id="QSS-5U-oHH"/>
<constraint firstAttribute="trailing" secondItem="7ow-Jk-Xtf" secondAttribute="trailing" id="dAT-my-HZC"/>
<constraint firstItem="lne-LW-nPv" firstAttribute="top" secondItem="SFF-e9-hE6" secondAttribute="top" id="eMM-I3-SpQ"/>
<constraint firstItem="7ow-Jk-Xtf" firstAttribute="leading" secondItem="SFF-e9-hE6" secondAttribute="leading" id="geZ-nO-hyA"/>
<constraint firstItem="FUc-8V-X5I" firstAttribute="leading" secondItem="lne-LW-nPv" secondAttribute="trailing" id="xLT-xE-iiu"/>
<constraint firstItem="FUc-8V-X5I" firstAttribute="centerY" secondItem="SFF-e9-hE6" secondAttribute="centerY" id="xyG-l9-ge7"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="AKU-nX-Kty"/>
<exclude reference="QSS-5U-oHH"/>
</mask>
</variation>
<connections>
<outletCollection property="gestureRecognizers" destination="mLJ-OU-y8G" appends="YES" id="fVF-We-VGt"/>
</connections>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="F5Z-f9-woo" userLabel="line">
<rect key="frame" x="0.0" y="20" width="375" height="1"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.85882352939999995" blue="0.87058823529999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
......@@ -1567,15 +1534,12 @@
<constraints>
<constraint firstItem="Os1-zi-TuD" firstAttribute="top" secondItem="hCm-Y0-mLE" secondAttribute="bottom" constant="5" id="1Op-ws-NER"/>
<constraint firstItem="RWh-QT-lMr" firstAttribute="leading" secondItem="GN1-MI-97h" secondAttribute="leading" id="FqV-QP-aGs"/>
<constraint firstItem="SFF-e9-hE6" firstAttribute="top" secondItem="RWh-QT-lMr" secondAttribute="bottom" id="GZU-BU-qqF"/>
<constraint firstAttribute="trailing" secondItem="SFF-e9-hE6" secondAttribute="trailing" id="K2R-b6-oqU"/>
<constraint firstItem="F5Z-f9-woo" firstAttribute="top" secondItem="hCm-Y0-mLE" secondAttribute="bottom" id="KrQ-le-ju8"/>
<constraint firstItem="F5Z-f9-woo" firstAttribute="leading" secondItem="GN1-MI-97h" secondAttribute="leading" id="LgM-fg-iqD"/>
<constraint firstItem="RWh-QT-lMr" firstAttribute="top" secondItem="Os1-zi-TuD" secondAttribute="bottom" id="M28-33-kXa"/>
<constraint firstAttribute="trailing" secondItem="RWh-QT-lMr" secondAttribute="trailing" id="RWN-IR-Enf"/>
<constraint firstItem="Os1-zi-TuD" firstAttribute="leading" secondItem="GN1-MI-97h" secondAttribute="leading" id="djL-HZ-jDK"/>
<constraint firstAttribute="trailing" secondItem="F5Z-f9-woo" secondAttribute="trailing" id="hk5-WF-ntv"/>
<constraint firstItem="SFF-e9-hE6" firstAttribute="leading" secondItem="GN1-MI-97h" secondAttribute="leading" id="lMM-72-TAd"/>
<constraint firstAttribute="trailing" secondItem="Os1-zi-TuD" secondAttribute="trailing" id="wN1-9o-QQf"/>
</constraints>
</view>
......@@ -1591,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>
......@@ -2138,7 +2097,6 @@
<image name="ic_count_bg" width="100" height="25"/>
<image name="ic_pay_AliPay" width="18" height="18"/>
<image name="ic_pay_WeChat" width="20" height="17"/>
<image name="ic_pay_credit_card" width="17" height="14"/>
<image name="ic_shopcar_delete" width="13" height="13"/>
</resources>
</document>
//
// 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