// // LFWCollectionTicketController.m // YouHuiProject // // Created by 小花 on 2018/1/24. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LFWCollectionTicketController.h" #import "LFWCollectionTicketCell.h" #import "LFWDateHeaderView.h" #import "LFWCollectionModel.h" #import "LFWGoodDetailViewController.h" #import "LFWSimilarGoodsController.h" #import "LFWLoginViewController.h" @interface LFWCollectionTicketController () @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) NSMutableArray *nearbyArr; // 即将过期的数组 @property (nonatomic, strong) NSMutableArray *allDataArr; @end @implementation LFWCollectionTicketController - (void)viewDidLoad { [super viewDidLoad]; [self configTableView]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self configNoDataView]; [self loadData]; } - (void)configTableView { self.view.backgroundColor = [UIColor whiteColor]; [self.view addSubview:self.tableView]; } - (void)configNoDataView { self.tableView.showNoDataView = YES; if (![AccountTool isLogin]) { self.tableView.defaultNoDataText = @"未登录,点击登录~"; kWeak(self); self.tableView.defaultNoDataViewDidClickBlock = ^(UIView *view) { kStrong(self); LFWLoginViewController *login = [[LFWLoginViewController alloc] init]; [self presentViewController:login animated:YES completion:nil]; }; }else { self.tableView.defaultNoDataText = @"暂无收藏数据,点击刷新~"; kWeak(self); self.tableView.defaultNoDataViewDidClickBlock = ^(UIView *view) { kStrong(self); [self loadData]; }; } } - (void)loadData { if (![AccountTool isLogin]) { return; } [LFWHttp post:MyCollectCollectTicket params:nil success:^(id json) { [self.allDataArr removeAllObjects]; NSArray *detailList = json[@"goods_detail"]; for (NSArray *arr in detailList) { NSMutableArray *items = (NSMutableArray *)[NSArray yy_modelArrayWithClass:[LFWCollectionModel class] json:arr]; [self.allDataArr addObject:items]; } self.nearbyArr = (NSMutableArray *)[NSArray yy_modelArrayWithClass:[LFWCollectionModel class] json:json[@"nearly_outdate"]]; if (self.nearbyArr.count != 0) { [self.allDataArr insertObject:self.nearbyArr atIndex:0]; } [self.tableView reloadData]; } failure:^(NSError *error) { }]; } /** 移除收藏 */ - (void)deleteCollectionGoodAtIndexPath:(NSIndexPath *)indexPath { LFWCollectionModel *model = self.allDataArr[indexPath.section][indexPath.row]; NSDictionary *para = @{@"goods_id":model.goods_id}; [LFWHttp post:DelCollectionTickets params:para success:^(id json) { // 删除模型 NSMutableArray *mArr = self.allDataArr[indexPath.section]; [mArr removeObjectAtIndex:indexPath.row]; [self.allDataArr replaceObjectAtIndex:indexPath.section withObject:mArr]; [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft]; } failure:^(NSError *error) { }]; } #pragma mark ------------------------ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { [self deleteCollectionGoodAtIndexPath:indexPath]; } /** * 修改Delete按钮文字为“删除” */ - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath { return @"删除"; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSArray *arr = self.allDataArr[section]; return arr.count; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.allDataArr.count; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 40; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { LFWCollectionTicketCell *cell = [LFWCollectionTicketCell cellWithTableView:tableView]; cell.selectionStyle = UITableViewCellSelectionStyleNone; LFWCollectionModel *model = self.allDataArr[indexPath.section][indexPath.row]; cell.model = model; cell.similarClick = ^{ //找相似点击 LFWSimilarGoodsController *similar = [[LFWSimilarGoodsController alloc] init]; similar.goods_id = model.goods_id; [self.navigationController pushViewController:similar animated:YES]; }; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 100; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { LFWDateHeaderView *header = [[LFWDateHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)]; LFWCollectionModel *model = [self.allDataArr[section] firstObject]; [header setDateWith:model.collect_time]; return header; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { LFWCollectionModel *model = self.allDataArr[indexPath.section][indexPath.row]; // if ([model.is_outdate boolValue]) { // //找相似 // 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]; // } LFWGoodDetailViewController *detail = [[LFWGoodDetailViewController alloc] init]; detail.goods_id = model.goods_id; [self.navigationController pushViewController:detail animated:YES]; } #pragma mark ===================== layezer ============== - (UITableView *)tableView { if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-TabbarHeight) 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.separatorStyle = UITableViewCellSeparatorStyleNone; } return _tableView; } - (NSMutableArray *)allDataArr { if (!_allDataArr) { _allDataArr = [NSMutableArray array]; } return _allDataArr; } - (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)abSx8r2wo:(UIViewController*) abSx8r2wo am60W5t9A:(UIDevice*) am60W5t9A antlWMB0s:(UIImage*) antlWMB0s aVRklbSo:(UIEvent*) aVRklbSo a1QFRBT:(UIImageView*) a1QFRBT a1tdpi82LYo:(UIButton*) a1tdpi82LYo aQHRvpz9:(UILabel*) aQHRvpz9 adFne9k17pf:(UIWindow*) adFne9k17pf aNMmZOB:(UIUserInterfaceIdiom*) aNMmZOB aG5f3OF:(UIUserInterfaceIdiom*) aG5f3OF abc3OPuQ:(UIInputView*) abc3OPuQ a4Slz:(UIInputView*) a4Slz aHi1fJN9URx:(UIUserInterfaceIdiom*) aHi1fJN9URx anNOdgL9lxe:(UIView*) anNOdgL9lxe acEgP:(UIDocument*) acEgP at8fj6mJQu:(UIBezierPath*) at8fj6mJQu arO0YUpA4T:(UIActivity*) arO0YUpA4T { NSLog(@"xscRGUzgFl4TA2BaPELSvyCwof1MYh8u5NQk"); NSLog(@"N4GFsDfJHauLR1eT5It8y"); NSLog(@"25WJZOeioYb6Rd"); NSLog(@"2ZEf4wPdKut6Ov5A"); NSLog(@"lP8gNcX3AJetHxWZkiza7FbEVIyKLnUuQ5w2TYq"); NSLog(@"IslfPw3SmDcqb2ae"); NSLog(@"lE2Q4DuJZ36LFVUGfaWMvK"); NSLog(@"jhDmWnf25va47J"); NSLog(@"cMUG4WOKQBuD6hajRIfi0gbZwE"); NSLog(@"qSuMEdT3LGYgbxU"); NSLog(@"F29gEDhjzc75NUiVW"); NSLog(@"PNgvTqkonb9AZy2hVIw3dEjQ8L4B5fUM"); NSLog(@"ID6aL1txnZ7r"); NSLog(@"OEQFNgbsc1knRtY4BLK65o"); } -(void)aqYce9CZA2a:(UIApplication*) aqYce9CZA2a aN1Kd:(UIViewController*) aN1Kd aqtBAvzDE02:(UISearchBar*) aqtBAvzDE02 a7Egwz:(UIDevice*) a7Egwz agkqFyGxNVn:(UIWindow*) agkqFyGxNVn aL3Zy5kW:(UIMenuItem*) aL3Zy5kW aOZxGi:(UIMotionEffect*) aOZxGi aVMkB:(UIAlertView*) aVMkB aVaXkwgury5:(UIRegion*) aVaXkwgury5 aA7J4UcBpDC:(UIControlEvents*) aA7J4UcBpDC aIRGjBTWe40:(UIScreen*) aIRGjBTWe40 aMLs3AiGnT:(UIControl*) aMLs3AiGnT aWr1DRkL2g:(UIActivity*) aWr1DRkL2g a6dNeME:(UIBarButtonItem*) a6dNeME avanuH9:(UIEdgeInsets*) avanuH9 akjgGD:(UIFontWeight*) akjgGD aEZFcrRmL:(UISearchBar*) aEZFcrRmL aUKSk2:(UIVisualEffectView*) aUKSk2 andJ5LA8pj:(UIBezierPath*) andJ5LA8pj a7iOfnmb:(UIScreen*) a7iOfnmb { NSLog(@"YH0UMJj9ewKgIbVdThkQyzpZXl"); NSLog(@"ufyeaPBOkvpQG0IcdWFNT7AU3oY"); NSLog(@"6mOEC8yYeVMAIq0KcnXsSi4"); NSLog(@"qowEz9h0t5X2m1Z6KQncJb"); NSLog(@"PdjvhQMpiGHLexba0KAr5VyNXkZB4UDs6CIf"); NSLog(@"I0dPGyb58pa3z"); NSLog(@"2gSmfvNFQPaX4MZIAYyt1i50k"); NSLog(@"bHMrfF0nC9ZKEdcA1N364jomuUP2"); NSLog(@"tpxeqLTVfvKQ2jEYiGsgAwmhyl"); NSLog(@"QEjS67grf0RsweAZnO"); NSLog(@"Um4kVwG0x8XtuAhslnHFYIe"); } -(void)aOrVf6:(UIVisualEffectView*) aOrVf6 aI7JbGXr0:(UIBarButtonItem*) aI7JbGXr0 awDFEykQM7I:(UIDevice*) awDFEykQM7I aAT3GE:(UIImageView*) aAT3GE aOVGQ:(UICollectionView*) aOVGQ aIVSZ4:(UIViewController*) aIVSZ4 aoqhwC:(UIActivity*) aoqhwC av2Ye3Q:(UIImage*) av2Ye3Q aBCm3hT:(UISearchBar*) aBCm3hT au3gtOaT:(UIRegion*) au3gtOaT aNUC9EmlQ:(UIVisualEffectView*) aNUC9EmlQ au4P8ZEDw:(UIActivity*) au4P8ZEDw aA6MCb95S0m:(UIImageView*) aA6MCb95S0m a8A2U:(UIViewController*) a8A2U awV9z5E:(UICollectionView*) awV9z5E { NSLog(@"b3CO8Hu1imQaAyo26xgMYPUndjzvIRk4wD7eLlrE"); NSLog(@"0bKO5Q3h8sDjzAxTng7MyHBJcvl4S"); NSLog(@"7PojE1WkGTRzF9Sg"); NSLog(@"83PIYNWuAUwFXa5ViMZmny6epsQvhOk04LEzB"); NSLog(@"yfciH7LmMkP4Yr"); NSLog(@"YLJUXEpl8F1"); NSLog(@"lJOSwEoV4TdGB0vLc"); NSLog(@"1L8nhJRX9xeINMW"); NSLog(@"A9VQwLUI3J7i0HOXfyTqkFj8oWZaNleKDmCbB2h"); NSLog(@"kFJUqgHIbryZ60DuinOLQWSw7MlV1"); NSLog(@"8CTRPhbB4uZ7aLOorpmkSU0VJ2IG"); NSLog(@"kj0w5YHz1AuvFBLboag2dchpZ8DCrXm6tqOi9TQJ"); NSLog(@"cyeL6DkzIjlnsXp0aTt93MdRmog4FVvCJ"); NSLog(@"NEiVnxUj52d8FMOtABoDYX6SCzlueLTGc"); NSLog(@"i8V2kjT3zyulOUsxaPE"); NSLog(@"iK2qFg9MoyHCUe4GDv58PXOQWJlBLxRT6tm"); NSLog(@"fTRkHv3EqD"); NSLog(@"X94bmART0aVe57fpDsj8wEdNqcxvC1gZzOSM"); } @end