Commit 5431dfa1 by houweibin

1,后台唤醒时刷新当前页面当页面在首页时

2,支付成功后跳转订单页面,使用checkout中的数据生成一个假订单
3,home页面部请求cache
4,所有品牌页面底部遮挡控件去除
5,我的订单页面调整为分页,准备接入所有订单API
parent eea3e72f
<?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="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" 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="13174"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<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>
<customFonts key="customFonts"> <customFonts key="customFonts">
...@@ -197,14 +197,6 @@ ...@@ -197,14 +197,6 @@
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="gJI-aS-DRK"> <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="gJI-aS-DRK">
<rect key="frame" x="0.0" y="65" width="375" height="602"/> <rect key="frame" x="0.0" y="65" width="375" height="602"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<view key="tableHeaderView" contentMode="scaleToFill" id="k52-E9-JpG" userLabel="vLine">
<rect key="frame" x="0.0" y="0.0" width="375" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.82461414700000002" green="0.82461414700000002" blue="0.82461414700000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="5" id="clL-qM-kLl"/>
</constraints>
</view>
<connections> <connections>
<outlet property="dataSource" destination="dZB-o0-0V5" id="av9-pj-b89"/> <outlet property="dataSource" destination="dZB-o0-0V5" id="av9-pj-b89"/>
<outlet property="delegate" destination="dZB-o0-0V5" id="eFV-p7-3lX"/> <outlet property="delegate" destination="dZB-o0-0V5" id="eFV-p7-3lX"/>
...@@ -235,7 +227,6 @@ ...@@ -235,7 +227,6 @@
<connections> <connections>
<outlet property="tbvSearchBrand" destination="gJI-aS-DRK" id="dl1-OG-S3y"/> <outlet property="tbvSearchBrand" destination="gJI-aS-DRK" id="dl1-OG-S3y"/>
<outlet property="vBackground" destination="Tbn-TE-Ey2" id="exj-ix-Ign"/> <outlet property="vBackground" destination="Tbn-TE-Ey2" id="exj-ix-Ign"/>
<outlet property="vLine" destination="k52-E9-JpG" id="3of-VM-esW"/>
</connections> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nbs-Cn-9zP" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="nbs-Cn-9zP" userLabel="First Responder" sceneMemberID="firstResponder"/>
......
...@@ -76,7 +76,11 @@ ...@@ -76,7 +76,11 @@
// self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormattedByCurrencyCode:lineItem.price]; // self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormattedByCurrencyCode:lineItem.price];
self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormatted:lineItem.price currencyCode:@"EUR"]; self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormatted:lineItem.price currencyCode:@"EUR"];
self.lbName.text = lineItem.title; self.lbName.text = lineItem.title;
self.lbSize.text = [NSString stringWithFormat:@"x%@/%@",lineItem.quantity,lineItem.variantTitle]; if([KWMStringUtil isEmpty:lineItem.variantTitle]){
self.lbSize.text = [NSString stringWithFormat:@"x%@",lineItem.quantity];
}else{
self.lbSize.text = [NSString stringWithFormat:@"x%@/%@",lineItem.quantity,lineItem.variantTitle];
}
} }
} }
......
<?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="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" 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="13527"/>
<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>
<customFonts key="customFonts">
<array key="PingFang.ttc">
<string>PingFangSC-Regular</string>
</array>
</customFonts>
<objects> <objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
...@@ -112,13 +117,13 @@ ...@@ -112,13 +117,13 @@
</constraints> </constraints>
</imageView> </imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="CAMAREL" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="McB-3J-L1c"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="CAMAREL" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="McB-3J-L1c">
<rect key="frame" x="109" y="5" width="69.5" height="18"/> <rect key="frame" x="109" y="5" width="256" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/> <fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.30588235294117649" green="0.30588235294117649" blue="0.30588235294117649" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="x1/2A/藏青" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gA4-v1-va1"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="x1/2A/藏青" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gA4-v1-va1">
<rect key="frame" x="109" y="50.5" width="60.5" height="14.5"/> <rect key="frame" x="109" y="50.5" width="60" height="14.5"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/> <fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.30588235289999999" green="0.30588235289999999" blue="0.30588235289999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.30588235289999999" green="0.30588235289999999" blue="0.30588235289999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
...@@ -136,6 +141,7 @@ ...@@ -136,6 +141,7 @@
<constraint firstItem="z2N-M1-Gfa" firstAttribute="bottom" secondItem="nIn-Ka-NkB" secondAttribute="bottom" id="574-Ns-CTp"/> <constraint firstItem="z2N-M1-Gfa" firstAttribute="bottom" secondItem="nIn-Ka-NkB" secondAttribute="bottom" id="574-Ns-CTp"/>
<constraint firstAttribute="height" constant="80" id="5sn-3g-rcJ"/> <constraint firstAttribute="height" constant="80" id="5sn-3g-rcJ"/>
<constraint firstItem="gA4-v1-va1" firstAttribute="bottom" secondItem="nIn-Ka-NkB" secondAttribute="bottom" id="6ui-1w-H10"/> <constraint firstItem="gA4-v1-va1" firstAttribute="bottom" secondItem="nIn-Ka-NkB" secondAttribute="bottom" id="6ui-1w-H10"/>
<constraint firstAttribute="trailing" secondItem="McB-3J-L1c" secondAttribute="trailing" constant="10" id="N8P-W1-4mc"/>
<constraint firstItem="nIn-Ka-NkB" firstAttribute="leading" secondItem="ijW-ut-DIo" secondAttribute="leading" constant="27" id="dfp-Nc-CW8"/> <constraint firstItem="nIn-Ka-NkB" firstAttribute="leading" secondItem="ijW-ut-DIo" secondAttribute="leading" constant="27" id="dfp-Nc-CW8"/>
<constraint firstItem="nIn-Ka-NkB" firstAttribute="top" secondItem="ijW-ut-DIo" secondAttribute="top" constant="5" id="dsB-67-ssI"/> <constraint firstItem="nIn-Ka-NkB" firstAttribute="top" secondItem="ijW-ut-DIo" secondAttribute="top" constant="5" id="dsB-67-ssI"/>
<constraint firstAttribute="trailing" secondItem="z2N-M1-Gfa" secondAttribute="trailing" constant="27" id="fuI-TM-gUP"/> <constraint firstAttribute="trailing" secondItem="z2N-M1-Gfa" secondAttribute="trailing" constant="27" id="fuI-TM-gUP"/>
......
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
// //
#import "KWMBaseVC.h" #import "KWMBaseVC.h"
#import "KWMBasePageVC.h"
#import "KWMOrderCell.h" #import "KWMOrderCell.h"
@interface KWMOrderVC : KWMBaseVC<UITableViewDelegate,UITableViewDataSource,KWMOrderCellDelegate> @interface KWMOrderVC : KWMBasePageVC<KWMOrderCellDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tbvOrder; @property (weak, nonatomic) IBOutlet UITableView *tbvOrder;
@property (nonatomic) BUYCheckout *paidCheckout;
@end @end
<?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="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" 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="13527"/>
<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>
<customFonts key="customFonts">
<array key="PingFang.ttc">
<string>PingFangSC-Regular</string>
</array>
</customFonts>
<scenes> <scenes>
<!--OrderVC--> <!--OrderVC-->
<scene sceneID="sv6-Dq-cKt"> <scene sceneID="sv6-Dq-cKt">
...@@ -22,14 +27,14 @@ ...@@ -22,14 +27,14 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dkl-7G-f7l" userLabel="vLine"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dkl-7G-f7l" userLabel="vLine">
<rect key="frame" x="0.0" y="64" width="375" height="1"/> <rect key="frame" x="0.0" y="20" width="375" height="1"/>
<color key="backgroundColor" red="0.82338023559999995" green="0.82338023559999995" blue="0.82338023559999995" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.82338023559999995" green="0.82338023559999995" blue="0.82338023559999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="1" id="r0c-J0-ZXk"/> <constraint firstAttribute="height" constant="1" id="r0c-J0-ZXk"/>
</constraints> </constraints>
</view> </view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="YW5-m6-sF5"> <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="YW5-m6-sF5">
<rect key="frame" x="0.0" y="65" width="375" height="602"/> <rect key="frame" x="0.0" y="20" width="375" height="647"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections> <connections>
<outlet property="dataSource" destination="fub-2P-w8Y" id="rlF-zh-XLR"/> <outlet property="dataSource" destination="fub-2P-w8Y" id="rlF-zh-XLR"/>
...@@ -40,13 +45,13 @@ ...@@ -40,13 +45,13 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstItem="YW5-m6-sF5" firstAttribute="leading" secondItem="Puz-FY-kmG" secondAttribute="leading" id="1eF-y4-KbG"/> <constraint firstItem="YW5-m6-sF5" firstAttribute="leading" secondItem="Puz-FY-kmG" secondAttribute="leading" id="1eF-y4-KbG"/>
<constraint firstItem="YW5-m6-sF5" firstAttribute="top" secondItem="Puz-FY-kmG" secondAttribute="top" constant="65" id="7DW-9k-7vn"/> <constraint firstItem="D4p-vJ-TZ7" firstAttribute="top" secondItem="YW5-m6-sF5" secondAttribute="bottom" id="EnE-Ux-wNa"/>
<constraint firstAttribute="bottom" secondItem="YW5-m6-sF5" secondAttribute="bottom" id="8eD-ia-gTT"/> <constraint firstItem="Dkl-7G-f7l" firstAttribute="top" secondItem="y2z-ec-nhN" secondAttribute="bottom" id="RQa-Q0-oyT"/>
<constraint firstAttribute="trailing" secondItem="YW5-m6-sF5" secondAttribute="trailing" id="Sp2-MW-ldC"/> <constraint firstAttribute="trailing" secondItem="YW5-m6-sF5" secondAttribute="trailing" id="Sp2-MW-ldC"/>
<constraint firstItem="YW5-m6-sF5" firstAttribute="top" secondItem="y2z-ec-nhN" secondAttribute="bottom" id="Tp4-49-Kch"/> <constraint firstItem="YW5-m6-sF5" firstAttribute="top" secondItem="y2z-ec-nhN" secondAttribute="bottom" id="Tp4-49-Kch"/>
<constraint firstAttribute="trailing" secondItem="Dkl-7G-f7l" secondAttribute="trailing" id="qgL-EZ-hOo"/> <constraint firstAttribute="trailing" secondItem="Dkl-7G-f7l" secondAttribute="trailing" id="qgL-EZ-hOo"/>
<constraint firstItem="Dkl-7G-f7l" firstAttribute="leading" secondItem="Puz-FY-kmG" secondAttribute="leading" id="r6y-XY-UDI"/> <constraint firstItem="Dkl-7G-f7l" firstAttribute="leading" secondItem="Puz-FY-kmG" secondAttribute="leading" id="r6y-XY-UDI"/>
<constraint firstItem="Dkl-7G-f7l" firstAttribute="top" secondItem="Puz-FY-kmG" secondAttribute="top" constant="64" id="rkJ-xF-SNd"/> <constraint firstItem="YW5-m6-sF5" firstAttribute="top" secondItem="y2z-ec-nhN" secondAttribute="bottom" id="tkN-kt-ssY"/>
</constraints> </constraints>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
......
...@@ -61,6 +61,8 @@ typedef enum{ ...@@ -61,6 +61,8 @@ typedef enum{
@property(nonatomic) NSMutableDictionary *dataMapping; @property(nonatomic) NSMutableDictionary *dataMapping;
@property(nonatomic) BOOL isRefreshUI;
//@property(nonatomic) NSString *clotingSetsHandle; //@property(nonatomic) NSString *clotingSetsHandle;
@end @end
...@@ -77,7 +79,6 @@ typedef enum{ ...@@ -77,7 +79,6 @@ typedef enum{
self.page = 1; self.page = 1;
// [self requestProduct:@""]; // [self requestProduct:@""];
[self loadHomeData]; [self loadHomeData];
} }
- (void)viewWillAppear:(BOOL)animated{ - (void)viewWillAppear:(BOOL)animated{
...@@ -89,6 +90,11 @@ typedef enum{ ...@@ -89,6 +90,11 @@ typedef enum{
[self.titleView resumeView]; [self.titleView resumeView];
} }
[self.cvHome reloadData]; [self.cvHome reloadData];
if(self.isRefreshUI){
self.isRefreshUI = YES;
}else{
[self loadHomeData];
}
} }
-(void)viewDidDisappear:(BOOL)animated{ -(void)viewDidDisappear:(BOOL)animated{
...@@ -327,44 +333,22 @@ typedef enum{ ...@@ -327,44 +333,22 @@ typedef enum{
} }
#pragma makr - api #pragma makr - api
//- (void)requestProduct:(NSString *)tag{
// NSMutableArray *tags = nil;
// if(tag){
// tags = [NSMutableArray array];
// [tags addObject:tag];
// }
//
// __weak KWMNewHomeVC *weakSelf = self;
// [self showLoading];
// [self.client getProductsPage:1 inCollection:@(Collection_All_ID) withTags:tags sortOrder:BUYCollectionSortBestSelling completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
// [weakSelf hideLoading];
// if(error){
// [weakSelf showError:error];
// }
// else if(products && products.count>0){
// weakSelf.productArray = products;
// [weakSelf.cvHome reloadData];
//// [weakSelf initTestData];
// }
// }];
//}
- (void) requestProductWithHandle:(NSString *) handle tags:(NSArray *) tags valueKeyPath:(NSString *) valueKeyPath { - (void) requestProductWithHandle:(NSString *) handle tags:(NSArray *) tags valueKeyPath:(NSString *) valueKeyPath {
[self showLoading]; [self showLoading];
BOOL isHome = [handle isEqualToString:@"products-list-app-homepage"]; BOOL isHome = [handle isEqualToString:@"products-list-app-homepage"];
NSInteger cpage = isHome ? self.page : 1; NSInteger cpage = isHome ? self.page : 1;
NSDictionary *parameters = [self getProductCacheKeyDictionary:cpage tags:tags handle:handle]; NSDictionary *parameters = [self getProductCacheKeyDictionary:cpage tags:tags handle:handle];
BOOL isUseCache = [self isUseProductDataCache:parameters valueKeyPath:valueKeyPath page:cpage isHome:isHome]; if(!self.isRefreshUI){
BOOL useHomeDataCache = [self useProductDataCache:parameters valueKeyPath:valueKeyPath page:cpage isHome:isHome];
}
[self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) { [self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
[self hideLoading]; [self hideLoading];
if (!error) { if (!error) {
[self.client getProductsPage:cpage inCollection:collection.identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) { [self.client getProductsPage:cpage inCollection:collection.identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) {
if (!error) { if (!error) {
[KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage products:products]; [KWMPPCacheUtil saveDataToCache:parameters urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage products:products];
if(!isUseCache){ [self setValue:products forKeyPath:valueKeyPath];
[self setValue:products forKeyPath:valueKeyPath]; [self.cvHome reloadData];
[self.cvHome reloadData];
}
}else{ }else{
// [self showError:error]; // [self showError:error];
} }
...@@ -379,33 +363,15 @@ typedef enum{ ...@@ -379,33 +363,15 @@ typedef enum{
}]; }];
} }
//- (void) requestProductWithId:(NSNumber *) identifier tags:(NSArray *) tags valueKeyPath:(NSString *) valueKeyPath home:(BOOL) isHome page:(NSInteger) cpage{ - (void) loadHomeData{
// [self showLoading];
// [self.client getProductsPage:cpage inCollection:identifier withTags:tags sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) {
// [self hideLoading];
//
// if (!error) {
// [self setValue:products forKeyPath:valueKeyPath];
// [self.cvHome reloadData];
// }else{
// [self showError:error];
// }
// if (isHome) {
// self.page = self.page + 1;
// products.count ? [self.cvHome.mj_footer endRefreshing] : [self.cvHome.mj_footer endRefreshingWithNoMoreData];
// }
// }];
//}
- (void) loadHomeData {
[self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"]; [self requestProductWithHandle:@"hot-sell-app" tags:nil valueKeyPath:@"recommendHeader.productArray"];
BOOL isUseCache = [self isUseHomeDataCache]; if(!self.isRefreshUI){
BOOL useCache = [self useHomeDataCache];
}
[self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) { [self.api getHomeDataWithSuccess:^(NSURLSessionDataTask *task, KWMHomeDataResult *result) {
[KWMPPCacheUtil saveDataToCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess homeData:result.data]; [KWMPPCacheUtil saveDataToCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess homeData:result.data];
if(!isUseCache){
self.homeData = result.data; self.homeData = result.data;
[self.cvHome reloadData]; [self.cvHome reloadData];
}
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
// [self showError:error]; // [self showError:error];
}]; }];
...@@ -456,17 +422,15 @@ typedef enum{ ...@@ -456,17 +422,15 @@ typedef enum{
#pragma mark -cache #pragma mark -cache
/** 因为homedata api的url是动态的,url上的时间戳随时间的改变,所以需要手动保存,和获取 **/ /** 因为homedata api的url是动态的,url上的时间戳随时间的改变,所以需要手动保存,和获取 **/
//缓存规则:网络请求数据照常,如果没网络,并且缓存有数据,会拿缓存的数据显示。 //缓存规则:网络请求数据照常,如果没网络,并且缓存有数据,会拿缓存的数据显示。
-(BOOL)isUseHomeDataCache{ -(BOOL)useHomeDataCache{
if(!kIsNetwork){
KWMHomeData *homeData = [KWMPPCacheUtil getHomeDataByCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess]; KWMHomeData *homeData = [KWMPPCacheUtil getHomeDataByCache:nil urlKey:CACHE_KEY_getHomeDataWithSuccess];
if(homeData){ if(homeData){
self.homeData = homeData; self.homeData = homeData;
[self.cvHome reloadData]; [self.cvHome reloadData];
return true;
}else{ }else{
return false; return false;
} }
}
return !kIsNetwork;
} }
//初始化缓存parameters key //初始化缓存parameters key
...@@ -487,8 +451,8 @@ typedef enum{ ...@@ -487,8 +451,8 @@ typedef enum{
} }
//缓存规则:网络请求数据照常,如果没网络,并且缓存有数据,会拿缓存的数据显示。 //缓存规则:网络请求数据照常,如果没网络,并且缓存有数据,会拿缓存的数据显示。
-(BOOL)isUseProductDataCache:(NSDictionary *)cacheKeyDictionary valueKeyPath:(NSString *)valueKeyPath page:(NSUInteger)page isHome:(BOOL)isHome{ -(BOOL)useProductDataCache:(NSDictionary *)cacheKeyDictionary valueKeyPath:(NSString *)valueKeyPath page:(NSUInteger)page isHome:(BOOL)isHome{
if(!kIsNetwork){ if(!kIsNetwork || page == 1){
[self hideLoading]; [self hideLoading];
NSArray *products = [KWMPPCacheUtil getProductDataByCache:cacheKeyDictionary urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage]; NSArray *products = [KWMPPCacheUtil getProductDataByCache:cacheKeyDictionary urlKey:CACHE_KEY_SDK_getCollectionByHandle_getProductsPage];
if(products && products.count > 0){ if(products && products.count > 0){
......
...@@ -736,6 +736,7 @@ ...@@ -736,6 +736,7 @@
-(void)paySuccess{ -(void)paySuccess{
[self clearCheckout]; [self clearCheckout];
KWMPaySuccessVC *successVC = (KWMPaySuccessVC *)[KWMBaseVC findControllerBy:[KWMPaySuccessVC kwmTag] fromStoryboard:@"ShopCart"]; KWMPaySuccessVC *successVC = (KWMPaySuccessVC *)[KWMBaseVC findControllerBy:[KWMPaySuccessVC kwmTag] fromStoryboard:@"ShopCart"];
successVC.paidCheckout = self.checkout;
[self.navigationController pushViewController:successVC animated:YES]; [self.navigationController pushViewController:successVC animated:YES];
} }
......
...@@ -22,4 +22,7 @@ ...@@ -22,4 +22,7 @@
- (IBAction)onClickMyOrder:(id)sender; - (IBAction)onClickMyOrder:(id)sender;
//用于在跳转后的订单列表页面生成即时订单(支付后的订单需要一定时间后才能从订单列表获取)
@property (nonatomic) BUYCheckout *paidCheckout;
@end @end
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
-(void)onClickMyOrder:(id)sender{ -(void)onClickMyOrder:(id)sender{
KWMOrderVC *orderVC = (KWMOrderVC *)[KWMBaseVC findControllerBy:[KWMOrderVC kwmTag] fromStoryboard:@"Mine"]; KWMOrderVC *orderVC = (KWMOrderVC *)[KWMBaseVC findControllerBy:[KWMOrderVC kwmTag] fromStoryboard:@"Mine"];
orderVC.paidCheckout = self.paidCheckout;
[self.navigationController pushViewController:orderVC animated:YES]; [self.navigationController pushViewController:orderVC animated:YES];
} }
......
<?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="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" 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="13174"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/> <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<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>
...@@ -1646,7 +1646,7 @@ ...@@ -1646,7 +1646,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="puG-Vo-gdd"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="puG-Vo-gdd">
<rect key="frame" x="0.0" y="259" width="375" height="150"/> <rect key="frame" x="0.0" y="224" width="375" height="220"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="你可能关心的问题" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T4V-4O-WbC"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="你可能关心的问题" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T4V-4O-WbC">
<rect key="frame" x="128" y="0.0" width="120" height="21"/> <rect key="frame" x="128" y="0.0" width="120" height="21"/>
...@@ -1682,7 +1682,7 @@ ...@@ -1682,7 +1682,7 @@
<action selector="onClickGetTime:" destination="iFV-ZT-0zX" eventType="touchUpInside" id="27h-gg-ltV"/> <action selector="onClickGetTime:" destination="iFV-ZT-0zX" eventType="touchUpInside" id="27h-gg-ltV"/>
</connections> </connections>
</button> </button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3ni-BC-6WW"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3ni-BC-6WW">
<rect key="frame" x="132" y="177" width="110" height="26"/> <rect key="frame" x="132" y="177" width="110" height="26"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="110" id="N0D-kQ-eGq"/> <constraint firstAttribute="width" constant="110" id="N0D-kQ-eGq"/>
...@@ -1704,7 +1704,7 @@ ...@@ -1704,7 +1704,7 @@
<constraint firstItem="3ni-BC-6WW" firstAttribute="centerX" secondItem="puG-Vo-gdd" secondAttribute="centerX" id="CqI-1L-ERJ"/> <constraint firstItem="3ni-BC-6WW" firstAttribute="centerX" secondItem="puG-Vo-gdd" secondAttribute="centerX" id="CqI-1L-ERJ"/>
<constraint firstItem="3ni-BC-6WW" firstAttribute="top" secondItem="3iW-9e-nhE" secondAttribute="bottom" constant="35" id="ISt-z3-thL"/> <constraint firstItem="3ni-BC-6WW" firstAttribute="top" secondItem="3iW-9e-nhE" secondAttribute="bottom" constant="35" id="ISt-z3-thL"/>
<constraint firstItem="T4V-4O-WbC" firstAttribute="centerX" secondItem="puG-Vo-gdd" secondAttribute="centerX" id="MvE-KT-EgQ"/> <constraint firstItem="T4V-4O-WbC" firstAttribute="centerX" secondItem="puG-Vo-gdd" secondAttribute="centerX" id="MvE-KT-EgQ"/>
<constraint firstAttribute="height" constant="150" id="Wbe-Fv-YHk"/> <constraint firstAttribute="height" constant="220" id="Wbe-Fv-YHk"/>
<constraint firstItem="3MF-En-1mW" firstAttribute="top" secondItem="T4V-4O-WbC" secondAttribute="bottom" constant="34" id="b1r-Lb-cP7"/> <constraint firstItem="3MF-En-1mW" firstAttribute="top" secondItem="T4V-4O-WbC" secondAttribute="bottom" constant="34" id="b1r-Lb-cP7"/>
<constraint firstItem="3MF-En-1mW" firstAttribute="centerX" secondItem="puG-Vo-gdd" secondAttribute="centerX" id="sVI-Au-PtI"/> <constraint firstItem="3MF-En-1mW" firstAttribute="centerX" secondItem="puG-Vo-gdd" secondAttribute="centerX" id="sVI-Au-PtI"/>
<constraint firstItem="3iW-9e-nhE" firstAttribute="top" secondItem="3MF-En-1mW" secondAttribute="bottom" constant="35" id="wpN-Nc-3yi"/> <constraint firstItem="3iW-9e-nhE" firstAttribute="top" secondItem="3MF-En-1mW" secondAttribute="bottom" constant="35" id="wpN-Nc-3yi"/>
......
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