Commit 5a45e8ed3b1f8411be4470a90191b1dddcabc6a6

Authored by “张旭”
1 parent b5e8e0eb

电商h5适配iPhoneX系列 , 开始播放点播视频上报正在追

metaCode/Classes/Main/HomePage/Controller/WebController/CNWebView.swift
... ... @@ -103,12 +103,14 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate
103 103 self.cnWebView.configuration.userContentController.add(self, name: "pop")
104 104 self.cnWebView.configuration.userContentController.add(self, name: "toShare")
105 105 self.cnWebView.configuration.userContentController.add(self, name: "openAppPayment")
  106 + self.cnWebView.configuration.userContentController.add(self, name: "getStatusHeight")
106 107 }
107 108  
108 109 func webViewRemoveScriptMessageHandler(){
109 110 self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "pop")
110 111 self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "toShare")
111 112 self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "openAppPayment")
  113 + self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "getStatusHeight")
112 114 }
113 115 //电商h5的回调
114 116 func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
... ... @@ -191,6 +193,22 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler,WKUIDelegate
191 193 }
192 194  
193 195 }
  196 + }else if message.name == "getStatusHeight" {
  197 + ////h5获取状态栏高度方法
  198 + let params: [String: Any] = [
  199 + "statusHeight": KStatusBarHeight,
  200 + "scale": UIScreen.main.scale
  201 + ]
  202 + let sparams = self.stringByJson(params)
  203 + let statusHeightJS = "getStatusHeight('\(sparams ?? "")')"
  204 + self.cnWebView.evaluateJavaScript(statusHeightJS) { (result: Any?, error: Error?) in
  205 + // 处理执行结果或错误
  206 + if let error = error {
  207 + print("JavaScript执行错误: \(error.localizedDescription)")
  208 + } else if let result = result {
  209 + print("JavaScript执行结果: \(result)")
  210 + }
  211 + }
194 212 }
195 213 }
196 214 // MARK: - 字典转字符串
... ...
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
... ... @@ -356,7 +356,24 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
356 356  
357 357 }
358 358  
359   -
  359 +// var title = ""
  360 +// if let blockListModel = self.vodPlayModel?.blockList.first as? CNLiveVodPlayBlockListModel{
  361 +// if let blockListListModel = blockListModel.list.first{
  362 +// title = blockListListModel.title
  363 +// }
  364 +// }
  365 + var title = ""
  366 + if self.vodPlayModel?.blockList.count ?? 0 > 0{
  367 + for mdl in self.vodPlayModel!.blockList{
  368 + if mdl.type == "5"{//详情
  369 + if mdl.list.count > 0{
  370 + let vodModel = mdl.list[0]
  371 + title = vodModel.title
  372 + }
  373 + }
  374 + }
  375 + }
  376 +
360 377 let isPaid = CNLivePlayerTool.isPaid(product: self.vodPlayModel?.product)
361 378 if isPaid{
362 379 var yuanString = ""
... ... @@ -383,14 +400,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
383 400 }
384 401 // 将结果转换为字符串
385 402 yuanString = String(yuan)
386   -
387   - var title = ""
388   - if let blockListModel = self.vodPlayModel?.blockList.first as? CNLiveVodPlayBlockListModel{
389   - if let blockListListModel = blockListModel.list.first{
390   - title = blockListListModel.title
391   - }
392   - }
393   -
  403 +
394 404 if isPayZhuanJi{
395 405 //已经付费
396 406 self.controlView.payBgView.isHidden = true
... ... @@ -432,53 +442,18 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
432 442 }
433 443  
434 444 }else{
  445 + //免费
435 446 self.controlView.payBgView.isHidden = true
436 447 isPayZhuanJi = true
  448 + self.playWithUrlAndTitle(url: self.url!.absoluteString, title: title)
  449 +
  450 +// var urls = [URL]()
  451 +// urls.append(self.url!)
  452 +// self.player.assetURLs = urls
  453 +// self.player.playTheIndex(0)
437 454  
438   - var urls = [URL]()
439   - urls.append(self.url!)
440   - self.player.assetURLs = urls
441   - self.player.playTheIndex(0)
442 455 }
443 456  
444   -// if self.vodPlayModel?.product?.productType == "2" || self.vodPlayModel?.product?.productType == "5"{//付费
445   -// }else{
446   -// if self.vodPlayModel?.product?.check == true {
447   -// //免费或者付过费了
448   -//
449   -//
450   -// } else {
451   -// if self.vodPlayModel?.product?.productType == "4" {
452   -// //这里表示可以进行试听
453   -// self.controlView.payBgView.isHidden = true
454   -// isPayZhuanJi = true
455   -// var urls = [URL]()
456   -// urls.append(self.url!)
457   -// self.player.assetURLs = urls
458   -// self.player.playTheIndex(0)
459   -// }else{
460   -// self.controlView.payBgView.isHidden = true
461   -// isPayZhuanJi = true
462   -// var urls = [URL]()
463   -// urls.append(self.url!)
464   -// self.player.assetURLs = urls
465   -// self.player.playTheIndex(0)
466   -// }
467   -// }
468   -// }
469   -
470   -
471   - var title = ""
472   - if self.vodPlayModel?.blockList.count ?? 0 > 0{
473   - for mdl in self.vodPlayModel!.blockList{
474   - if mdl.type == "5"{//详情
475   - if mdl.list.count > 0{
476   - let vodModel = mdl.list[0]
477   - title = vodModel.title
478   - }
479   - }
480   - }
481   - }
482 457 self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape)
483 458 self.playTitle = title
484 459 self.controlView.vodPlayerPayBlock = {[weak self] vodPlayMdl in
... ... @@ -635,6 +610,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
635 610 self.player.assetURLs = urls
636 611 self.player.playTheIndex(0)
637 612 self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape)
  613 + //上报end
  614 + CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1")
  615 + print("2222222:\(self.contentId),\(self.vodPlayModel?.model ?? "1")")
638 616 }
639 617 func seekPlayerWithUrlAndTitle(url:String,title:String,seekTime:TimeInterval){
640 618 self.isSeek = true
... ...