123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- //
- // ASOrderDetailsViewController.m
- // Asteria
- //
- // Created by xingyu on 2024/5/15.
- //
- #import "ASOrderDetailsViewController.h"
- #import "ASOrderDetailsVM.h"
- #import "ASOrderDetailsModel.h"
- #import "ASOrderDetailsInfoCell.h"
- #import "ASOrderDetailsItemsCell.h"
- #import "ASOrderDetailsPriceCell.h"
- #import "ASPayFinishHeadView.h"
- @interface ASOrderDetailsViewController ()<UITableViewDelegate, UITableViewDataSource>
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) ASOrderDetailsVM *orderDetailsVM;
- @property (nonatomic, strong) ASOrderDetailsModel *orderDetailsModel;
- @property (nonatomic, strong) ASPayFinishHeadView *paySuccessView;
- @end
- @implementation ASOrderDetailsViewController
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- if (self.isPay) {
- //支付成功页面禁止侧滑返回
- self.navigationController.interactivePopGestureRecognizer.enabled = NO;
- }
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- self.navigationController.interactivePopGestureRecognizer.enabled = YES;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- if (self.isPay) {
- self.titleStr = @"Payment";
- } else {
- self.titleStr = @"Orders Information";
- }
-
- self.statusBgV.backgroundColor = Col_FFF;
- self.customNavBar.backgroundColor = Col_FFF;
-
- self.orderDetailsVM = [ASOrderDetailsVM new];
-
- [self loadSubV];
-
- [self requestOrderDetailsData];
- }
- - (void)requestOrderDetailsData {
- [MBProgressHUD showHUDAddedTo:self.view animated:true];
- @weakify(self)
- [self.orderDetailsVM getOrderDetailsWithOrderid:self.orderId complete:^(ASOrderDetailsModel *orderModel) {
- @strongify(self)
- [MBProgressHUD hideHUDForView:self.view animated:true];
-
- self.orderDetailsModel = orderModel;
-
- [self.tableView reloadData];
-
- [self checkEmpty];
- }];
- }
- - (void)checkEmpty {
- if (!self.orderDetailsModel) {
- [self showEmptyV:self.tableView];
- } else {
- [self hiddenEmpty];
- }
- }
- #pragma mark - UITableViewDelegate,UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- if (self.orderDetailsModel) {
- return 3;
- }
- return 0;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if (section == 1) {
- return self.orderDetailsModel.items.count;
- }
- return 1;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- if (indexPath.section == 0) {
- ASOrderDetailsInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASOrderDetailsInfoCell" forIndexPath:indexPath];
- cell.orderModel = self.orderDetailsModel;
- return cell;
- } else if (indexPath.section == 1) {
- ASOrderDetailsItemsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASOrderDetailsItemsCell" forIndexPath:indexPath];
- NSArray *itemArr = self.orderDetailsModel.items;
- ASOrderDetailsItemModel *itemModel = itemArr[indexPath.row];
-
- cell.itemModel = itemModel;
-
- return cell;
- } else {
- ASOrderDetailsPriceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASOrderDetailsPriceCell" forIndexPath:indexPath];
- cell.orderModel = self.orderDetailsModel;
- return cell;
- }
- }
- - (void)backAction {
- if (self.isPay) {
- [self.navigationController popToRootViewControllerAnimated:YES];
- } else {
- [self.navigationController popViewControllerAnimated:YES];
- }
- }
- #pragma mark ---- UI ----
- - (void)loadSubV {
-
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.customNavBar.mas_bottom);
- make.leading.trailing.bottom.equalTo(self.view);
- }];
-
- if (self.isPay) {
- self.tableView.tableHeaderView = self.paySuccessView;
- }
- }
- // MARK: - subvs
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- [_tableView registerClass:[ASOrderDetailsInfoCell class] forCellReuseIdentifier:@"ASOrderDetailsInfoCell"];
- [_tableView registerClass:[ASOrderDetailsItemsCell class] forCellReuseIdentifier:@"ASOrderDetailsItemsCell"];
- [_tableView registerClass:[ASOrderDetailsPriceCell class] forCellReuseIdentifier:@"ASOrderDetailsPriceCell"];
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.backgroundColor = _F8F8F8;
- _tableView.estimatedRowHeight = 50;
- }
- return _tableView;
- }
- - (ASPayFinishHeadView *)paySuccessView {
- if (!_paySuccessView) {
- _paySuccessView = [[ASPayFinishHeadView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 100) status:1 desc:self.orderId];
- K_WEAK_SELF;
- _paySuccessView.clickBlock = ^(int type) {
- K_STRONG_SELF;
- if (type == 1) {
- [Fuction_Tool popToHomeVc];
- }
- };
- _paySuccessView.frame = CGRectMake(0, 0, KScreenWidth, [_paySuccessView getViewHeight]);
- }
- return _paySuccessView;
- }
- @end
|