IHCallView.swift 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // IHCallView.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2019/12/13.
  6. // Copyright © 2019 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHCallView: UIView {
  10. var didSelectedCallout:(()->Void)?
  11. var hotelData:HotelMapData?{
  12. didSet{
  13. if let data = self.hotelData{
  14. if let location = data.location ,let avatar = data.avatar,let purifiers = data.airPurCount,let sensors = data.sensorCount,let lights = data.lightCount,let cirLights = data.cicLightCount,let hotelname = data.name{
  15. self.address = location
  16. self.imageName = avatar
  17. self.purifiersCount.text = purifiers
  18. self.sensorsCount.text = sensors
  19. self.lightsCount.text = lights
  20. self.cirLightsCount.text = cirLights
  21. self.hotelName = hotelname
  22. }
  23. }
  24. }
  25. }
  26. var imageName :String?{
  27. didSet{
  28. if let imageName = self.imageName {
  29. hotelIcon.netImage(url: imageName, placeholder: "酒店头像")
  30. }
  31. }
  32. }
  33. deinit {
  34. log.debug("IHCallView销毁")
  35. }
  36. var hotelName :String?{
  37. didSet{
  38. hotelNameLabel.text = self.hotelName
  39. }
  40. }
  41. var address :String?{
  42. didSet{
  43. addressLabel.text = self.address
  44. }
  45. }
  46. @IBOutlet private weak var touchView: UIView!
  47. var closeCallback:(()->Void)?
  48. @IBOutlet private weak var purifiersCount:UILabel!
  49. @IBOutlet private weak var sensorsCount:UILabel!
  50. @IBOutlet private weak var lightsCount:UILabel!
  51. @IBOutlet private weak var cirLightsCount:UILabel!
  52. @IBOutlet private weak var hotelIcon: UIImageView!
  53. @IBOutlet private weak var hotelNameLabel: UILabel!
  54. @IBOutlet private weak var addressLabel: UILabel!
  55. override func awakeFromNib() {
  56. super.awakeFromNib()
  57. touchView.isUserInteractionEnabled = true
  58. let tap = UITapGestureRecognizer(target: self, action: #selector(tapViewAction))
  59. touchView.addGestureRecognizer(tap)
  60. }
  61. @objc func tapViewAction() {
  62. log.debug("tapViewAction")
  63. didSelectedCallout!()
  64. }
  65. @IBAction private func closeAction(_ sender: Any) {
  66. if let callback = self.closeCallback {
  67. callback()
  68. }
  69. }
  70. }