Commit cc1a1c40 authored by Sandy's avatar Sandy

query都加上了域 domain

parent 6b482276
...@@ -92,6 +92,7 @@ ...@@ -92,6 +92,7 @@
1979754A1CAA4DB900407E3F /* CommodityMutipleSelectBottomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 197975491CAA4DB900407E3F /* CommodityMutipleSelectBottomView.xib */; }; 1979754A1CAA4DB900407E3F /* CommodityMutipleSelectBottomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 197975491CAA4DB900407E3F /* CommodityMutipleSelectBottomView.xib */; };
1979754D1CAB6E1300407E3F /* JavenMultipleViewWithHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1979754C1CAB6E1300407E3F /* JavenMultipleViewWithHeader.m */; }; 1979754D1CAB6E1300407E3F /* JavenMultipleViewWithHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1979754C1CAB6E1300407E3F /* JavenMultipleViewWithHeader.m */; };
197975511CAB6F5D00407E3F /* OrderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 197975501CAB6F5D00407E3F /* OrderViewController.m */; }; 197975511CAB6F5D00407E3F /* OrderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 197975501CAB6F5D00407E3F /* OrderViewController.m */; };
1983EF451CBE2726004510B3 /* ManagementSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1983EF441CBE2726004510B3 /* ManagementSearchViewController.m */; };
199B4D681CABBCF600451E0E /* OrderDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 199B4D671CABBCF600451E0E /* OrderDetailViewController.m */; }; 199B4D681CABBCF600451E0E /* OrderDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 199B4D671CABBCF600451E0E /* OrderDetailViewController.m */; };
199B4D6A1CABBEF400451E0E /* OrderDetailTopView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 199B4D691CABBEF400451E0E /* OrderDetailTopView.xib */; }; 199B4D6A1CABBEF400451E0E /* OrderDetailTopView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 199B4D691CABBEF400451E0E /* OrderDetailTopView.xib */; };
199B4D6D1CABBF0800451E0E /* OrderDetailTopView.m in Sources */ = {isa = PBXBuildFile; fileRef = 199B4D6C1CABBF0800451E0E /* OrderDetailTopView.m */; }; 199B4D6D1CABBF0800451E0E /* OrderDetailTopView.m in Sources */ = {isa = PBXBuildFile; fileRef = 199B4D6C1CABBF0800451E0E /* OrderDetailTopView.m */; };
...@@ -382,6 +383,8 @@ ...@@ -382,6 +383,8 @@
1979754C1CAB6E1300407E3F /* JavenMultipleViewWithHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JavenMultipleViewWithHeader.m; sourceTree = "<group>"; }; 1979754C1CAB6E1300407E3F /* JavenMultipleViewWithHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JavenMultipleViewWithHeader.m; sourceTree = "<group>"; };
1979754F1CAB6F5D00407E3F /* OrderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderViewController.h; sourceTree = "<group>"; }; 1979754F1CAB6F5D00407E3F /* OrderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderViewController.h; sourceTree = "<group>"; };
197975501CAB6F5D00407E3F /* OrderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OrderViewController.m; sourceTree = "<group>"; }; 197975501CAB6F5D00407E3F /* OrderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OrderViewController.m; sourceTree = "<group>"; };
1983EF431CBE2726004510B3 /* ManagementSearchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManagementSearchViewController.h; sourceTree = "<group>"; };
1983EF441CBE2726004510B3 /* ManagementSearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ManagementSearchViewController.m; sourceTree = "<group>"; };
199B4D661CABBCF600451E0E /* OrderDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderDetailViewController.h; 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>"; }; 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>"; }; 199B4D691CABBEF400451E0E /* OrderDetailTopView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OrderDetailTopView.xib; sourceTree = "<group>"; };
...@@ -911,6 +914,8 @@ ...@@ -911,6 +914,8 @@
1979752D1CA90D6C00407E3F /* CommodityManagementViewController.m */, 1979752D1CA90D6C00407E3F /* CommodityManagementViewController.m */,
197975431CAA2FAB00407E3F /* ManagementViewController.h */, 197975431CAA2FAB00407E3F /* ManagementViewController.h */,
197975441CAA2FAB00407E3F /* ManagementViewController.m */, 197975441CAA2FAB00407E3F /* ManagementViewController.m */,
1983EF431CBE2726004510B3 /* ManagementSearchViewController.h */,
1983EF441CBE2726004510B3 /* ManagementSearchViewController.m */,
); );
name = CommodityManagement; name = CommodityManagement;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1905,6 +1910,7 @@ ...@@ -1905,6 +1910,7 @@
1946DC9A1CB7542D00AC6557 /* CatgoryModel.m in Sources */, 1946DC9A1CB7542D00AC6557 /* CatgoryModel.m in Sources */,
197975511CAB6F5D00407E3F /* OrderViewController.m in Sources */, 197975511CAB6F5D00407E3F /* OrderViewController.m in Sources */,
19DCCBDF1C9AA0450072C3BF /* ICRPlaceholderTextView.m in Sources */, 19DCCBDF1C9AA0450072C3BF /* ICRPlaceholderTextView.m in Sources */,
1983EF451CBE2726004510B3 /* ManagementSearchViewController.m in Sources */,
1900A33C1CB602D500B2B7C4 /* StoreNameViewController.m in Sources */, 1900A33C1CB602D500B2B7C4 /* StoreNameViewController.m in Sources */,
19DCCBCD1C9AA0450072C3BF /* UIFont+Custom.m in Sources */, 19DCCBCD1C9AA0450072C3BF /* UIFont+Custom.m in Sources */,
19DCCBE41C9AA0450072C3BF /* ICRFunctionEntity.m in Sources */, 19DCCBE41C9AA0450072C3BF /* ICRFunctionEntity.m in Sources */,
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
[[HTTPCilent shareCilent] POST:@"shop/addGoods" parameters:param success:^(NSURLSessionDataTask *task, id responseObject) { [[HTTPCilent shareCilent] POST:@"shop/addGoods" parameters:param success:^(NSURLSessionDataTask *task, id responseObject) {
if ([responseObject[@"code"] isEqualToNumber: @0]) { if ([responseObject[@"code"] isEqualToNumber: @0]) {
[weakSelf addSUccess];
weakSelf.successBlock(); weakSelf.successBlock();
} }
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
......
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface CommodityManagementTopView : UIView @interface CommodityManagementTopView : UIView
@property (nonatomic, strong) NSMutableArray *arrDatas;
@end @end
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
ManagementViewController *manageVC = [[ManagementViewController alloc] init]; ManagementViewController *manageVC = [[ManagementViewController alloc] init];
[self hideSortView]; [self hideSortView];
manageVC.isShowNavigationBar = YES; manageVC.isShowNavigationBar = YES;
manageVC.arrCellData = [self.arrDatas mutableCopy];
[[self viewController] PushViewController:manageVC animated:YES]; [[self viewController] PushViewController:manageVC animated:YES];
CLog(@"m"); CLog(@"m");
......
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
//配置navigationbar //配置navigationbar
self.navigationItem.title = @"商品列表"; self.navigationItem.title = @"商品列表";
self.view.backgroundColor = kBacroundColor; self.view.backgroundColor = kBacroundColor;
self.field = @"";
self.direction = @"desc";
[self setUpSortView]; [self setUpSortView];
[self setUpCollectionView]; [self setUpCollectionView];
[self setUpData]; [self setUpData];
...@@ -53,38 +56,43 @@ ...@@ -53,38 +56,43 @@
- (void)setUpData { - (void)setUpData {
//前期发送请求生成参数的方式,后来不这么做了 //前期发送请求生成参数的方式,后来不这么做了
NSString *jsonString = @"{\"defintion\":{\"conditions\":[{\"operation\":\"string\",\"parameter\":{},\"parameters\":[{}]}],\"orders\":[{\"field\":\"string\",\"direction\":\"asc\"}],\"pageSize\":0,\"page\":0,\"probePages\":0},\"fetchParts\":[\"string\"]}";
NSDictionary *dic = [jsonString mj_JSONObject]; NSString *parameters;
CommotityRequestModel *requstBody = [CommotityRequestModel modelObjectWithDictionary:dic]; NSString *operation;
requstBody.defintion.pageSize = kPageSize;
requstBody.defintion.page = @0;
requstBody.defintion.probePages = @0;
requstBody.defintion.orders[0].field = self.field;
requstBody.defintion.orders[0].direction = self.direction;
if ([self.model isKindOfClass:[HotBrandModel class]]) {//热门品牌 if ([self.model isKindOfClass:[HotBrandModel class]]) {//热门品牌
//设置请求模型 //设置请求模型
HotBrandModel *model = self.model; HotBrandModel *model = self.model;
requstBody.defintion.conditions[0].operation = @"goodsData brand uuid equals"; operation = @"goodsData brand uuid equals";
requstBody.defintion.conditions[0].parameters = @[model.uuid]; parameters = model.uuid;
}else if([self.model isKindOfClass:[CatgoryModel class]]){//分类 }else if([self.model isKindOfClass:[CatgoryModel class]]){//分类
CatgoryModel *model = self.model; CatgoryModel *model = self.model;
requstBody.defintion.conditions[0].operation = @"goodsData category uuid equals"; operation = @"goodsData category uuid equals";
requstBody.defintion.conditions[0].parameters = @[model.uuid]; parameters = model.uuid;
}else if ([self.model isKindOfClass:[JavenHotTagsModel class]]){//热门标签 }else if ([self.model isKindOfClass:[JavenHotTagsModel class]]){//热门标签
CatgoryModel *model = self.model; CatgoryModel *model = self.model;
requstBody.defintion.conditions[0].operation = @"goodsData category uuid equals"; operation = @"goodsData category uuid equals";
requstBody.defintion.conditions[0].parameters = @[model.uuid]; parameters = model.uuid;
} }
//请求模型转化为字典 NSDictionary *myDictionary = @{@"defintion" : @{@"conditions" : @[@{@"operation" : @"domain equals",
NSDictionary *params = requstBody.mj_keyValues; @"parameter" : @{@"operation" : @"string"},
@"parameters" : @[[UserInfo shareInstance].domain]},
@{@"operation" : operation,
@"parameter" : @{@"operation" : @"string"},
@"parameters" : @[parameters]}],
@"orders" : @[@{@"field" : self.field,
@"direction" : self.direction}],
@"pageSize" : kPageSize,
@"page" : @0,
@"probePages" : @0},
@"fetchParts" : @[@"string"]};
NSString *string = [myDictionary mj_JSONString];
WS(weakSelf) WS(weakSelf)
[[HTTPCilent shareCilent] POST:@"goods/query2" parameters:params success:^(NSURLSessionDataTask *task, id responseObject) { [[HTTPCilent shareCilent] POST:@"goods/query2" parameters:myDictionary success:^(NSURLSessionDataTask *task, id responseObject) {
for (NSDictionary *dic in responseObject[@"queryResult"]) { for (NSDictionary *dic in responseObject[@"queryResult"]) {
CommotityListModel *model = [CommotityListModel modelObjectWithDictionary:dic]; CommotityListModel *model = [CommotityListModel modelObjectWithDictionary:dic];
...@@ -133,8 +141,8 @@ ...@@ -133,8 +141,8 @@
switch (row) { switch (row) {
case 0: case 0:
{ {
self.field = nil; self.field = @"";
self.direction = nil; self.direction = @"desc";
} }
break; break;
case 1://价格 高-低 case 1://价格 高-低
...@@ -221,7 +229,9 @@ ...@@ -221,7 +229,9 @@
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
CommodityListCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath]; CommodityListCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
cell.successBlock = ^{
};
[cell cellWithModel:self.arrItemDatas[indexPath.row]]; [cell cellWithModel:self.arrItemDatas[indexPath.row]];
return cell; return cell;
} }
......
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.direction = @"desc";
self.field = @"";
[self setUpSearchBar]; [self setUpSearchBar];
[self setUpSortView]; [self setUpSortView];
[self setUpCollectionView]; [self setUpCollectionView];
...@@ -73,24 +74,22 @@ ...@@ -73,24 +74,22 @@
- (void)setUpData { - (void)setUpData {
//前期发送请求生成参数的方式,后来不这么做了 NSDictionary *myDictionary = @{@"defintion" : @{@"conditions" : @[@{@"operation" : @"goodsData name like",
NSString *jsonString = @"{\"defintion\":{\"conditions\":[{\"operation\":\"string\",\"parameter\":{},\"parameters\":[{}]}],\"orders\":[{\"field\":\"string\",\"direction\":\"asc\"}],\"pageSize\":0,\"page\":0,\"probePages\":0},\"fetchParts\":[\"string\"]}"; @"parameters" : @[self.searchText]},
NSDictionary *dic = [jsonString mj_JSONObject]; @{@"operation" : @"domain equals",
CommotityRequestModel *requstBody = [CommotityRequestModel modelObjectWithDictionary:dic]; @"parameters" : @[[UserInfo shareInstance].domain]},
requstBody.defintion.conditions[0].operation = @"goodsData name like"; ],
requstBody.defintion.conditions[0].parameters = @[self.searchText]; @"orders" : @[@{@"direction" : self.direction,
requstBody.defintion.pageSize = kPageSize; @"field" : self.field}],
requstBody.defintion.page = @0; @"page" : @0,
requstBody.defintion.probePages = @0; @"pageSize" : @999,
requstBody.defintion.orders[0].field = self.field; @"probePages" : @0},
requstBody.defintion.orders[0].direction = self.direction; @"fetchParts" : [NSNull null]};
//请求模型转化为字典
NSDictionary *params = requstBody.mj_keyValues;
WS(weakSelf) WS(weakSelf)
[[HTTPCilent shareCilent] POST:@"goods/query2" parameters:params success:^(NSURLSessionDataTask *task, id responseObject) { [[HTTPCilent shareCilent] POST:@"goods/query2" parameters:myDictionary success:^(NSURLSessionDataTask *task, id responseObject) {
for (NSDictionary *dic in responseObject[@"queryResult"]) { for (NSDictionary *dic in responseObject[@"queryResult"]) {
CommotityListModel *model = [CommotityListModel modelObjectWithDictionary:dic]; CommotityListModel *model = [CommotityListModel modelObjectWithDictionary:dic];
...@@ -231,7 +230,7 @@ ...@@ -231,7 +230,7 @@
CLog(@"点击搜索"); CLog(@"点击搜索");
[self.navigationController.navigationBar endEditing:YES]; [self.navigationController.navigationBar endEditing:YES];
[self setUpData]; [self resetReloadData];
} }
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
......
...@@ -12,10 +12,12 @@ ...@@ -12,10 +12,12 @@
#import "CommodityTableViewCell.h" #import "CommodityTableViewCell.h"
#import "CommotityRequestModel.h" #import "CommotityRequestModel.h"
#import "CommodityListModel/CommotityListModel.h" #import "CommodityListModel/CommotityListModel.h"
#import "ManagementViewController.h"
#import "Conditions.h"
#define kCellID @"commodityCell" #define kCellID @"commodityCell"
#define kPageSize @10 #define kPageSize @999
#define kCellId @"CommodityTableViewCell.h" #define kCellId @"CommodityTableViewCell.h"
@interface CommodityManagementViewController ()<UITableViewDelegate, UITableViewDataSource> @interface CommodityManagementViewController ()<UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate>
@property (nonatomic, strong) CommodityManagementTopView *topView; @property (nonatomic, strong) CommodityManagementTopView *topView;
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *arrItemDatas; @property (nonatomic, strong) NSMutableArray *arrItemDatas;
...@@ -23,25 +25,78 @@ ...@@ -23,25 +25,78 @@
@property (nonatomic, copy) NSString *field; //排序的字段 @property (nonatomic, copy) NSString *field; //排序的字段
@property (nonatomic, copy) NSString *direction; //排序的顺序 升序或降序 @property (nonatomic, copy) NSString *direction; //排序的顺序 升序或降序
@property (nonatomic, copy) NSString *searchText; //正在搜索的字段 @property (nonatomic, copy) NSString *searchText; //正在搜索的字段
@property (nonatomic, copy) NSString *condition;
@property (nonatomic, strong) UISearchBar *searchBar;
@property (nonatomic, strong) UIBarButtonItem *rightItem;
@property (nonatomic, strong) UIView *titleView;
@property (nonatomic, strong) UIView *searchTitleView;
@end @end
@implementation CommodityManagementViewController @implementation CommodityManagementViewController
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.condition = @"shop online only";
self.searchText = @"";
self.field = @"";
self.direction = @"desc";
[self setUpNavigationbar];
[self setUpViews];
[self setUpData];
[self setUpSearchBar];
}
- (void)setUpSearchBar {
UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kWidth - 100, 35)];//allocate titleView
UIColor *color = self.navigationController.navigationBar.barTintColor;
[titleView setBackgroundColor:color];
self.searchBar = [[UISearchBar alloc] init];
self.searchBar.backgroundColor = kRandomColor;
self.searchBar.delegate = self;
self.searchBar.frame = CGRectMake(0, 0, 0, 35);
self.searchBar.centerX = titleView.centerX;
self.searchBar.backgroundImage = [UIImage imageWithColor:color];
[titleView addSubview:self.searchBar];
self.searchTitleView = titleView;
}
- (void)cancelSearchAction {
self.searchText = @"";
self.condition = @"shop online only";
self.searchBar.width = 0;
self.searchBar.centerX = (kWidth - 100) / 2;
self.navigationItem.titleView = self.titleView;
self.navigationItem.rightBarButtonItem = self.rightItem;
}
- (void)setUpNavigationbar {
self.navigationItem.title = @"商品管理"; self.navigationItem.title = @"商品管理";
self.titleView = self.navigationItem.titleView;
self.rightItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"searchIcon"] style:UIBarButtonItemStyleDone target:self action:@selector(searchAct)];
self.rightItem.tintColor = kTextColorDarkGray;
self.navigationItem.rightBarButtonItem = self.rightItem;
}
UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"searchIcon"] style:UIBarButtonItemStyleDone target:self action:@selector(searchAct)];
rightBtn.tintColor = kTextColorDarkGray;
self.navigationItem.rightBarButtonItem = rightBtn;
- (void)setUpViews {
[self.view addSubview:self.topView]; [self.view addSubview:self.topView];
[self.view addSubview:self.sorView]; [self.view addSubview:self.sorView];
WS(weakSelf)
self.sorView.leftTableSelect = ^(NSInteger row){ self.sorView.leftTableSelect = ^(NSInteger row){
[weakSelf leftSelectCodtition:row];
CLog(@"l"); CLog(@"l");
}; };
self.sorView.rightTableSelect = ^(NSInteger row){ self.sorView.rightTableSelect = ^(NSInteger row){
[weakSelf rightSelectCondition:row];
CLog(@"r"); CLog(@"r");
}; };
...@@ -49,10 +104,74 @@ ...@@ -49,10 +104,74 @@
_tableView = [UITableView plainTableViewWithTarget:self cellNibName:@"CommodityTableViewCell" cellId:kCellId]; _tableView = [UITableView plainTableViewWithTarget:self cellNibName:@"CommodityTableViewCell" cellId:kCellId];
[self.view addSubview:_tableView]; [self.view addSubview:_tableView];
_tableView.sd_layout.topSpaceToView(self.sorView,0).leftEqualToView(self.view).rightEqualToView(self.view).bottomEqualToView(self.view); _tableView.sd_layout.topSpaceToView(self.sorView,0).leftEqualToView(self.view).rightEqualToView(self.view).bottomEqualToView(self.view);
}
- (void)leftSelectCodtition:(NSInteger)row {
switch (row) {
case 0:
{
self.condition = @"shop online only";
}
break;
case 1:
{
self.condition = @"shop offline only";
}
break;
default:
break;
}
[self resetReloadData];
}
//改变排序条件之后重新请求数据
- (void)resetReloadData {
[self.arrItemDatas removeAllObjects];
[self setUpData]; [self setUpData];
}
- (void)rightSelectCondition:(NSInteger)row {
switch (row) {
case 0:
{
self.field = @"shop goods create time";
self.direction = @"desc";
}
break;
case 1:
{
self.field = @"salesvolume";
self.direction = @"desc";
}
break;
case 2:
{
self.field = @"brokerageRate";
self.direction = @"desc";
}
break;
case 3:
{
self.field = @" spec price";
self.direction = @"desc";
}
break;
default:
break;
}
[self resetReloadData];
} }
- (NSMutableArray *)arrItemDatas { - (NSMutableArray *)arrItemDatas {
if (!_arrItemDatas) { if (!_arrItemDatas) {
_arrItemDatas = [NSMutableArray array]; _arrItemDatas = [NSMutableArray array];
...@@ -62,21 +181,21 @@ ...@@ -62,21 +181,21 @@
- (void)setUpData { - (void)setUpData {
//前期发送请求生成参数的方式,后来不这么做了 NSDictionary *params = @{@"defintion" : @{@"probePages" : @0,
NSString *jsonString = @"{\"defintion\":{\"conditions\":[{\"operation\":\"string\",\"parameter\":{},\"parameters\":[{}]}],\"orders\":[{\"field\":\"string\",\"direction\":\"asc\"}],\"pageSize\":0,\"page\":0,\"probePages\":0},\"fetchParts\":[\"string\"]}"; @"orders" : @[@{@"field" : self.field,
NSDictionary *dic = [jsonString mj_JSONObject]; @"direction" : self.direction}],
CommotityRequestModel *requstBody = [CommotityRequestModel modelObjectWithDictionary:dic]; @"conditions" : @[@{@"parameters" : @[[UserInfo shareInstance].domain],
requstBody.defintion.conditions[0].operation = @"shop uuid equals"; @"operation" : @"domain equals",
requstBody.defintion.conditions[0].parameters = @[[UserInfo shareInstance].shop.uuid]; @"parameter" : @{@"operation" : @"string"}},
requstBody.defintion.pageSize = kPageSize; @{@"parameters" : @[@[[UserInfo shareInstance].shop.uuid]],
requstBody.defintion.page = @0; @"operation" : @"shop uuid equals",
requstBody.defintion.probePages = @0; @"parameter" : @{@"operation" : @"sring"}},
requstBody.defintion.orders[0].field = self.field; @{@"parameters" : @[self.searchText],
requstBody.defintion.orders[0].direction = self.direction; @"operation" : self.condition,
@"parameter" : @{@"operation" : @"sring"}}],
@"pageSize" : kPageSize,
//请求模型转化为字典 @"page" : @0},
NSDictionary *params = requstBody.mj_keyValues; @"fetchParts" : @[@"string"]};
WS(weakSelf) WS(weakSelf)
[[HTTPCilent shareCilent] POST:@"goods/query2" parameters:params success:^(NSURLSessionDataTask *task, id responseObject) { [[HTTPCilent shareCilent] POST:@"goods/query2" parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
...@@ -98,13 +217,28 @@ ...@@ -98,13 +217,28 @@
- (void)searchAct { - (void)searchAct {
[self.sorView hide]; [self.sorView hide];
CLog(@"search"); CLog(@"search");
WS(weakSelf)
self.navigationItem.titleView = self.searchTitleView;
[UIView animateWithDuration:0.3 animations:^{
weakSelf.searchBar.width = kWidth - 100;
weakSelf.searchBar.centerX = (kWidth - 100) / 2;
} completion:^(BOOL finished) {
[weakSelf.searchBar becomeFirstResponder];
}] ;
UIBarButtonItem *cancelSearch = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStyleDone target:self action:@selector(cancelSearchAction)];
self.navigationItem.rightBarButtonItem = cancelSearch;
} }
- (void)viewWillDisappear:(BOOL)animated { - (void)viewWillDisappear:(BOOL)animated {
[self.navigationController.navigationBar endEditing:YES];
[super viewWillDisappear:animated]; [super viewWillDisappear:animated];
[self.sorView hide]; [self.sorView hide];
} }
#pragma mark =========== tableview delegate =========== #pragma mark =========== tableview delegate ===========
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
...@@ -122,11 +256,31 @@ ...@@ -122,11 +256,31 @@
return 130; return 130;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
#pragma mark =========== searchBar Delegate ===========
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
CLog(@"点击搜索");
self.condition = @"goodsData name like";
[self.navigationController.navigationBar endEditing:YES];
[self resetReloadData];
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
self.searchText = searchText;
}
#pragma mark =========== lazy loading =========== #pragma mark =========== lazy loading ===========
- (CommodityManagementSortView *)sorView { - (CommodityManagementSortView *)sorView {
if (!_sorView) { if (!_sorView) {
_sorView = [[CommodityManagementSortView new] sortView]; _sorView = [[CommodityManagementSortView new] sortView];
_sorView.frame = CGRectMake(0, _topView.bottom - 50, kWidth, 49); _sorView.frame = CGRectMake(0, _topView.bottom - 50, kWidth, 49);
} }
return _sorView; return _sorView;
} }
...@@ -135,6 +289,7 @@ ...@@ -135,6 +289,7 @@
if (!_topView) { if (!_topView) {
_topView = [CommodityManagementTopView viewWithNibName:@"CommodityManagementTopView"]; _topView = [CommodityManagementTopView viewWithNibName:@"CommodityManagementTopView"];
_topView.frame = CGRectMake(0, 0, kWidth, 64 + 64); _topView.frame = CGRectMake(0, 0, kWidth, 64 + 64);
_topView.arrDatas = self.arrItemDatas;
} }
return _topView; return _topView;
} }
......
//
// ManagementSearchViewController.h
// ALand
//
// Created by Z on 16/4/13.
// Copyright © 2016年 Z. All rights reserved.
//
#import "IBTUIViewController.h"
@interface ManagementSearchViewController : IBTUIViewController
@end
//
// ManagementSearchViewController.m
// ALand
//
// Created by Z on 16/4/13.
// Copyright © 2016年 Z. All rights reserved.
//
#import "ManagementSearchViewController.h"
@interface ManagementSearchViewController ()<UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource>
@end
@implementation ManagementSearchViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpSearchBar];
// Do any additional setup after loading the view.
}
- (void)setUpSearchBar {
UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 35)];//allocate titleView
UIColor *color = self.navigationController.navigationBar.barTintColor;
[titleView setBackgroundColor:color];
UISearchBar *searchBar = [[UISearchBar alloc] init];
searchBar.delegate = self;
searchBar.frame = CGRectMake(0, 0, 260, 35);
searchBar.centerX = titleView.centerX;
searchBar.backgroundImage = [UIImage imageWithColor:color];
[searchBar setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[titleView addSubview:searchBar];
self.navigationItem.titleView = titleView;
[searchBar becomeFirstResponder];
}
- (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
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#import "IBTUIViewController.h" #import "IBTUIViewController.h"
#import "CommodityManagementSortView.h" #import "CommodityManagementSortView.h"
#import "CommodityManagementViewController.h"
@interface ManagementViewController : IBTUIViewController @interface ManagementViewController : IBTUIViewController
@property (nonatomic, strong) CommodityManagementSortView *sorView; @property (nonatomic, strong) CommodityManagementSortView *sorView;
@property (nonatomic, strong) NSMutableArray *arrCellData;
@end @end
...@@ -87,12 +87,12 @@ ...@@ -87,12 +87,12 @@
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10; return self.arrCellData.count;
} }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CommodityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId forIndexPath:indexPath]; CommodityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId forIndexPath:indexPath];
[cell cellWithModel:self.arrCellData[indexPath.row]];
return cell; return cell;
} }
......
...@@ -43,29 +43,29 @@ ...@@ -43,29 +43,29 @@
//本地已有密码时登录 //本地已有密码时登录
- (void)defaultLoginAction { - (void)defaultLoginAction {
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"userName"]) { // if ([[NSUserDefaults standardUserDefaults] objectForKey:@"userName"]) {
//
NSDictionary *paramers = @{@"domain":kDomain, // NSDictionary *paramers = @{@"domain":kDomain,
@"loginName":[[NSUserDefaults standardUserDefaults] objectForKey:@"userName"] , // @"loginName":[[NSUserDefaults standardUserDefaults] objectForKey:@"userName"] ,
@"password":[[NSUserDefaults standardUserDefaults] objectForKey:@"passWord"], // @"password":[[NSUserDefaults standardUserDefaults] objectForKey:@"passWord"],
@"rememberMe":@"true"}; // @"rememberMe":@"true"};
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; // [MBProgressHUD showHUDAddedTo:self.view animated:YES];
WS(weakSelf) // WS(weakSelf)
[[HTTPCilent shareCilent] POST:@"app/resellerLogin" parameters:paramers success:^(NSURLSessionDataTask *task, id responseObject) { // [[HTTPCilent shareCilent] POST:@"app/resellerLogin" parameters:paramers success:^(NSURLSessionDataTask *task, id responseObject) {
UserInfo *info = [UserInfo shareInstance]; // UserInfo *info = [UserInfo shareInstance];
[info UserInfoWithDictionary:responseObject[@"reseller"]]; // [info UserInfoWithDictionary:responseObject[@"reseller"]];
//
//
[MBProgressHUD hideHUDForView:self.view animated:YES]; // [MBProgressHUD hideHUDForView:self.view animated:YES];
BaseViewController *baseVC = [[BaseViewController alloc] init]; // BaseViewController *baseVC = [[BaseViewController alloc] init];
baseVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; // baseVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[weakSelf presentViewController:baseVC animated:YES completion:nil]; // [weakSelf presentViewController:baseVC animated:YES completion:nil];
} failure:^(NSURLSessionDataTask *task, NSError *error) { // } failure:^(NSURLSessionDataTask *task, NSError *error) {
//
}]; // }];
//
//
} // }
} }
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
CLog(@"POST请求失败!----->%@", [error localizedDescription]); CLog(@"POST请求失败!----->%@", [error localizedDescription]);
failure(task, error); failure(task, error);
}]; }];
} }
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
@interface Defintion : NSObject <NSCoding, NSCopying> @interface Defintion : NSObject <NSCoding, NSCopying>
@property (nonatomic, strong) NSNumber *pageSize; @property (nonatomic, strong) NSNumber *pageSize;
@property (nonatomic, strong) NSArray<Orders *> *orders; @property (nonatomic, strong) NSMutableArray<Orders *> *orders;
@property (nonatomic, strong) NSArray<Conditions *> *conditions; @property (nonatomic, strong) NSMutableArray<Conditions *> *conditions;
@property (nonatomic, assign) NSNumber *probePages; @property (nonatomic, assign) NSNumber *probePages;
@property (nonatomic, strong) NSNumber *page; @property (nonatomic, strong) NSNumber *page;
......
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