// // MyOrderDtialViewController.swift // xingchuangke // // Created by Apple on 2020/10/21. // Copyright © 2020 Virgil. All rights reserved. // import UIKit class MyOrderDtialViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var tableView: UITableView! var orderId = "" var arrTitle = ["订单编号:", "订单金额:", "订单运费:", "下单时间:", "付款时间:", "付款方式:", "快递公司:", "快递单号:"] var arrText = ["order_code", "total", "freight", "createtime", "paytime", "paytype", "courier_name", "courier_code"] var dataArray = NSArray.init() override func viewDidLoad() { super.viewDidLoad() self.title = "订单详情" initNavLeftBackButton() tableView.register(UINib(nibName: "MyOrderTableViewCell", bundle: nil), forCellReuseIdentifier: "MyOrderTableViewCell") tableView.delegate = self tableView.dataSource = self tableView.separatorStyle = .none tableView.showsVerticalScrollIndicator = false tableView.estimatedRowHeight = 100 self.view.addSubview(tableView) // Do any additional setup after loading the view. } func loadData() { let url = RequestURL.getProductOrderMain let params = NSMutableDictionary() params.setValue(orderId, forKey: "id") TloadDataInfo(url: url, params: params, tag: 1002) } override func returnData(tag: Int) { let dicPro = dicData["productOrderlist"] as! NSArray self.dataArray = dicPro tableView.reloadData() let fooerView = UIView.init() fooerView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: 500) fooerView.backgroundColor = .white tableView.tableFooterView = fooerView let okBtn = UIButton.init() okBtn.frame = CGRect(x: kScreenWidth/2-75, y: 10, width: 150, height: 30) okBtn.layer.cornerRadius = 15 okBtn.backgroundColor = .blue okBtn.addTarget(self, action: #selector(okBtnTouch(sender:)), for: .touchUpInside) fooerView.addSubview(okBtn) var num = 0 let status = getIntValue(key: "status", dic: dicData) if status == 0 { fooerView.setSizeHeight(height: 180+45*3+100) okBtn.setTitle("去支付", for: .normal) okBtn.tag = 1001 num = 3 } else if status == 1 { fooerView.setSizeHeight(height: 110+45*6+100) okBtn.isHidden = true num = 6 } else if status == 2 { fooerView.setSizeHeight(height: 180+45*8+300) okBtn.setTitle("确认收货", for: .normal) okBtn.tag = 1002 num = 8 } else if status == 3 { fooerView.setSizeHeight(height: 110+45*8+100) okBtn.isHidden = true num = 8 }else if status == -1 { fooerView.isHidden = true okBtn.isHidden = true SVProgressHUD.showError(withStatus: "数据错误无法查看相关信息") // num = 8 } fooerView.setSizeHeight(height: 900) tableView.contentSize = CGSize(width: kScreenWidth, height:CGFloat( 900+self.dataArray.count*101)) okBtn.setLocationY(y: CGFloat(90+45*num+20+20)) let lineLabel1 = UILabel.init() lineLabel1.frame = CGRect(x: 0, y: 0, width: Int(kScreenWidth), height: 10) lineLabel1.backgroundColor = UIColor.init(red: 242.0/255.0, green: 242/255.0, blue: 242/255.0, alpha: 1) fooerView.addSubview(lineLabel1) let lineLabel2 = UILabel.init() lineLabel2.frame = CGRect(x: 0, y: 100, width: Int(kScreenWidth), height: 10) lineLabel2.backgroundColor = UIColor.init(red: 242.0/255.0, green: 242/255.0, blue: 242/255.0, alpha: 1) fooerView.addSubview(lineLabel2) let addressView = UIView.init() addressView.frame = CGRect(x: 0, y: 10, width: kScreenWidth, height: 90) addressView.backgroundColor = .white fooerView.addSubview(addressView) let nameLabel = UILabel.init() nameLabel.frame = CGRect(x: 10, y: 10, width: 100, height: 30) nameLabel.text = getString(key: "linkname", dic: dicData) nameLabel.textAlignment = .left addressView.addSubview(nameLabel) let phoneLabel = UILabel.init() phoneLabel.frame = CGRect(x: kScreenWidth-150, y: 10, width: 140, height: 30) phoneLabel.text = getString(key: "linkphone", dic: dicData) phoneLabel.textAlignment = .right addressView.addSubview(phoneLabel) let addressTextView = UITextView.init() addressTextView.frame = CGRect(x: 15, y: 40, width: kScreenWidth-30, height: 40) addressTextView.text = getString(key: "linkaddress", dic: dicData) addressView.isUserInteractionEnabled = false addressTextView.textAlignment = .center addressTextView.font = UIFont.systemFont(ofSize: 14) addressView.addSubview(addressTextView) var height = 0 if getIntValue(key: "delivery_type", dic: dicData) == 1 { height = 0 addressView.isHidden = true lineLabel2.isHidden = true lineLabel1.isHidden = true // num = 6 } else { height = 110 lineLabel2.isHidden = false lineLabel1.isHidden = false } for i in 0.. Int { return 1 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.dataArray.count } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 101 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "MyOrderTableViewCell", for: indexPath as IndexPath) as! MyOrderTableViewCell cell.selectionStyle = .none let dic = self.dataArray[indexPath.row]as!NSDictionary cell.initCell(rowIndex: indexPath.row, dic: dic) return cell // return cell } @objc func btnContentClick(btn: UIButton) { let vc = CommonWebViewViewController() vc.strTitle = "快递详情" vc.url = "https://m.kuaidi100.com/result.jsp?nu=\(self.dicData["courier_code"]as!String)" toViewController(viewController: vc) } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let view = ShoppingMallDetailViewController() let dic = self.dataArray[indexPath.row]as!NSDictionary view.id = dic.getString(key: "product_id") self.navigationController?.pushViewController(view, animated: true) } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) loadData() } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "MyOrderDtialViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }