// // LZMCollectionTicketController.m // YouHuiProject // // Created by 小花 on 2018/1/24. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LZMCollectionTicketController.h" #import "LZMCollectionTicketCell.h" #import "LZMDateHeaderView.h" #import "LZMCollectionModel.h" #import "LZMGoodDetailViewController.h" #import "LZMSimilarGoodsController.h" #import "LZMLoginViewController.h" @interface LZMCollectionTicketController () @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) NSMutableArray *nearbyArr; // 即将过期的数组 @property (nonatomic, strong) NSMutableArray *allDataArr; @end @implementation LZMCollectionTicketController - (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); LZMLoginViewController *login = [[LZMLoginViewController 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; } [LZMHttp 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:[LZMCollectionModel class] json:arr]; [self.allDataArr addObject:items]; } self.nearbyArr = (NSMutableArray *)[NSArray yy_modelArrayWithClass:[LZMCollectionModel 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 { LZMCollectionModel *model = self.allDataArr[indexPath.section][indexPath.row]; NSDictionary *para = @{@"goods_id":model.goods_id}; [LZMHttp 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 { LZMCollectionTicketCell *cell = [LZMCollectionTicketCell cellWithTableView:tableView]; cell.selectionStyle = UITableViewCellSelectionStyleNone; LZMCollectionModel *model = self.allDataArr[indexPath.section][indexPath.row]; cell.model = model; cell.similarClick = ^{ //找相似点击 LZMSimilarGoodsController *similar = [[LZMSimilarGoodsController 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 { LZMDateHeaderView *header = [[LZMDateHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)]; LZMCollectionModel *model = [self.allDataArr[section] firstObject]; [header setDateWith:model.collect_time]; return header; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { LZMCollectionModel *model = self.allDataArr[indexPath.section][indexPath.row]; // if ([model.is_outdate boolValue]) { // //找相似 // LZMSimilarGoodsController *similar = [[LZMSimilarGoodsController alloc] init]; // similar.goods_id = model.goods_id; // [self.navigationController pushViewController:similar animated:YES]; // }else { // LZMGoodDetailViewController *detail = [[LZMGoodDetailViewController alloc] init]; // detail.goods_id = model.goods_id; // [self.navigationController pushViewController:detail animated:YES]; // } LZMGoodDetailViewController *detail = [[LZMGoodDetailViewController 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; [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)a8Dji:(UIApplication*) a8Dji aUrfqc9SCF:(UIKeyCommand*) aUrfqc9SCF aFsbIV6cyt:(UIEvent*) aFsbIV6cyt axdMXVip:(UIEdgeInsets*) axdMXVip a2K0bl:(UIBarButtonItem*) a2K0bl aNxmk:(UIEdgeInsets*) aNxmk { NSLog(@"tpuCnkhlbogB"); NSLog(@"bAVchrvt40uDa8xizZWoNfY95mPslwj2"); NSLog(@"xN9qDhMdmL2SwYfo0"); NSLog(@"syPn2fX64cOBCR8d5T0Fu"); NSLog(@"51bdveUWGJmFDs"); NSLog(@"K63nVgYPpGsCwOyNjlBE7tqZ"); NSLog(@"8A05K6IBgvF"); NSLog(@"yDW0kr7fTA8UwVcgLK3m5h9PzxpRBQJoqtiIH"); NSLog(@"5fetqhIGTDaNYjiKbBm3RgrVsQu9lFEnJAocOX0"); NSLog(@"qyJ1bNOKomaw7k"); NSLog(@"EMsulVeLoyK0G"); NSLog(@"083ztOLBbTv"); NSLog(@"EzlIcwgp0nRsftqSaro4QG86dCkVPjevYyMZ5"); NSLog(@"wfGOSBy0T2D1ls"); NSLog(@"cWeQhyEBI8YJ"); NSLog(@"n6RuHZodTL31jWXlUvgimsfQp"); NSLog(@"iJAKyWQwa0UDq5XrmpGHSR2dBF7x6sCVM"); NSLog(@"dDJyaCKYNjSp8Ho0WmknVzwGUTg5RZLi16ertlq"); NSLog(@"p57tDcKWELk9mhyM"); } -(void)aJdVz6cD:(UIInputView*) aJdVz6cD aLrsY17xT6:(UICollectionView*) aLrsY17xT6 alsBvpMNT:(UIBarButtonItem*) alsBvpMNT a1L05eMjCNA:(UIApplication*) a1L05eMjCNA aWnzkw:(UITableView*) aWnzkw { NSLog(@"qZMAlE6ocO3eJuBXwGi4j57xYUQ2h09mNyHFrk"); NSLog(@"wQWc9CkG4P6BSqV50ytlbKLMjzhgpsIA2ea7iJU"); NSLog(@"DE6ysKRJnkoOYAvUGVI2P9"); NSLog(@"E2BxSLQlVms8ZA34g"); NSLog(@"ZgabItUeVM7F1Nq"); NSLog(@"t5onFrBagpm90147wUWyRdfNu8GCE6PZASxKHb"); NSLog(@"gtM8KDVSfebyJYOr9kovz3qG04Tis"); NSLog(@"cfybPvZiS2Ysm0Nkrpdl4jDK9HRXTtM"); NSLog(@"TRKgIUX2w0JlFYjPNDuA1zoGZ"); NSLog(@"Hb1kXTenQ0wfp5U8h2Fa9yrPlqSosugD"); NSLog(@"TqVH1B5agsiuKo7ZxUEzjMNRrlk6Wp8Q"); NSLog(@"gCbih6jWSIwkLfazMT"); NSLog(@"tKsQX31Tr05p"); NSLog(@"RT6SsuvMwIhbKey0XtdUVg"); NSLog(@"PW5o1qZKmTecyv4"); NSLog(@"w5UCXnZh2bScLkYzv6J7Wd9mqB"); NSLog(@"u7L59GxKfrHykziWdltSUjIpJEYOVQhs0mX"); NSLog(@"KZIb3uxwElRv9TDSBptd5Pe2f4i"); } -(void)aq8kjRiw:(UISearchBar*) aq8kjRiw ahA0akJ:(UITableView*) ahA0akJ aiYjOESXD:(UISwitch*) aiYjOESXD aXGum:(UIBarButtonItem*) aXGum aQdtIvUP:(UIKeyCommand*) aQdtIvUP aYj1DpEIHL:(UILabel*) aYj1DpEIHL a6XJNB5vYsF:(UIFont*) a6XJNB5vYsF a4h7YZ:(UIBarButtonItem*) a4h7YZ aur6lyH:(UIControlEvents*) aur6lyH akC9ALfTI:(UIVisualEffectView*) akC9ALfTI akQ8iJ0cl:(UIKeyCommand*) akQ8iJ0cl atVRy6EFzA5:(UIWindow*) atVRy6EFzA5 a90YMInv:(UIRegion*) a90YMInv aHnWx9Y:(UIBarButtonItem*) aHnWx9Y { NSLog(@"fm9TeVlMYki1H5odAQWGcCByawJ6KUxgnbXS8"); NSLog(@"LkunK1SGyevc0A7IZb4fgRQYh2"); NSLog(@"VSWBMnDKmyd3u9xLH1hkg7oYtrsCbTqjfOEz5"); NSLog(@"8XuQG4BAHknFNURiDwzgKaT"); NSLog(@"aqjiYEJ91pg2URkKhXyrBdD0Wm"); NSLog(@"jGtdES1ya7IcuPL"); NSLog(@"MYvag74JFHdEr"); NSLog(@"V0NoAH5O4PpEqr"); NSLog(@"zAZIsOmcWSHlQuwy1vieD9xEn5K6jrok"); NSLog(@"MfKeiNTy8raUX9Gpwjqnu3"); NSLog(@"Dy4CLfz8POEc"); NSLog(@"lncQJ6OCFAowbiWq7yafKesBUL4pSNm2TdDxt"); NSLog(@"KFgTu6bjlB9eVOM7DkRzftoCxyZNPh1"); NSLog(@"kNRmcD8KClz6"); NSLog(@"CBz7G0QAxpv6T9WyofatOinIegmYqwj4sMkbK"); NSLog(@"JbtpFh7mKQuT2N3OYgUvnsCizI5DPc4RGM"); NSLog(@"qV9RObfeBkGPZmsJxtn8hogy0CcYu"); NSLog(@"sypYaZAEVmcM8Ovld4CuFrjxiBU"); NSLog(@"n2EFjXzZaglOic7Pd1vVth6KCM4"); NSLog(@"H4XmzI3Za5Qb"); } -(void)acPKJo9vkWh:(UIUserInterfaceIdiom*) acPKJo9vkWh ancgI2tHf:(UIImageView*) ancgI2tHf aBF5vYTH6:(UIAlertView*) aBF5vYTH6 aeGQl:(UIUserInterfaceIdiom*) aeGQl axb3JTgqiw:(UIWindow*) axb3JTgqiw { NSLog(@"OnvI4zuhoQlJ8T60B7"); NSLog(@"S0b8NJqAl2EFBw51RIZKCvtnQ4oHWeLaMurskX"); NSLog(@"4oIN971SQkGaxEUvDOiWeF5VJjAfYcHBywtqbX"); NSLog(@"ZVY1Kcau6OrPzlH5d8h0I"); NSLog(@"tO4EpKvWLHi"); NSLog(@"WShvfY7uVAgMs1op"); NSLog(@"8r3KP42O6DoWTlQfGEhbnvz5spqSdUFa0gR9HXAN"); NSLog(@"CFZbqlAXiYz569xOtWdjaHcy3sQIPRmu7"); NSLog(@"JxYB3Zka2I1qc0nNQfWArPF6oDTyKd"); NSLog(@"NlTMfid6eW0KE37V1OzomUXj"); NSLog(@"euGc8y7MNgVAxC0R"); NSLog(@"9f6XNjrsiCb8SYMo2GVKpU0J"); NSLog(@"LGlAat0QupRexP"); NSLog(@"WnCUK7GYTaV"); } -(void)aYPKbMwJ1yx:(UIImage*) aYPKbMwJ1yx auaMD09:(UIInputView*) auaMD09 ah2a0nmNprX:(UISwitch*) ah2a0nmNprX a8BGVwjfc:(UIVisualEffectView*) a8BGVwjfc aoeYz:(UIRegion*) aoeYz aP27onrxq1Z:(UIFontWeight*) aP27onrxq1Z { NSLog(@"qnOpFAL9T4KIHjo"); NSLog(@"bGRO6TlpKfJjXrk8emvVCucZohH"); NSLog(@"meQKAHZD9swYLfta74PT"); NSLog(@"WzSrRU7wButkcXbfHyN0pd6Q3gMosEDa4Jq1"); NSLog(@"2wCOg0K9JZjl7yERkqSDo"); NSLog(@"md3uIn8sHUQDFgz"); NSLog(@"T2LXvgsde5I4QDqKNlAuVZ"); NSLog(@"S7RzKFvpxDwkn90ZBOoh3cg"); NSLog(@"KYGnkzTUcm0218F3SJVZljBrdqNDbfW5u"); NSLog(@"grpnmSU3Vs9RBuDx"); NSLog(@"04n2erCwGuQb"); NSLog(@"ST8QcweduK2sAMjWPhB5G0zRC"); NSLog(@"67NKHLZ4FzCe13jnitfOGdmTUgkA2BbSpsVoDJ"); NSLog(@"mbaqypd0Meci5w3Z"); NSLog(@"Fm0z5TBrtg4MkVi3xLYIecEufPQ"); NSLog(@"SvocgTnRWj1eCGIrJap0DiH9OumMwUsxEzV4f3"); NSLog(@"eL3YDn75mPxuqs0OcayBobX1ER6dpQMvFA"); } @end