| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- //
- // OrderdetailViewController.m
- // jitao
- //
- // Created by 罗云飞 on 2017/12/24.
- // Copyright © 2017年 罗云飞. All rights reserved.
- //
- #import "OrderdetailViewController.h"
- #import "OrderdetailCell.h"
- #import "OrdercontentCell.h"
- #import "PaymentinformationCell.h"
- #import "OrderdetailModel.h"
- #import "BusinesswaterDetaiViewController.h"
- #import "CommoditysCell.h"
- @interface OrderdetailViewController ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>{
- UITableView *newtableView;
- NSMutableArray *dataArray;
- NSString *money;
- }
- @end
- @implementation OrderdetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setNavTitle:@"订单详情"];
- [self dataInitialization];
- [self loadsView];
- [self networkRequest];
- // Do any additional setup after loading the view.
- }
- - (void)networkRequest{
- [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
- NSMutableDictionary *dic = NewMutableDictionaryInit;
- [dic safeSetObject:_orderID forKey:@"orderNo"];
- [NetworkRequestManager requestGetWithInterfacePrefix:JT_orderDetails parameters:dic onSuccess:^(id requestData) {
- [MBProgressHUD hideHUDForView:self.view];
- NSLog(@"服务器返回数据 :%@",requestData);
- if ([requestData[@"error"] count] !=0) {
- for (NSDictionary *dic in requestData[@"error"]) {
- [MBProgressHUD showError:dic[@"message"] toView:self.view];
- }
- }else{
- OrderdetailModel *model = [[OrderdetailModel alloc] initWithDictionary:requestData[@"data"] error:nil];
- [dataArray addObject:model];
- money = model.orderAmount;
- [newtableView reloadData];
- }
- } onFailure:^{
-
- }];
- }
- #pragma mark - 数据初始化
- - (void)dataInitialization{
- dataArray = NewMutableArrayInit;
- money = @"";
- }
- #pragma mark ----加载界面
- - (void)loadsView{
- [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, NavHeader, SCREEN_WIDTH, SCREEN_HEIGHT-(NavHeader)) backgroundColor:NewGroupTableViewBackgroundColor style:1 delegate:self dataSource:self showsHorizontalScrollIndicator:NO showsVerticalScrollIndicator:NO hidden:NO tag:100 userInteractionEnabled:YES]];
- newtableView.separatorStyle = NO;
- }
- #pragma mark-------------------------UITableView------------------------------------
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- //返回每段行数
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- if (dataArray.count>0) {
- OrderdetailModel *model = dataArray[0];
- NSDictionary *dic = model.operatorActive;
- NSString *a2 = [NSString stringWithFormat:@"%@",dic[@"payForFirst"]];
- NSString *a3 = [NSString stringWithFormat:@"%@",dic[@"payForLast"]];
- if ([a2 isEqualToString:@"1"]||[a3 isEqualToString:@"1"]) {
- return 4;
- }else{
- return 3;
- }
- }
- return 2;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *Cell = @"Cell";
- static NSString *Cell1 = @"Cell1";
- static NSString *Cell2 = @"Cell2";
- static NSString *Cell3 = @"Cell3";
- if (indexPath.row == 0) {
- OrderdetailCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell];
- if (cell == nil) {
- cell = [[OrderdetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- if (dataArray.count>0) {
- cell.price.delegate = self;
- [cell.price addTarget:self action:@selector(textfieldclick:) forControlEvents:UIControlEventEditingChanged];
- [cell assignment:dataArray[0]];
- }
- return cell;
- }else if (indexPath.row == 1){
- CommoditysCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell3];
- if (cell == nil) {
- cell = [[CommoditysCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell3];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- if (dataArray.count>0) {
- [cell assignment:dataArray[0]];
- }
- return cell;
-
- }else if (indexPath.row == 2){
- OrdercontentCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell1];
- if (cell == nil) {
- cell = [[OrdercontentCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell1];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- if (dataArray.count>0) {
- [cell assignment:dataArray[0]];
- }
- return cell;
- }else if (indexPath.row == 3){
- PaymentinformationCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell2];
- if (cell == nil) {
- cell = [[PaymentinformationCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell2];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- // [cell assignment:dataArray[indexPath.row]];
- return cell;
- }
- return [[UITableViewCell alloc] init];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.row == 0) {
- return fitScreenWidth(130+44);
- }else if (indexPath.row == 1){
- if (dataArray.count>0) {
- OrderdetailModel *model = dataArray[0];
- return 20+model.commoditys.count*30;
- }else{
- return 0;
- }
- }else if (indexPath.row == 2){
- if (dataArray.count>0) {
- OrderdetailModel *model = dataArray[0];
- CGFloat height = [NewUtils heightforString:model.introduction andWidth:SCREEN_WIDTH-30 fontSize:fitScreenWidth(12)];
- return height+30;
- }else{
- return 0;
- }
- }else{
- return fitScreenWidth(150);
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return 75+65+54;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- return [[UIView alloc] init];
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
- if (dataArray.count>0) {
- OrderdetailModel *model = dataArray[0];
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 75)];
- view.backgroundColor = NewGroupTableViewBackgroundColor;
-
- UIButton *flowingwaterBT = [UIButton new];
- flowingwaterBT.frame = CGRectMake(0, 10, SCREEN_WIDTH, 44);
- [flowingwaterBT setTitle:@"查看往来流水" forState:UIControlStateNormal];
- flowingwaterBT.backgroundColor = NewWhiteColor;
- [flowingwaterBT setTitleColor:NewBlackColor forState:UIControlStateNormal];
- flowingwaterBT.titleLabel.font = NewFont(fitScreenWidth(14));
- flowingwaterBT.titleLabel.textAlignment = NSTextAlignmentLeft;
- NewTouchUpInside(flowingwaterBT, flowingwaterBTclick:);
- [view addSubview:flowingwaterBT];
-
-
- UIButton *_cancelintention;
- _cancelintention = [UIButton new];
- [_cancelintention setTitleColor:NewWhiteColor forState:UIControlStateNormal];
- _cancelintention.titleLabel.font = NewFont(16);
- _cancelintention.frame = CGRectMake(30, 30+54, SCREEN_WIDTH-60, 45);
- [_cancelintention setBackgroundColor:NewButtonColor];
- NewTouchUpInside(_cancelintention, _cancelintentionclick:);
- ViewRadius(_cancelintention, 5);
- [view addSubview:_cancelintention];
-
- UIButton *_cancelintention1111;
- _cancelintention1111 = [UIButton new];
- [_cancelintention1111 setTitleColor:NewWhiteColor forState:UIControlStateNormal];
- _cancelintention1111.titleLabel.font = NewFont(16);
- _cancelintention1111.frame = CGRectMake(30, 95+54, SCREEN_WIDTH-60, 45);
- [_cancelintention1111 setBackgroundColor:NewButtonColor];
- ViewRadius(_cancelintention1111, 5);
- NewTouchUpInside(_cancelintention1111, _cancelintentionclick:);
- [view addSubview:_cancelintention1111];
-
- NSDictionary *dic = model.operatorActive;
- NSString *a = [NSString stringWithFormat:@"%@",dic[@"refuseIntention"]];
- NSString *a1 = [NSString stringWithFormat:@"%@",dic[@"applyForCancel"]];
- NSString *a2 = [NSString stringWithFormat:@"%@",dic[@"payForFirst"]];
- NSString *a3 = [NSString stringWithFormat:@"%@",dic[@"payForLast"]];
- NSString *a4 = [NSString stringWithFormat:@"%@",dic[@"applyForWithdraw"]];
- NSString *a5 = [NSString stringWithFormat:@"%@",dic[@"confirmPayForLast"]];
- NSString *a6 = [NSString stringWithFormat:@"%@",dic[@"confirmRefund"]];
- NSString *a7 = [NSString stringWithFormat:@"%@",dic[@"confirmWithdraw"]];
- NSString *a8 = [NSString stringWithFormat:@"%@",dic[@"confirmIntention"]];
- NSString *a9 = [NSString stringWithFormat:@"%@",dic[@"confirmPayForFirst"]];
- NSArray *array = @[a.length>0?a:@"0",
- a1.length>0?a1:@"0",
- a2.length>0?a2:@"0",
- a3.length>0?a3:@"0",
- a4.length>0?a4:@"0",
- a5.length>0?a5:@"0",
- a6.length>0?a6:@"0",
- a7.length>0?a7:@"0",
- a8.length>0?a8:@"0",
- a9.length>0?a9:@"0"];
- NSMutableArray *dataArray = [NSMutableArray array];
-
- for (int i=0; i<array.count; i++) {
- NSString *state = array[i];
- if ([state isEqualToString:@"1"]) {
- switch (i) {
- case 0:
- [dataArray addObject:@{@"title":@"拒绝意向",@"state":@"1"}];
- break;
- case 1:
- [dataArray addObject:@{@"title":@"取消订单",@"state":@"1"}];
- break;
- case 2:
- [dataArray addObject:@{@"title":@"支付首付",@"state":@"1"}];
- break;
- case 3:
- [dataArray addObject:@{@"title":@"支付尾款",@"state":@"1"}];
- break;
- case 4:
- [dataArray addObject:@{@"title":@"提现",@"state":@"1"}];
- break;
- case 5:
- [dataArray addObject:@{@"title":@"确认支付尾款",@"state":@"1"}];
- break;
- case 6:
- [dataArray addObject:@{@"title":@"确认退款",@"state":@"1"}];
- break;
- case 7:
- [dataArray addObject:@{@"title":@"确认提现",@"state":@"1"}];
- break;
- case 8:
- [dataArray addObject:@{@"title":@"确认意向",@"state":@"1"}];
- break;
- case 9:
- [dataArray addObject:@{@"title":@"确认支付首付",@"state":@"1"}];
- break;
- default:
- break;
- }
- }
- }
- if (dataArray.count==0||dataArray.count>2) {
- _cancelintention.hidden = YES;
- _cancelintention1111.hidden = YES;
- }else if (dataArray.count==1) {
- [_cancelintention setTitle:dataArray[0][@"title"] forState:UIControlStateNormal];
- _cancelintention.hidden = NO;
- _cancelintention1111.hidden = YES;
- }else if (dataArray.count==2) {
- [_cancelintention setTitle:dataArray[0][@"title"] forState:UIControlStateNormal];
- [_cancelintention1111 setTitle:dataArray[1][@"title"] forState:UIControlStateNormal];
- _cancelintention.hidden = NO;
- _cancelintention1111.hidden = NO;
-
- }
- return view;
- }
- return [[UIView alloc] init];
- }
- #pragma mark ------操作按钮网络请求-----
- - (void)_cancelintentionclick:(UIButton*)button{
- NSString *str = [NSString stringWithFormat:@"是否%@?",button.titleLabel.text];
-
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:str preferredStyle:(UIAlertControllerStyleAlert)];
-
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *action) {
- [self faafa:button];
-
- }];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction *action) {
- //NSLog(@"取消");
- }];
- [alertController addAction:okAction];
- [alertController addAction:cancelAction];
- [self presentViewController:alertController animated:YES completion:nil];
- }
- - (void)faafa:(UIButton *)button{
- [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
- OrderdetailModel *model = dataArray[0];
- /*
- 拒绝意向 和 确认意向 调取 /api/user/order/confirmIntention
- */
- NSMutableDictionary *dic = NewMutableDictionaryInit;
- NSString *url;
- if ([button.titleLabel.text isEqualToString:@"取消订单"]) {
- [dic safeSetObject:model.orderNo forKey:@"orderNo"];
- url = JT_applyForCancel;//取消订单
- }else if ([button.titleLabel.text isEqualToString:@"支付首付"]){
- [dic safeSetObject:model.orderNo forKey:@"orderNo"];
- [dic safeSetObject:money forKey:@"fundAmount"];
- [dic safeSetObject:@"" forKey:@"remarks"];
- url = JT_payForFirst;//支付首付
- }else if ([button.titleLabel.text isEqualToString:@"支付尾款"]){
- [dic safeSetObject:model.orderNo forKey:@"orderNo"];
- [dic safeSetObject:money forKey:@"fundAmount"];
- [dic safeSetObject:@"" forKey:@"remarks"];
- url = JT_payForLast;//支付尾款
- }else if ([button.titleLabel.text isEqualToString:@"拒绝意向"]||[button.titleLabel.text isEqualToString:@"确认意向"]){
- [dic safeSetObject:model.orderNo forKey:@"orderNo"];
- if ([button.titleLabel.text isEqualToString:@"拒绝意向"]) {
- [dic safeSetObject:@"true" forKey:@"confirm"];
- }else{
- [dic safeSetObject:@"false" forKey:@"confirm"];
- }
- url = JT_confirmIntention;
- }else if ([button.titleLabel.text isEqualToString:@"提现"]){
- [dic safeSetObject:model.orderNo forKey:@"orderNo"];
- url = JT_applyForWithdraw;
- }
- [NetworkRequestManager requestPostWithInterfacePrefix:url parameters:dic onSuccess:^(id requestData) {
- [MBProgressHUD hideHUDForView:self.view];
- if ([requestData[@"error"] count] !=0) {
- for (NSDictionary *dic in requestData[@"error"]) {
- [MBProgressHUD showError:dic[@"message"] toView:self.view];
- }
- }else{
- if ([button.titleLabel.text isEqualToString:@"取消订单"]) {
- [MBProgressHUD showSuccess:@"取消订单成功" toView:self.view];
- }else if ([button.titleLabel.text isEqualToString:@"支付首付"]){
- [MBProgressHUD showSuccess:@"支付首付成功" toView:self.view];
- }else if ([button.titleLabel.text isEqualToString:@"支付尾款"]){
- [MBProgressHUD showSuccess:@"支付尾款成功" toView:self.view];
- }else if ([button.titleLabel.text isEqualToString:@"拒绝意向"]){
- [MBProgressHUD showSuccess:@"拒绝意向成功" toView:self.view];
- }else if ([button.titleLabel.text isEqualToString:@"确认意向"]){
- [MBProgressHUD showSuccess:@"确认意向成功" toView:self.view];
- }else if ([button.titleLabel.text isEqualToString:@"提现"]){
- [MBProgressHUD showSuccess:@"提现成功" toView:self.view];
- }
- //其它通过名门项目协议唤醒APP
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- NewPopViewController;
- });
- }
- } onFailure:^{
- [MBProgressHUD hideHUDForView:self.view];
- }];
- }
- #pragma mark -------查看业务流水--------
- - (void)flowingwaterBTclick:(UIButton *)sender {
- NSLog(@"%@",@"查看业务流水");
- BusinesswaterDetaiViewController *vc = [[BusinesswaterDetaiViewController alloc] init];
- vc.orderID = _orderID;
- NewPushViewController(vc);
- }
- - (void)textfieldclick:(UITextField *)textField {
- money = textField.text;
- NSLog(@"%@",textField.text);
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|