IHGuestsVCtr.swift 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // IHGuestsVCtr.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2020/1/19.
  6. // Copyright © 2020 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHGuestsVCtr: UIViewController {
  10. @IBOutlet weak var imageView: UIImageView!
  11. @IBOutlet weak var box: UIView!
  12. @IBOutlet weak var locationBtn: UIButton!
  13. @IBOutlet weak var lightCountLabel
  14. : UILabel!
  15. @IBOutlet weak var SensorStatusLabel: UILabel!
  16. @IBOutlet weak var purStatusLabel: UILabel!
  17. var roomInfo:CustomerRoom?{
  18. didSet{
  19. if let roomInfo = self.roomInfo {
  20. if let image = roomInfo.image,let lightTotalCount = roomInfo.lightTotalCount,let lightCount = roomInfo.lightCount,let sensorOnline = roomInfo.sensorOnline,let purStatus = roomInfo.purStatus ,let location = roomInfo.location {
  21. imageView.netImage(url: image, placeholder: "编组")
  22. lightCountLabel.text = "\(lightCount)/\(lightTotalCount)"
  23. var sensorStatus = "Off-line"
  24. if sensorOnline == "0"{
  25. sensorStatus = "Off-line"
  26. }else if sensorOnline == "1"{
  27. sensorStatus = "On-line"
  28. }
  29. SensorStatusLabel.text = sensorStatus
  30. var purStr = "Enable"
  31. if purStatus == "0" {
  32. purStr = "Disable"
  33. }else if purStatus == "1"{
  34. purStr = "Enable"
  35. }
  36. purStatusLabel.text = purStr
  37. locationBtn.setTitle(location, for: .disabled)
  38. }
  39. }
  40. }
  41. }
  42. override func viewDidLoad() {
  43. super.viewDidLoad()
  44. setNavigationBar()
  45. createUI()
  46. IHAddressService.share.getFirstHotel { (hotelId, hotelName) in
  47. Intermediate.hotelId = hotelId!
  48. self.navigationBarTitle = hotelName
  49. }
  50. IHLoginService.share.GuestsRoom(requstSuccess: { (roomInfo) in
  51. self.roomInfo = roomInfo
  52. }) {
  53. }
  54. }
  55. func createUI() {
  56. let width : CGFloat = 325
  57. let height : CGFloat = 350
  58. let r : CGFloat = (width * 0.5 * width * 0.5 + 35 * 35 ) / (2 * 35)
  59. let path0 = UIBezierPath(rect: CGRect(x: 0, y: 0, width: width, height: height - 35))
  60. path0.addArc(withCenter: CGPoint(x: width * 0.5, y: height - r), radius: r, startAngle: 1 / 4 * .pi, endAngle: 3 / 4 * .pi, clockwise: true)
  61. let masklayer = CAShapeLayer()
  62. masklayer.frame = self.imageView.bounds
  63. masklayer.path = path0.cgPath
  64. self.imageView.layer.mask = masklayer
  65. box.allRoundShadow()
  66. }
  67. func setNavigationBar() {
  68. //导航栏的渲染方式
  69. self.navigationBarTitle = " "
  70. let mapItem = UIBarButtonItem(image: UIImage(named: "map")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(mapAction))
  71. let setItem = UIBarButtonItem(image: UIImage(named: "设置")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(setAction))
  72. let leftItem = UIBarButtonItem(image: UIImage(named: "定位")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(mapAction1))
  73. self.navigationItem.rightBarButtonItems = [mapItem,setItem]
  74. self.navigationItem.leftBarButtonItem = leftItem
  75. }
  76. @objc func setAction(){
  77. log.debug("点击了")
  78. log.debug("个人中心")
  79. let personalVC = IHPersonalCenterVCtr()
  80. self.navigationController?.pushViewController(personalVC, animated: true)
  81. }
  82. @objc func mapAction1(){
  83. log.debug("点击了")
  84. // let addressVC = IHAddressController()
  85. // addressVC.delegate = self
  86. // self.modal(addressVC, controllerHeight: 350)
  87. let picker = IHHotelPickerVCtr.shareInstance
  88. self.navigationController?.pushViewController(picker, animated: true)
  89. }
  90. @objc func mapAction(){
  91. log.debug("点击了")
  92. let map = IHDashboardMapMainVCtr()
  93. self.navigationController?.pushViewController(map, animated: true)
  94. }
  95. }
  96. extension IHGuestsVCtr:IHAddressControllerDelegate {
  97. func selectedAddress(address: String, addressID: String) {
  98. self.navigationBarTitle = address
  99. Intermediate.hotelId = addressID
  100. }
  101. }