CNLiveDownSlideViewModel.swift
2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// CNLiveDownSlideViewModel.swift
// metaCode
//
// Created by zx on 2023/10/19.
//
import Foundation
import CNLiveRequestBastKit
enum CNLiveDownSlideResponseType {
case success
case failed
case noNetwork
case unkonw
}
typealias downSlideResultBlock = (_ result: Any,_ status:CNLiveDownSlideResponseType) -> Void
class CNLiveDownSlideViewModel:NSObject{
/// 获取下滑页原生页面数据
/// - Parameters:
/// - userId: 用户ID
/// - pageId: 页面ID
static func requestGetPage(pageId:NSString, resultBlock: @escaping downSlideResultBlock) {
let param = NSMutableDictionary()
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "userId")
param.setValue(pageId, forKey: "pageId")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseCMSUrl+"/contentApi/getPage", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["errorCode"] ?? "0")"
if (errorCode == "0") {
let downSlideModelArr = resp["data"] as! NSArray
var modelArray:[BaseModel] = []
for downSlideDic in downSlideModelArr {
let downSlideModel = newDictionaryToModel(downSlideDic as! [String : Any], CNLiveDownSlideModel.self)
modelArray.append(downSlideModel)
}
resultBlock(modelArray,.success)
}
else{
resultBlock(NSNull(),.failed)
}
}
}
}
}