Commit d29beda4 authored by 勾芒's avatar 勾芒

caoyunxiao

parent 27d221f0
......@@ -22,4 +22,9 @@
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *productCollectionLayout;
/**
* 搜索code
*/
@property (nonatomic,copy) NSString *selectedCode;
@end
......@@ -87,6 +87,31 @@
[self getScreeningdatas];
}
#pragma mark -热门搜索
- (void)setSelectedCode:(NSString *)selectedCode
{
_selectedCode = selectedCode;
//默认数据
GoodsCondition *conditon = [[GoodsCondition alloc]init];
//分页数据
DataPage *Newpage = [[DataPage alloc]init];
Newpage.page = 0;
conditon.page = Newpage;
conditon.categoryEquals = _selectedCode;
__weak typeof(self)weakSelf = self;
[self getGoodsListdatas:conditon returnResponse:^(GoodsResponse *response) {
if (response.goodsEntity.count == 0) {
[self ErrorMBProgressView:@"暂无数据"];
return ;
}
weakSelf.datasArray = response;
[weakSelf.productCollectionView reloadData];
}];
}
#pragma mark -获取商品列表数据
- (void)getGoodsListDatas
......@@ -194,7 +219,8 @@
#pragma mark -返回根视图
- (void)popTorootviewController:(NSNotification *)not
{
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex_opple:1] animated:NO];
}
......
......@@ -93,9 +93,6 @@
page.page = 0;
condition.page = page;
[self getSceneLibrarydatas:condition];
}
......
......@@ -74,40 +74,26 @@
//保存输入内容
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(searchInputString:) name:SEARCHSTRING object:nil];
//返回根视图
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popTorootviewController:) name:POPROOTCONTROLLER object:nil];
}
#pragma mark -返回根视图
- (void)popTorootviewController:(NSNotification *)not
{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark -输入内容
- (void)searchInputString:(NSNotification *)not
{
[self.localSearchArray addObject:not.object];
//调用商品控制器
ProductLibraryViewController *productVC = [[self getStoryboardWithName] instantiateViewControllerWithIdentifier:@"productlibrary"];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:productVC];
[self.navigationController pushViewController:nav animated:YES];
[self.navigationController pushViewController:productVC animated:YES];
}
#pragma mark -获取本地存储搜索历史
- (void)getlocalsaveDatas
{
NSString *homeDictionary = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0];
NSString *homepath = [homeDictionary stringByAppendingPathComponent:@"LOCALSAVE"];//添加储存的文件名
NSString *homepath = [homeDictionary stringByAppendingPathComponent:SEARCHHISTORY];//添加储存的文件名
self.localSearchArray = [NSKeyedUnarchiver unarchiveObjectWithFile:homepath];
[self.historyCollectionView reloadData];
}
......@@ -116,11 +102,30 @@
- (void)SaveSearchDatas
{
NSString *homeDictionary = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0];
NSString *homepath = [homeDictionary stringByAppendingPathComponent:@"LOCALSAVE"];//添加储存的文件名
NSString *homepath = [homeDictionary stringByAppendingPathComponent:SEARCHHISTORY];//添加储存的文件名
BOOL flag = [NSKeyedArchiver archiveRootObject:self.localSearchArray toFile:homepath];//归档一个字符串
if (flag) {
NSLog(@"归档成功");
}
}
#pragma mark -将要加载前获取本地搜索历史
- (void)viewWillAppear:(BOOL)animated
{
[self getlocalsaveDatas];
}
#pragma mark -视图消失后归档搜索历史
- (void)viewDidDisappear:(BOOL)animated
{
[self.view endEditing:YES];
[self SaveSearchDatas];
}
#pragma mark -获取热门搜索数据
- (void)getHotSearchdatas
......@@ -175,6 +180,19 @@
return self.localSearchArray.count;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if ([collectionView isEqual:self.hotCollectionView]) {
[self.localSearchArray addObject:[[self.response.list objectAtIndex_opple:indexPath.item] name]];
//调用商品控制器
ProductLibraryViewController *productVC = [[self getStoryboardWithName] instantiateViewControllerWithIdentifier:@"productlibrary"];
productVC.selectedCode = [[self.response.list objectAtIndex_opple:indexPath.item] fid];
[self.navigationController pushViewController:productVC animated:YES];
}
}
#pragma mark -释放
- (void)dealloc
......@@ -184,6 +202,21 @@
#pragma mark -清除搜索历史
- (IBAction)delecteSearchHistoryButtonClick:(UIButton *)sender {
NSString *homeDictionary = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0];
NSString *homepath = [homeDictionary stringByAppendingPathComponent:SEARCHHISTORY];//添加储存的文件名
NSFileManager *manager = [NSFileManager defaultManager];
[manager removeItemAtPath:homepath error:nil];
[self.localSearchArray removeAllObjects];
[self.historyCollectionView reloadData];
}
- (void)didReceiveMemoryWarning {
......
......@@ -344,6 +344,7 @@
page.page = 0;
order.datapage = page;
//收货地址
TOOrderEntity *orderReceiver = [[TOOrderEntity alloc]init];
NSArray *Adressarr = [self.datasArray objectAtIndex_opple:1];
......
......@@ -210,7 +210,6 @@
}
#pragma mark -二维码扫描
- (void)QrcodeButtonClick
{
......@@ -243,7 +242,7 @@
if (textField.text != nil) {
[textField resignFirstResponder];
self.selectedIndex = 4;
// self.selectedIndex = 4;
//搜索
[[NSNotificationCenter defaultCenter] postNotificationName:SEARCHSTRING object:textField.text];
......
......@@ -145,8 +145,10 @@
#define POPROOTCONTROLLER @"POPROOTCONTROLLER"
/**
* 储存本地的搜索历史文件名
*/
#define SEARCHHISTORY @"searchhistory"
#endif /* PrefixHeader_pch */
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