Aucune description

LFWCollectionTicketController.m 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. //
  2. // LFWCollectionTicketController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/1/24.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LFWCollectionTicketController.h"
  9. #import "LFWCollectionTicketCell.h"
  10. #import "LFWDateHeaderView.h"
  11. #import "LFWCollectionModel.h"
  12. #import "LFWGoodDetailViewController.h"
  13. #import "LFWSimilarGoodsController.h"
  14. #import "LFWLoginViewController.h"
  15. @interface LFWCollectionTicketController ()<UITableViewDelegate,UITableViewDataSource>
  16. @property (nonatomic, strong) UITableView *tableView;
  17. @property (nonatomic, strong) NSMutableArray *nearbyArr; // 即将过期的数组
  18. @property (nonatomic, strong) NSMutableArray *allDataArr;
  19. @end
  20. @implementation LFWCollectionTicketController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. [self configTableView];
  24. }
  25. - (void)viewWillAppear:(BOOL)animated {
  26. [super viewWillAppear:animated];
  27. [self configNoDataView];
  28. [self loadData];
  29. }
  30. - (void)configTableView {
  31. self.view.backgroundColor = [UIColor whiteColor];
  32. [self.view addSubview:self.tableView];
  33. }
  34. - (void)configNoDataView {
  35. self.tableView.showNoDataView = YES;
  36. if (![AccountTool isLogin]) {
  37. self.tableView.defaultNoDataText = @"未登录,点击登录~";
  38. kWeak(self);
  39. self.tableView.defaultNoDataViewDidClickBlock = ^(UIView *view) {
  40. kStrong(self);
  41. LFWLoginViewController *login = [[LFWLoginViewController alloc] init];
  42. [self presentViewController:login animated:YES completion:nil];
  43. };
  44. }else {
  45. self.tableView.defaultNoDataText = @"暂无收藏数据,点击刷新~";
  46. kWeak(self);
  47. self.tableView.defaultNoDataViewDidClickBlock = ^(UIView *view) {
  48. kStrong(self);
  49. [self loadData];
  50. };
  51. }
  52. }
  53. - (void)loadData {
  54. if (![AccountTool isLogin]) {
  55. return;
  56. }
  57. [LFWHttp post:MyCollectCollectTicket params:nil success:^(id json) {
  58. [self.allDataArr removeAllObjects];
  59. NSArray *detailList = json[@"goods_detail"];
  60. for (NSArray *arr in detailList) {
  61. NSMutableArray *items = (NSMutableArray *)[NSArray yy_modelArrayWithClass:[LFWCollectionModel class] json:arr];
  62. [self.allDataArr addObject:items];
  63. }
  64. self.nearbyArr = (NSMutableArray *)[NSArray yy_modelArrayWithClass:[LFWCollectionModel class] json:json[@"nearly_outdate"]];
  65. if (self.nearbyArr.count != 0) {
  66. [self.allDataArr insertObject:self.nearbyArr atIndex:0];
  67. }
  68. [self.tableView reloadData];
  69. } failure:^(NSError *error) {
  70. }];
  71. }
  72. /**
  73. 移除收藏
  74. */
  75. - (void)deleteCollectionGoodAtIndexPath:(NSIndexPath *)indexPath {
  76. LFWCollectionModel *model = self.allDataArr[indexPath.section][indexPath.row];
  77. NSDictionary *para = @{@"goods_id":model.goods_id};
  78. [LFWHttp post:DelCollectionTickets params:para success:^(id json) {
  79. // 删除模型
  80. NSMutableArray *mArr = self.allDataArr[indexPath.section];
  81. [mArr removeObjectAtIndex:indexPath.row];
  82. [self.allDataArr replaceObjectAtIndex:indexPath.section withObject:mArr];
  83. [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
  84. } failure:^(NSError *error) {
  85. }];
  86. }
  87. #pragma mark ------------------------
  88. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  89. {
  90. [self deleteCollectionGoodAtIndexPath:indexPath];
  91. }
  92. /**
  93. * 修改Delete按钮文字为“删除”
  94. */
  95. - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
  96. {
  97. return @"删除";
  98. }
  99. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  100. NSArray *arr = self.allDataArr[section];
  101. return arr.count;
  102. }
  103. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  104. return self.allDataArr.count;
  105. }
  106. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  107. return 40;
  108. }
  109. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  110. LFWCollectionTicketCell *cell = [LFWCollectionTicketCell cellWithTableView:tableView];
  111. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  112. LFWCollectionModel *model = self.allDataArr[indexPath.section][indexPath.row];
  113. cell.model = model;
  114. cell.similarClick = ^{
  115. //找相似点击
  116. LFWSimilarGoodsController *similar = [[LFWSimilarGoodsController alloc] init];
  117. similar.goods_id = model.goods_id;
  118. [self.navigationController pushViewController:similar animated:YES];
  119. };
  120. return cell;
  121. }
  122. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  123. return 100;
  124. }
  125. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  126. LFWDateHeaderView *header = [[LFWDateHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
  127. LFWCollectionModel *model = [self.allDataArr[section] firstObject];
  128. [header setDateWith:model.collect_time];
  129. return header;
  130. }
  131. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  132. LFWCollectionModel *model = self.allDataArr[indexPath.section][indexPath.row];
  133. // if ([model.is_outdate boolValue]) {
  134. // //找相似
  135. // LFWSimilarGoodsController *similar = [[LFWSimilarGoodsController alloc] init];
  136. // similar.goods_id = model.goods_id;
  137. // [self.navigationController pushViewController:similar animated:YES];
  138. // }else {
  139. // LFWGoodDetailViewController *detail = [[LFWGoodDetailViewController alloc] init];
  140. // detail.goods_id = model.goods_id;
  141. // [self.navigationController pushViewController:detail animated:YES];
  142. // }
  143. LFWGoodDetailViewController *detail = [[LFWGoodDetailViewController alloc] init];
  144. detail.goods_id = model.goods_id;
  145. [self.navigationController pushViewController:detail animated:YES];
  146. }
  147. #pragma mark ===================== layezer ==============
  148. - (UITableView *)tableView {
  149. if (!_tableView) {
  150. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-TabbarHeight) style:UITableViewStylePlain];
  151. _tableView.estimatedSectionHeaderHeight = 0;
  152. _tableView.estimatedSectionFooterHeight = 0;
  153. _tableView.sectionFooterHeight = 0;
  154. _tableView.sectionHeaderHeight = 0;
  155. _tableView.delegate = self;
  156. _tableView.dataSource = self;
  157. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  158. _tableView.backgroundColor = [UIColor yhGrayColor];
  159. _tableView.bounces = YES;
  160. _tableView.showsVerticalScrollIndicator = NO;
  161. // _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  162. }
  163. return _tableView;
  164. }
  165. - (NSMutableArray *)allDataArr {
  166. if (!_allDataArr) {
  167. _allDataArr = [NSMutableArray array];
  168. }
  169. return _allDataArr;
  170. }
  171. - (void)didReceiveMemoryWarning {
  172. [super didReceiveMemoryWarning];
  173. // Dispose of any resources that can be recreated.
  174. }
  175. /*
  176. #pragma mark - Navigation
  177. // In a storyboard-based application, you will often want to do a little preparation before navigation
  178. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  179. // Get the new view controller using [segue destinationViewController].
  180. // Pass the selected object to the new view controller.
  181. }
  182. */
  183. -(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 {
  184. NSLog(@"xscRGUzgFl4TA2BaPELSvyCwof1MYh8u5NQk");
  185. NSLog(@"N4GFsDfJHauLR1eT5It8y");
  186. NSLog(@"25WJZOeioYb6Rd");
  187. NSLog(@"2ZEf4wPdKut6Ov5A");
  188. NSLog(@"lP8gNcX3AJetHxWZkiza7FbEVIyKLnUuQ5w2TYq");
  189. NSLog(@"IslfPw3SmDcqb2ae");
  190. NSLog(@"lE2Q4DuJZ36LFVUGfaWMvK");
  191. NSLog(@"jhDmWnf25va47J");
  192. NSLog(@"cMUG4WOKQBuD6hajRIfi0gbZwE");
  193. NSLog(@"qSuMEdT3LGYgbxU");
  194. NSLog(@"F29gEDhjzc75NUiVW");
  195. NSLog(@"PNgvTqkonb9AZy2hVIw3dEjQ8L4B5fUM");
  196. NSLog(@"ID6aL1txnZ7r");
  197. NSLog(@"OEQFNgbsc1knRtY4BLK65o");
  198. }
  199. -(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 {
  200. NSLog(@"YH0UMJj9ewKgIbVdThkQyzpZXl");
  201. NSLog(@"ufyeaPBOkvpQG0IcdWFNT7AU3oY");
  202. NSLog(@"6mOEC8yYeVMAIq0KcnXsSi4");
  203. NSLog(@"qowEz9h0t5X2m1Z6KQncJb");
  204. NSLog(@"PdjvhQMpiGHLexba0KAr5VyNXkZB4UDs6CIf");
  205. NSLog(@"I0dPGyb58pa3z");
  206. NSLog(@"2gSmfvNFQPaX4MZIAYyt1i50k");
  207. NSLog(@"bHMrfF0nC9ZKEdcA1N364jomuUP2");
  208. NSLog(@"tpxeqLTVfvKQ2jEYiGsgAwmhyl");
  209. NSLog(@"QEjS67grf0RsweAZnO");
  210. NSLog(@"Um4kVwG0x8XtuAhslnHFYIe");
  211. }
  212. -(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 {
  213. NSLog(@"b3CO8Hu1imQaAyo26xgMYPUndjzvIRk4wD7eLlrE");
  214. NSLog(@"0bKO5Q3h8sDjzAxTng7MyHBJcvl4S");
  215. NSLog(@"7PojE1WkGTRzF9Sg");
  216. NSLog(@"83PIYNWuAUwFXa5ViMZmny6epsQvhOk04LEzB");
  217. NSLog(@"yfciH7LmMkP4Yr");
  218. NSLog(@"YLJUXEpl8F1");
  219. NSLog(@"lJOSwEoV4TdGB0vLc");
  220. NSLog(@"1L8nhJRX9xeINMW");
  221. NSLog(@"A9VQwLUI3J7i0HOXfyTqkFj8oWZaNleKDmCbB2h");
  222. NSLog(@"kFJUqgHIbryZ60DuinOLQWSw7MlV1");
  223. NSLog(@"8CTRPhbB4uZ7aLOorpmkSU0VJ2IG");
  224. NSLog(@"kj0w5YHz1AuvFBLboag2dchpZ8DCrXm6tqOi9TQJ");
  225. NSLog(@"cyeL6DkzIjlnsXp0aTt93MdRmog4FVvCJ");
  226. NSLog(@"NEiVnxUj52d8FMOtABoDYX6SCzlueLTGc");
  227. NSLog(@"i8V2kjT3zyulOUsxaPE");
  228. NSLog(@"iK2qFg9MoyHCUe4GDv58PXOQWJlBLxRT6tm");
  229. NSLog(@"fTRkHv3EqD");
  230. NSLog(@"X94bmART0aVe57fpDsj8wEdNqcxvC1gZzOSM");
  231. }
  232. @end