Commit 580161d340b56a2e7cb679b58ff626be720a25e8

Authored by “张旭”
1 parent 16699f9c

播放视频上报 , 支付弹窗逻辑

metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
... ... @@ -307,6 +307,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
307 307 self.player.playerDidToEnd = {
308 308 [weak self] asset in
309 309 guard let self = self else { return }
  310 +
310 311 if endAssetURL == nil {
311 312 endAssetURL = asset.assetURL
312 313 self.playNextIfExist()
... ... @@ -318,6 +319,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
318 319 DispatchQueue.main.asyncAfter(deadline: delayTime) {
319 320 endAssetURL = nil
320 321 }
  322 + //上报end
  323 + CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1")
  324 + print("\(self.contentId),\(self.vodPlayModel?.model)")
321 325 }
322 326  
323 327 var urls = [URL]()
... ... @@ -337,7 +341,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
337 341 }
338 342 self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape)
339 343 self.playTitle = title
340   - self.controlView.vodPlayerPayBlock = {[weak self] in
  344 + self.controlView.vodPlayerPayBlock = {[weak self] vodPlayMdl in
341 345 guard let self = self else { return }
342 346 //支付按钮,拉起内购
343 347 //成功用pay参数 刷新页面
... ... @@ -359,8 +363,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
359 363 }
360 364 // 将结果转换为字符串
361 365 let yuanString = String(yuan)
362   -
363   - let prdId = "com.cnlive.metaCode."+yuanString//"com.cnlive.metaCode."+"1"//+(viewcell.homeModel.albumMsgModel?.product?.iosRmb ?? "1")
  366 + let prdId = vodPlayMdl.product?.productId ?? ""//"com.cnlive.metaCode."+yuanString//"com.cnlive.metaCode."+"1"//+(viewcell.homeModel.albumMsgModel?.product?.iosRmb ?? "1")
364 367  
365 368 let body = self.payVodAlbumListModel?.product?.productTitle ?? ""
366 369 let total_fee = yuan*100
... ... @@ -372,7 +375,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
372 375 dataDic.setValue(total_fee, forKey: "total_fee")
373 376  
374 377 //后台设置一个 com.cnlive.meta.1 2 60 3 78
375   - //苹果内购暂时报错 验证失败支付失败
  378 + //苹果内购
376 379 CNLivePayCostModule.showApplePayViw(withParamDict: dataDic as! [AnyHashable : Any], fromVC: currentViewController()!) {[weak self] result in
377 380 guard let self = self else { return }
378 381 if result == CNLivePayCostTypeResultSucc{
... ... @@ -411,6 +414,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
411 414 self.albumIndex = nextIdx
412 415 if let albumModel = self.albumListArr[nextIdx] as? CNLiveVodAlbumListModel{
413 416 //播专辑列表下一条
  417 + self.contentId = albumModel.contentId
414 418 self.kanDianOrAlbumChangeContentApi(contentId: albumModel.contentId, title: albumModel.title, isAlbum: self.isAblumVideo, activeId: albumModel.activityId)
415 419 // self.changeContentApi(vodModel: albumModel)
416 420 }
... ... @@ -494,6 +498,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
494 498 if status == .success{
495 499 if let vodPlayModel = result as? CNLiveVodPlayModel{
496 500 self.vodPlayModel = vodPlayModel
  501 + self.controlView.vodPlayModel = vodPlayModel
497 502 self.configDataArray()
498 503 self.tableView.reloadData()
499 504 }else{
... ... @@ -561,6 +566,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
561 566 if isReplace{
562 567 self.dataArray.replaceObject(at: index, with: tempMdl as Any)
563 568 }else{}
  569 + self.controlView.vodPlayModel = vodPlayModel
564 570 self.configDataArray()
565 571 self.tableView.reloadData()
566 572 }else{
... ... @@ -619,7 +625,8 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
619 625 }
620 626 tempVodPlayModel?.goodsJson = vodPlayModel.goodsJson
621 627 self.vodPlayModel = tempVodPlayModel
622   -
  628 + self.controlView.vodPlayModel = tempVodPlayModel
  629 +
623 630 //刷新url 1955_71512cfbcd5b497580732b48e26d16d6
624 631 CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: activityId) {[weak self] result, status in
625 632 guard let self = self else { return }
... ... @@ -651,6 +658,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
651 658 guard let self = self else { return }
652 659 if status == .success{
653 660 self.vodPlayModel = vodPlayModel
  661 + self.controlView.vodPlayModel = vodPlayModel
654 662 self.contentId = contentId
655 663 if let vodAlbumListBaseModel = result{
656 664 self.vodAlbumListBaseModel = vodAlbumListBaseModel
... ... @@ -729,6 +737,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
729 737 }
730 738 cell.selectBlock = { [weak self] model,index,kanDianListArr in
731 739 guard let self = self else { return }
  740 + //点击看点
732 741 self.contentId = model.contentId
733 742 let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false
734 743 // let isAblumVideo = model.model == "1" ? false : true
... ... @@ -804,6 +813,11 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
804 813 }else{
805 814 //没付费
806 815 //显示付费页面
  816 + let vodMdl = CNLiveVodPlayModel()
  817 + vodMdl.product = vodModel.product
  818 + vodMdl.contentId = vodModel.contentId
  819 + vodMdl.model = vodModel.modelId
  820 + self.controlView.vodPlayModel = vodMdl
807 821 self.controlView.payBgView.isHidden = false
808 822 self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本专辑", for: .normal)
809 823 //成功用pay参数 刷新页面
... ...
metaCode/Classes/Main/HuBiLieHomePage/View/Home/Home/CNLiveHomeFollowCell.swift
... ... @@ -28,6 +28,7 @@ class CNLiveHomeFollowCell:UITableViewCell{
28 28 iconImgView.layer.cornerRadius = 25
29 29 iconImgView.clipsToBounds = true
30 30 iconImgView.contentMode = .scaleAspectFill
  31 + iconImgView.isUserInteractionEnabled = true
31 32 iconImgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(followImgViewAction)))
32 33 iconImgView.addSubview(followIconImgView)
33 34 iconImgView.addSubview(titleLabel)
... ... @@ -36,7 +37,7 @@ class CNLiveHomeFollowCell:UITableViewCell{
36 37 return iconImgView
37 38 }()
38 39 lazy var followIconImgView :UIImageView = {
39   - let iconImgView = UIImageView(frame: CGRect(x: 20, y: (self.followImgView.height-30.0)*0.5, width: 30, height: 30))
  40 + let iconImgView = UIImageView(frame: CGRect(x: 20, y: (50-30.0)*0.5, width: 30, height: 30))
40 41 iconImgView.image = UIImage(named: "home_followIcon")
41 42 iconImgView.contentMode = .scaleAspectFill
42 43 return iconImgView
... ... @@ -87,6 +88,8 @@ class CNLiveHomeFollowCell:UITableViewCell{
87 88  
88 89 @objc func followImgViewAction(){
89 90  
  91 + CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: self.followModel?.modelId ?? "", contentId: self.followModel?.contentId ?? "", pid: self.followModel?.activeId ?? "", shareUrl: self.followModel?.shareUrl ?? "", thirdUrl: "", title: self.followModel?.title ?? "", s_to: "", trailerId: "", controller: navigationViewController().visibleViewController, slideModel: nil)
  92 +
90 93 }
91 94  
92 95 }
... ...
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveZFPlayerControlView.swift
... ... @@ -10,10 +10,21 @@ import ZFPlayer
10 10  
11 11 //标清 2 ,高清 3 ,超清 4
12 12 typealias CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock = (_ gaoqing:Int)->Void
13   -typealias CNLiveVodPlayerPayBlock = ()->Void
  13 +typealias CNLiveVodPlayerPayBlock = (_ vodPlayModel : CNLiveVodPlayModel)->Void
14 14  
15 15 class CNLiveZFPlayerControlView:ZFPlayerControlView{
16 16  
  17 + //CNLiveVodPlayModel 单集model
  18 + var _vodPlayModel : CNLiveVodPlayModel?
  19 + var vodPlayModel : CNLiveVodPlayModel? {
  20 + get{
  21 + _vodPlayModel
  22 + }
  23 + set{
  24 + _vodPlayModel = newValue!
  25 + }
  26 + }
  27 +
17 28 var controlGaoqingUpdateBlock:CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock?
18 29 var vodPlayerPayBlock:CNLiveVodPlayerPayBlock?
19 30  
... ... @@ -124,8 +135,7 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{
124 135 self.payBgView.isHidden = true
125 136 self.payBgView.payBlock = {
126 137 //拉起内购
127   - self.vodPlayerPayBlock?()
128   -
  138 + self.vodPlayerPayBlock?(self.vodPlayModel ?? CNLiveVodPlayModel())
129 139 }
130 140  
131 141 }
... ...
metaCode/Classes/Main/HuBiLieHomePage/ViewModel/CNLiveVodPlayViewModel.swift
... ... @@ -95,4 +95,5 @@ class CNLiveVodPlayViewModel:NSObject,URLSessionTaskDelegate{
95 95 }
96 96 }
97 97 }
  98 +
98 99 }
... ...
metaCode/Classes/Main/VideoPage/ViewModel/CNLiveShortVideoViewModel.swift
... ... @@ -257,6 +257,41 @@ class CNLiveShortVideoViewModel: NSObject {
257 257 }
258 258 }
259 259 }
  260 + //!!!: 点播上报播放了视频
  261 + /// 上报播放了某一集视频
  262 + /// - Parameters:
  263 + /// - contentId: 内容 id
  264 + /// - channelName:
  265 + /// - model:
  266 + static func requestVodPlayRecordEnd(contentId: String, channelName: String,model:String) {
  267 + let param = NSMutableDictionary()
  268 + param.setValue("", forKey: "schedule")
  269 + param.setValue(contentId, forKey: "contentId")
  270 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  271 + param.setValue(channelName, forKey: "channelName")
  272 + param.setValue(model, forKey: "model")
  273 +
  274 + let custom_param = NSMutableDictionary()
  275 + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId")
  276 + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey_wjj, forKey: "appKey")
  277 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  278 + CNLiveNetworking.setupShowDataResult(false)
  279 + CNLiveNetworking.setupShowResult(true)
  280 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  281 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseCMSClassUrl+"/recordApi/end", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  282 + hiddenLoading()
  283 + if (error == nil) {
  284 + let resp = result as! NSDictionary
  285 + let errorCode = "\(resp["errorCode"] ?? "0")"
  286 + if (errorCode == "0") {
  287 + print(resp)
  288 + } else {
  289 + }
  290 + } else {
  291 + }
  292 + }
  293 + }
  294 +
260 295  
261 296 //!!!: 评论相关
262 297  
... ...