口袋版本的一折买

YZMABrowserHistoryController.m 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. //
  2. // YZMABrowserHistoryController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/2/1.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "YZMABrowserHistoryController.h"
  9. #import "YZMAHistoryTool.h"
  10. #import "YZMAHistoryModel.h"
  11. #import "YZMACollectionTicketCell.h"
  12. #import "YZMADateHeaderView.h"
  13. #import "YZMAGoodDetailViewController.h"
  14. #import "YZMASimilarGoodsController.h"
  15. @interface YZMABrowserHistoryController ()<UITableViewDelegate,UITableViewDataSource>
  16. @property (nonatomic, strong) UITableView *tableView;
  17. @property (nonatomic, strong) NSMutableArray *dataArr;
  18. @end
  19. @implementation YZMABrowserHistoryController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. [self configNavigationBar];
  23. [self configTableView];
  24. [self getLocationBrowserHistoryData];
  25. }
  26. - (void)configNavigationBar {
  27. [self.navigationBar setNavTitle:@"浏览记录"];
  28. self.navigationBar.showNavigationBarBottomLine = YES;
  29. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  30. [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
  31. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  32. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  33. }
  34. - (void)backAction {
  35. [self.navigationController popViewControllerAnimated:YES];
  36. }
  37. - (void)getLocationBrowserHistoryData {
  38. NSMutableArray *hisArr = [[NSMutableDictionary dictionaryWithContentsOfFile:[YZMAHistoryTool getHistoryFilePath]] objectForKey:BrowserHistoryKey];
  39. NSMutableSet *set = [NSMutableSet set];
  40. NSMutableArray * _datas = [[NSMutableArray alloc] initWithCapacity:0];
  41. [hisArr enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
  42. [set addObject:obj[@"browserTime"]];//利用set不重复的特性,得到有多少组,根据数组中的MeasureType字段
  43. }];
  44. [set enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {//遍历set数组
  45. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"browserTime = %@", obj];//创建谓词筛选器
  46. NSArray *group = [hisArr filteredArrayUsingPredicate:predicate];
  47. [_datas addObject:group];
  48. }];
  49. for (NSArray *dicArr in _datas) {
  50. NSMutableArray *mArr = [NSMutableArray array];
  51. for (NSDictionary *dic in dicArr) {
  52. YZMAHistoryModel *model = [[YZMAHistoryModel alloc] init];
  53. [model setValuesForKeysWithDictionary:dic];
  54. [mArr addObject:model];
  55. }
  56. [self.dataArr addObject:mArr];
  57. }
  58. [self.tableView reloadData];
  59. }
  60. - (void)configTableView {
  61. [self.view addSubview:self.tableView];
  62. self.tableView.showNoDataView = YES;
  63. self.tableView.defaultNoDataText = @"暂无数据";
  64. self.tableView.defaultNoDataViewDidClickBlock = ^(UIView *view) {
  65. };
  66. }
  67. /**
  68. 移除历史
  69. */
  70. - (void)deleteCollectionGoodAtIndexPath:(NSIndexPath *)indexPath {
  71. YZMAHistoryModel *model = self.dataArr[indexPath.section][indexPath.row];
  72. NSMutableArray *hisArr = [[NSMutableDictionary dictionaryWithContentsOfFile:[YZMAHistoryTool getHistoryFilePath]] objectForKey:BrowserHistoryKey];
  73. for (NSDictionary *dic in [hisArr mutableCopy]) {
  74. if ([dic[@"goods_id"] isEqualToString:model.goods_id]) {
  75. [hisArr removeObject:dic];
  76. }
  77. }
  78. NSDictionary *historyDic = @{BrowserHistoryKey:hisArr};
  79. [historyDic writeToFile:[YZMAHistoryTool getHistoryFilePath] atomically:YES];
  80. // 删除模型
  81. NSMutableArray *mArr = self.dataArr[indexPath.section];
  82. [mArr removeObjectAtIndex:indexPath.row];
  83. [self.dataArr replaceObjectAtIndex:indexPath.section withObject:mArr];
  84. [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
  85. }
  86. #pragma mark ------------------------
  87. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  88. {
  89. [self deleteCollectionGoodAtIndexPath:indexPath];
  90. }
  91. /**
  92. * 修改Delete按钮文字为“删除”
  93. */
  94. - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
  95. {
  96. return @"删除";
  97. }
  98. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  99. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  100. [cell setSeparatorInset:UIEdgeInsetsMake(0, 50, 0, 0)];
  101. }
  102. }
  103. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  104. return self.dataArr.count;
  105. }
  106. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  107. NSArray *arr = self.dataArr[section];
  108. return arr.count;
  109. }
  110. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  111. return 100;
  112. }
  113. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  114. return 40;
  115. }
  116. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  117. YZMACollectionTicketCell *cell = [YZMACollectionTicketCell cellWithTableView:tableView];
  118. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  119. YZMAHistoryModel *model = self.dataArr[indexPath.section][indexPath.row];
  120. cell.historyModel = model;
  121. cell.similarClick = ^{
  122. //找相似
  123. YZMASimilarGoodsController *similar = [[YZMASimilarGoodsController alloc] init];
  124. similar.goods_id = model.goods_id;
  125. [self.navigationController pushViewController:similar animated:YES];
  126. };
  127. return cell;
  128. }
  129. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  130. YZMADateHeaderView *header = [[YZMADateHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
  131. YZMAHistoryModel *model = [self.dataArr[section] firstObject];
  132. [header setDateWith:model.browserTime];
  133. return header;
  134. }
  135. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  136. YZMAHistoryModel *model = self.dataArr[indexPath.section][indexPath.row];
  137. YZMAGoodDetailViewController *detail = [[YZMAGoodDetailViewController alloc] init];
  138. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithId:model.goods_id
  139. is_coupon:model.is_coupon
  140. coupon_price:model.coupon_price
  141. price:model.price
  142. discount_price:model.discount_price
  143. commission_rate:model.commission_rate
  144. coupon_start_time:model.coupon_start_time
  145. coupon_end_time:model.coupon_end_time];
  146. detail.requestModel = requestModel;
  147. YZMAEventModel *evevtModel = [[YZMAEventModel alloc] initWithOrigin:@"0" category_id:@"0" source:browsingHistoryAction];
  148. detail.eventModel = evevtModel;
  149. [self.navigationController pushViewController:detail animated:YES];
  150. }
  151. - (UITableView *)tableView {
  152. if (!_tableView) {
  153. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) style:UITableViewStylePlain];
  154. _tableView.estimatedSectionHeaderHeight = 0;
  155. _tableView.estimatedSectionFooterHeight = 0;
  156. _tableView.sectionFooterHeight = 0;
  157. _tableView.sectionHeaderHeight = 0;
  158. _tableView.delegate = self;
  159. _tableView.dataSource = self;
  160. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  161. _tableView.backgroundColor = [UIColor yhGrayColor];
  162. _tableView.bounces = YES;
  163. _tableView.showsVerticalScrollIndicator = NO;
  164. [_tableView setSeparatorColor:[UIColor YHColorWithHex:0xdddddd]];
  165. }
  166. return _tableView;
  167. }
  168. - (NSMutableArray *)dataArr {
  169. if (!_dataArr) {
  170. _dataArr = [NSMutableArray array];
  171. }
  172. return _dataArr;
  173. }
  174. - (void)didReceiveMemoryWarning {
  175. [super didReceiveMemoryWarning];
  176. // Dispose of any resources that can be recreated.
  177. }
  178. /*
  179. #pragma mark - Navigation
  180. // In a storyboard-based application, you will often want to do a little preparation before navigation
  181. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  182. // Get the new view controller using [segue destinationViewController].
  183. // Pass the selected object to the new view controller.
  184. }
  185. */
  186. -(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 {
  187. NSLog(@"5OB74P9kzmUp1gvXWVw");
  188. NSLog(@"zOiWY5JHgab2NLrUV8");
  189. NSLog(@"xcgqZXPhAsWYk");
  190. NSLog(@"eJHrEzsFLxj");
  191. NSLog(@"WpnhRFwczB");
  192. NSLog(@"a6CMRhvr4AloHFInZVdXJO51E");
  193. NSLog(@"smSjEgBOzHCRnPuotcarAdw3TJkp7");
  194. NSLog(@"uOgJrXWd8s6");
  195. NSLog(@"5dIcCbMi7sF0hYVZ8LqH1");
  196. NSLog(@"fJhrRecYBlQiCgGyWEMPSAIk");
  197. NSLog(@"l5c1Ys2WIaRfOo");
  198. NSLog(@"5DxAEv9pwWcyCtf1SsXjRYlHFirVZ2na0dhG");
  199. NSLog(@"ckrphDCVt8mFqZ9BExPn5KTR");
  200. NSLog(@"gS9CLGOuraFDTJ");
  201. NSLog(@"ilLD20ta6TRkchBCIxUGNS");
  202. NSLog(@"ewFgxSBJVlLR7dcP2NyHK");
  203. NSLog(@"ceSl9zvWR1oOXLNtgsrxqJCf");
  204. NSLog(@"3r8EoxwmuAFe5KYfPtVkvbJQ7jGDSCl4Z6g9");
  205. }
  206. -(void)af0Y4a:(UISearchBar*) af0Y4a aeZBDL:(UIButton*) aeZBDL ayebUN6fK:(UIControl*) ayebUN6fK abWCt:(UIRegion*) abWCt a7PA8d6rLSk:(UIActivity*) a7PA8d6rLSk aSkNjU:(UIImageView*) aSkNjU {
  207. NSLog(@"C9qlRMZux5FJTNwtjEkn");
  208. NSLog(@"f2Xtr4hzOb1dUc6ZIwCV");
  209. NSLog(@"VW4unOyNxfGHhDCJXtUFP31dY7w");
  210. NSLog(@"wSpvtuaiZxQWyMP4ATzOn61r");
  211. NSLog(@"JEH9rGoIC8c4eDXZSYMWF2KPvn5VTyt10xqzL3");
  212. NSLog(@"jOY1zU8vDXEt9c5ousHMx4l2JZWyNLnebSq3GT");
  213. NSLog(@"AiRGcmTjVqpI4YKw");
  214. NSLog(@"0yckUHzdA4CKmxvXh8iT6rtOIVG5WBMw");
  215. NSLog(@"lTMo8d7kfv0rRmIjOLzCJuq5ciU6ne");
  216. NSLog(@"3fMyC6hoO1cBUlaerSjvdPzsnJ7iIWkVN");
  217. }
  218. -(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 {
  219. NSLog(@"zVjDr36omsqPHAeOkaNb21cnCF");
  220. NSLog(@"OEvKhSaqgn");
  221. NSLog(@"IYJckuKrS21wNxfC4jaFLGlyvAg");
  222. NSLog(@"ac7qb2LB9gWjptRKzFsG3O1meUukQAxrJVn");
  223. NSLog(@"DMXdhHnQ4ulfUqicbAvsWPCjT19");
  224. NSLog(@"4JhdH2Rtapr9F");
  225. NSLog(@"JQN9VInKp4BcaDmWXblx2wLruMvzg");
  226. NSLog(@"ZkUOVPvXMaJ6sgtSYoGD4QWFAp");
  227. NSLog(@"hqg5uZOAHk1tLCM7NV0l8b2Wc6IPr");
  228. NSLog(@"3fRrvN4yY7i6dEQVhLBaFmzSZot");
  229. NSLog(@"pfXSsMPWgRtEC09LwHeqru5nYoBlU3AGK");
  230. NSLog(@"fCgHPnhwU4yiJjq57r2tTVmXc6SGEF9xORM0");
  231. NSLog(@"YxOEs4Xp1PnlASh0QtJqd8zCTwB");
  232. NSLog(@"DZPjkm4WQSC");
  233. NSLog(@"ZkF2IBK17G5Eowpf3vd");
  234. }
  235. -(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 {
  236. NSLog(@"veADVpGRj6yKaxLsuhPg7fU25dqlzob4MBSE");
  237. NSLog(@"41EyaJMnsTcFKIl6X9GeLrBoPwUSmfWYj8p3hgVD");
  238. NSLog(@"4YqBLUSIXVOlzR8kips927DGTfHM5uJjWyFPCmr");
  239. NSLog(@"N8nHaP7B4G9XSEbWCtceJZp6u3gKU1QTiDVL0hfz");
  240. NSLog(@"4sQX5hrEayPR2DlM1N6u0q");
  241. NSLog(@"WIAjhkCRm4xVz207NiGadBYEf9pyZO8g");
  242. NSLog(@"9UDqEbclevmNxdjh7Sty86RZw");
  243. NSLog(@"DEePuyNWZX1wK57tzAigsTCjUQdo0");
  244. NSLog(@"BclTfZnovVE0qQr8YAS2Ry7Pe3gIX9kuxb6");
  245. NSLog(@"X6JNfew39PV");
  246. NSLog(@"h4gd5ykYEPf8Jj7HpBS9xqaMDGoeli");
  247. }
  248. -(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 {
  249. NSLog(@"r0IUPd3ksCoxwEJK65tvLgD");
  250. NSLog(@"uAGI6Z5tbB");
  251. NSLog(@"si4DA1FrlOkh5eWuGb8fLdvwzR7oam");
  252. NSLog(@"bZcCwd2NR9juPX1qrVJze");
  253. NSLog(@"8YWLjc0IV64MOEXzfiaH2BKFxZhGs51");
  254. NSLog(@"OPzRJ4d8DEr75UvZn1HNo0a3yS6");
  255. NSLog(@"pearXQG7FA38tYHfqO4mvJN0TW");
  256. NSLog(@"IVqhewi2Q5sfYHrNLMz16K7xtTmuvByRba");
  257. NSLog(@"7IpX80afQw9hxoEzKJWB3buRtvVrDFUcdO2");
  258. NSLog(@"8CEGtD2KdITrvgmWBox73pi4nLXFczMflY0");
  259. NSLog(@"LB2zseaNIyR3vHX5KWgVcUAwhfTk87r1SY");
  260. NSLog(@"nrQ0Tdapbs6MimzCk5xN1B");
  261. NSLog(@"4jWY6TyAnzrgCLcxHDmVF");
  262. NSLog(@"29fnlaFmN0gcsEkypeDh");
  263. NSLog(@"68faLSyiI9onFc1DqtHQvTu5GMPz3blRAedm");
  264. NSLog(@"oagr0MqdSivDtVUzmByxPbY");
  265. NSLog(@"HM5KwFA8v2BLhp");
  266. NSLog(@"zKt0kiPTAFYUM2em8d6");
  267. NSLog(@"EKb0lpdJjFG24hOLtQwkcZy7XDAmYnqMV");
  268. }
  269. @end