IHHotelMapManager.swift 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // IHHotelMapManager.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 IHHotelMapManager: NSObject ,IHViewManagerProtocolDelegate{
  10. // private var vc = UIViewController()
  11. private weak var vc : UIViewController?
  12. lazy var mainView: IHHotelMapView = {
  13. let mainView = IHHotelMapView()
  14. mainView.delegate = self
  15. return mainView
  16. }()
  17. deinit {
  18. log.debug("IHHotelMapManager销毁")
  19. }
  20. func bindController(_ vc: UIViewController) {
  21. self.vc = vc
  22. createUI()
  23. if let coordinate = Intermediate.share.selectedCoordinate {
  24. mainView.selectedCoordinate = coordinate
  25. }
  26. getAllHotelData()
  27. }
  28. func getAllHotelData() {
  29. DispatchQueue.global(qos: .background).async {//启动后台线程 //因为可能内容比较多 需要延时下载
  30. IHHotelMapService.share.getHotelMapData("-180", lng_high: "180", lat_low: "-90", lat_high: "90", requestSuccess: { (hotelDatas) in
  31. log.debug("搜索内容 -- \(hotelDatas)")
  32. DispatchQueue.main.async {// 回到主线程,通知数据h
  33. NotificationCenter.default.post(name: NSNotification.Name(kNotificationIHHotelMapViewGetAllHotelData), object: hotelDatas)
  34. }
  35. }) {
  36. }
  37. }
  38. }
  39. func createUI() {
  40. mainView.frame = CGRect(x: 0, y: 0, width: KSCREENWIDTH, height: KSCREENHEIGHT - 50 - KNavBarHeight)
  41. self.vc?.view.addSubview(mainView)
  42. }
  43. }
  44. extension IHHotelMapManager: IHHotelMapViewDelegate{
  45. func locationManagerDidFailWithError() {
  46. let alert = UIAlertController(title: "定位提示", message: "请在设置中打开定位", preferredStyle: .alert)
  47. let okAction = UIAlertAction(title: "打开定位", style: .default, handler: nil)
  48. let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: nil)
  49. alert.addAction(okAction)
  50. alert.addAction(cancelAction)
  51. self.vc?.present(alert, animated: true, completion: nil)
  52. }
  53. func getMapViewRegin(_ lat_low: String, long_low: String, lat_high: String, long_high: String) {
  54. }
  55. ///TODO :点击callout的处理事件
  56. func didSelectCalloutView(_ annotation: IHAnotation) {
  57. // NotificationCenter.default.post(name: NSNotification.Name(kNotificationIHDashboardManagerNotifyHotleInfo), object: annotation)
  58. // self.vc.navigationController?.popViewController(animated: true, nil)
  59. /*
  60. // let hotel = IHHistoryHotelModel(id: selectedHotel!.hotelId, name: selectedHotel!.hotelName)
  61. let hotel = IHHistoryHotelModel(id: selectedHotel!.hotelId, name: selectedHotel!.hotelName, countryId: Intermediate.countryId, countryName: Intermediate.countryName, provinceId: Intermediate.provinceId, provinceName: Intermediate.provinceName, cityId: Intermediate.cityId, cityName: Intermediate.cityName, buildId: Intermediate.buildId, buildName: Intermediate.buildName)
  62. IHHistroyPlist.share.addHotel(hotel)
  63. Intermediate.hotelId = selectedHotel!.hotelId
  64. Intermediate.hotelName = selectedHotel!.hotelName
  65. Intermediate.buildId = selectedBuid!.id!
  66. Intermediate.buildName = selectedBuid!.name!
  67. let info = StorageInfo(countryId: Intermediate.countryId, countryName: Intermediate.countryName, provinceId: Intermediate.provinceId, provinceName: Intermediate.provinceName, cityId: Intermediate.cityId, cityName: Intermediate.cityName, hotelId: Intermediate.hotelId, hotelName: Intermediate.hotelName, buildId: Intermediate.buildId, buildName: Intermediate.buildName)
  68. IHHotelStorage.shareInstance.storageHotelInfo(info)
  69. NotificationCenter.default.post(name: NSNotification.Name(kNotificationIHAddressControllerReloadAddress), object: nil)
  70. NotificationCenter.default.post(name: NSNotification.Name(kNotifactionIHTabBarControllerUpdateBadgeNumber), object: Intermediate.hotelId)
  71. self.dismiss(animated: true, completion: nil)
  72. if let block = self.completion {
  73. NotificationCenter.default.post(name: NSNotification.Name(kNotifactionIHHotelPickerViewGetHistory), object: nil)
  74. block()
  75. isClickBuild = false
  76. }
  77. */
  78. }
  79. }