Commit 85b6a274 by lee

a deep blog home com

parent 89357459
......@@ -11,6 +11,7 @@
#import "AppDelegate.h"
#import "KWMProductDetailVC.h"
#import "KWMSelectedGoodsVC.h"
#import "KWMBlogDetailVC.h"
@implementation AppDelegate (Deeplink)
......@@ -36,6 +37,12 @@
[[AppDelegate mainViewController].selectedViewController pushViewController:productDetailVC animated:YES];
return YES;
}];
[routes addRoute:@"/blogs/:blog/:handle" handler:^BOOL(NSDictionary<NSString *,id> * _Nonnull parameters) {
KWMBlogDetailVC *blogDetailVC = (KWMBlogDetailVC *)[KWMBlogDetailVC findControllerBy:@"KWMBlogDetailVC" fromStoryboard:@"Home"];
blogDetailVC.handle = parameters[@"handle"];
[[AppDelegate mainViewController].selectedViewController pushViewController:blogDetailVC animated:YES];
return YES;
}];
}
- (BOOL)handleURL:(NSURL *)url {
......
......@@ -9,6 +9,8 @@
#import "UIViewController+HTTP.h"
#import <JLRoutes/JLRoutes.h>
#import <RegexKitLite/RegexKitLite.h>
#import <TOWebViewController/TOWebViewController.h>
#import "AppDelegate.h"
@implementation UIViewController (HTTP)
......@@ -17,10 +19,12 @@
NSURL *url = [[NSURL alloc] initWithString:[URLString stringByReplacingOccurrencesOfRegex:@"^https?" withString:@"cemarose"]];
if ([JLRoutes canRouteURL:url]) {
[JLRoutes routeURL:url];
}else if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
[application openURL:[NSURL URLWithString:URLString] options:@{} completionHandler:nil];
// }else if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
// [application openURL:[NSURL URLWithString:URLString] options:@{} completionHandler:nil];
} else {
[application openURL:[NSURL URLWithString:URLString]];
// [application openURL:[NSURL URLWithString:URLString]];
TOWebViewController *wv = [[TOWebViewController alloc] initWithURLString:URLString];
[[AppDelegate mainViewController].selectedViewController pushViewController:wv animated:YES];
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12118" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" 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="12086"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
......@@ -32,7 +32,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="648"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_ home_content_title" translatesAutoresizingMaskIntoConstraints="NO" id="6b3-4L-fqj">
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_ home_content_title" translatesAutoresizingMaskIntoConstraints="NO" id="6b3-4L-fqj">
<rect key="frame" x="20" y="10" width="14" height="9"/>
<constraints>
<constraint firstAttribute="height" constant="9" id="SlC-wh-5e0"/>
......@@ -40,17 +40,17 @@
</constraints>
</imageView>
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XjH-A0-ATq">
<rect key="frame" x="0.0" y="83.5" width="375" height="564.5"/>
<rect key="frame" x="0.0" y="34" width="375" height="614"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</webView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="35I-9E-t9l">
<rect key="frame" x="20" y="23" width="325" height="32.5"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="35I-9E-t9l">
<rect key="frame" x="20" y="23" width="325" height="0.0"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="23"/>
<color key="textColor" red="0.29803921568627451" green="0.34901960784313724" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gjF-Th-7MU">
<rect key="frame" x="20" y="66.5" width="345" height="17"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gjF-Th-7MU">
<rect key="frame" x="20" y="34" width="345" height="0.0"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.29803921570000003" green="0.34901960780000002" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
......@@ -83,6 +83,7 @@
</constraints>
</view>
<connections>
<outlet property="flagImg" destination="6b3-4L-fqj" id="Zw9-1P-Fjp"/>
<outlet property="lbTitle" destination="35I-9E-t9l" id="zpt-Oq-Rhh"/>
<outlet property="publishTime" destination="gjF-Th-7MU" id="HE9-1B-5Yl"/>
<outlet property="tbvArticle" destination="XdN-GP-LIS" id="3qw-6w-72k"/>
......
......@@ -16,5 +16,8 @@
@property (weak, nonatomic) IBOutlet UILabel *lbTitle;
@property (weak, nonatomic) IBOutlet UILabel *publishTime;
@property (weak, nonatomic) IBOutlet UIView *vHeader;
@property (weak, nonatomic) IBOutlet UIImageView *flagImg;
@property (nonatomic) KWMArticlesResult *article;
@property (nonatomic) NSString *handle;
@end
......@@ -23,7 +23,28 @@
// Do any additional setup after loading the view
self.title = @"正文";
self.automaticallyAdjustsScrollViewInsets = NO;
if (!self.handle) {
[self initData];
}else{
[self requestData];
}
}
- (void) requestData {
[self showLoading];
[self.api getAllBlog:@{@"handle":self.handle} success:^(NSURLSessionDataTask *task, KWMBlogResult *result) {
[self hideLoading];
self.article = result.blogs.firstObject;
[self initData];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
[self showError:error];
NSLog(@"error:%@",error);
self.view.hidden = NO;
}];
}
- (void) initData {
self.flagImg.hidden = NO;
self.wbArticle.delegate = self;
self.wbArticle.scrollView.scrollEnabled = NO;
self.lbTitle.text = _article.title;
......
......@@ -43,6 +43,7 @@
[super viewDidLoad];
_dataArr = [NSArray array];
[self requestBlogAPI];
// FIXME: mo to main
[self.api loginWebSuccess:nil failure:nil];
}
......
......@@ -67,7 +67,7 @@
<constraint firstAttribute="height" constant="190" id="NbW-Kh-s5O"/>
</constraints>
</view>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="UGY-II-IMu">
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="UGY-II-IMu">
<rect key="frame" x="0.0" y="250" width="375" height="0.0"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
......
......@@ -345,6 +345,7 @@ typedef enum{
- (void)setHomeData:(KWMHomeData *)homeData {
_homeData = homeData;
[homeData.ad_banner[0] setUrl:@"https://www.cemarose.com/blogs/news/article-1"];
self.adHeader.adArray = self.homeData.ad_banner;
// self.recommendHeader.productArray = self.productArray;
// self.clothingSetsHeader.productArray = self.productArray;
......
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