IHPanelService.swift 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // IHPanelService.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2020/7/28.
  6. // Copyright © 2020 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHPanelService: NSObject {
  10. //单例
  11. static let share = IHPanelService()
  12. let username = AppShare.username
  13. let client_key = AppShare.client_key
  14. let os = AppShare.os
  15. let token = AppShare.token
  16. let version = AppShare.version
  17. //获取窗帘的数据
  18. func getSchoolPanelModel(id: String, complete:@escaping( _ panelModel_info : PanelModel_info?) -> Void) {
  19. net_school_get_panel_mode(username: self.username, client_key: self.client_key, os: self.os, version: self.version, token: self.token, id: id, success: { (json) -> (Void) in
  20. let panelModeInfo = PanelModel_info.fromJSON(json)
  21. complete(panelModeInfo)
  22. }) { () -> (Void) in
  23. }
  24. }
  25. //设置窗帘的数据
  26. func setSchoolPanelModel(id: String, key1: String, key2: String, key3: String, key4: String, key5: String, key6: String,compelete:@escaping (_ respone: String?, _ code : String?) -> Void) {
  27. IHWebSocketManager.shareInstance().schoolDeviceOpation(isSchool: true) { (isSuccess, responeStr,code) in
  28. if isSuccess == 2 {
  29. log.debug("websocket面板返回的数据")
  30. compelete(responeStr, code)
  31. }else{
  32. net_school_set_panel_mode(username: self.username, client_key: self.client_key, os: self.os, version: self.version, token: self.token, id: id, key1: key1, key2: key2, key3: key3, key4: key4, key5: key5, key6: key6, clientId: responeStr, success: { (json) -> (Void) in
  33. }) { () -> (Void) in
  34. }
  35. }
  36. }
  37. }
  38. }