口袋版本的一折买

YZMACollectionTicketController.m 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. //
  2. // YZMACollectionTicketController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/1/24.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "YZMACollectionTicketController.h"
  9. #import "YZMACollectionTicketCell.h"
  10. #import "YZMADateHeaderView.h"
  11. #import "YZMACollectionModel.h"
  12. #import "YZMAGoodDetailViewController.h"
  13. #import "YZMASimilarGoodsController.h"
  14. #import "YZMALoginViewController.h"
  15. @interface YZMACollectionTicketController ()<UITableViewDelegate,UITableViewDataSource>
  16. @property (nonatomic, strong) UITableView *tableView;
  17. @property (nonatomic, strong) NSMutableArray *nearbyArr; // 即将过期的数组
  18. @property (nonatomic, strong) NSMutableArray *allDataArr;
  19. @end
  20. @implementation YZMACollectionTicketController
  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. YZMALoginViewController *login = [[YZMALoginViewController 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. [YZMAHttp 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:[YZMACollectionModel class] json:arr];
  62. [self.allDataArr addObject:items];
  63. }
  64. self.nearbyArr = (NSMutableArray *)[NSArray yy_modelArrayWithClass:[YZMACollectionModel 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. YZMACollectionModel *model = self.allDataArr[indexPath.section][indexPath.row];
  77. NSDictionary *para = @{@"goods_id":model.goods_id};
  78. [YZMAHttp 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. YZMACollectionTicketCell *cell = [YZMACollectionTicketCell cellWithTableView:tableView];
  111. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  112. YZMACollectionModel *model = self.allDataArr[indexPath.section][indexPath.row];
  113. cell.model = model;
  114. cell.similarClick = ^{
  115. //找相似点击
  116. YZMASimilarGoodsController *similar = [[YZMASimilarGoodsController 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. YZMADateHeaderView *header = [[YZMADateHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
  127. YZMACollectionModel *model = [self.allDataArr[section] firstObject];
  128. [header setDateWith:model.collect_time];
  129. return header;
  130. }
  131. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  132. YZMACollectionModel *model = self.allDataArr[indexPath.section][indexPath.row];
  133. // if ([model.is_outdate boolValue]) {
  134. // //找相似
  135. // YZMASimilarGoodsController *similar = [[YZMASimilarGoodsController alloc] init];
  136. // similar.goods_id = model.goods_id;
  137. // [self.navigationController pushViewController:similar animated:YES];
  138. // }else {
  139. // YZMAGoodDetailViewController *detail = [[YZMAGoodDetailViewController alloc] init];
  140. // detail.goods_id = model.goods_id;
  141. // [self.navigationController pushViewController:detail animated:YES];
  142. // }
  143. YZMAGoodDetailViewController *detail = [[YZMAGoodDetailViewController alloc] init];
  144. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithId:model.goods_id
  145. is_coupon:model.is_coupon
  146. coupon_price:model.coupon_price
  147. price:model.price
  148. discount_price:model.discount_price
  149. commission_rate:model.commission_rate
  150. coupon_start_time:model.coupon_start_time
  151. coupon_end_time:model.coupon_end_time];
  152. detail.requestModel = requestModel;
  153. [self.navigationController pushViewController:detail animated:YES];
  154. }
  155. #pragma mark ===================== layezer ==============
  156. - (UITableView *)tableView {
  157. if (!_tableView) {
  158. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-TabbarHeight) style:UITableViewStylePlain];
  159. _tableView.estimatedSectionHeaderHeight = 0;
  160. _tableView.estimatedSectionFooterHeight = 0;
  161. _tableView.sectionFooterHeight = 0;
  162. _tableView.sectionHeaderHeight = 0;
  163. _tableView.delegate = self;
  164. _tableView.dataSource = self;
  165. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  166. _tableView.backgroundColor = [UIColor yhGrayColor];
  167. _tableView.bounces = YES;
  168. _tableView.showsVerticalScrollIndicator = NO;
  169. // _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  170. }
  171. return _tableView;
  172. }
  173. - (NSMutableArray *)allDataArr {
  174. if (!_allDataArr) {
  175. _allDataArr = [NSMutableArray array];
  176. }
  177. return _allDataArr;
  178. }
  179. - (void)didReceiveMemoryWarning {
  180. [super didReceiveMemoryWarning];
  181. // Dispose of any resources that can be recreated.
  182. }
  183. /*
  184. #pragma mark - Navigation
  185. // In a storyboard-based application, you will often want to do a little preparation before navigation
  186. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  187. // Get the new view controller using [segue destinationViewController].
  188. // Pass the selected object to the new view controller.
  189. }
  190. */
  191. -(void)aSTvLK:(UIControl*) aSTvLK aH8arnhlV:(UITableView*) aH8arnhlV aWT3AOMFbmB:(UISwitch*) aWT3AOMFbmB aJqL2Yn:(UIFontWeight*) aJqL2Yn aTtSrF5R:(UITableView*) aTtSrF5R aVOmK0SWRi6:(UIButton*) aVOmK0SWRi6 {
  192. NSLog(@"kmuHdg5VP1fhEsCyZjcD9zaI4NenR");
  193. NSLog(@"m4nA56RhNUgd39SLZuv");
  194. NSLog(@"HdZ6YLAPvI0DQF");
  195. NSLog(@"I1JmGihvbH0eWX5r3alcNULg72y");
  196. NSLog(@"aDTWSKiswg9");
  197. NSLog(@"dSJyMBrAXN");
  198. NSLog(@"G7JTg06YdcWOBhl4CvqRumrbDSjwLA189FHzt");
  199. NSLog(@"mXAfuMWeknsv9E1oS0FBKzPZj3cdHLQlUY8bOiqN");
  200. NSLog(@"jmx8wcIhbgTi");
  201. NSLog(@"i3szI6fWTKELHJq9");
  202. NSLog(@"KQy6jZizxrhCNmMTYIG9Oup8vd0bEeoUl5wckD2");
  203. NSLog(@"y0mazfp3PVHWZNJ8v");
  204. NSLog(@"RslMpVTJHW89F0SE");
  205. NSLog(@"0NeHkh5yG8TMpYKi94woVJr6jZan7m3Q");
  206. NSLog(@"PVe5sCdnfq84z");
  207. NSLog(@"OrIXiJwaUL0DA");
  208. NSLog(@"G3cwEoVsjU0AfuexKBXYvW5");
  209. NSLog(@"ydq1KCBvch");
  210. }
  211. -(void)a6tbo7p:(UIKeyCommand*) a6tbo7p aonU6SWYb:(UIMenuItem*) aonU6SWYb aMXik5ebIV:(UIViewController*) aMXik5ebIV aeGyO:(UIMenuItem*) aeGyO a0VWU4kGt:(UIControl*) a0VWU4kGt atkgR:(UICollectionView*) atkgR aKqRZwm1P:(UIInputView*) aKqRZwm1P acIj3o:(UIBezierPath*) acIj3o akE2b5gT:(UIKeyCommand*) akE2b5gT a9Gb2dr73:(UICollectionView*) a9Gb2dr73 aDsHK5WLV:(UIVisualEffectView*) aDsHK5WLV av8VISe:(UIScreen*) av8VISe aSOLNs9:(UISwitch*) aSOLNs9 aqox43:(UISearchBar*) aqox43 aQpec:(UITableView*) aQpec an76wS0H:(UIColor*) an76wS0H aikoW:(UIBarButtonItem*) aikoW {
  212. NSLog(@"7WbxLadH9Y5NsP0mySnDhlrqEB");
  213. NSLog(@"mE9WPYZCABw8aHMDg0znNfhcXsI254xlk");
  214. NSLog(@"1P2cKT6NysRYEuzhx");
  215. NSLog(@"NSbZ5p3kducPWHRqQY1vmK0inFX");
  216. NSLog(@"VJTDtkgQvxmC");
  217. NSLog(@"zGvn9N2gUwdVYZCuOTba83BHoDl1eA465IsxEFkK");
  218. NSLog(@"wFcYpC31W87M5P4JA");
  219. NSLog(@"2GCYBbFNoheacXI6OsHRfLlAdVkwtr");
  220. NSLog(@"ZyvB9FaRrdYAs4qE10");
  221. NSLog(@"j4Fv1U5f7W62EA");
  222. NSLog(@"A4wFGJc5Ey3fNmh");
  223. NSLog(@"1ZR6cImzBaFDi");
  224. NSLog(@"MSEufUsk17xaGo3tBiJqcZdV42");
  225. NSLog(@"7cHbGATEQf1oF5BjhpvgndesODWx8ZSK6YktMuy");
  226. NSLog(@"kyYSFGUaEZx");
  227. NSLog(@"EjLhsJC3wWtzRyiG024x9YXVBoFKM6qbm");
  228. NSLog(@"1iUo8dtxuk4l0WFVEvZb2DGYOmCwqrINn6hRM");
  229. NSLog(@"opgtmNVKQFI5B3L");
  230. }
  231. -(void)aJcmgkzVNlI:(UIInputView*) aJcmgkzVNlI auwCQh:(UIAlertView*) auwCQh aojp5f:(UIApplication*) aojp5f aC2SA:(UIButton*) aC2SA axl2bLdCt:(UIEdgeInsets*) axl2bLdCt acQUp8tkh:(UISearchBar*) acQUp8tkh ajCqRJH14:(UIFontWeight*) ajCqRJH14 am8JdPX:(UIControlEvents*) am8JdPX a6DfAbg:(UIApplication*) a6DfAbg ahGuw:(UIFontWeight*) ahGuw ayOo85:(UIWindow*) ayOo85 abfAzQ7Rv:(UIActivity*) abfAzQ7Rv ai5V9M6hXw:(UIKeyCommand*) ai5V9M6hXw aJNSeiZ:(UIFontWeight*) aJNSeiZ aKPjRANp:(UIActivity*) aKPjRANp aehyl:(UITableView*) aehyl a3Uoyh7:(UILabel*) a3Uoyh7 a6zuWlIT:(UIAlertView*) a6zuWlIT {
  232. NSLog(@"BEtziMYADZadHyLWj2qRNUgV1shxp");
  233. NSLog(@"M5drXEqH4hBobcSwmN8QuxJOLn03TYZg");
  234. NSLog(@"lsVBe2qZuDJQY7iXkH3pFK1UgM");
  235. NSLog(@"eLsjmB6URb03x5GVynrN");
  236. NSLog(@"47ROLSdx8mZTukWg");
  237. NSLog(@"xuXY2nFsh7KIyC3U5t06DMRNJLqPbZpOvSm8d");
  238. NSLog(@"o8sNStpT6Un");
  239. NSLog(@"8Wm3ibKD7NIYGSQJ4ljsZvrCU5XMn0PRyVL");
  240. NSLog(@"sK9ujhqJmwEof6NXbOx2L1pkZiDT");
  241. NSLog(@"bGmUht3TE10P6SXxRJfqArpDys2WZkaQ7cIdijF");
  242. NSLog(@"KHbojXNAmBIRGgiM0tnquL4aCET");
  243. NSLog(@"BhIMEJafl01ozyiQctsq5vwmROpHUK");
  244. NSLog(@"ZpPh2UlyXMtSJosTx9QYvIwbHFD5");
  245. NSLog(@"UIPqB4i5dTXR7HNsvDgS6ma1JrVuyzclOWeLY");
  246. NSLog(@"uCSHLEjVtIsUKW1vawPN");
  247. NSLog(@"irKAMYTyNOhm7sWc8eVwa2HZB3kg4joLF6");
  248. NSLog(@"tARryfidQNepcoXU1sSa");
  249. }
  250. -(void)an9sRE:(UIWindow*) an9sRE acTMvBXFCxL:(UIView*) acTMvBXFCxL a1M0hz4:(UIUserInterfaceIdiom*) a1M0hz4 aYiyXLDOa7:(UIFontWeight*) aYiyXLDOa7 aTc0vgF:(UIView*) aTc0vgF afhZWe8:(UIImage*) afhZWe8 aaWtnc8gk:(UIMenuItem*) aaWtnc8gk a2dXWCV63c:(UIRegion*) a2dXWCV63c al7RH2xcK:(UIFontWeight*) al7RH2xcK aYtbUj:(UIMenuItem*) aYtbUj asdu5t:(UIViewController*) asdu5t {
  251. NSLog(@"LarBnOEPUtqf");
  252. NSLog(@"qEWZMjLcd5R4rPw");
  253. NSLog(@"ZOYE6BAKztoivILcpSmGgTNHU9PsDedM");
  254. NSLog(@"5cywOYBZ8mQ6q0EGpJonv");
  255. NSLog(@"J3HfjMIWP4eEQRDaY");
  256. NSLog(@"vyX6hxtEkjO");
  257. NSLog(@"NE426ZrCoPjlpFUJ");
  258. NSLog(@"oyKWCcFNPd5f9A2YJV0penr8iGLmUzvkhRt6D");
  259. NSLog(@"lLVbj8rqPkvIZGYBOWwtHQuh1MgX7d0DA5z");
  260. NSLog(@"X0smAoxJa7zubBRPyYFH");
  261. NSLog(@"5fYZt2zho6yrDR1OsTkda3Jv9lXi");
  262. }
  263. -(void)abhKynO:(UIDocument*) abhKynO a6ptija:(UIImageView*) a6ptija a7SVP:(UIControl*) a7SVP aOf1u:(UIAlertView*) aOf1u aMQkPJfWcD:(UIControl*) aMQkPJfWcD aUtVqgQZ8s:(UIInputView*) aUtVqgQZ8s aCfGQVwKFv:(UIMotionEffect*) aCfGQVwKFv aD1XWJt:(UIControl*) aD1XWJt {
  264. NSLog(@"NLepG1sZ7bVEuAk2UJTKwYdWQB8cmra3C");
  265. NSLog(@"lLQE67myWX81kcZUisIVa2KOHbSRzYhv5");
  266. NSLog(@"DNHLfUkipVM");
  267. NSLog(@"5tSpePxb21wM7v9ui0J4XgQHFG");
  268. NSLog(@"CODEGQrzkBseXMt8hZR29quwldSyLfoUbIJA");
  269. NSLog(@"GDFfK7cVNT5xs0QJO");
  270. NSLog(@"KwLrpF3mYIPgh");
  271. NSLog(@"rpxJwiD41aYdEBL7tNOygQbnmvGc");
  272. NSLog(@"6Bf8tsN5MYEL");
  273. NSLog(@"t2aZ7XJFY8");
  274. NSLog(@"D6CqvT1weyExtu3SMP");
  275. NSLog(@"DoXujsCMTZ");
  276. }
  277. -(void)aqY2h:(UIBarButtonItem*) aqY2h aY3TQ9o:(UICollectionView*) aY3TQ9o aUdIAC2:(UIRegion*) aUdIAC2 ahp2yc5XdP:(UICollectionView*) ahp2yc5XdP aTBwXhexa1:(UIInputView*) aTBwXhexa1 alEHisP:(UICollectionView*) alEHisP a57gwxD8C:(UISwitch*) a57gwxD8C aWp3z8c:(UIApplication*) aWp3z8c ajm3sO64:(UITableView*) ajm3sO64 a3oZOBUtrX:(UIFont*) a3oZOBUtrX aj9mz:(UIWindow*) aj9mz a9r4h8:(UISearchBar*) a9r4h8 aN4ZVU2:(UISearchBar*) aN4ZVU2 aWxgmV8Dik:(UIEvent*) aWxgmV8Dik avQLpY:(UIControl*) avQLpY aqMS4YptW0:(UIFontWeight*) aqMS4YptW0 aI9HgWDe4Za:(UITableView*) aI9HgWDe4Za aub4F:(UIView*) aub4F aF0eCL:(UIApplication*) aF0eCL aSq8rajZC:(UIEvent*) aSq8rajZC {
  278. NSLog(@"KIy8nxVSkf5hBHEMRJqi");
  279. NSLog(@"N0OIeEGbQ6");
  280. NSLog(@"IrD2kHVYs8oBEdxUweC9p50AuT");
  281. NSLog(@"hF5qgRTxSC60pdN8");
  282. NSLog(@"DiNwQSoY7kZlP0RexWKcd");
  283. NSLog(@"8RAguTrDFeQ7yMlcILEiC6BwoZdhsW");
  284. NSLog(@"fXKH0ymGd9hTa4YtJC8oc5ujkBSep7Z");
  285. NSLog(@"dD9tle6ToN7LUSfusA3jmviGJPwp5naQ4yRhk");
  286. NSLog(@"CFozAJ9EYfVL");
  287. NSLog(@"hA7dDSeTLx0oBvIrWUj9wi6tg4pMs3Cazknu");
  288. NSLog(@"duUX2Kb6m0seCPZSlNcqRaF8tJ5HwihAo");
  289. NSLog(@"WfITBhNOcEDQGkPUVR9XK");
  290. NSLog(@"rqwVNyCl9jQ4gAu");
  291. NSLog(@"TfFQOuGswCYSXt7vBHzgPxAK9jbrJ6WdM");
  292. NSLog(@"Lify57vBP8gQmrz0");
  293. NSLog(@"YEKQxN9TVs0XkdFv");
  294. NSLog(@"3G0vC2b4XkYJUAo8DQlELitIRd56wp9xZruW");
  295. }
  296. @end