CNLiveShortVideoViewModel.swift 27.9 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555
//
//  CNLiveShortVideoViewModel.swift
//  metaCode
//
//  Created by open on 2024/1/8.
//

import Foundation
import CNLiveRequestBastKit
import QMUIKit
typealias resultShortVideoBlock = (_ result: Any,_ respStatue :CNLiveMineResponseType) -> Void
class CNLiveShortVideoViewModel: NSObject {
    
    /// 获取短视频数据
    /// - Parameters:
    ///   - aid: 专辑 id
    ///   - reultShortVideoBlock: 返回
    static func requstWithShortVideo(aid: String,page: NSInteger,reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        param.setValue(aid, forKey: "aid")
        param.setValue("", forKey: "app_channel_id")
        param.setValue("\(page)", forKey: "page")
        param.setValue("10", forKey: "pageSize")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        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.setupCustomParam(custom_param as? [String : String])
        CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseCMSUrl+"/ugcApi/albumList", 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") {
                    if resp["data"] is NSNull {
                        reultShortVideoBlock(NSNull(), .failed)
                    } else {
                        CNLiveShortVideoViewModel.requstWithAlbumMsgVideo(aid: aid) { result, respStatue in
                            if respStatue == .success {
                                let resp_dict = resp["data"] as! NSDictionary
                                let array = resp_dict["list"] as! NSArray
                                let tempArray = NSMutableArray()
                                let tempUrlArray = NSMutableArray()
                                for item in array {
                                    let listModel = dictionaryToModel(item as! [String : Any], CNLiveAlbumListModel.self,"") as! CNLiveAlbumListModel
                                    listModel.albumMsgModel = result as? CNLiveAlbumMsgModel
                                    tempArray.add(listModel)
                                    tempUrlArray.add(listModel.videoUrl as String)
                                }
                                reultShortVideoBlock([tempArray, resp_dict["hasNextPage"], tempUrlArray], .success)
                            } else {
                                let resp_dict = resp["data"] as! NSDictionary
                                let array = resp_dict["list"] as! NSArray
                                let tempArray = NSMutableArray()
                                let tempUrlArray = NSMutableArray()
                                for item in array {
                                    let listModel = dictionaryToModel(item as! [String : Any], CNLiveAlbumListModel.self,"") as! CNLiveAlbumListModel
                                    tempArray.add(listModel)
                                    tempUrlArray.add(listModel.videoUrl as String)
                                }
                                reultShortVideoBlock([tempArray, resp_dict["hasNextPage"], tempUrlArray], .success)
                            }
                        }
                    }
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    ///  获取专辑信息接口
    /// - Parameters:
    ///   - aid: 专辑名称
    ///   - reultShortVideoBlock: 返回
    static func requstWithAlbumMsgVideo(aid: String,reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        param.setValue(aid, forKey: "aid")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        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.setupCustomParam(custom_param as? [String : String])
        CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseCMSUrl+"/contentApi/getAlbumMsg", param: param as! [String : Any], cacheType: .networkOnly) { task, result, error in
            hiddenLoading()
            if (error == nil) {
                let resp = result as! NSDictionary
                let errorCode = "\(resp["errorCode"] ?? "0")"
                if (errorCode == "0") {
                    if resp["data"] is NSNull {
                        reultShortVideoBlock(NSNull(), .failed)
                    } else {
                        let listModel = dictionaryToModel(resp["data"] as! [String : Any], CNLiveAlbumMsgModel.self,"") as! CNLiveAlbumMsgModel
                        reultShortVideoBlock(listModel, .success)
                    }
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    
    /// 短视频点赞分享功能
    /// - Parameters:
    ///   - contentId: 点赞内容 id
    ///   - contentTitle: 点赞的视频标题
    ///   - support: 1:点赞 0:取消点赞
    ///   - isShare: 是否是分享
    ///   - reultShortVideoBlock: 返回
    static func requestRankWithLike(contentId: String, contentTitle: String, contentSid: String, support: Bool,isShare: Bool,reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        if isShare {
            param.setValue("\(contentId)_share", forKey: "contentId")
            param.setValue("1", forKey: "support")
        } else {
            param.setValue(contentId, forKey: "contentId")
            param.setValue(support ? "0":"1", forKey: "support")
        }
        param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        param.setValue(contentTitle, forKey: "contentTitle")
        param.setValue(contentSid, forKey: "contentSid")
        param.setValue("false", forKey: "isRank")
        param.setValue("1", forKey: "isUgc")
        param.setValue("i", forKey: "plat")
        param.setValue("", forKey: "contentTag")
        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/supportBySpIdForRank/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") {
                    if isShare {
                        reultShortVideoBlock("分享成功", .success)
                    } else {
                        reultShortVideoBlock(support ? "取消点赞成功" : "点赞成功", .success)
                    }
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    /// 对专辑进行收藏
    /// - Parameters:
    ///   - aid: 专辑 id
    ///   - type: 是否收藏
    ///   - reultShortVideoBlock: 返回
    static func requestCollect(aid: String, type: Bool,reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        param.setValue(aid, forKey: "aid")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        param.setValue(type ? "2": "1", forKey: "type")
        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.setupShowDataResult(true)
        CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
        CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseCMSUrl+"/contentApi/albumCollect", 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") {
                    reultShortVideoBlock(type ? "取消收藏成功" : "收藏成功", .success)
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    
    
    //!!!: 评论相关
    
    /// 获取评论列表数
    /// - Parameters:
    ///   - pid: 视频 pid
    ///   - page: 页数
    ///   - reultShortVideoBlock: 返回
    static func requestCommentList(pid: String,page: NSInteger,reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        param.setValue(pid, forKey: "topicId")
        param.setValue("i", forKey: "plat")
        param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        param.setValue("\(page)", forKey: "seqId")
        param.setValue("10", forKey: "count")
        let custom_param = NSMutableDictionary()
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey, forKey: "appKey")
        CNLiveNetworking.setAllowRequestDefaultArgument(true)
        CNLiveNetworking.setupShowDataResult(false)
        CNLiveNetworking.setupShowResult(true)
        CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
        CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/loadUgcComments", 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") {
                    if resp["data"] is NSNull {
                        reultShortVideoBlock(NSNull(), .failed)
                    } else {
                        let listModel = dictionaryToModel(resp["data"] as! [String : Any], ShortVideoHomeCommentModel.self,"") as! ShortVideoHomeCommentModel
                        reultShortVideoBlock(listModel, .success)
                    }
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    /// 发布评论
    /// - Parameters:
    ///   - videoId: 视频 id
    ///   - comment: 评论内容
    ///   - isAuthor: 是否是作者
    ///   - reultShortVideoBlock: 返回
    static func requestCommentWithSend(videoId: String, comment: String, isAuthor: Bool,reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        param.setValue(videoId, forKey: "topicId")
        param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        param.setValue("i", forKey: "plat")
        param.setValue(comment.qmui_trim, forKey: "comment")
        param.setValue(isAuthor ? "1" :  "0", forKey: "isAuthor")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        let custom_param = NSMutableDictionary()
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey, forKey: "appKey")
        CNLiveNetworking.setAllowRequestDefaultArgument(true)
        CNLiveNetworking.setupShowDataResult(false)
        CNLiveNetworking.setupDSRequest(false)
        CNLiveNetworking.setupShowResult(true)
        CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
        CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/insertComment", param: param as? [AnyHashable : Any], cacheType: .networkOnly) { task, result, error in
            hiddenLoading()
            if (error == nil) {
                let resp = result as! NSDictionary
                let errorCode = "\(resp["errorCode"] ?? "0")"
                if (errorCode == "0") {
                    reultShortVideoBlock("评论成功", .success)
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    
    /// 对评论进行回复
    /// - Parameters:
    ///   - commentId: 评论 id
    ///   - comment: 评论内容
    ///   - toSid: 被回复者ID
    ///   - fromSid: 回复者ID
    ///   - level: 1:一级评论回复 2:二级评论回复
    ///   - reultShortVideoBlock: 返回
    static func requestCommentWithReply(commentId: String, comment: String, toSid: String, fromSid: String, level: String,reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        param.setValue(commentId, forKey: "commentId")
        param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        param.setValue(comment, forKey: "comment")
        param.setValue(toSid, forKey: "toSid")
        param.setValue(fromSid, forKey: "fromSid")
        param.setValue(level, forKey: "level")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        let custom_param = NSMutableDictionary()
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey, forKey: "appKey")
        CNLiveNetworking.setAllowRequestDefaultArgument(true)
        CNLiveNetworking.setupShowDataResult(false)
        CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
        CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/insertReply", 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") {
                    reultShortVideoBlock("回复成功", .success)
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    
    /// 获取回复数据列表
    /// - Parameters:
    ///   - commentId: 评论 id
    ///   - page: 页数
    ///   - reultShortVideoBlock: 返回
    static func requestcommentWithReplyList(commentId: String,seqId: Int,reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        param.setValue(commentId, forKey: "commentId")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        param.setValue("i", forKey: "plat")
        param.setValue("\(seqId)", forKey: "seqId")//从 时间戳 开始
        param.setValue("10", forKey: "count")
        let custom_param = NSMutableDictionary()
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey, forKey: "appKey")
        CNLiveNetworking.setAllowRequestDefaultArgument(true)
        CNLiveNetworking.setupShowDataResult(false)
        CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
        CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/loadReplys", 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") {
                    if resp["data"] is NSNull {
                        reultShortVideoBlock(NSNull(), .failed)
                    } else {
                        let resp_dict = resp["data"] as! NSDictionary
                        let resp_reply_dict = resp_dict["replyData"] as! NSDictionary
                        if resp_reply_dict["replys"] != nil {
                            let array = resp_reply_dict["replys"] as! NSArray
                            let tempArray = NSMutableArray()
                            for item in array {
                                let listModel = dictionaryToModel(item as! [String : Any], ShortVideoHomeCommentRListItemModel.self,"") as! ShortVideoHomeCommentRListItemModel
                                tempArray.add(listModel)
                            }
                            reultShortVideoBlock(tempArray, .success)
                        } else {
                            reultShortVideoBlock(Array<Any>(), .success)
                        }
                    }
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    /// 删除评论
    /// - Parameters:
    ///   - videoId: 视频 id
    ///   - commentId: 评论 id
    ///   - reultShortVideoBlock: 返回
    static func requestCommentDelete(videoId: String, commentId: String, reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        param.setValue(commentId, forKey: "commentId")
        param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        param.setValue(videoId, forKey: "topicId")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        let custom_param = NSMutableDictionary()
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey, forKey: "appKey")
        CNLiveNetworking.setAllowRequestDefaultArgument(true)
        CNLiveNetworking.setupShowDataResult(false)
        CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
        CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/deleteComment", 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") {
                    reultShortVideoBlock("删除成功", .success)
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    /// 删除回复
    /// - Parameters:
    ///   - replyId: 回复 id
    ///   - commentId: 评论 id
    ///   - reultShortVideoBlock: 返回
    static func requestCommentReplyDelete(replyId: String, commentId: String, reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        param.setValue(commentId, forKey: "commentId")
        param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        param.setValue(replyId, forKey: "replyId")
        param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
        let custom_param = NSMutableDictionary()
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
        custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey, forKey: "appKey")
        CNLiveNetworking.setAllowRequestDefaultArgument(true)
        CNLiveNetworking.setupShowDataResult(false)
        CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
        CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/deleteReply", 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") {
                    reultShortVideoBlock("删除成功", .success)
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
    
    /// 对回复和评论进行点赞
    /// - Parameters:
    ///   - contentId: 内容 id
    ///   - support: 是否点赞    0 取消 1点赞
    ///   - isComment: 是不是对评论进行点赞
    ///   - reultShortVideoBlock: 返回
    static func requestCommentWithLike(contentId: String, support: Bool,isComment: Bool,reultShortVideoBlock: @escaping resultShortVideoBlock) {
        let param = NSMutableDictionary()
        if isComment {
            param.setValue("ugc_hd_comment:\(contentId)", forKey: "id")
        } else {
            param.setValue("ugc_hd_reply:\(contentId)", forKey: "id")
        }
        param.setValue(support ? "0":"1", 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") {
                    reultShortVideoBlock(support ? "取消点赞成功" : "点赞成功", .success)
                } else {
                    showMessage(message: resp["errorMessage"] as! String)
                    reultShortVideoBlock(NSNull(),.failed)
                }
            } else {
                if CNLiveNetworking.isNetworking() {
                    showMessage(message: "请求失败")
                    reultShortVideoBlock(NSNull(),.failed)
                } else {
                    showMessage(message: "似乎与网络断开链接")
                    reultShortVideoBlock(NSNull(),.noNetwork)
                }
            }
        }
    }
    
}