Commit 24c0de27 by houweibin

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

2,完善筛选页面。
3,修复添加优惠码时的崩溃问题。
parent a1f26c03
<?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">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<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"/>
</dependencies>
<scenes>
......@@ -112,6 +112,10 @@
<constraint firstItem="R23-SN-2Bb" firstAttribute="centerY" secondItem="evT-5t-rty" secondAttribute="centerY" id="w2g-0d-F8E"/>
</constraints>
</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">
<rect key="frame" x="0.0" y="64" width="375" height="30"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
......@@ -119,10 +123,6 @@
<constraint firstAttribute="height" constant="30" id="HK4-OE-vEa"/>
</constraints>
</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>
<color key="backgroundColor" red="0.95686274509803915" green="0.96078431372549022" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
......
......@@ -214,8 +214,11 @@ static NSString *idStr = @"KWMBrandCaramelCell";
#pragma mark -- KWMNormalFilterTabDelegate
-(void)kwm_onClickTab:(KWMFilterMode)filterMode isExpandView:(BOOL)isExpand{
self.filterView.hidden = !isExpand;
self.filterView.filterMode = filterMode;
if(isExpand){
[self.filterView show];
}
self.filterView.hidden = !isExpand;
}
#pragma mark -- KWMBrandCaramelCellDelegate
......
......@@ -291,40 +291,71 @@
- (void)showError:(NSError *)error{
if ([error.domain isEqualToString:NSURLErrorDomain]) {
[self showToast:@"网络已断开,请重新连接"];
// [self showToast:@"请求数据失败"];
return;
}
// NSDictionary *userInfo = [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]){
if (!error.userInfo){
return;
}
errors = [BUYError errorsFromSignUpJSON:error.userInfo];
if([self checkBuyErrors:errors]){
if ([self isCheckOutError:error]){
return;
}
NSString *toast = [self getErrorMessage:error];
if(![KWMStringUtil isEmpty:toast]){
[self showToast:toast];
if ([self isSignUpError:error]){
return;
}
if ([self isNormalError:error]){
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(toast!=nil && [toast isEqualToString:@"Unidentified customer"]){
if([toast isEqualToString:@"Unidentified customer"]){
toast = @"登录已失效,请重新登录";
}
[self showToast:toast];
return;
return YES;
}
[self showToast:[error localizedDescription]];
return NO;
}
//判断buyerror是否有效,有效则吐司错误
......@@ -350,18 +381,26 @@
return NO;
}
//获取key为message的错误信息
//获取key为message/error的错误信息
- (NSString *)getErrorMessage:(NSError *)error{
return [self getErrorMessageForKey:@"message = \"" error:error];
}
//获取key为error的错误信息
- (NSString *)getErrorMessage2:(NSError *)error{
return [self getErrorMessageForKey:@"error = \"" error:error];
NSString *errorString;
errorString = [self getErrorMessageForKey:@"message = \"" error:error];
if(![KWMStringUtil isEmpty:errorString]){
return errorString;
}
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 *errorString = [self dictionaryToJson:error.userInfo];
NSString *errorString = [self dictionaryToString:error.userInfo];
NSRange startRange = [errorString rangeOfString:key];
if (startRange.location != NSNotFound) {
NSString *errorString2 = [errorString substringFromIndex:startRange.location + startRange.length];
......@@ -378,13 +417,13 @@
}
//字典转换为字符串
- (NSString*)dictionaryToJson:(NSDictionary *)dic{
- (NSString*)dictionaryToString:(NSDictionary *)dic{
NSString *a = [NSString stringWithFormat:@"%@",dic];
return a;
}
- (BOOL)hasError:(id)result{
NSInteger code = -1;
NSString *message;
if ([result isKindOfClass:[KWMRequestResult class]]) {
......
......@@ -45,6 +45,17 @@
-(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.tfPhone.delegate = self;
self.tfCountry.delegate = self;
......
......@@ -19,4 +19,6 @@
@property(nonatomic) BUYCollectionSort selectedSort;
-(void)show;
@end
......@@ -14,7 +14,9 @@
@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;
......@@ -70,5 +72,17 @@
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
<?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">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<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"/>
</dependencies>
<objects>
......@@ -13,6 +13,7 @@
<connections>
<outlet property="filterView" destination="AFM-lg-PjC" id="pNw-rv-IvA"/>
<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"/>
</connections>
</placeholder>
......@@ -32,7 +33,7 @@
<outletCollection property="gestureRecognizers" destination="XTx-4h-dka" appends="YES" id="BFR-eg-lnB"/>
</connections>
</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"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
......
......@@ -62,7 +62,7 @@
#define Cemarose_KEY @"4a119ac523d53c98bbd2983b798a0d53"
//
////
////测试
//#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