OrderDetailFootView.swift 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // OrderDetailFootView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/11/8.
  6. //
  7. import UIKit
  8. class OrderDetailFootView: UIView {
  9. @IBOutlet weak var countLab: UILabel!
  10. @IBOutlet weak var priceLab: UILabel!
  11. @IBOutlet weak var orderNumLab: UILabel!
  12. ///下单时间
  13. @IBOutlet weak var takeOrderTimeLab: UILabel!
  14. /// 结算方式
  15. @IBOutlet weak var paySetLab: UILabel!
  16. @IBOutlet weak var tableView: UITableView!
  17. /// 原价
  18. @IBOutlet weak var oldPriceLab: UILabel!
  19. /// 优惠价格
  20. @IBOutlet weak var salePriceLab: UILabel!
  21. @IBOutlet weak var saleTableBackView: UIView!
  22. @IBOutlet weak var tableViewHeight: NSLayoutConstraint!
  23. var dataModel : OrderOutDetailModel?
  24. var dataSource : [SaleDetailModel]?
  25. /// hud 提示
  26. lazy var hud : MCHud! = {
  27. return MCHud()
  28. }()
  29. override func awakeFromNib() {
  30. super.awakeFromNib()
  31. self.tableView.register(withType: SaleDetailViewCellTableViewCell.self)
  32. }
  33. func configModel(model : OrderOutDetailModel){
  34. self.dataModel = model
  35. self.dataSource = model.mealPriceMsgs
  36. self.countLab.text = LanguagesUtil.createTextBy(Ctext: "共\(model.mealNum ?? "")件 合计S$", Etext: "There are \(model.mealNum ?? "") dishes,total S$")
  37. self.priceLab.text = "\(model.price ?? "")"
  38. self.orderNumLab.text = "\(model.orderNo ?? "")"
  39. self.takeOrderTimeLab.text = "\(model.createTime ?? "")"
  40. ///结算方式,1全款,2定金
  41. if model.settleType === 1{
  42. self.paySetLab.text = LanguagesUtil.createTextBy(Ctext: "全款", Etext: "full payment")
  43. }else{
  44. self.paySetLab.text = LanguagesUtil.createTextBy(Ctext: "定金", Etext: "deposit")
  45. }
  46. self.oldPriceLab.text = "S$\(model.originalPrice ?? "")"
  47. self.salePriceLab.text = "S$\(model.discountAmount ?? "")"
  48. self.tableView.reloadData()
  49. if self.dataSource?.count ?? 0 > 0{
  50. self.tableViewHeight.constant = CGFloat(60 + (self.dataSource?.count ?? 0) * 44)
  51. }else{
  52. self.tableViewHeight.constant = 0
  53. }
  54. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height: 230 + self.tableViewHeight.constant))
  55. }
  56. @IBAction func copyOrderNumAcTion(_ sender: UIButton) {
  57. let pastboard = UIPasteboard.general
  58. pastboard.string = "\(self.dataModel?.orderNo ?? "")"
  59. if !(pastboard.string.isEmptyStr){
  60. print("%@",pastboard.string!)
  61. self.hud.showSuccess(LanguagesUtil.createTextBy(Ctext: "复制成功", Etext: "copy success"))
  62. }
  63. }
  64. @IBAction func checkSaleDetailAction(_ sender: UIButton) {
  65. }
  66. }
  67. extension OrderDetailFootView : UITableViewDelegate,UITableViewDataSource{
  68. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  69. return self.dataSource?.count ?? 0
  70. }
  71. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  72. let cell = tableView.dequeueReusableCell(withIdentifier: "SaleDetailViewCellTableViewCell") as! SaleDetailViewCellTableViewCell
  73. let model : SaleDetailModel = self.dataSource![indexPath.row]
  74. cell.configModel(model: model)
  75. return cell
  76. }
  77. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  78. return 0.01
  79. }
  80. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  81. }
  82. func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
  83. return 0.01
  84. }
  85. }