CNLiveVodPlayViewModel.swift
4.5 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// CNLiveVodPlayViewModel.swift
// metaCode
//
// Created by zx on 2025/3/19.
//
import Foundation
import CNLiveRequestBastKit
import CNLiveBusinessTools
class CNLiveVodPlayViewModel:NSObject,URLSessionTaskDelegate{
static let shared = CNLiveVodPlayViewModel()
/// 点赞
/// - Parameters:
/// - support: 是否点赞 0 取消 1点赞
static func vodSupport(contentId: String, support: Bool,resultBlock: @escaping downSlideResultBlock) {
let param = NSMutableDictionary()
param.setValue(contentId, forKey: "id")
param.setValue(support ? "1":"0", forKey: "support")
param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId")
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
param.setValue("i", forKey: "plat")
let custom_param = NSMutableDictionary()
custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId")
custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupShowResult(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/support/supportBySpId/insert", 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") {
resultBlock(support ? "点赞成功" : "取消点赞成功", .success)
} else {
//showMessage(message: resp["errorMessage"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "请求失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
/// 收藏
/// - Parameters:
/// type 1收藏 2取消收藏
static func vodCollection(type:String,vodPlayBlockListListModel:CNLiveVodPlayBlockListListModel,resultBlock: @escaping downSlideResultBlock) {
let param = NSMutableDictionary()
param.setValue(type, forKey: "type")
param.setValue("1", forKey: "model")
param.setValue(vodPlayBlockListListModel.contentId, forKey: "contentId")
param.setValue(vodPlayBlockListListModel.album?.albumId, forKey: "albumId")
param.setValue("yszg", forKey: "source")
param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId")
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
param.setValue("i", forKey: "plat")
let custom_param = NSMutableDictionary()
custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId")
custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupShowResult(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseCMSUrl+"/contentApi/collection", 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") {
resultBlock("成功", .success)
} else {
//showMessage(message: resp["errorMessage"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "请求失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
}