Commit d3ecc584 authored by licong's avatar licong

添加请求前的支持

parent 9202091a
......@@ -21,7 +21,7 @@
WMNetService *service = [WMNetService sharedInstance];
service.apiHost = @"http://backend.gmei.com";
NSString *path = @"/api/index/v3?version=5.9.5";
NSString *path = @"/api/index/v3?version=7.0.0";
service.urlCommonParameters = @"";
// 我的需求就是能快速获取几种情况
[[WMNetService sharedInstance] sendRequestWithURLString:path parameters:nil method:HttpMethodGet success:^(id responseObject) {
......@@ -31,6 +31,9 @@
NSLog(@"message");
}];
service.beforeAction = ^ {
};
// [[WMNetService sharedInstance] sendRequestWithUrl:path parameters:nil method:HttpMethodGet success:^(NSDictionary *data, NSString *message) {
// NSLog(@"message");
// } failed:^(NSString *message) {
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="whP-gf-Uak">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="whP-gf-Uak">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
......@@ -14,9 +18,9 @@
<viewControllerLayoutGuide type="bottom" id="Mvr-aV-6Um"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="TpU-gO-2f1">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="tc2-Qw-aMS" userLabel="First Responder" sceneMemberID="firstResponder"/>
......
......@@ -34,6 +34,8 @@
@property (nonatomic, strong) NSString *webHost;
@property (nonatomic, strong) NSString *loginExpiredName;
@property (nonatomic, strong) NSString *urlCommonParameters;
//请求网络之前调用
@property (nonatomic, copy) void (^beforeAction) (void);
@property (nonatomic, copy) void (^handleResponse) (NSDictionary *response);
+ (instancetype)sharedInstance;
......
......@@ -88,6 +88,9 @@
success:(HttpSuccessBlock)success
failed:(HttpFailedBlock)failed{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
if (self.beforeAction) {
_beforeAction();
}
if (method == HttpMethodGet) {
[networking GET:URLString parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
[self successWithTask:task responseObject:responseObject success:success];
......@@ -156,7 +159,9 @@
} error:nil];
request.timeoutInterval = 30;
if (self.beforeAction) {
_beforeAction();
}
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:NULL completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
......@@ -216,7 +221,6 @@
#pragma mark - setter
- (void)setApiHost:(NSString *)apiHost{
_apiHost = apiHost;
_networking = [GMHTTPSessionManager shareInstanceWithApiHost:_apiHost];
}
......
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