ASOrderDetailsViewController.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. //
  2. // ASOrderDetailsViewController.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/15.
  6. //
  7. #import "ASOrderDetailsViewController.h"
  8. #import "ASOrderDetailsVM.h"
  9. #import "ASOrderDetailsModel.h"
  10. #import "ASOrderDetailsInfoCell.h"
  11. #import "ASOrderDetailsItemsCell.h"
  12. #import "ASOrderDetailsPriceCell.h"
  13. #import "ASPayFinishHeadView.h"
  14. @interface ASOrderDetailsViewController ()<UITableViewDelegate, UITableViewDataSource>
  15. @property (nonatomic, strong) UITableView *tableView;
  16. @property (nonatomic, strong) ASOrderDetailsVM *orderDetailsVM;
  17. @property (nonatomic, strong) ASOrderDetailsModel *orderDetailsModel;
  18. @property (nonatomic, strong) ASPayFinishHeadView *paySuccessView;
  19. @end
  20. @implementation ASOrderDetailsViewController
  21. - (void)viewDidDisappear:(BOOL)animated {
  22. [super viewDidDisappear:animated];
  23. if (self.isPay) {
  24. //支付成功页面禁止侧滑返回
  25. self.navigationController.interactivePopGestureRecognizer.enabled = YES;
  26. }
  27. }
  28. - (void)viewDidAppear:(BOOL)animated {
  29. [super viewDidAppear:animated];
  30. if (self.isPay) {
  31. //支付成功页面禁止侧滑返回
  32. self.navigationController.interactivePopGestureRecognizer.enabled = NO;
  33. }
  34. }
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. if (self.isPay) {
  38. self.titleStr = @"Payment";
  39. } else {
  40. self.titleStr = @"Orders Information";
  41. }
  42. self.statusBgV.backgroundColor = Col_FFF;
  43. self.customNavBar.backgroundColor = Col_FFF;
  44. self.orderDetailsVM = [ASOrderDetailsVM new];
  45. [self loadSubV];
  46. [self requestOrderDetailsData];
  47. }
  48. - (void)requestOrderDetailsData {
  49. [MBProgressHUD showHUDAddedTo:self.view animated:true];
  50. @weakify(self)
  51. [self.orderDetailsVM getOrderDetailsWithOrderid:self.orderId complete:^(ASOrderDetailsModel *orderModel) {
  52. @strongify(self)
  53. [MBProgressHUD hideHUDForView:self.view animated:true];
  54. self.orderDetailsModel = orderModel;
  55. [self.tableView reloadData];
  56. [self checkEmpty];
  57. }];
  58. }
  59. - (void)checkEmpty {
  60. if (!self.orderDetailsModel) {
  61. [self showEmptyV:self.tableView];
  62. } else {
  63. [self hiddenEmpty];
  64. }
  65. }
  66. #pragma mark - UITableViewDelegate,UITableViewDataSource
  67. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  68. if (self.orderDetailsModel) {
  69. return 3;
  70. }
  71. return 0;
  72. }
  73. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  74. if (section == 1) {
  75. return self.orderDetailsModel.items.count;
  76. }
  77. return 1;
  78. }
  79. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  80. if (indexPath.section == 0) {
  81. ASOrderDetailsInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASOrderDetailsInfoCell" forIndexPath:indexPath];
  82. cell.orderModel = self.orderDetailsModel;
  83. return cell;
  84. } else if (indexPath.section == 1) {
  85. ASOrderDetailsItemsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASOrderDetailsItemsCell" forIndexPath:indexPath];
  86. NSArray *itemArr = self.orderDetailsModel.items;
  87. ASOrderDetailsItemModel *itemModel = itemArr[indexPath.row];
  88. cell.itemModel = itemModel;
  89. return cell;
  90. } else {
  91. ASOrderDetailsPriceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASOrderDetailsPriceCell" forIndexPath:indexPath];
  92. cell.orderModel = self.orderDetailsModel;
  93. return cell;
  94. }
  95. }
  96. - (void)backAction {
  97. if (self.isPay) {
  98. [self.navigationController popToRootViewControllerAnimated:YES];
  99. } else {
  100. [self.navigationController popViewControllerAnimated:YES];
  101. }
  102. }
  103. #pragma mark ---- UI ----
  104. - (void)loadSubV {
  105. [self.view addSubview:self.tableView];
  106. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.top.equalTo(self.customNavBar.mas_bottom);
  108. make.leading.trailing.bottom.equalTo(self.view);
  109. }];
  110. if (self.isPay) {
  111. self.tableView.tableHeaderView = self.paySuccessView;
  112. }
  113. }
  114. // MARK: - subvs
  115. - (UITableView *)tableView {
  116. if (!_tableView) {
  117. _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  118. [_tableView registerClass:[ASOrderDetailsInfoCell class] forCellReuseIdentifier:@"ASOrderDetailsInfoCell"];
  119. [_tableView registerClass:[ASOrderDetailsItemsCell class] forCellReuseIdentifier:@"ASOrderDetailsItemsCell"];
  120. [_tableView registerClass:[ASOrderDetailsPriceCell class] forCellReuseIdentifier:@"ASOrderDetailsPriceCell"];
  121. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  122. _tableView.delegate = self;
  123. _tableView.dataSource = self;
  124. _tableView.backgroundColor = _F8F8F8;
  125. _tableView.estimatedRowHeight = 50;
  126. }
  127. return _tableView;
  128. }
  129. - (ASPayFinishHeadView *)paySuccessView {
  130. if (!_paySuccessView) {
  131. _paySuccessView = [[ASPayFinishHeadView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 100) status:1 desc:self.orderId];
  132. K_WEAK_SELF;
  133. _paySuccessView.clickBlock = ^(int type) {
  134. K_STRONG_SELF;
  135. if (type == 1) {
  136. [Fuction_Tool popToHomeVc];
  137. } else if (type == 2) {
  138. UIViewController *vc = [CTMediator.sharedInstance getWebViewVc:@{
  139. @"title":@"Faq",
  140. @"url":HelpFaqsWebUrl,
  141. }];
  142. [self.navigationController pushViewController:vc animated:true];
  143. }
  144. };
  145. _paySuccessView.frame = CGRectMake(0, 0, KScreenWidth, [_paySuccessView getViewHeight]);
  146. }
  147. return _paySuccessView;
  148. }
  149. @end