// // LFWBrowserHistoryController.m // YouHuiProject // // Created by 小花 on 2018/2/1. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LFWBrowserHistoryController.h" #import "LFWHistoryTool.h" #import "LFWHistoryModel.h" #import "LFWCollectionTicketCell.h" #import "LFWDateHeaderView.h" #import "LFWGoodDetailViewController.h" #import "LFWSimilarGoodsController.h" @interface LFWBrowserHistoryController () @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) NSMutableArray *dataArr; @end @implementation LFWBrowserHistoryController - (void)viewDidLoad { [super viewDidLoad]; [self configNavigationBar]; [self configTableView]; [self getLocationBrowserHistoryData]; } - (void)configNavigationBar { [self.navigationBar setNavTitle:@"浏览记录"]; self.navigationBar.showNavigationBarBottomLine = YES; UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal]; [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; [self.navigationBar setCustomLeftButtons:@[leftBtn]]; } - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } - (void)getLocationBrowserHistoryData { NSMutableArray *hisArr = [[NSMutableDictionary dictionaryWithContentsOfFile:[LFWHistoryTool getHistoryFilePath]] objectForKey:BrowserHistoryKey]; NSMutableSet *set = [NSMutableSet set]; NSMutableArray * _datas = [[NSMutableArray alloc] initWithCapacity:0]; [hisArr enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [set addObject:obj[@"browserTime"]];//利用set不重复的特性,得到有多少组,根据数组中的MeasureType字段 }]; [set enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {//遍历set数组 NSPredicate *predicate = [NSPredicate predicateWithFormat:@"browserTime = %@", obj];//创建谓词筛选器 NSArray *group = [hisArr filteredArrayUsingPredicate:predicate]; [_datas addObject:group]; }]; for (NSArray *dicArr in _datas) { NSMutableArray *mArr = [NSMutableArray array]; for (NSDictionary *dic in dicArr) { LFWHistoryModel *model = [[LFWHistoryModel alloc] init]; [model setValuesForKeysWithDictionary:dic]; [mArr addObject:model]; } [self.dataArr addObject:mArr]; } [self.tableView reloadData]; } - (void)configTableView { [self.view addSubview:self.tableView]; self.tableView.showNoDataView = YES; self.tableView.defaultNoDataText = @"暂无数据~"; self.tableView.defaultNoDataViewDidClickBlock = ^(UIView *view) { }; } /** 移除历史 */ - (void)deleteCollectionGoodAtIndexPath:(NSIndexPath *)indexPath { LFWHistoryModel *model = self.dataArr[indexPath.section][indexPath.row]; NSMutableArray *hisArr = [[NSMutableDictionary dictionaryWithContentsOfFile:[LFWHistoryTool getHistoryFilePath]] objectForKey:BrowserHistoryKey]; for (NSDictionary *dic in [hisArr mutableCopy]) { if ([dic[@"goods_id"] isEqualToString:model.goods_id]) { [hisArr removeObject:dic]; } } NSDictionary *historyDic = @{BrowserHistoryKey:hisArr}; [historyDic writeToFile:[LFWHistoryTool getHistoryFilePath] atomically:YES]; // 删除模型 NSMutableArray *mArr = self.dataArr[indexPath.section]; [mArr removeObjectAtIndex:indexPath.row]; [self.dataArr replaceObjectAtIndex:indexPath.section withObject:mArr]; [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft]; } #pragma mark ------------------------ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { [self deleteCollectionGoodAtIndexPath:indexPath]; } /** * 修改Delete按钮文字为“删除” */ - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath { return @"删除"; } - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { [cell setSeparatorInset:UIEdgeInsetsMake(0, 50, 0, 0)]; } } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.dataArr.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSArray *arr = self.dataArr[section]; return arr.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 100; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 40; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { LFWCollectionTicketCell *cell = [LFWCollectionTicketCell cellWithTableView:tableView]; cell.selectionStyle = UITableViewCellSelectionStyleNone; LFWHistoryModel *model = self.dataArr[indexPath.section][indexPath.row]; cell.historyModel = model; return cell; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { LFWDateHeaderView *header = [[LFWDateHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)]; LFWHistoryModel *model = [self.dataArr[section] firstObject]; [header setDateWith:model.browserTime]; return header; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { LFWHistoryModel *model = self.dataArr[indexPath.section][indexPath.row]; if ([PublicFunction isOuttimeDate:model.end_time]) { //找相似 LFWSimilarGoodsController *similar = [[LFWSimilarGoodsController alloc] init]; similar.goods_id = model.goods_id; [self.navigationController pushViewController:similar animated:YES]; }else { LFWGoodDetailViewController *detail = [[LFWGoodDetailViewController alloc] init]; detail.goods_id = model.goods_id; [self.navigationController pushViewController:detail animated:YES]; } } - (UITableView *)tableView { if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) style:UITableViewStylePlain]; _tableView.estimatedSectionHeaderHeight = 0; _tableView.estimatedSectionFooterHeight = 0; _tableView.sectionFooterHeight = 0; _tableView.sectionHeaderHeight = 0; _tableView.delegate = self; _tableView.dataSource = self; _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; _tableView.backgroundColor = [UIColor yhGrayColor]; _tableView.bounces = YES; _tableView.showsVerticalScrollIndicator = NO; [_tableView setSeparatorColor:[UIColor YHColorWithHex:0xdddddd]]; } return _tableView; } - (NSMutableArray *)dataArr { if (!_dataArr) { _dataArr = [NSMutableArray array]; } return _dataArr; } - (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. } */ -(void)aA8oK:(UIRegion*) aA8oK aQYdHa98J:(UIViewController*) aQYdHa98J aQlaORd:(UISearchBar*) aQlaORd alUOY6Ag:(UIImageView*) alUOY6Ag actQb:(UIWindow*) actQb aVDsHlh:(UIAlertView*) aVDsHlh aw619nepl0:(UIRegion*) aw619nepl0 anTKkod:(UILabel*) anTKkod aKdCU9V78Z:(UIKeyCommand*) aKdCU9V78Z aG0lY:(UIApplication*) aG0lY awgljRXCP:(UIDocument*) awgljRXCP aPUxpYF38v:(UISearchBar*) aPUxpYF38v ah0j8D:(UIEdgeInsets*) ah0j8D amArYIR7LoE:(UIKeyCommand*) amArYIR7LoE { NSLog(@"eEpfIC78hdxNJX"); NSLog(@"0kReLn6VYhZDlxIMjOvFtiopg"); NSLog(@"NuWSoDEYMw8e57pjiVCLgRAKFlczU"); NSLog(@"3YbDVf0j8QhcLPoJCTK19E"); NSLog(@"5kgNFEMbBvX6TYPnj1aC7upIHmltQ"); NSLog(@"kateW9qvPJjBd67Q2CFDubyn0cfMpZIHhmT"); NSLog(@"fTJrIqXuZAdhbxe39COUtvBWgQFcnyjp"); NSLog(@"rY8CFKWmoX92MLEVaPGxBpDlUJ"); NSLog(@"GiXA1BfDKIzZoNUCmP4eJjVYh9OgQHLrlcn"); NSLog(@"Rkpro76xFHIc5Az9v"); NSLog(@"sxW4L53TUdMk2ViGnH0bZr8eaXf7pwh"); NSLog(@"v6PWNxcpJDgS9CRF3QMO1UnXqfZGzh"); NSLog(@"Coe6wkqzGhlE4y1"); NSLog(@"D7Pt5XbcOBSa3oIWZg"); NSLog(@"7jZ9EtoORYJVAP5FQxn"); NSLog(@"VKrhHFLktnUd3Z"); NSLog(@"CZwrTqthx5eF82L"); } -(void)akTIQOsH:(UIEvent*) akTIQOsH adLMrwW:(UIEvent*) adLMrwW auy2sN:(UIScreen*) auy2sN aUphF5:(UIFont*) aUphF5 afsJo9jz:(UIView*) afsJo9jz aPwi5dH:(UIControl*) aPwi5dH aMy16:(UIFontWeight*) aMy16 aNEvPMpI:(UIImage*) aNEvPMpI aWqygc:(UIUserInterfaceIdiom*) aWqygc atZCDpdALiU:(UIVisualEffectView*) atZCDpdALiU aEKCn3XR0:(UIBarButtonItem*) aEKCn3XR0 arF0oZgdH:(UIMenuItem*) arF0oZgdH aJfK70uDo:(UIViewController*) aJfK70uDo aRSZv3jh:(UIBezierPath*) aRSZv3jh a0AL8JrT63O:(UIBarButtonItem*) a0AL8JrT63O { NSLog(@"097DEi8AgZo3YNfRJC6Fa"); NSLog(@"nq0ymOjSXIMNsWK"); NSLog(@"z4Q7KkFwxYupy3Z69oTEVcWb"); NSLog(@"vk1MpJoXtV"); NSLog(@"2oKG5Squ97iv4UmbtkXQ"); NSLog(@"vud0CYaoqh5X483"); NSLog(@"UDHrimoM5NvOnIB3tE1GSRVljuKFT9fQwhaZpk"); NSLog(@"bQywDmGZO0zJ1jqAgPTClotikL"); NSLog(@"Y9j8UzHeuyKlVpF2a"); NSLog(@"j71Dp6LydSFBm8xqWPf5lrKTXcAC"); NSLog(@"LGYJNKbgca2uwAn387Xm6kdHt"); NSLog(@"hy0RKkMiaN6qSJ"); NSLog(@"tfWwuZDyQSnq78vzhTMl"); NSLog(@"I2RUVzg4LelsJaQBbrG3P8"); NSLog(@"DWEUZLOFemwuh4qGxTtSXksal8HA"); NSLog(@"Uwpt8GVX6r"); NSLog(@"n7u1aZpqQ8heECmKH"); NSLog(@"FKuycljBoViCAUrkEH8PwIQ7"); } -(void)aAW3uky:(UIMotionEffect*) aAW3uky aT4MI0:(UIDocument*) aT4MI0 aqumavTb:(UIControl*) aqumavTb aWxoG:(UISearchBar*) aWxoG aB12a4C:(UICollectionView*) aB12a4C a5JXRwZ:(UIEdgeInsets*) a5JXRwZ aMsWG:(UILabel*) aMsWG aRYVQk:(UIInputView*) aRYVQk apoyCm:(UIMenuItem*) apoyCm alcSCwF6:(UIScreen*) alcSCwF6 aSF9o:(UIBezierPath*) aSF9o aR7fJN:(UIApplication*) aR7fJN as284MXbg:(UIFont*) as284MXbg atqG0f:(UIControlEvents*) atqG0f a4VAWQNkES:(UIEvent*) a4VAWQNkES az5fY7CDd2F:(UIFontWeight*) az5fY7CDd2F aiuWDGja5Ub:(UIFontWeight*) aiuWDGja5Ub a4ah7uBN:(UIFontWeight*) a4ah7uBN askwy8q:(UICollectionView*) askwy8q { NSLog(@"UqTjXcLiouRmpAvHVhst2Q6rDeMO7E5PN4g"); NSLog(@"NGluOHdoxzpVD16afQSJMY9htcqW47kT"); NSLog(@"WiX6nhyYlEDzLOk4RZdFPjTU5mNKtrC"); NSLog(@"lE8Rq9mS7Dgedf"); NSLog(@"VzTahY2A013fdRFbsoDi5GHvExn6"); NSLog(@"D8YqQO73vCxLXWfKl4bkUJh"); NSLog(@"Wnck9VKwDMZ7hx2dy8b46FeYP"); NSLog(@"McX65C9Q0YEqwljHtD"); NSLog(@"wMVD4BRrp1QCaPfql3N6kzGjcuy"); NSLog(@"zshpOn7uM5ZCKogU0LliSTVFH4XDb6"); NSLog(@"BoKHhOJAmwRDZFbNW"); NSLog(@"zmr3GCJKTNnufj0baSOphXyQceWxVRPYFkIi2H"); NSLog(@"WGHwkRgz80m7KTX9Sdvfasj"); NSLog(@"OmY8ilzLj4teCubGKRwyIQh7UFHdpPfvs"); NSLog(@"WuH0eQ6bMtT"); NSLog(@"GadnCSVzQq0tZc2leHfWjBXguYA7Fib9x"); NSLog(@"dnYaeLSVpXKCjUO8Jbqw9GFr7E"); } -(void)a6Ihpdkn:(UIBezierPath*) a6Ihpdkn aZ4sjP:(UIImageView*) aZ4sjP a0tidZXRO:(UIInputView*) a0tidZXRO ad3rw:(UIInputView*) ad3rw aL4X6OhWfjl:(UISwitch*) aL4X6OhWfjl { NSLog(@"FYgZPtqk3K7684dIrXGObVa1"); NSLog(@"elDXhmH6iGIQ4t3aZ0xjP2cuwVvLdqfNM5KkE1Tg"); NSLog(@"LTQ52f3a1EYSIpw9AzUZJChPsDNc6Gv4F0i7"); NSLog(@"1fBgCLZP9eOKypEJI58zRTG4qNHmjku"); NSLog(@"d5ARXBMFb7gSJ8eHrI4jU6ckOlGaPoT3K"); NSLog(@"DP0VNJF2dw3uKbskYf7rcmWC"); NSLog(@"EuizD0tFkr5yvgJ8MA4CR9G2KLapVqHX3wh6QN7j"); NSLog(@"LcSBaNAhC19d6GmX3IHPyfoT4t8pgxeYK"); NSLog(@"DodLq5Z2r7lSHMx"); NSLog(@"4UR2i5tjACQSBu6ry3ehN1Hm7lLVaWXpG8cfzEvg"); NSLog(@"lCrxzPJvfO"); NSLog(@"Ee10dLlXKwzaBtcro4Y58QND9fg3x2TA"); NSLog(@"L1biJQZFvynMXmS5d8DchUA9Eu3txPGo0"); NSLog(@"TtqVehaCopAQlSLWm2P9r"); NSLog(@"eOfJijq6DdwIxAa3FQSrgk8"); } -(void)au6q0:(UIViewController*) au6q0 adNKe5:(UICollectionView*) adNKe5 agxDhFE1T:(UISearchBar*) agxDhFE1T aU9spHn:(UIInputView*) aU9spHn abFqXuT:(UIImageView*) abFqXuT aQn47yFKWd:(UIAlertView*) aQn47yFKWd ak5CZ:(UIApplication*) ak5CZ a6DYjTtk0pQ:(UIRegion*) a6DYjTtk0pQ aEeU4abs7:(UIScreen*) aEeU4abs7 aCRlGxXYIaJ:(UIDocument*) aCRlGxXYIaJ { NSLog(@"2udVHiN9thCF1MEnArpfDlUcGeqm6Tk5X8QjvJ"); NSLog(@"NmjH1OpnkcLCZ5aygi0Fx"); NSLog(@"8cH9BbnNUOoEAWP452LS"); NSLog(@"0HGbw8fRigyIlY39QxhtJdNVkOS64zrBAM"); NSLog(@"U9Nv8Lx6bIsYie3Wu5gQohFHywOXrJSVMjK"); NSLog(@"7pAKhyxRVBEHX6oNYv4nmP2Gj0UsDzqfQ"); NSLog(@"K2AJdzjN9smXk7wrQWtPbHp48LvSeEGyRlI0u5MZ"); NSLog(@"VK483jiEs0JkGUCPSOQtIB6xynML"); NSLog(@"8ywFmboELdeS7k3zcOrZTHUfiJ9Xxj10G"); NSLog(@"ceGah7tFifklZmIWzuObUgTxB1CsY2j36o5yAL"); NSLog(@"CMyI5oRQpPWG7wlSfire"); NSLog(@"WH6QoEISkvNXaCh8jPbZKTA"); NSLog(@"TXCFKpomZSWYfrQUjR2y5IEcqH73gBst"); NSLog(@"vhfCLEaYkD9W"); NSLog(@"LpoKIkwNrU5dHVtlh"); NSLog(@"wCth4dVzlbFIG8WK"); NSLog(@"RJnVMHa0c5YCutK8Py64zXBIeodmN1x"); NSLog(@"rshIdBlXg7NpqWRPycfnAZUYu8O6m4Et"); } -(void)azlDZbyT7:(UIBarButtonItem*) azlDZbyT7 amBiCbJvNr:(UIViewController*) amBiCbJvNr a9siTZqcr:(UILabel*) a9siTZqcr aJUyZwA:(UIInputView*) aJUyZwA aoPMd4m:(UIAlertView*) aoPMd4m a1EgjL:(UIKeyCommand*) a1EgjL aiqgX6:(UIScreen*) aiqgX6 afwqZ7t:(UIMenuItem*) afwqZ7t { NSLog(@"4QIS5mviqCwPbrO1zpn9xoa"); NSLog(@"wJQLPnT6kMmhG2Nbgrs"); NSLog(@"dZYIx2T3SNGEWq"); NSLog(@"zekYpHM7NXWs0CcbVjIxAyltmfL3D1"); NSLog(@"CNFsglDIeQZ4wquVL2yXam1O7MAto3WPKhbR"); NSLog(@"2DOX9Y5Ud8GMch"); NSLog(@"HinKmVtN8eh6r2LCQW1FokAPpdqUTOf"); NSLog(@"E9M2YxXmPnbzj"); NSLog(@"hAB4JLMf3uXUzd0S"); NSLog(@"sNI7Byc4pvPO0XuDwbixQmE6TVKa2R3Mg"); } -(void)ar6fKc:(UIViewController*) ar6fKc ap7naW:(UIFont*) ap7naW a7RMsG:(UIMotionEffect*) a7RMsG aiAEY2UHx:(UISwitch*) aiAEY2UHx aV3r4RtcN:(UIControl*) aV3r4RtcN ab1qcI82T:(UIWindow*) ab1qcI82T aPvjYXfeKW:(UIApplication*) aPvjYXfeKW afKDTIe:(UITableView*) afKDTIe ajdtksD:(UIFontWeight*) ajdtksD amzfH:(UICollectionView*) amzfH aHYKPx5S:(UIDevice*) aHYKPx5S { NSLog(@"Atir2UH4MRa8ydBPY5bgKneSoEzLsFxm"); NSLog(@"jU6own4ZRyNEHtLXSGsJkvlf75Q1"); NSLog(@"wRTjVl1ELI4oq85A6pCnrPzGXUB3JNgi"); NSLog(@"OgpXe4UsLfCFAvS"); NSLog(@"iMQ6bdflytAPj2V9FLerJHkG0zOw5W4K7R8n"); NSLog(@"uxRH4sNWDzSqlwvaQG3r9JP2KL8FMC5eOihm"); NSLog(@"Zr9kGxoYa630eESpBDcPWIMlsOj"); NSLog(@"jq2K6Yh07kpFWlVaS5udNtsZ"); NSLog(@"fTJbQuVv4zsal8kiYWmj2Urd07D"); NSLog(@"tVKmQjDM61Yk"); NSLog(@"PF9MKYCic7ENIdzDhBLxQ0UJGfwbAgZS5H86y"); NSLog(@"VyprE6Qb85mDWFl"); NSLog(@"gXikVwZObyFACaKSe5EGWIzHn"); NSLog(@"8jBntOuwU7Cil2TvkZrxy"); NSLog(@"wUr9DAOgP5eXtCb2QYsvc8NW6h0jkHK"); NSLog(@"o1keYOZtVx4yGdiPD9FLENJbhWMcsRK7XH"); NSLog(@"2wgR6YdveWMq4H89BCziAofxXPKNIDraJG0ZLQSb"); NSLog(@"GZol5OhzkmNb2pK4grajSicyITnCLweYR0VP9q"); NSLog(@"Hghil2twdKYJLCB7eraOVEM"); } @end