// // IHHotelMapManager.swift // Inhealth // // Created by weclouds on 2019/12/13. // Copyright © 2019 weclouds. All rights reserved. // import UIKit class IHHotelMapManager: NSObject ,IHViewManagerProtocolDelegate{ // private var vc = UIViewController() private weak var vc : UIViewController? lazy var mainView: IHHotelMapView = { let mainView = IHHotelMapView() mainView.delegate = self return mainView }() deinit { log.debug("IHHotelMapManager销毁") } func bindController(_ vc: UIViewController) { self.vc = vc createUI() if let coordinate = Intermediate.share.selectedCoordinate { mainView.selectedCoordinate = coordinate } getAllHotelData() } func getAllHotelData() { DispatchQueue.global(qos: .background).async {//启动后台线程 //因为可能内容比较多 需要延时下载 IHHotelMapService.share.getHotelMapData("-180", lng_high: "180", lat_low: "-90", lat_high: "90", requestSuccess: { (hotelDatas) in log.debug("搜索内容 -- \(hotelDatas)") DispatchQueue.main.async {// 回到主线程,通知数据h NotificationCenter.default.post(name: NSNotification.Name(kNotificationIHHotelMapViewGetAllHotelData), object: hotelDatas) } }) { } } } func createUI() { mainView.frame = CGRect(x: 0, y: 0, width: KSCREENWIDTH, height: KSCREENHEIGHT - 50 - KNavBarHeight) self.vc?.view.addSubview(mainView) } } extension IHHotelMapManager: IHHotelMapViewDelegate{ func locationManagerDidFailWithError() { let alert = UIAlertController(title: "定位提示", message: "请在设置中打开定位", preferredStyle: .alert) let okAction = UIAlertAction(title: "打开定位", style: .default, handler: nil) let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: nil) alert.addAction(okAction) alert.addAction(cancelAction) self.vc?.present(alert, animated: true, completion: nil) } func getMapViewRegin(_ lat_low: String, long_low: String, lat_high: String, long_high: String) { } ///TODO :点击callout的处理事件 func didSelectCalloutView(_ annotation: IHAnotation) { // NotificationCenter.default.post(name: NSNotification.Name(kNotificationIHDashboardManagerNotifyHotleInfo), object: annotation) // self.vc.navigationController?.popViewController(animated: true, nil) /* // let hotel = IHHistoryHotelModel(id: selectedHotel!.hotelId, name: selectedHotel!.hotelName) 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) IHHistroyPlist.share.addHotel(hotel) Intermediate.hotelId = selectedHotel!.hotelId Intermediate.hotelName = selectedHotel!.hotelName Intermediate.buildId = selectedBuid!.id! Intermediate.buildName = selectedBuid!.name! 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) IHHotelStorage.shareInstance.storageHotelInfo(info) NotificationCenter.default.post(name: NSNotification.Name(kNotificationIHAddressControllerReloadAddress), object: nil) NotificationCenter.default.post(name: NSNotification.Name(kNotifactionIHTabBarControllerUpdateBadgeNumber), object: Intermediate.hotelId) self.dismiss(animated: true, completion: nil) if let block = self.completion { NotificationCenter.default.post(name: NSNotification.Name(kNotifactionIHHotelPickerViewGetHistory), object: nil) block() isClickBuild = false } */ } }