Commit 24c0de27 by houweibin

1,编辑地址页面,tf为无边框模式时,输入中文会导致文字下沉的问题。

2,完善筛选页面。
3,修复添加优惠码时的崩溃问题。
parent a1f26c03
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<scenes> <scenes>
...@@ -112,6 +112,10 @@ ...@@ -112,6 +112,10 @@
<constraint firstItem="R23-SN-2Bb" firstAttribute="centerY" secondItem="evT-5t-rty" secondAttribute="centerY" id="w2g-0d-F8E"/> <constraint firstItem="R23-SN-2Bb" firstAttribute="centerY" secondItem="evT-5t-rty" secondAttribute="centerY" id="w2g-0d-F8E"/>
</constraints> </constraints>
</view> </view>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cy8-TS-7aW" customClass="KWMNormalFilterView">
<rect key="frame" x="0.0" y="94" width="375" height="573"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hDa-nl-Tlr" customClass="KWMNormalFilterTab"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hDa-nl-Tlr" customClass="KWMNormalFilterTab">
<rect key="frame" x="0.0" y="64" width="375" height="30"/> <rect key="frame" x="0.0" y="64" width="375" height="30"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
...@@ -119,10 +123,6 @@ ...@@ -119,10 +123,6 @@
<constraint firstAttribute="height" constant="30" id="HK4-OE-vEa"/> <constraint firstAttribute="height" constant="30" id="HK4-OE-vEa"/>
</constraints> </constraints>
</view> </view>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cy8-TS-7aW" customClass="KWMNormalFilterView">
<rect key="frame" x="0.0" y="94" width="375" height="573"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</subviews> </subviews>
<color key="backgroundColor" red="0.95686274509803915" green="0.96078431372549022" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.95686274509803915" green="0.96078431372549022" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
......
...@@ -214,8 +214,11 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -214,8 +214,11 @@ static NSString *idStr = @"KWMBrandCaramelCell";
#pragma mark -- KWMNormalFilterTabDelegate #pragma mark -- KWMNormalFilterTabDelegate
-(void)kwm_onClickTab:(KWMFilterMode)filterMode isExpandView:(BOOL)isExpand{ -(void)kwm_onClickTab:(KWMFilterMode)filterMode isExpandView:(BOOL)isExpand{
self.filterView.hidden = !isExpand;
self.filterView.filterMode = filterMode; self.filterView.filterMode = filterMode;
if(isExpand){
[self.filterView show];
}
self.filterView.hidden = !isExpand;
} }
#pragma mark -- KWMBrandCaramelCellDelegate #pragma mark -- KWMBrandCaramelCellDelegate
......
...@@ -291,40 +291,71 @@ ...@@ -291,40 +291,71 @@
- (void)showError:(NSError *)error{ - (void)showError:(NSError *)error{
if ([error.domain isEqualToString:NSURLErrorDomain]) { if ([error.domain isEqualToString:NSURLErrorDomain]) {
[self showToast:@"网络已断开,请重新连接"]; [self showToast:@"网络已断开,请重新连接"];
// [self showToast:@"请求数据失败"];
return; return;
} }
// NSDictionary *userInfo = [error userInfo]; if (!error.userInfo){
// if (userInfo != nil) {
// NSNumber *errorCodeKey = [userInfo objectForKey:@"_kCFStreamErrorCodeKey"];
// if (errorCodeKey.intValue == 8) {
// [self showToast:@"网络已断开,请重新连接"];
// return;
// }
// }
NSArray<BUYError *> *errors = [BUYError errorsFromCheckoutJSON:error.userInfo];
if([self checkBuyErrors:errors]){
return; return;
} }
errors = [BUYError errorsFromSignUpJSON:error.userInfo]; if ([self isCheckOutError:error]){
if([self checkBuyErrors:errors]){
return; return;
} }
NSString *toast = [self getErrorMessage:error]; if ([self isSignUpError:error]){
if(![KWMStringUtil isEmpty:toast]){ return;
[self showToast:toast]; }
if ([self isNormalError:error]){
return; return;
} }
toast = [self getErrorMessage2:error]; //如果并不是shopify error,则正常吐司。
[self showToast:[error localizedDescription]];
}
-(BOOL)isCheckOutError:(NSError *)error{
//虽然errorsFromCheckoutJSON里面有判断了,但为了保险起见,还是加上判断
NSDictionary *errorsDictionary = error.userInfo[@"errors"];
if(!errorsDictionary || ![errorsDictionary isKindOfClass:[NSDictionary class]]){
return NO;
}
NSDictionary *customerDictionary = errorsDictionary[@"checkout"];
if(!customerDictionary || ![customerDictionary isKindOfClass:[NSDictionary class]]){
return NO;
}
NSArray<BUYError *> *errors = [BUYError errorsFromCheckoutJSON:error.userInfo];
// 现在下单时不会报quantity错误了。所以这段代码注释
// if(errors && errors.count > 0){
// NSString *quantityRemainingMessage = [errors.firstObject quantityRemainingMessage];
// }
if([self checkBuyErrors:errors]){
return YES;
}
return NO;
}
-(BOOL)isSignUpError:(NSError *)error{
NSDictionary *errorsDictionary = error.userInfo[@"errors"];
if(!errorsDictionary || ![errorsDictionary isKindOfClass:[NSDictionary class]]){
return NO;
}
NSDictionary *customerDictionary = errorsDictionary[@"customer"];
if(!customerDictionary || ![customerDictionary isKindOfClass:[NSDictionary class]]){
return NO;
}
NSArray<BUYError *> *errors = [BUYError errorsFromSignUpJSON:error.userInfo];
if([self checkBuyErrors:errors]){
return YES;
}
return NO;
}
- (BOOL)isNormalError:(NSError *)error{
NSString *toast = [self getErrorMessage:error];
if(![KWMStringUtil isEmpty:toast]){ if(![KWMStringUtil isEmpty:toast]){
if(toast!=nil && [toast isEqualToString:@"Unidentified customer"]){ if([toast isEqualToString:@"Unidentified customer"]){
toast = @"登录已失效,请重新登录"; toast = @"登录已失效,请重新登录";
} }
[self showToast:toast]; [self showToast:toast];
return; return YES;
} }
return NO;
[self showToast:[error localizedDescription]];
} }
//判断buyerror是否有效,有效则吐司错误 //判断buyerror是否有效,有效则吐司错误
...@@ -350,18 +381,26 @@ ...@@ -350,18 +381,26 @@
return NO; return NO;
} }
//获取key为message的错误信息 //获取key为message/error的错误信息
- (NSString *)getErrorMessage:(NSError *)error{ - (NSString *)getErrorMessage:(NSError *)error{
return [self getErrorMessageForKey:@"message = \"" error:error]; NSString *errorString;
} errorString = [self getErrorMessageForKey:@"message = \"" error:error];
if(![KWMStringUtil isEmpty:errorString]){
//获取key为error的错误信息 return errorString;
- (NSString *)getErrorMessage2:(NSError *)error{ }
return [self getErrorMessageForKey:@"error = \"" error:error]; errorString = [self getErrorMessageForKey:@"error = \"" error:error];
if(![KWMStringUtil isEmpty:errorString]){
return errorString;
}
errorString = [self getErrorMessageForKey:@"errors = \"" error:error];
if(![KWMStringUtil isEmpty:errorString]){
return errorString;
}
return @"";
} }
-(NSString *)getErrorMessageForKey:(NSString *)key error:(NSError *)error{ -(NSString *)getErrorMessageForKey:(NSString *)key error:(NSError *)error{
NSString *errorString = [self dictionaryToJson:error.userInfo]; NSString *errorString = [self dictionaryToString:error.userInfo];
NSRange startRange = [errorString rangeOfString:key]; NSRange startRange = [errorString rangeOfString:key];
if (startRange.location != NSNotFound) { if (startRange.location != NSNotFound) {
NSString *errorString2 = [errorString substringFromIndex:startRange.location + startRange.length]; NSString *errorString2 = [errorString substringFromIndex:startRange.location + startRange.length];
...@@ -378,13 +417,13 @@ ...@@ -378,13 +417,13 @@
} }
//字典转换为字符串 //字典转换为字符串
- (NSString*)dictionaryToJson:(NSDictionary *)dic{ - (NSString*)dictionaryToString:(NSDictionary *)dic{
NSString *a = [NSString stringWithFormat:@"%@",dic]; NSString *a = [NSString stringWithFormat:@"%@",dic];
return a; return a;
} }
- (BOOL)hasError:(id)result{ - (BOOL)hasError:(id)result{
NSInteger code = -1; NSInteger code = -1;
NSString *message; NSString *message;
if ([result isKindOfClass:[KWMRequestResult class]]) { if ([result isKindOfClass:[KWMRequestResult class]]) {
......
...@@ -45,6 +45,17 @@ ...@@ -45,6 +45,17 @@
-(void)initTextField{ -(void)initTextField{
//http://www.cocoachina.com/bbs/read.php?tid-250044-page-8.html #78
//tf为无边框模式时,输入中文会导致文字下沉的问题。
self.tfName.borderStyle = UITextBorderStyleNone;
self.tfPhone.borderStyle = UITextBorderStyleNone;
self.tfCountry.borderStyle = UITextBorderStyleNone;
self.tfProvince.borderStyle = UITextBorderStyleNone;
self.tfCity.borderStyle = UITextBorderStyleNone;
self.tfAddress.borderStyle = UITextBorderStyleNone;
self.tfAddressDetail.borderStyle = UITextBorderStyleNone;
self.tfZip.borderStyle = UITextBorderStyleNone;
self.tfName.delegate = self; self.tfName.delegate = self;
self.tfPhone.delegate = self; self.tfPhone.delegate = self;
self.tfCountry.delegate = self; self.tfCountry.delegate = self;
......
...@@ -19,4 +19,6 @@ ...@@ -19,4 +19,6 @@
@property(nonatomic) BUYCollectionSort selectedSort; @property(nonatomic) BUYCollectionSort selectedSort;
-(void)show;
@end @end
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
@property(weak,nonatomic) IBOutlet KWMFilterView *filterView; @property(weak,nonatomic) IBOutlet KWMFilterView *filterView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightFilter; @property(weak,nonatomic) IBOutlet NSLayoutConstraint *heightFilter;
@property(weak,nonatomic) IBOutlet NSLayoutConstraint *marginTopFilter;
-(IBAction)onClickBlank:(id)sender; -(IBAction)onClickBlank:(id)sender;
...@@ -70,5 +72,17 @@ ...@@ -70,5 +72,17 @@
self.hidden = YES; self.hidden = YES;
} }
-(void)show{
if(self.hidden){
self.marginTopFilter.constant = -self.heightFilter.constant;
self.hidden = NO;
[self layoutIfNeeded];
[UIView animateWithDuration:self.filterMode == ModeFilter?0.5:0.25 animations:^{
self.marginTopFilter.constant = 0;
[self layoutIfNeeded];
}];
}
}
@end @end
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<connections> <connections>
<outlet property="filterView" destination="AFM-lg-PjC" id="pNw-rv-IvA"/> <outlet property="filterView" destination="AFM-lg-PjC" id="pNw-rv-IvA"/>
<outlet property="heightFilter" destination="6KX-Dg-66z" id="Wo3-eH-eHC"/> <outlet property="heightFilter" destination="6KX-Dg-66z" id="Wo3-eH-eHC"/>
<outlet property="marginTopFilter" destination="SiA-l8-az5" id="Azb-Jh-GQP"/>
<outlet property="vContent" destination="iN0-l3-epB" id="7BZ-YQ-Bpg"/> <outlet property="vContent" destination="iN0-l3-epB" id="7BZ-YQ-Bpg"/>
</connections> </connections>
</placeholder> </placeholder>
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
<outletCollection property="gestureRecognizers" destination="XTx-4h-dka" appends="YES" id="BFR-eg-lnB"/> <outletCollection property="gestureRecognizers" destination="XTx-4h-dka" appends="YES" id="BFR-eg-lnB"/>
</connections> </connections>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AFM-lg-PjC" customClass="KWMFilterView"> <view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AFM-lg-PjC" customClass="KWMFilterView">
<rect key="frame" x="0.0" y="0.0" width="375" height="300"/> <rect key="frame" x="0.0" y="0.0" width="375" height="300"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints> <constraints>
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
#define Cemarose_KEY @"4a119ac523d53c98bbd2983b798a0d53" #define Cemarose_KEY @"4a119ac523d53c98bbd2983b798a0d53"
// ////
////测试 ////测试
//#define TestModel @"YES" //#define TestModel @"YES"
// //
......
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