OOMeetingRoomDetailViewModel.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // OOMeetingRoomDetailViewModel.swift
  3. // o2app
  4. //
  5. // Created by 刘振兴 on 2018/1/22.
  6. // Copyright © 2018年 zone. All rights reserved.
  7. //
  8. import UIKit
  9. class OOMeetingRoomDetailViewModel: NSObject {
  10. //HTTP API
  11. private let o2MeetingAPI = OOMoyaProvider<O2MeetingAPI>()
  12. //
  13. var ooMeetingRoomInfo:OOMeetingRoomInfo?{
  14. didSet {
  15. }
  16. }
  17. //回调块类型定义
  18. typealias CallbackBlockDefine = (_ msg:String?) -> Void
  19. //回调块定义
  20. var callbackExecutor:CallbackBlockDefine?
  21. override init() {
  22. super.init()
  23. }
  24. func refreshData(){
  25. guard let block = callbackExecutor else {
  26. return
  27. }
  28. block(nil)
  29. }
  30. }
  31. // MARK:- UITableView DataSource
  32. extension OOMeetingRoomDetailViewModel{
  33. func numberOfSections() -> Int {
  34. return 2
  35. }
  36. func numberOfRowsInSection(_ section: Int) -> Int {
  37. if section == 0 {
  38. return 1
  39. }else if(section == 1){
  40. return (ooMeetingRoomInfo?.meetingList?.count) ?? 0
  41. }
  42. return 0
  43. }
  44. func nodeForIndexPath(_ indexPath:IndexPath) -> DataModel? {
  45. if indexPath.section == 0 {
  46. return ooMeetingRoomInfo
  47. }else if(indexPath.section == 1){
  48. return ooMeetingRoomInfo?.meetingList![indexPath.row]
  49. }
  50. return nil
  51. }
  52. }