// // OrderDetailViewController.swift // ADHTuanCan // // Created by 敖德亨 on 2023/11/6. // import UIKit import RxSwift import RxCocoa import StripePaymentSheet class OrderDetailViewController: ADHBaseVC { @IBOutlet weak var topCont: NSLayoutConstraint! @IBOutlet weak var tableView: UITableView! /// 订单ID var orderId : NSNumber?{ didSet{ self.viewModel.getOrderDetailModel.id = orderId } } /// 购物车ID var shopcartId : NSNumber?{ didSet{ self.viewModel.getOrderDetailModel.id = shopcartId } } let viewModel : OrderViewModel = OrderViewModel.init() let diposableBag = DisposeBag() let headView = Bundle.main.loadNibNamed("OderDetailHeadView", owner: nil, options: nil)?.last as? OderDetailHeadView let footView = Bundle.main.loadNibNamed("OrderDetailFootView", owner: nil, options: nil)?.last as? OrderDetailFootView /// 当前选中支付方式 var payMentModel : PayMentTypeModel? /// 支付配置参数 后台返回 var clientSecret : String! /// 支付使用商户名 var merchantDisplayName : String! /// StripeSDK 类 var paymentSheet: PaymentSheet? ///支付方式 let userPayTypeView = Bundle.main.loadNibNamed("UserPayMentSheet", owner: nil, options: nil)?.last as? UserPayMentSheet /// 密码支付View let pswPayView = Bundle.main.loadNibNamed("PswPayView", owner: nil, options: nil)?.last as? PswPayView ///呼叫客服 let callView = Bundle.main.loadNibNamed("phoneCallView", owner: nil, options: nil)?.last as? phoneCallView ///修改地址 let addrView = Bundle.main.loadNibNamed("selectAddressView", owner: nil, options: nil)?.last as? selectAddressView var section : [[ShopMealMsgDetailModel]?]? override func viewDidLoad() { super.viewDidLoad() // self.view.backgroundColor = kTBackgroundColor self.navBar = MCNavBarView.init(title: LanguagesUtil.createTextBy(Ctext: "订单详情", Etext: "Order detail"), subTitle: nil) self.topCont.constant = kNavAndStatuHeight // Do any additional setup after loading the view. self.tableView.register(withType: OrderReadyCell.self) self.tableView.contentInsetAdjustmentBehavior = .never self.tableView.tableHeaderView = self.headView self.tableView.tableFooterView = self.footView // self.tableView.backgroundColor = UIColor.clear self.headView?.isHidden = true self.footView?.isHidden = true ///type = 1去支付 2修改地址 3再来一单 4确认收货 5去评价 6联系商家 7取消订单 self.headView?.headBtnBlock = {[unowned self] type in if type == 1{ self.userPayTypeView?.priceLab.text = "\(self.viewModel.orderOutDataModel?.price ?? "")" self.getPayMent() } if type == 2{ self.addrView?.show() } if type == 3{ } if type == 4{ self.confirmReceipt() } if type == 5{ let vc = AddEvaluateViewController() vc.orderId = self.orderId self.navigationController?.pushViewController(vc, animated: true) } if type == 6{ self.callView?.showWithPhone(phoneNum: "123") } if type == 7{ self.cancelOrder() } } //去支付 self.userPayTypeView?.payTypeBlock = {[weak self] model in self?.payMentModel = model self?.getIsStripePay() } //密码支付 self.pswPayView?.pswPayBlock = {[weak self] str in self?.pswPayAction(psw: str) } //选择地址保存 self.addrView?.saveBlock = {[unowned self] model in self.editOrderAddress(addModel: model) } //去添加地址 self.addrView?.addAddressBlock = {[weak self] in let vc = AddressEditorVC() self?.navigationController?.pushViewController(vc, animated: true) } //去修改地址 shopcartId绑定购物车的地址 self.addrView?.editAddressBlock = {[unowned self] model in let vc = AddressEditorVC() vc.configDefualData(model: model) self.navigationController?.pushViewController(vc, animated: true) } self.getData() } func getData(){ self.hud.showLoading() self.viewModel.signalGetOrderDetail()?.on(success: { dd in self.hud.hidden() self.headView?.isHidden = false self.footView?.isHidden = false self.headView?.configModel(model: self.viewModel.orderOutDataModel!) self.footView?.configModel(model: self.viewModel.orderOutDataModel!) self.section = [] if let _ = self.viewModel.orderOutDataModel?.timeVoList{ for item in self.viewModel.orderOutDataModel!.timeVoList! { var list : [ShopMealMsgDetailModel]? = [] let DetailModel : OrderDetailModel = item if let _ = DetailModel.orderInsideMsgs{ for item1 in DetailModel.orderInsideMsgs!{ let insideMsgsModel = item1 let zzwdata : [ShopMealMsgDetailModel] = insideMsgsModel.orderMealMsgVos! for i in 0.. Int { let modelList = self.section![section] return modelList?.count ?? 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withType: OrderReadyCell.self) let modelList = self.section![indexPath.section] let model : ShopMealMsgDetailModel = modelList![indexPath.row] cell.configModel(model: model, isfirstLine: model.isFistLine) return cell } func numberOfSections(in tableView: UITableView) -> Int { return self.section?.count ?? 0 } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let dayModel : OrderDetailModel = (self.viewModel.orderOutDataModel?.timeVoList![section])! let sectionView = Bundle.main.loadNibNamed("OrderDetailSectionView", owner: nil, options: nil)?.last as? OrderDetailSectionView sectionView?.configModel(model: dayModel) return sectionView } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 50 } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return 0.01 } }