AddresViewCell.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // AddresViewCell.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/31.
  6. //
  7. import UIKit
  8. import SwiftyUserDefaults
  9. class AddresViewCell: UITableViewCell {
  10. @IBOutlet weak var haadImgView: UIImageView!
  11. @IBOutlet weak var nameLab: UILabel!
  12. @IBOutlet weak var phoneLab: UILabel!
  13. @IBOutlet weak var isDefualTypeLab: UILabel!
  14. @IBOutlet weak var postNumLab: UILabel!
  15. @IBOutlet weak var addressLab: UILabel!
  16. @IBOutlet weak var isDefualBtn: UIButton!
  17. var setDefualBlock : (()->Void)?
  18. var deleteBlock : (()->Void)?
  19. var addressModel : AddressModel?
  20. override func awakeFromNib() {
  21. super.awakeFromNib()
  22. // Initialization code
  23. }
  24. override func setSelected(_ selected: Bool, animated: Bool) {
  25. super.setSelected(selected, animated: animated)
  26. // Configure the view for the selected state
  27. }
  28. @IBAction func setDefualAction(_ sender: UIButton) {
  29. if self.setDefualBlock != nil{
  30. self.setDefualBlock!()
  31. }
  32. }
  33. @IBAction func deleteAction(_ sender: UIButton) {
  34. if self.deleteBlock != nil{
  35. self.deleteBlock!()
  36. }
  37. }
  38. func configModel(model : AddressModel){
  39. self.addressModel = model
  40. self.haadImgView.sd_setImage(url: URL.init(string: "\(Defaults[\.Avatar] ?? "")") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
  41. self.nameLab.text = "\(model.receiving ?? "")"
  42. self.phoneLab.text = "\(model.phoneNum ?? "")"
  43. if model.isDefault == "1"{
  44. self.isDefualTypeLab.isHidden = false
  45. self.isDefualBtn.isSelected = true
  46. }else{
  47. self.isDefualTypeLab.isHidden = true
  48. self.isDefualBtn.isSelected = false
  49. }
  50. self.addressLab.text = "\(model.detailAddress ?? "")"
  51. self.postNumLab.text = "\(model.postcode ?? "")"
  52. }
  53. }