// // CheckOrderHeadView.swift // ADHTuanCan // // Created by 敖德亨 on 2023/10/31. // import UIKit import SwiftyUserDefaults class CheckOrderHeadView: UIView { @IBOutlet weak var addressView: UIView! @IBOutlet weak var addAddressView: UIView! @IBOutlet weak var salesmanView: UIView! @IBOutlet weak var dateBackView: UIView! @IBOutlet weak var nameLab: UILabel! @IBOutlet weak var jieSuanBtn: UIButton! @IBOutlet weak var addressLab: UILabel! @IBOutlet weak var addAddressBtn: UIButton! @IBOutlet weak var addAdddressImg: UIImageView! /// 某天日期 @IBOutlet weak var whichDayLab: UILabel! /// 包含类型 早中晚 @IBOutlet weak var typeLab: UILabel! let dateView = Bundle.main.loadNibNamed("HomeDateView", owner: nil, options: nil)?.last as? HomeDateView var addAddressBlock : (()->Void)? var changeAddressBlock : (()->Void)? var payMentTouchBlock : (()->Void)? var selectBlock : ((_ model : HomeTimeItem)->Void)? var addresModel : AddressModel? override func awakeFromNib() { super.awakeFromNib() dateBackView.addSubview(self.dateView!) self.dateView?.isShowHead = false self.dateView?.dateScrollView.backgroundColor = UIColor.color(hex: "#EDEDED") self.dateView?.mas_remakeConstraints { make in make?.edges.mas_equalTo()(self.dateBackView) } self.jieSuanBtn.setTitle(LanguagesUtil.createTextBy(Ctext: "结算方式", Etext: "means of payments"), for: .normal) self.dateView?.selectBlock = {[weak self] model in if self?.selectBlock != nil{ self?.selectBlock!(model) } } if Defaults[\.userType] === 1{ self.salesmanView.isHidden = true }else{ self.salesmanView.isHidden = false } } func setMeansOfPayments(model : PaySettleTypeModel){ self.jieSuanBtn.setTitle("\(model.name ?? "")", for: .normal) } func configModel(dateModel : HomeTimeRangModel ){ self.dateView?.configModel(dateModel: dateModel) } func configAddressModel(dateModel : AddressModel?){ self.addresModel = dateModel if self.addresModel != nil{ self.addAddressView.isHidden = true self.addressView.isHidden = false self.addressLab.text = "\(dateModel?.street ?? "")\(dateModel?.detailAddress ?? "")\(dateModel?.street ?? "")\(dateModel?.detailAddress ?? "")" self.nameLab.text = "\(dateModel?.receiving ?? "") \(dateModel?.phoneNum ?? "")" self.addressLab.sizeToFit() let labHeight : CGFloat = (self.addressLab.frame.size.height) if Defaults[\.userType] === 2{ // self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 88 + 60 + 70 + labHeight + 25)) self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 60 + 44 + 104 - 20 + labHeight)) }else{ self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 60 + 104 - 20 + labHeight)) } }else{ self.addAddressView.isHidden = false self.addressView.isHidden = true if Defaults[\.userType] === 2{ self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 60 + 88 + 25)) }else{ self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:200 + 60 + 44 + 25)) } } } @IBAction func meansOfPaymentsAction(_ sender: UIButton) { if self.payMentTouchBlock != nil{ self.payMentTouchBlock!() } } @IBAction func addAddressAction(_ sender: UIButton) { if self.addAddressBlock != nil{ self.addAddressBlock!() } } @IBAction func changeAddressAction(_ sender: UIButton) { if self.changeAddressBlock != nil{ self.changeAddressBlock!() } } }