CheckOrderHeadView.swift 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // CheckOrderHeadView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/31.
  6. //
  7. import UIKit
  8. import SwiftyUserDefaults
  9. class CheckOrderHeadView: UIView {
  10. @IBOutlet weak var addressView: UIView!
  11. @IBOutlet weak var addAddressView: UIView!
  12. @IBOutlet weak var salesmanView: UIView!
  13. @IBOutlet weak var dateBackView: UIView!
  14. @IBOutlet weak var nameLab: UILabel!
  15. @IBOutlet weak var jieSuanBtn: UIButton!
  16. @IBOutlet weak var addressLab: UILabel!
  17. @IBOutlet weak var addAddressBtn: UIButton!
  18. @IBOutlet weak var addAdddressImg: UIImageView!
  19. /// 某天日期
  20. @IBOutlet weak var whichDayLab: UILabel!
  21. /// 包含类型 早中晚
  22. @IBOutlet weak var typeLab: UILabel!
  23. let dateView = Bundle.main.loadNibNamed("HomeDateView", owner: nil, options: nil)?.last as? HomeDateView
  24. var addAddressBlock : (()->Void)?
  25. var changeAddressBlock : (()->Void)?
  26. var payMentTouchBlock : (()->Void)?
  27. var selectBlock : ((_ model : HomeTimeItem)->Void)?
  28. var addresModel : AddressModel?
  29. override func awakeFromNib() {
  30. super.awakeFromNib()
  31. dateBackView.addSubview(self.dateView!)
  32. self.dateView?.isShowHead = false
  33. self.dateView?.dateScrollView.backgroundColor = UIColor.color(hex: "#EDEDED")
  34. self.dateView?.mas_remakeConstraints { make in
  35. make?.edges.mas_equalTo()(self.dateBackView)
  36. }
  37. self.jieSuanBtn.setTitle(LanguagesUtil.createTextBy(Ctext: "结算方式", Etext: "means of payments"), for: .normal)
  38. self.dateView?.selectBlock = {[weak self] model in
  39. if self?.selectBlock != nil{
  40. self?.selectBlock!(model)
  41. }
  42. }
  43. if Defaults[\.userType] === 1{
  44. self.salesmanView.isHidden = true
  45. }else{
  46. self.salesmanView.isHidden = false
  47. }
  48. }
  49. func setMeansOfPayments(model : PaySettleTypeModel){
  50. self.jieSuanBtn.setTitle("\(model.name ?? "")", for: .normal)
  51. }
  52. func configModel(dateModel : HomeTimeRangModel ){
  53. self.dateView?.configModel(dateModel: dateModel)
  54. }
  55. func configAddressModel(dateModel : AddressModel?){
  56. self.addresModel = dateModel
  57. if self.addresModel != nil{
  58. self.addAddressView.isHidden = true
  59. self.addressView.isHidden = false
  60. self.addressLab.text = "\(dateModel?.street ?? "")\(dateModel?.detailAddress ?? "")\(dateModel?.street ?? "")\(dateModel?.detailAddress ?? "")"
  61. self.nameLab.text = "\(dateModel?.receiving ?? "") \(dateModel?.phoneNum ?? "")"
  62. self.addressLab.sizeToFit()
  63. let labHeight : CGFloat = (self.addressLab.frame.size.height)
  64. if Defaults[\.userType] === 2{
  65. // self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 88 + 60 + 70 + labHeight + 25))
  66. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 60 + 44 + 104 - 20 + labHeight))
  67. }else{
  68. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 60 + 104 - 20 + labHeight))
  69. }
  70. }else{
  71. self.addAddressView.isHidden = false
  72. self.addressView.isHidden = true
  73. if Defaults[\.userType] === 2{
  74. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 60 + 88 + 25))
  75. }else{
  76. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 60 + 44 + 25))
  77. }
  78. }
  79. }
  80. @IBAction func meansOfPaymentsAction(_ sender: UIButton) {
  81. if self.payMentTouchBlock != nil{
  82. self.payMentTouchBlock!()
  83. }
  84. }
  85. @IBAction func addAddressAction(_ sender: UIButton) {
  86. if self.addAddressBlock != nil{
  87. self.addAddressBlock!()
  88. }
  89. }
  90. @IBAction func changeAddressAction(_ sender: UIButton) {
  91. if self.changeAddressBlock != nil{
  92. self.changeAddressBlock!()
  93. }
  94. }
  95. }