Commit 3bd50962 authored by Sandy's avatar Sandy

删除多余界面,封装

parent 51667527
......@@ -59,8 +59,9 @@
192118F91D41CEDC000A56EA /* UserInfoConsumer.m in Sources */ = {isa = PBXBuildFile; fileRef = 192118F81D41CEDC000A56EA /* UserInfoConsumer.m */; };
192118FC1D41CF6C000A56EA /* UserInfoOwnerOrg.m in Sources */ = {isa = PBXBuildFile; fileRef = 192118FB1D41CF6C000A56EA /* UserInfoOwnerOrg.m */; };
192118FF1D41CF84000A56EA /* UserInfoReseller.m in Sources */ = {isa = PBXBuildFile; fileRef = 192118FE1D41CF84000A56EA /* UserInfoReseller.m */; };
192119021D41F1C6000A56EA /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 192119011D41F1C6000A56EA /* WebViewController.m */; };
192119051D41FC31000A56EA /* QueryParamsTools.m in Sources */ = {isa = PBXBuildFile; fileRef = 192119041D41FC31000A56EA /* QueryParamsTools.m */; };
1921EF6D1CE5987B00B0BC4A /* HomeCollectionFooterReusableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1921EF6C1CE5987B00B0BC4A /* HomeCollectionFooterReusableView.m */; };
1921EF701CE5C0E900B0BC4A /* ShopWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1921EF6F1CE5C0E900B0BC4A /* ShopWebViewController.m */; };
19272BD31CEB209B00735755 /* ChangeMyBankCardViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 19272BD11CEB209B00735755 /* ChangeMyBankCardViewController.m */; };
19272BD41CEB209B00735755 /* ChangeMyBankCardViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 19272BD21CEB209B00735755 /* ChangeMyBankCardViewController.xib */; };
192860FF1CBF708C00FA6E85 /* MBProgressHUD+Javen.m in Sources */ = {isa = PBXBuildFile; fileRef = 192860FE1CBF708C00FA6E85 /* MBProgressHUD+Javen.m */; };
......@@ -193,7 +194,6 @@
197BA6821CD851DB000E2087 /* JavenDetailReseller.m in Sources */ = {isa = PBXBuildFile; fileRef = 197BA6811CD851DB000E2087 /* JavenDetailReseller.m */; };
197BA6851CD85632000E2087 /* NSNumber+Fommater.m in Sources */ = {isa = PBXBuildFile; fileRef = 197BA6841CD85632000E2087 /* NSNumber+Fommater.m */; };
197BA6891CD865D1000E2087 /* JavencommissionAccountModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 197BA6881CD865D1000E2087 /* JavencommissionAccountModel.m */; };
197DCD381D40CC1F00589E2C /* OrderPayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 197DCD371D40CC1F00589E2C /* OrderPayViewController.m */; };
199B4D681CABBCF600451E0E /* OrderDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 199B4D671CABBCF600451E0E /* OrderDetailViewController.m */; };
199B4D6A1CABBEF400451E0E /* OrderDetailTopView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 199B4D691CABBEF400451E0E /* OrderDetailTopView.xib */; };
199B4D6D1CABBF0800451E0E /* OrderDetailTopView.m in Sources */ = {isa = PBXBuildFile; fileRef = 199B4D6C1CABBF0800451E0E /* OrderDetailTopView.m */; };
......@@ -447,10 +447,12 @@
192118FB1D41CF6C000A56EA /* UserInfoOwnerOrg.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserInfoOwnerOrg.m; sourceTree = "<group>"; };
192118FD1D41CF84000A56EA /* UserInfoReseller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserInfoReseller.h; sourceTree = "<group>"; };
192118FE1D41CF84000A56EA /* UserInfoReseller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserInfoReseller.m; sourceTree = "<group>"; };
192119001D41F1C6000A56EA /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewController.h; sourceTree = "<group>"; };
192119011D41F1C6000A56EA /* WebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewController.m; sourceTree = "<group>"; };
192119031D41FC31000A56EA /* QueryParamsTools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueryParamsTools.h; sourceTree = "<group>"; };
192119041D41FC31000A56EA /* QueryParamsTools.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueryParamsTools.m; sourceTree = "<group>"; };
1921EF6B1CE5987B00B0BC4A /* HomeCollectionFooterReusableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeCollectionFooterReusableView.h; sourceTree = "<group>"; };
1921EF6C1CE5987B00B0BC4A /* HomeCollectionFooterReusableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeCollectionFooterReusableView.m; sourceTree = "<group>"; };
1921EF6E1CE5C0E900B0BC4A /* ShopWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShopWebViewController.h; sourceTree = "<group>"; };
1921EF6F1CE5C0E900B0BC4A /* ShopWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShopWebViewController.m; sourceTree = "<group>"; };
19272BD01CEB209B00735755 /* ChangeMyBankCardViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChangeMyBankCardViewController.h; sourceTree = "<group>"; };
19272BD11CEB209B00735755 /* ChangeMyBankCardViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChangeMyBankCardViewController.m; sourceTree = "<group>"; };
19272BD21CEB209B00735755 /* ChangeMyBankCardViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ChangeMyBankCardViewController.xib; sourceTree = "<group>"; };
......@@ -687,8 +689,6 @@
197BA6841CD85632000E2087 /* NSNumber+Fommater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNumber+Fommater.m"; sourceTree = "<group>"; };
197BA6871CD865D1000E2087 /* JavencommissionAccountModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavencommissionAccountModel.h; sourceTree = "<group>"; };
197BA6881CD865D1000E2087 /* JavencommissionAccountModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JavencommissionAccountModel.m; sourceTree = "<group>"; };
197DCD361D40CC1F00589E2C /* OrderPayViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderPayViewController.h; sourceTree = "<group>"; };
197DCD371D40CC1F00589E2C /* OrderPayViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OrderPayViewController.m; sourceTree = "<group>"; };
199B4D661CABBCF600451E0E /* OrderDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderDetailViewController.h; sourceTree = "<group>"; };
199B4D671CABBCF600451E0E /* OrderDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OrderDetailViewController.m; sourceTree = "<group>"; };
199B4D691CABBEF400451E0E /* OrderDetailTopView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OrderDetailTopView.xib; sourceTree = "<group>"; };
......@@ -1378,8 +1378,6 @@
199BC7A01C9AA7DF00E4E0B8 /* HomeViewController.m */,
1929F18C1CA10C94000E9B26 /* HomeCollectionViewController.h */,
1929F18D1CA10C94000E9B26 /* HomeCollectionViewController.m */,
1921EF6E1CE5C0E900B0BC4A /* ShopWebViewController.h */,
1921EF6F1CE5C0E900B0BC4A /* ShopWebViewController.m */,
196944E21CEC7D500036E574 /* HomeAdViewController.h */,
196944E31CEC7D500036E574 /* HomeAdViewController.m */,
);
......@@ -1494,8 +1492,6 @@
197975501CAB6F5D00407E3F /* OrderViewController.m */,
199B4D661CABBCF600451E0E /* OrderDetailViewController.h */,
199B4D671CABBCF600451E0E /* OrderDetailViewController.m */,
197DCD361D40CC1F00589E2C /* OrderPayViewController.h */,
197DCD371D40CC1F00589E2C /* OrderPayViewController.m */,
);
name = "Order(订单)";
path = Order;
......@@ -1733,6 +1729,8 @@
194FB0E41CE472D20089A3D5 /* NavigationbarView.xib */,
1952C2F81CEDC6160017E4D6 /* JavenCustomerService.h */,
1952C2F91CEDC6160017E4D6 /* JavenCustomerService.m */,
192119031D41FC31000A56EA /* QueryParamsTools.h */,
192119041D41FC31000A56EA /* QueryParamsTools.m */,
);
path = Global;
sourceTree = "<group>";
......@@ -1899,6 +1897,8 @@
19DCCA861C9A95E70072C3BF /* Model */,
19DCCA871C9A95E70072C3BF /* View */,
19DCCA881C9A95E70072C3BF /* ViewController */,
192119001D41F1C6000A56EA /* WebViewController.h */,
192119011D41F1C6000A56EA /* WebViewController.m */,
);
name = "Home(主页)";
path = Home;
......@@ -2663,7 +2663,6 @@
192118F31D41CE75000A56EA /* UserInfoBaseClass.m in Sources */,
190A465C1CE04265006037CB /* AgreementViewController.m in Sources */,
1912FCDA1CCDC955004CF976 /* JavenResellerModel.m in Sources */,
197DCD381D40CC1F00589E2C /* OrderPayViewController.m in Sources */,
194CB5391CD8AA4A0050E59F /* JavenQNManager.m in Sources */,
191AEE5E1CBCC6D100F5E535 /* Conditions.m in Sources */,
19563C4A1CDAEA3800AFD0E0 /* MyBandBottomView.m in Sources */,
......@@ -2751,7 +2750,6 @@
194FB0C91CE2F8E20089A3D5 /* JavenPostalAddresses.m in Sources */,
19DCCBDF1C9AA0450072C3BF /* ICRPlaceholderTextView.m in Sources */,
194FB0D31CE2FA370089A3D5 /* JavenResellerBigModel.m in Sources */,
1921EF701CE5C0E900B0BC4A /* ShopWebViewController.m in Sources */,
1900A33C1CB602D500B2B7C4 /* StoreNameViewController.m in Sources */,
196944DC1CEC4E6C0036E574 /* NoBillHistoryView.m in Sources */,
19DCCBCD1C9AA0450072C3BF /* UIFont+Custom.m in Sources */,
......@@ -2763,6 +2761,8 @@
194FB0CA1CE2F8E20089A3D5 /* JavenReferrer.m in Sources */,
194FB0AA1CE2E95B0089A3D5 /* UserInfoAddress.m in Sources */,
19632DA81CB356050024A8A1 /* UIImage+QRCode.m in Sources */,
192119021D41F1C6000A56EA /* WebViewController.m in Sources */,
192119051D41FC31000A56EA /* QueryParamsTools.m in Sources */,
19DC6B2B1CC0CEDD0064A9FD /* MBTextFieldWithFontAdapter.m in Sources */,
192900741CD0B7AE00D226E7 /* ShareContentView.m in Sources */,
19DC6B2D1CC0CEDD0064A9FD /* MBFontAdapter.m in Sources */,
......
......@@ -18,7 +18,7 @@
<constraint firstAttribute="height" constant="44" id="saD-TZ-a7b"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="22"/>
<state key="normal" title="去支付" backgroundImage="logistics_btn">
<state key="normal" title="去付款" backgroundImage="logistics_btn">
<color key="titleColor" red="0.48627450979999998" green="0.76470588240000004" blue="0.1450980392" alpha="1" colorSpace="calibratedRGB"/>
</state>
</button>
......
......@@ -22,8 +22,7 @@
#import "JavencommissionAccountModel.h"
#import "MyAcountViewController.h"
#import "HomeCollectionFooterReusableView.h"
#import "ShopWebViewController.h"
#import "WebViewController.h"
#define kHomeCollectionViewID @"HomeCollectionViewID"
#define kCollectionViewHeadHeight 230
......@@ -237,8 +236,11 @@
break;
case 6://课堂
{
ShopWebViewController *shopVC = [[ShopWebViewController alloc] init];
WebViewController *shopVC = [[WebViewController alloc] init];
UserInfo *userInfo = [UserInfo shareInstance];
NSString *inviteWebUrl = [NSString stringWithFormat:@"%@Wap/index_shop/shop_id/%@/mobile/%@.html", userInfo.appConfig.webShopBaseUrl, userInfo.reseller.shop.uuid, userInfo.reseller.mobilephone];
shopVC.isShowNavigationBar = YES;
shopVC.URL = inviteWebUrl;
shopVC.title = @"微商城";
shopVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:shopVC animated:YES];
......
......@@ -18,6 +18,7 @@
#import "OrderListFooterView.h"
#import "NSString+OrderState.h"
#import "SeeLogistics.h"
#import "QueryParamsTools.h"
#define kExpressCell @"OrderExpressTableViewCell.h"
#define kCellId @"OrderTableViewCell.h"
#define kPageSize 10
......@@ -105,39 +106,18 @@
orderState = [NSNull null];
}
NSDictionary *myDictionary;
if ([self.orderTag isEqualToString:@"待支付"]) {
myDictionary = @{@"defintion" : @{@"conditions" : @[@{@"operation" : @"domain equals",
@"parameters" : @[kDomain]},
@{@"operation" : @"reseller uuid equals",
@"parameters" : @[[UserInfo shareInstance].reseller.uuid]},
@{@"operation" : @"my unpay order",
@"parameters" : @[[UserInfo shareInstance].consumer.uuid]},
@{@"operation" : @"order state equals",
@"parameters" : @[orderState]}],
@"orders" : @[@{@"field" : @"createInfo.time",
@"direction" : @"desc"}],
@"pageSize" : @(kPageSize),
@"page" : @(self.page),
@"probePages" : @0},
@"fetchParts" : @[@"string"]};
}else{
myDictionary = @{@"defintion" : @{@"conditions" : @[@{@"operation" : @"domain equals",
@"parameters" : @[kDomain]},
@{@"operation" : @"reseller uuid equals",
@"parameters" : @[[UserInfo shareInstance].reseller.uuid]},
@{@"operation" : @"order state equals",
@"parameters" : @[orderState]}],
@"orders" : @[@{@"field" : @"createInfo.time",
@"direction" : @"desc"}],
@"pageSize" : @(kPageSize),
@"page" : @(self.page),
@"probePages" : @0},
@"fetchParts" : @[@"string"]};
QueryParamsTools *query = [QueryParamsTools queryParamsToolWithPage:@(self.page) pageSize:@(kPageSize)];
[query addOrderField:@"createInfo.time" direction:@"desc"];
[query addConditionsOperation:@"domain equals" value:kDomain];
[query addConditionsOperation:@"reseller uuid equals" value:[UserInfo shareInstance].reseller.uuid];
[query addConditionsOperation:@"order state equals" value:orderState];
if ([self.orderTag isEqualToString:@"待支付"]){
[query addConditionsOperation:@"consumer uuid equals" value:[UserInfo shareInstance].consumer.uuid];
}else if([self.orderTag isEqualToString:@"全部订单"]){
[query addConditionsOperation:@"my unpay order" value:[UserInfo shareInstance].consumer.uuid];
}
return myDictionary;
return query.params;
}
......
......@@ -14,7 +14,7 @@
#import "OrderDetailBottomView.h"
#import "CommodityDetailViewController.h"
#import "CommodityListModel/CommotityListModel.h"
#import "OrderPayViewController.h"
#import "WebViewController.h"
#define kCellId @"OrderDetailTableViewCell.h"
@interface OrderDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
......@@ -66,8 +66,11 @@
}
- (void)actionPay {
OrderPayViewController *payVC = [[OrderPayViewController alloc] init];
payVC.model = self.model;
WebViewController *payVC = [[WebViewController alloc] init];
UserInfo *user = [UserInfo shareInstance];
NSString *url = [NSString stringWithFormat:@"%@Wap/orderDetail/id/%@/shop_id/%@/mobile/%@.html",user.appConfig.webShopBaseUrl,self.model.billNumber,self.model.shop.uuid,user.reseller.mobilephone];
payVC.URL = url;
payVC.title = @"付款";
[self.navigationController pushViewController:payVC animated:YES];
}
......
//
// OrderPayViewController.h
// ALand
//
// Created by Z on 16/7/21.
// Copyright © 2016年 Z. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "IBTUIViewController.h"
#import "JavenOrderModel.h"
@interface OrderPayViewController : IBTUIViewController
@property (nonatomic, strong) JavenOrderModel *model;
@end
//
// OrderPayViewController.m
// ALand
//
// Created by Z on 16/7/21.
// Copyright © 2016年 Z. All rights reserved.
//
#import "OrderPayViewController.h"
#import <WebKit/WebKit.h>
@interface OrderPayViewController ()<WKNavigationDelegate, WKUIDelegate>
@property (nonatomic, strong) WKWebView *webView;
@end
@implementation OrderPayViewController
- (void)viewDidLoad {
[super viewDidLoad];
WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight - 64)];
UserInfo *user = [UserInfo shareInstance];
NSString *url = [NSString stringWithFormat:@"%@Wap/orderDetail/id/%@/shop_id/%@/mobile/%@.html",user.appConfig.webShopBaseUrl,self.model.billNumber,self.model.shop.uuid,user.reseller.mobilephone];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
self.webView = webView;
webView.navigationDelegate = self;
webView.UIDelegate = self;
[self.view addSubview:webView];
// Do any additional setup after loading the view from its nib.
}
#pragma mark - wkwebview delegate
// 页面开始加载时调用
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
}
- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL))completionHandler {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:message
message:nil
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"确定"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
completionHandler(YES);
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"取消"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action){
completionHandler(NO);
}]];
[self presentViewController:alertController animated:YES completion:^{}];
}
// 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
self.title = webView.title;
[MBProgressHUD hideHUDForView:self.view];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
//
// ShopWebViewController.h
// WebViewController.h
// ALand
//
// Created by Z on 16/5/13.
// Created by Z on 16/7/22.
// Copyright © 2016年 Z. All rights reserved.
//
#import "IBTUIViewController.h"
@interface ShopWebViewController : IBTUIViewController
@interface WebViewController : IBTUIViewController
@property (nonatomic, copy) NSString *URL;
@end
//
// ShopWebViewController.m
// WebViewController.m
// ALand
//
// Created by Z on 16/5/13.
// Created by Z on 16/7/22.
// Copyright © 2016年 Z. All rights reserved.
//
#import "ShopWebViewController.h"
#import "WebViewController.h"
#import <WebKit/WebKit.h>
@interface ShopWebViewController ()<WKNavigationDelegate, WKUIDelegate>
@interface WebViewController ()<WKNavigationDelegate, WKUIDelegate>
@property (nonatomic, weak) WKWebView * webView;
@property (nonatomic, weak) UIButton * backItem;
@property (nonatomic, weak) UIButton * closeItem;
@end
@implementation ShopWebViewController
@implementation WebViewController
- (void)viewDidLoad {
[super viewDidLoad];
UserInfo *userInfo = [UserInfo shareInstance];
NSString *inviteWebUrl = [NSString stringWithFormat:@"%@Wap/index_shop/shop_id/%@/mobile/%@.html", userInfo.appConfig.webShopBaseUrl, userInfo.reseller.shop.uuid, userInfo.reseller.mobilephone];
WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight - 64)];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:inviteWebUrl]]];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.URL]]];
self.webView = webView;
webView.navigationDelegate = self;
webView.UIDelegate = self;
......@@ -30,7 +28,6 @@
[self initNaviBar];
// Do any additional setup after loading the view.
}
- (void)initNaviBar{
UIView * backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
......@@ -38,7 +35,7 @@
[backItem setImage:[UIImage imageNamed:@"bac"] forState:UIControlStateNormal];
[backItem setImageEdgeInsets:UIEdgeInsetsMake(0, -15, 0, 0)];
[backItem setTitle:@"返回" forState:UIControlStateNormal];
// backItem.titleLabel.font = [UIFont systemFontOfSize:17];
// backItem.titleLabel.font = [UIFont systemFontOfSize:17];
[backItem setTitleEdgeInsets:UIEdgeInsetsMake(0, -5, 0, 0)];
[backItem setTitleColor:kTextColorGray forState:UIControlStateNormal];
[backItem addTarget:self action:@selector(clickedBackItem:) forControlEvents:UIControlEventTouchUpInside];
......
//
// QueryParamsTools.h
// ALand
//
// Created by Z on 16/7/22.
// Copyright © 2016年 Z. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface QueryParamsTools : NSObject
@property (nonatomic, strong) NSMutableDictionary *params;
+ (QueryParamsTools *)queryParamsToolWithPage:(NSNumber *)page pageSize:(NSNumber *)pageSize;
- (void)addOrderField:(NSString *)order direction:(NSString *)direction;
- (void)addConditionsOperation:(NSString *)condition value:(NSString *)value;
@end
//
// QueryParamsTools.m
// ALand
//
// Created by Z on 16/7/22.
// Copyright © 2016年 Z. All rights reserved.
//
#import "QueryParamsTools.h"
@interface QueryParamsTools ()
@property (nonatomic, strong) NSMutableDictionary *defintion;
@property (nonatomic, strong) NSMutableArray *arrFetchParts;
@property (nonatomic, strong) NSMutableArray *orders;
@property (nonatomic, strong) NSMutableArray *conditions;
@end
@implementation QueryParamsTools
+ (QueryParamsTools *)queryParamsToolWithPage:(NSNumber *)page pageSize:(NSNumber *)pageSize {
QueryParamsTools *tools = [[self alloc] initWithWithPage:page pageSize:pageSize];
return tools;
}
- (instancetype)initWithWithPage:(NSNumber *)page pageSize:(NSNumber *)pageSize {
self = [super init];
if (self) {
self.params = [NSMutableDictionary dictionary];
self.defintion = [NSMutableDictionary dictionary];
self.arrFetchParts = [NSMutableArray array];
self.orders = [NSMutableArray array];
self.conditions = [NSMutableArray array];
[self.defintion setValue:page forKey:@"page"];
[self.defintion setValue:pageSize forKey:@"pageSize"];
[self.defintion setValue:@0 forKey:@"probePages"];
[self.defintion setObject:self.conditions forKey:@"conditions"];
[self.defintion setObject:self.orders forKey:@"orders"];
[self.params setObject:self.defintion forKey:@"defintion"];
}
return self;
}
- (void)addOrderField:(NSString *)order direction:(NSString *)direction {
NSDictionary *myDictionary = @{@"field" : order,
@"direction" : direction};
[self.orders addObject:myDictionary];
}
- (void)addConditionsOperation:(NSString *)condition value:(NSString *)value {
NSDictionary *myDictionary = @{@"operation" : condition,
@"parameters" : @[value]};
[self.conditions addObject:myDictionary];
}
@end
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