12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- //
- // IHActivityService.swift
- // Inhealth
- //
- // Created by weclouds on 2019/12/24.
- // Copyright © 2019 weclouds. All rights reserved.
- //
- import UIKit
- class IHActivityService: NSObject {
- static let share = IHActivityService()
-
- lazy var loglist: [LogData] = {
- let loglist = [LogData]()
- return loglist
- }()
-
-
- deinit {
- NotificationCenter.default.removeObserver(self)
- }
- func getLoglist(_ page : Int,requestSuccess:((Bool,String?)->Void)?,requestFail:@escaping (()->Void)) {
- let username = AppShare.username
- let token = AppShare.token
- let os = AppShare.os
- let version = AppShare.version
- let client_key = AppShare.client_key
- let userId = AppShare.mLoginData?.id
- let count = 10
- g_operation_log_listHttpRequest(username, client_key: client_key, os: os, version: version, token: token, userId: userId!, page: page, count: count, success: { (json) -> (Void) in
- if page == 1{
- self.loglist.removeAll()
- }
- let mLoginInfo = Log_Info.fromJSON(json)
- let result = mLoginInfo?.result
- if result?.code == .Success{
- requestSuccess!(true,nil)
- }else{
- let msg = result?.msg
- requestSuccess!(false,msg)
- return
- }
- guard let _loglist = result?.list else{return}
-
- if page == 1 {
- self.loglist = _loglist
- }else{
- let total = (result?.total)!
- if self.loglist.count < total {
- self.loglist += _loglist
- }
- }
-
-
- NotificationCenter.default.post(name: NSNotification.Name(kNotifactionIHActivityHistoryViewGetlogList), object: self.loglist)
-
- }) { () -> (Void) in
-
- }
- }
-
-
- }
|