IHHotelMapService.swift 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // IHHotelMapService.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2019/12/25.
  6. // Copyright © 2019 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHHotelMapService: NSObject {
  10. static let share = IHHotelMapService()
  11. deinit {
  12. log.debug("IHHotelMapService销毁")
  13. }
  14. ///获取首页概览列表
  15. func getHotelMapData(_ lng_low:String,lng_high:String, lat_low:String,lat_high:String,requestSuccess:@escaping ([HotelMapData])->Void,requestFail:@escaping (()->Void)) {
  16. let username = AppShare.username
  17. let client_key = AppShare.client_key
  18. let os = AppShare.os
  19. let version = AppShare.version
  20. let token = AppShare.token
  21. g_app_hotel_mapHttpRequest(username, client_key: client_key, os: os, version: version, token: token, lng_low: lng_low, lng_high: lng_high, lat_low: lat_low, lat_high: lat_high, success: { (json) -> (Void) in
  22. var hotelList = [HotelMapData]()
  23. let mHotelMapInfo = HotelMap_Info.fromJSON(json)
  24. let result = mHotelMapInfo?.result
  25. guard let list = result?.list else {return}
  26. for hotel in list {
  27. if let id = hotel.id,let name = hotel.name,let latitude = hotel.latitude,let longitude = hotel.longitude ,let roomCount = hotel.roomCount,let deviceCount = hotel.deviceCount,let lightCount = hotel.lightCount,let cicLightCount = hotel.cicLightCount,let sensorCount = hotel.sensorCount,let airPurCount = hotel.airPurCount,let aqi = hotel.aqi,let location = hotel.location,let countryId = hotel.countryId,let proId = hotel.proId,let cityId = hotel.cityId,let avatar = hotel.avatar {
  28. let aHotel = HotelMapData(id: id, name: name, longitude: longitude, latitude: latitude, roomCount: roomCount, deviceCount: deviceCount, lightCount: lightCount, cicLightCount: cicLightCount, sensorCount: sensorCount, airPurCount: airPurCount, aqi: aqi, location: location, countryId: countryId, proId: proId, cityId: cityId, avatar: avatar)
  29. hotelList.append(aHotel)
  30. }
  31. }
  32. requestSuccess(hotelList)
  33. }) { () -> (Void) in
  34. requestFail()
  35. }
  36. }
  37. }