123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- //
- // SPSBQueryListDetailsTransactionViewViewController.m
- //
- //
- // Created by jiaxian_he on 2021/5/29.
- //
- #import "SPSBQueryListDetailsTransactionViewViewController.h"
- #import "SPSBUIGeneralHeader.h"
- #import "SPSBQueryListDetailsTransactionTableViewController.h"
- #import <JXHClassifyView.h>
- #import "UIViewController+SPSBNetworkManager.h"
- #import "UIViewController+SPSBDefault.h"
- #import "SPSBQueryListDetailsTransactionModel.h"
- @interface SPSBQueryListDetailsTransactionViewViewController () {
- JXHClassifyView *_classifyView;
- SPSBQueryListDetailsTransactionTableViewController *_tableVC;
- }
- @end
- @implementation SPSBQueryListDetailsTransactionViewViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setupUI];
- [self getOrderBalanceAndRefund];
- }
- #pragma mark - Action
- - (void)classifyViewAction:(NSInteger)index {
- [_classifyView scrollClassifyForIndex:index];
- if (index == 0) {
- _tableVC.spsb_type = SPSBQueryListDetailsTransactionTypeOrderBalance;
- } else {
- _tableVC.spsb_type = SPSBQueryListDetailsTransactionTypeRefund;
- }
- [_tableVC.tableView reloadData];
- }
- #pragma mark - NetworkAction
- - (void)getOrderBalanceAndRefund {
- @weakify(self)
- [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:@"正在加载" isLogin:true url:spsb_appUrl(SPSBUrlQueryPriceDifferencePaymentAndRefund) urlParameters:nil parameters:^NSDictionary * _Nonnull{
- return @{@"order_no": self->_spsb_orderNo};
- } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- [self getOrderBalanceAndRefundSuccess:data];
- return @"";
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- [self getOrderBalanceAndRefundFailure:error];
- return @"加载失败";
- }];
- }
- - (void)getOrderBalanceAndRefundSuccess:(id)data {
- [self removeDefaultView];
- bool isHaveWaitForPay = false;
- NSArray *orderBalanceArray = [SPSBQueryListDetailsTransactionOrderBalanceModel getModelListWithArray:data[@"data"][@"repay"] isHaveWaitForPay:&isHaveWaitForPay];
- NSArray *refundArray = [SPSBQueryListDetailsTransactionRefundModel getModelListWithArray:data[@"data"][@"refund"]];
- SPSBQueryListDetailsTransactionType type = SPSBQueryListDetailsTransactionTypeOrderBalance;
- if (orderBalanceArray.count == 0 && refundArray.count == 0) {
- [self createNoDataView];
- return;
- }
- if (orderBalanceArray.count != 0 && refundArray.count != 0) {
- [self createClassifyView];
- } else if (refundArray.count != 0) {
- type = SPSBQueryListDetailsTransactionTypeRefund;
- }
- [self createTableViewWithType:type orderBalanceData:orderBalanceArray refundData:refundArray isHaveWaitForPay:isHaveWaitForPay];
- }
- - (void)getOrderBalanceAndRefundFailure:(NSError *)error {
- @weakify(self)
- [self setDefaultViewWithError:error image:nil action:^{
- @strongify(self)
- [self getOrderBalanceAndRefund];
- }];
- }
- #pragma mark - UI
- - (void)setupUI {
- self.title = @"交易详情";
- }
- - (void)createTableViewWithType:(SPSBQueryListDetailsTransactionType)type orderBalanceData:(NSArray *)orderBalanceData refundData:(NSArray *)refundData isHaveWaitForPay:(bool)isHaveWaitForPay {
- _tableVC = SPSBQueryListDetailsTransactionTableViewController.new;
- _tableVC.spsb_type = type;
- _tableVC.spsb_refundData = refundData;
- _tableVC.spsb_orderBalanceData = orderBalanceData;
- _tableVC.spsb_isHaveWaitForPay = isHaveWaitForPay;
- [self addChildViewController:_tableVC];
- [self.view addSubview:_tableVC.tableView];
- [_tableVC.tableView makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.and.trailing.and.bottom.equalTo(0);
- if (self->_classifyView) {
- make.top.equalTo(self->_classifyView.bottom);
- } else {
- make.top.equalTo(self.view.safetop);
- }
- }];
- }
- - (void)createClassifyView {
- JXHClassifyViewConfiguration *configuration = ({
- JXHClassifyViewConfiguration *configuration = JXHClassifyViewConfiguration.new;
- configuration.jxh_titleArray = @[@"补差额", @"退款"];
- configuration.jxh_height = 50;
- configuration.jxh_font = spsb_font(16);
- configuration.jxh_normalColor = spsb_666666_color();
- configuration.jxh_selectedColor = spsb_3296FB_color();
- configuration.jxh_margen = 0.f;
- configuration.jxh_interval = 0.f;
- configuration.jxh_selectedViewSize = (CGSize){60, 2.5};
- configuration.jxh_selectedViewColor = spsb_3296FB_color();
- configuration.jxh_equalWidth = jxh_screenWidth() / 2;
- configuration.jxh_isNeedSelectedView = true;
- configuration;
- });
-
- @weakify(self)
- _classifyView = [[JXHClassifyView alloc] initWithConfiguration:configuration chooseAction:^(JXHClassifyView * _Nonnull classifyView, NSInteger index) {
- @strongify(self)
- [self classifyViewAction:index];
- }];
- [self.view addSubview:_classifyView];
- [_classifyView makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.and.trailing.equalTo(0);
- make.top.equalTo(self.view.safetop);
- make.height.equalTo(configuration.jxh_height);
- }];
- }
- - (void)createNoDataView {
- UIImageView *noDataView = [[UIImageView alloc] initWithImage:jxh_getImage(bujiaoxiangqing_qs)];
- [self.view addSubview:noDataView];
- [noDataView makeConstraints:^(JXHConstraintMaker *make) {
- make.centerX.equalTo(0);
- make.centerY.equalTo(-64);
- }];
-
- UILabel *tips = [UILabel convenienceWithFont:spsb_font(14) text:@"此订单没有退补缴" textColor:spsb_9197A3_color() textAlignment:NSTextAlignmentCenter];
- [self.view addSubview:tips];
- [tips makeConstraints:^(JXHConstraintMaker *make) {
- make.centerX.equalTo(0);
- make.top.equalTo(noDataView.bottom);
- }];
- }
- @end
|