// // OrderDetailFootView.swift // ADHTuanCan // // Created by 敖德亨 on 2023/11/8. // import UIKit class OrderDetailFootView: UIView { @IBOutlet weak var countLab: UILabel! @IBOutlet weak var priceLab: UILabel! @IBOutlet weak var orderNumLab: UILabel! ///下单时间 @IBOutlet weak var takeOrderTimeLab: UILabel! /// 结算方式 @IBOutlet weak var paySetLab: UILabel! @IBOutlet weak var tableView: UITableView! /// 原价 @IBOutlet weak var oldPriceLab: UILabel! /// 优惠价格 @IBOutlet weak var salePriceLab: UILabel! @IBOutlet weak var saleTableBackView: UIView! @IBOutlet weak var tableViewHeight: NSLayoutConstraint! var dataModel : OrderOutDetailModel? var dataSource : [SaleDetailModel]? /// hud 提示 lazy var hud : MCHud! = { return MCHud() }() override func awakeFromNib() { super.awakeFromNib() self.tableView.register(withType: SaleDetailViewCellTableViewCell.self) } func configModel(model : OrderOutDetailModel){ self.dataModel = model self.dataSource = model.mealPriceMsgs self.countLab.text = LanguagesUtil.createTextBy(Ctext: "共\(model.mealNum ?? "")件 合计S$", Etext: "There are \(model.mealNum ?? "") dishes,total S$") self.priceLab.text = "\(model.price ?? "")" self.orderNumLab.text = "\(model.orderNo ?? "")" self.takeOrderTimeLab.text = "\(model.createTime ?? "")" ///结算方式,1全款,2定金 if model.settleType === 1{ self.paySetLab.text = LanguagesUtil.createTextBy(Ctext: "全款", Etext: "full payment") }else{ self.paySetLab.text = LanguagesUtil.createTextBy(Ctext: "定金", Etext: "deposit") } self.oldPriceLab.text = "S$\(model.originalPrice ?? "")" self.salePriceLab.text = "S$\(model.discountAmount ?? "")" self.tableView.reloadData() if self.dataSource?.count ?? 0 > 0{ self.tableViewHeight.constant = CGFloat(60 + (self.dataSource?.count ?? 0) * 44) }else{ self.tableViewHeight.constant = 0 } self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height: 230 + self.tableViewHeight.constant)) } @IBAction func copyOrderNumAcTion(_ sender: UIButton) { let pastboard = UIPasteboard.general pastboard.string = "\(self.dataModel?.orderNo ?? "")" if !(pastboard.string.isEmptyStr){ print("%@",pastboard.string!) self.hud.showSuccess(LanguagesUtil.createTextBy(Ctext: "复制成功", Etext: "copy success")) } } @IBAction func checkSaleDetailAction(_ sender: UIButton) { } } extension OrderDetailFootView : UITableViewDelegate,UITableViewDataSource{ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.dataSource?.count ?? 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "SaleDetailViewCellTableViewCell") as! SaleDetailViewCellTableViewCell let model : SaleDetailModel = self.dataSource![indexPath.row] cell.configModel(model: model) return cell } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 0.01 } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return 0.01 } }