MealHeadView.swift 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // MealHeadView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/26.
  6. //
  7. import UIKit
  8. class MealHeadView: UIView {
  9. ///优惠图标
  10. @IBOutlet weak var saleImg: UIImageView!
  11. @IBOutlet weak var foodImg: UIImageView!
  12. @IBOutlet weak var nameLab: UILabel!
  13. @IBOutlet weak var describLab: UILabel!
  14. @IBOutlet weak var sellDetailLab: UILabel!
  15. @IBOutlet weak var scoreLab: UILabel!
  16. var evaluateActionBlock : (()->Void)?
  17. var lookBigPicBlock : (()->Void)?
  18. override func awakeFromNib() {
  19. super.awakeFromNib()
  20. // topConstraint.constant = kStatuBarHeight + 25
  21. }
  22. func configModel(model : SetMealDetailModel){
  23. self.foodImg.sd_setImage(url: URL.init(string: model.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
  24. self.nameLab.text = "\(model.name ?? "")"
  25. self.describLab.text = "\(model.sellingPoints ?? "")"
  26. self.sellDetailLab.text = "\(model.specialty ?? "")"
  27. self.scoreLab.text = "\(model.score ?? "")"
  28. let labHeight : CGFloat = (self.describLab.frame.size.height)
  29. if self.describLab.text.isNotEmptyStr{
  30. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:476 ))
  31. }else{
  32. self.setFrameSize(CGSize.init(width: kSCREEN_WIDTH, height:476 - 15 + labHeight ))
  33. }
  34. if model.disType === 1 || model.disType === 2 || model.disType === 3{
  35. self.saleImg.isHidden = false
  36. }else{
  37. self.saleImg.isHidden = true
  38. }
  39. if model.disType === 1{
  40. self.saleImg.image = UIImage(named: "优惠ICON")
  41. }
  42. if model.disType === 2{
  43. self.saleImg.image = UIImage(named: "折扣ICON")
  44. }
  45. if model.disType === 3{
  46. self.saleImg.image = UIImage(named: "活动ICON")
  47. }
  48. }
  49. @IBAction func evaluateAction(_ sender: UIButton) {
  50. if self.evaluateActionBlock != nil{
  51. self.evaluateActionBlock!()
  52. }
  53. }
  54. @IBAction func checkBigPic(_ sender: UIButton) {
  55. if self.lookBigPicBlock != nil{
  56. self.lookBigPicBlock!()
  57. }
  58. }
  59. }