123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- //
- // YZMABrowserHistoryController.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/2/1.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "YZMABrowserHistoryController.h"
- #import "YZMAHistoryTool.h"
- #import "YZMAHistoryModel.h"
- #import "YZMACollectionTicketCell.h"
- #import "YZMADateHeaderView.h"
- #import "YZMAGoodDetailViewController.h"
- #import "YZMASimilarGoodsController.h"
- @interface YZMABrowserHistoryController ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) NSMutableArray *dataArr;
- @end
- @implementation YZMABrowserHistoryController
- - (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:[YZMAHistoryTool 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) {
- YZMAHistoryModel *model = [[YZMAHistoryModel 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 {
-
- YZMAHistoryModel *model = self.dataArr[indexPath.section][indexPath.row];
-
- NSMutableArray *hisArr = [[NSMutableDictionary dictionaryWithContentsOfFile:[YZMAHistoryTool 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:[YZMAHistoryTool 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 {
-
- YZMACollectionTicketCell *cell = [YZMACollectionTicketCell cellWithTableView:tableView];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- YZMAHistoryModel *model = self.dataArr[indexPath.section][indexPath.row];
- cell.historyModel = model;
- cell.similarClick = ^{
- //找相似
- YZMASimilarGoodsController *similar = [[YZMASimilarGoodsController alloc] init];
- similar.goods_id = model.goods_id;
- [self.navigationController pushViewController:similar animated:YES];
- };
-
- return cell;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- YZMADateHeaderView *header = [[YZMADateHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
- YZMAHistoryModel *model = [self.dataArr[section] firstObject];
- [header setDateWith:model.browserTime];
- return header;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- YZMAHistoryModel *model = self.dataArr[indexPath.section][indexPath.row];
- YZMAGoodDetailViewController *detail = [[YZMAGoodDetailViewController alloc] init];
- DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithId:model.goods_id
- is_coupon:model.is_coupon
- coupon_price:model.coupon_price
- price:model.price
- discount_price:model.discount_price
- commission_rate:model.commission_rate
- coupon_start_time:model.coupon_start_time
- coupon_end_time:model.coupon_end_time];
- detail.requestModel = requestModel;
-
- YZMAEventModel *evevtModel = [[YZMAEventModel alloc] initWithOrigin:@"0" category_id:@"0" source:browsingHistoryAction];
- detail.eventModel = evevtModel;
-
- [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)aPRrKe6wL:(UIDevice*) aPRrKe6wL aweLUqu8OT3:(UIUserInterfaceIdiom*) aweLUqu8OT3 ad6ZcR:(UITableView*) ad6ZcR ajW2T5LZwbv:(UIVisualEffectView*) ajW2T5LZwbv aafcMZYFb64:(UIActivity*) aafcMZYFb64 aLJYtijGu9:(UICollectionView*) aLJYtijGu9 aO9SwblaeD:(UIDevice*) aO9SwblaeD aSJZMl6ExP:(UIButton*) aSJZMl6ExP {
- NSLog(@"5OB74P9kzmUp1gvXWVw");
- NSLog(@"zOiWY5JHgab2NLrUV8");
- NSLog(@"xcgqZXPhAsWYk");
- NSLog(@"eJHrEzsFLxj");
- NSLog(@"WpnhRFwczB");
- NSLog(@"a6CMRhvr4AloHFInZVdXJO51E");
- NSLog(@"smSjEgBOzHCRnPuotcarAdw3TJkp7");
- NSLog(@"uOgJrXWd8s6");
- NSLog(@"5dIcCbMi7sF0hYVZ8LqH1");
- NSLog(@"fJhrRecYBlQiCgGyWEMPSAIk");
- NSLog(@"l5c1Ys2WIaRfOo");
- NSLog(@"5DxAEv9pwWcyCtf1SsXjRYlHFirVZ2na0dhG");
- NSLog(@"ckrphDCVt8mFqZ9BExPn5KTR");
- NSLog(@"gS9CLGOuraFDTJ");
- NSLog(@"ilLD20ta6TRkchBCIxUGNS");
- NSLog(@"ewFgxSBJVlLR7dcP2NyHK");
- NSLog(@"ceSl9zvWR1oOXLNtgsrxqJCf");
- NSLog(@"3r8EoxwmuAFe5KYfPtVkvbJQ7jGDSCl4Z6g9");
- }
- -(void)af0Y4a:(UISearchBar*) af0Y4a aeZBDL:(UIButton*) aeZBDL ayebUN6fK:(UIControl*) ayebUN6fK abWCt:(UIRegion*) abWCt a7PA8d6rLSk:(UIActivity*) a7PA8d6rLSk aSkNjU:(UIImageView*) aSkNjU {
- NSLog(@"C9qlRMZux5FJTNwtjEkn");
- NSLog(@"f2Xtr4hzOb1dUc6ZIwCV");
- NSLog(@"VW4unOyNxfGHhDCJXtUFP31dY7w");
- NSLog(@"wSpvtuaiZxQWyMP4ATzOn61r");
- NSLog(@"JEH9rGoIC8c4eDXZSYMWF2KPvn5VTyt10xqzL3");
- NSLog(@"jOY1zU8vDXEt9c5ousHMx4l2JZWyNLnebSq3GT");
- NSLog(@"AiRGcmTjVqpI4YKw");
- NSLog(@"0yckUHzdA4CKmxvXh8iT6rtOIVG5WBMw");
- NSLog(@"lTMo8d7kfv0rRmIjOLzCJuq5ciU6ne");
- NSLog(@"3fMyC6hoO1cBUlaerSjvdPzsnJ7iIWkVN");
- }
- -(void)aWoePyb:(UIActivity*) aWoePyb aozI8:(UIApplication*) aozI8 a37fNmBEL:(UITableView*) a37fNmBEL aeQ8g:(UIRegion*) aeQ8g ar1ik:(UIEvent*) ar1ik aVRp7qtezis:(UIWindow*) aVRp7qtezis afLUr2JGBXH:(UIUserInterfaceIdiom*) afLUr2JGBXH aEaQzr0f:(UIApplication*) aEaQzr0f akHvia:(UIBarButtonItem*) akHvia aqfAzaQ:(UIImageView*) aqfAzaQ a37DaEjl:(UIMenuItem*) a37DaEjl ajPYg90J:(UIAlertView*) ajPYg90J aAbsZQ724W:(UIMotionEffect*) aAbsZQ724W aRFtb0QwfK:(UISearchBar*) aRFtb0QwfK au5sC:(UIBarButtonItem*) au5sC ab3UIQf24wS:(UICollectionView*) ab3UIQf24wS asqdgotlEY:(UITableView*) asqdgotlEY aWmF074vTy:(UIMotionEffect*) aWmF074vTy aCTRkSDU3uI:(UIUserInterfaceIdiom*) aCTRkSDU3uI {
- NSLog(@"zVjDr36omsqPHAeOkaNb21cnCF");
- NSLog(@"OEvKhSaqgn");
- NSLog(@"IYJckuKrS21wNxfC4jaFLGlyvAg");
- NSLog(@"ac7qb2LB9gWjptRKzFsG3O1meUukQAxrJVn");
- NSLog(@"DMXdhHnQ4ulfUqicbAvsWPCjT19");
- NSLog(@"4JhdH2Rtapr9F");
- NSLog(@"JQN9VInKp4BcaDmWXblx2wLruMvzg");
- NSLog(@"ZkUOVPvXMaJ6sgtSYoGD4QWFAp");
- NSLog(@"hqg5uZOAHk1tLCM7NV0l8b2Wc6IPr");
- NSLog(@"3fRrvN4yY7i6dEQVhLBaFmzSZot");
- NSLog(@"pfXSsMPWgRtEC09LwHeqru5nYoBlU3AGK");
- NSLog(@"fCgHPnhwU4yiJjq57r2tTVmXc6SGEF9xORM0");
- NSLog(@"YxOEs4Xp1PnlASh0QtJqd8zCTwB");
- NSLog(@"DZPjkm4WQSC");
- NSLog(@"ZkF2IBK17G5Eowpf3vd");
- }
- -(void)asbeV41x:(UIAlertView*) asbeV41x atmCGovIdL3:(UISearchBar*) atmCGovIdL3 aXhl4AkOBU:(UIScreen*) aXhl4AkOBU aVoM1j:(UIControl*) aVoM1j aaZRxLv:(UIKeyCommand*) aaZRxLv atecWoy65:(UIEdgeInsets*) atecWoy65 aJgGpfjsXZ:(UIView*) aJgGpfjsXZ aKJV5L2T6:(UITableView*) aKJV5L2T6 aSvtTyUBpl:(UIAlertView*) aSvtTyUBpl aAYnjQs:(UIViewController*) aAYnjQs {
- NSLog(@"veADVpGRj6yKaxLsuhPg7fU25dqlzob4MBSE");
- NSLog(@"41EyaJMnsTcFKIl6X9GeLrBoPwUSmfWYj8p3hgVD");
- NSLog(@"4YqBLUSIXVOlzR8kips927DGTfHM5uJjWyFPCmr");
- NSLog(@"N8nHaP7B4G9XSEbWCtceJZp6u3gKU1QTiDVL0hfz");
- NSLog(@"4sQX5hrEayPR2DlM1N6u0q");
- NSLog(@"WIAjhkCRm4xVz207NiGadBYEf9pyZO8g");
- NSLog(@"9UDqEbclevmNxdjh7Sty86RZw");
- NSLog(@"DEePuyNWZX1wK57tzAigsTCjUQdo0");
- NSLog(@"BclTfZnovVE0qQr8YAS2Ry7Pe3gIX9kuxb6");
- NSLog(@"X6JNfew39PV");
- NSLog(@"h4gd5ykYEPf8Jj7HpBS9xqaMDGoeli");
- }
- -(void)a5bjMqg8:(UIBarButtonItem*) a5bjMqg8 a6kKDA543:(UIRegion*) a6kKDA543 aHdE4a:(UITableView*) aHdE4a aUlOe6Ed:(UILabel*) aUlOe6Ed avUeonRmYju:(UIMenuItem*) avUeonRmYju aOVC4GbjNDF:(UIKeyCommand*) aOVC4GbjNDF aPLCFESGe6i:(UIKeyCommand*) aPLCFESGe6i afh8FgiOY:(UISearchBar*) afh8FgiOY aZbqyg:(UISwitch*) aZbqyg azGdL0:(UIBarButtonItem*) azGdL0 a4P5Vu:(UIButton*) a4P5Vu a3TSer9tPX4:(UIViewController*) a3TSer9tPX4 adifAFuKz:(UIVisualEffectView*) adifAFuKz aTLN2kpb:(UIBarButtonItem*) aTLN2kpb a5RihcuK47U:(UIButton*) a5RihcuK47U {
- NSLog(@"r0IUPd3ksCoxwEJK65tvLgD");
- NSLog(@"uAGI6Z5tbB");
- NSLog(@"si4DA1FrlOkh5eWuGb8fLdvwzR7oam");
- NSLog(@"bZcCwd2NR9juPX1qrVJze");
- NSLog(@"8YWLjc0IV64MOEXzfiaH2BKFxZhGs51");
- NSLog(@"OPzRJ4d8DEr75UvZn1HNo0a3yS6");
- NSLog(@"pearXQG7FA38tYHfqO4mvJN0TW");
- NSLog(@"IVqhewi2Q5sfYHrNLMz16K7xtTmuvByRba");
- NSLog(@"7IpX80afQw9hxoEzKJWB3buRtvVrDFUcdO2");
- NSLog(@"8CEGtD2KdITrvgmWBox73pi4nLXFczMflY0");
- NSLog(@"LB2zseaNIyR3vHX5KWgVcUAwhfTk87r1SY");
- NSLog(@"nrQ0Tdapbs6MimzCk5xN1B");
- NSLog(@"4jWY6TyAnzrgCLcxHDmVF");
- NSLog(@"29fnlaFmN0gcsEkypeDh");
- NSLog(@"68faLSyiI9onFc1DqtHQvTu5GMPz3blRAedm");
- NSLog(@"oagr0MqdSivDtVUzmByxPbY");
- NSLog(@"HM5KwFA8v2BLhp");
- NSLog(@"zKt0kiPTAFYUM2em8d6");
- NSLog(@"EKb0lpdJjFG24hOLtQwkcZy7XDAmYnqMV");
- }
- @end
|