Commit 4de43f91687b51befcee51d287aa6bb6635787b3
1 parent
580161d3
看点/专辑 选集
Showing
5 changed files
with
721 additions
and
7 deletions
metaCode.xcodeproj/project.pbxproj
| ... | ... | @@ -200,6 +200,7 @@ |
| 200 | 200 | 196A55F72D963ACE00B06DB7 /* CNLiveVodLandscapeXuanjiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55F62D963ACE00B06DB7 /* CNLiveVodLandscapeXuanjiView.swift */; }; |
| 201 | 201 | 196A55F92D963AE700B06DB7 /* CNLiveVodLandscapeGaoqingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */; }; |
| 202 | 202 | 196A55FB2D9BE7DC00B06DB7 /* CNLiveVodPayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55FA2D9BE7DC00B06DB7 /* CNLiveVodPayView.swift */; }; |
| 203 | + 196A55FD2DA66AEE00B06DB7 /* CNLiveVodXuanjiKandianCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55FC2DA66AED00B06DB7 /* CNLiveVodXuanjiKandianCell.swift */; }; | |
| 203 | 204 | 197325D22BB11C18002E41A3 /* DatabaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 197325D12BB11C18002E41A3 /* DatabaseManager.swift */; }; |
| 204 | 205 | 1975636E2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1975636D2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift */; }; |
| 205 | 206 | 197563712C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 197563702C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift */; }; |
| ... | ... | @@ -603,6 +604,7 @@ |
| 603 | 604 | 196A55F62D963ACE00B06DB7 /* CNLiveVodLandscapeXuanjiView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodLandscapeXuanjiView.swift; sourceTree = "<group>"; }; |
| 604 | 605 | 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodLandscapeGaoqingView.swift; sourceTree = "<group>"; }; |
| 605 | 606 | 196A55FA2D9BE7DC00B06DB7 /* CNLiveVodPayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodPayView.swift; sourceTree = "<group>"; }; |
| 607 | + 196A55FC2DA66AED00B06DB7 /* CNLiveVodXuanjiKandianCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodXuanjiKandianCell.swift; sourceTree = "<group>"; }; | |
| 606 | 608 | 197325D12BB11C18002E41A3 /* DatabaseManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseManager.swift; sourceTree = "<group>"; }; |
| 607 | 609 | 1975636D2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVitaeWorkDetailController.swift; sourceTree = "<group>"; }; |
| 608 | 610 | 197563702C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVitaeWorkCell.swift; sourceTree = "<group>"; }; |
| ... | ... | @@ -1492,6 +1494,7 @@ |
| 1492 | 1494 | 196A55F42D95432B00B06DB7 /* CNLiveVodLandscapeBeiSuView.swift */, |
| 1493 | 1495 | 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */, |
| 1494 | 1496 | 196A55F62D963ACE00B06DB7 /* CNLiveVodLandscapeXuanjiView.swift */, |
| 1497 | + 196A55FC2DA66AED00B06DB7 /* CNLiveVodXuanjiKandianCell.swift */, | |
| 1495 | 1498 | 196A55FA2D9BE7DC00B06DB7 /* CNLiveVodPayView.swift */, |
| 1496 | 1499 | ); |
| 1497 | 1500 | path = HengPing; |
| ... | ... | @@ -2739,6 +2742,7 @@ |
| 2739 | 2742 | 79868B192B874294008E0F5C /* CNLiveSaveAuthStateDB.swift in Sources */, |
| 2740 | 2743 | 790D019A2A2DCAE400C5978D /* CNLiveViewController.swift in Sources */, |
| 2741 | 2744 | 191733192B10A05D007BCC04 /* CNLivePlayerProgressView.swift in Sources */, |
| 2745 | + 196A55FD2DA66AEE00B06DB7 /* CNLiveVodXuanjiKandianCell.swift in Sources */, | |
| 2742 | 2746 | 79803E272AD68D3100F05F68 /* CNLiveMineShopViewController.swift in Sources */, |
| 2743 | 2747 | 197325D22BB11C18002E41A3 /* DatabaseManager.swift in Sources */, |
| 2744 | 2748 | 192ED47A2C5383340057244C /* CNLiveVitaeAddCertificateController.swift in Sources */, | ... | ... |
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
| ... | ... | @@ -322,12 +322,132 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa |
| 322 | 322 | //上报end |
| 323 | 323 | CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1") |
| 324 | 324 | print("\(self.contentId),\(self.vodPlayModel?.model)") |
| 325 | + | |
| 326 | + //刷新选集-专辑列表 | |
| 327 | + if self.isPlayAblumOrKandian{ | |
| 328 | + self.controlView.xuanjiBgView.currSeleIdx = self.albumIndex | |
| 329 | + }else{ | |
| 330 | + //刷新选集-看点列表 | |
| 331 | + self.controlView.xuanjiBgView.currSeleIdx = self.kanDianIndex | |
| 332 | + self.controlView.xuanjiBgView.kandianTableView.reloadData() | |
| 333 | + } | |
| 334 | + | |
| 335 | + | |
| 336 | + } | |
| 337 | + self.controlView.xuanjiBgView.vodPlayerLandscapeXuanjiKanDianSelectBlock = { [weak self] seleIndex,vodPlayBlockListListModel in | |
| 338 | + guard let self = self else { return } | |
| 339 | + //切换横屏看点视频 | |
| 340 | + self.contentId = vodPlayBlockListListModel.contentId | |
| 341 | + var isAblumVideo = false | |
| 342 | + if vodPlayBlockListListModel.album?.albumId.count ?? 0 > 0{ | |
| 343 | + isAblumVideo = true | |
| 344 | + }else{ | |
| 345 | + isAblumVideo = false | |
| 346 | + } | |
| 347 | + self.isPlayAblumOrKandian = false | |
| 348 | + self.kanDianIndex = seleIndex | |
| 349 | + self.kanDianOrAlbumChangeContentApi(contentId: vodPlayBlockListListModel.contentId, title: vodPlayBlockListListModel.title, isAlbum: isAblumVideo, activeId: vodPlayBlockListListModel.pid) | |
| 350 | + | |
| 325 | 351 | } |
| 326 | 352 | |
| 327 | - var urls = [URL]() | |
| 328 | - urls.append(self.url!) | |
| 329 | - self.player.assetURLs = urls | |
| 330 | - self.player.playTheIndex(0) | |
| 353 | + if self.vodPlayModel?.product?.check == true { | |
| 354 | + //免费或者付过费了 | |
| 355 | + self.controlView.payBgView.isHidden = true | |
| 356 | + isPayZhuanJi = true | |
| 357 | + | |
| 358 | + var urls = [URL]() | |
| 359 | + urls.append(self.url!) | |
| 360 | + self.player.assetURLs = urls | |
| 361 | + self.player.playTheIndex(0) | |
| 362 | + | |
| 363 | + } else { | |
| 364 | + var yuanString = "" | |
| 365 | + if self.vodPlayModel?.product?.productType == "4" { | |
| 366 | + //这里表示可以进行试听 | |
| 367 | + self.controlView.payBgView.isHidden = true | |
| 368 | + isPayZhuanJi = true | |
| 369 | + var urls = [URL]() | |
| 370 | + urls.append(self.url!) | |
| 371 | + self.player.assetURLs = urls | |
| 372 | + self.player.playTheIndex(0) | |
| 373 | + | |
| 374 | + } else { | |
| 375 | + //需要付费 | |
| 376 | + self.controlView.payBgView.isHidden = false | |
| 377 | + isPayZhuanJi = false | |
| 378 | + var urls = [URL]() | |
| 379 | + urls.append(self.url!) | |
| 380 | + self.player.assetURLs = urls | |
| 381 | + self.player.playTheIndex(0) | |
| 382 | + self.player.currentPlayerManager.pause() | |
| 383 | + //分转元,没有小数点 | |
| 384 | + let fenString = self.vodPlayModel!.product!.iosRmb | |
| 385 | + // 将字符串转换为整数 | |
| 386 | + // 使用guard语句确保字符串可以转换为整数 | |
| 387 | + guard let fen = Int(fenString) else { | |
| 388 | + print("无法将字符串转换为整数") | |
| 389 | + return | |
| 390 | + } | |
| 391 | + // 计算元值(整数除法,自动舍去小数部分) | |
| 392 | + var yuan = fen / 100 | |
| 393 | + if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元 | |
| 394 | + yuan = 1 | |
| 395 | + } | |
| 396 | + // 将结果转换为字符串 | |
| 397 | + yuanString = String(yuan) | |
| 398 | + | |
| 399 | + } | |
| 400 | + | |
| 401 | + var title = "" | |
| 402 | + if let blockListModel = self.vodPlayModel?.blockList.first as? CNLiveVodPlayBlockListModel{ | |
| 403 | + if let blockListListModel = blockListModel.list.first{ | |
| 404 | + title = blockListListModel.title | |
| 405 | + } | |
| 406 | + } | |
| 407 | + | |
| 408 | + if isPayZhuanJi{ | |
| 409 | + //已经付费 | |
| 410 | + self.controlView.payBgView.isHidden = true | |
| 411 | + self.contentId = self.vodPlayModel?.contentId ?? "" | |
| 412 | + self.albumListArr = albumListArr | |
| 413 | + self.albumIndex = 0 | |
| 414 | + self.kanDianIndex = -1 | |
| 415 | + self.isPlayAblumOrKandian = true | |
| 416 | + self.kanDianOrAlbumChangeContentApi(contentId: self.vodPlayModel?.contentId ?? "", title: title, isAlbum: true, activeId: self.vodPlayModel?.contentId ?? "") | |
| 417 | + self.player.allowOrentitaionRotation = true | |
| 418 | + }else{ | |
| 419 | + //没付费 | |
| 420 | + //显示付费页面 | |
| 421 | + let vodMdl = CNLiveVodPlayModel() | |
| 422 | + vodMdl.product = self.vodPlayModel?.product | |
| 423 | + vodMdl.contentId = self.vodPlayModel?.contentId ?? "" | |
| 424 | + vodMdl.model = self.vodPlayModel?.model ?? "" | |
| 425 | + self.controlView.vodPlayModel = vodMdl | |
| 426 | + self.controlView.payBgView.isHidden = false | |
| 427 | + self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本专辑", for: .normal) | |
| 428 | + //成功用pay参数 刷新页面 | |
| 429 | + self.albumListArr = NSMutableArray(array: self.vodAlbumListBaseModel?.list ?? [CNLiveVodAlbumListModel]()) | |
| 430 | + if self.albumListArr.count > 0{ | |
| 431 | + if let vodAlbumListModel = self.albumListArr[0] as? CNLiveVodAlbumListModel{ | |
| 432 | + self.payVodAlbumListModel = vodAlbumListModel | |
| 433 | + self.payAid = vodAlbumListModel.albumId//.contentId | |
| 434 | + self.payContentId = vodAlbumListModel.contentId | |
| 435 | + self.payAlbumListArr = albumListArr | |
| 436 | + self.payIndex = 0 | |
| 437 | + self.kanDianIndex = -1 | |
| 438 | + self.isPlayAblumOrKandian = true | |
| 439 | + self.payTitle = title | |
| 440 | + self.payIsAlbum = true | |
| 441 | + self.payActivityId = vodAlbumListModel.activityId | |
| 442 | + self.player.allowOrentitaionRotation = false | |
| 443 | + } | |
| 444 | + } | |
| 445 | + | |
| 446 | + } | |
| 447 | + | |
| 448 | + } | |
| 449 | + | |
| 450 | + | |
| 331 | 451 | var title = "" |
| 332 | 452 | if self.vodPlayModel?.blockList.count ?? 0 > 0{ |
| 333 | 453 | for mdl in self.vodPlayModel!.blockList{ |
| ... | ... | @@ -391,6 +511,20 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa |
| 391 | 511 | |
| 392 | 512 | |
| 393 | 513 | } |
| 514 | + | |
| 515 | + self.controlView.controlXuanjiUpdateBlock = { [weak self] index,albumModel in | |
| 516 | + guard let self = self else { return } | |
| 517 | + let title = albumModel.title | |
| 518 | + CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: albumModel.activityId) { result, status in | |
| 519 | + if status == .success{ | |
| 520 | + if let url = result as? String{ | |
| 521 | + self.playWithUrlAndTitle(url: url, title: title) | |
| 522 | + } | |
| 523 | + } | |
| 524 | + | |
| 525 | + } | |
| 526 | + | |
| 527 | + } | |
| 394 | 528 | self.controlView.controlGaoqingUpdateBlock = { [weak self] gaoqing in |
| 395 | 529 | guard let self = self else { return } |
| 396 | 530 | // |
| ... | ... | @@ -459,6 +593,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa |
| 459 | 593 | }else{ |
| 460 | 594 | self.controlView.gaoqingBgView.resetGaoqing() |
| 461 | 595 | } |
| 596 | + self.controlView.payBgView.isHidden = true | |
| 462 | 597 | self.isSeek = false |
| 463 | 598 | self.player.currentPlayerManager.rate = 1.0 |
| 464 | 599 | self.playTitle = title |
| ... | ... | @@ -746,7 +881,10 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa |
| 746 | 881 | self.kanDianListArr = kanDianListArr |
| 747 | 882 | //只更新 此视频的长id,换url(不管是不是专辑) |
| 748 | 883 | self.isPlayAblumOrKandian = false |
| 749 | - | |
| 884 | + //更新选集-看点列表 | |
| 885 | + //kanDianListArr cnLivevodPlayBlocjListlistModel | |
| 886 | + self.controlView.xuanjiBgView.currSeleIdx = index | |
| 887 | + self.controlView.xuanjiBgView.kanDianListArr = kanDianListArr | |
| 750 | 888 | self.kanDianOrAlbumChangeContentApi(contentId: model.contentId, title: model.title, isAlbum: isAblumVideo, activeId: model.pid) |
| 751 | 889 | // self.refreshVodData(isAblumVideo: isAblumVideo) |
| 752 | 890 | } |
| ... | ... | @@ -763,7 +901,16 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa |
| 763 | 901 | } |
| 764 | 902 | cell.currSeleIdx = self.albumIndex |
| 765 | 903 | cell.vodAlbumListBaseModel = vodAlbumListBaseModel |
| 766 | - | |
| 904 | + if self.isPlayAblumOrKandian{ | |
| 905 | + //播放的专辑 | |
| 906 | + self.controlView.xuanjiBgView.currSeleIdx = self.albumIndex | |
| 907 | + self.controlView.xuanjiBgView.vodAlbumListBaseModel = vodAlbumListBaseModel | |
| 908 | + }else{ | |
| 909 | + //播放的看点 | |
| 910 | +// self.controlView.xuanjiBgView.currSeleIdx = self.kanDianIndex | |
| 911 | +// self.controlView.xuanjiBgView.kanDianListArr = self.kanDianListArr | |
| 912 | + //CNLiveVodPlayblockListListModel | |
| 913 | + } | |
| 767 | 914 | cell.selectBlock = {[weak self] vodModel, index ,albumListArr in |
| 768 | 915 | guard let self = self else { return } |
| 769 | 916 | self.player.currentPlayerManager.pause() |
| ... | ... | @@ -851,6 +998,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa |
| 851 | 998 | }else { |
| 852 | 999 | return UITableViewCell() |
| 853 | 1000 | } |
| 1001 | + | |
| 854 | 1002 | return UITableViewCell() |
| 855 | 1003 | } |
| 856 | 1004 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| ... | ... | @@ -946,6 +1094,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa |
| 946 | 1094 | // isAblumVideo = true |
| 947 | 1095 | // } |
| 948 | 1096 | self.isPlayAblumOrKandian = false |
| 1097 | + self.kanDianIndex = seleIdx | |
| 949 | 1098 | self.kanDianOrAlbumChangeContentApi(contentId: model.contentId, title: model.title, isAlbum: isAblumVideo, activeId: model.pid) |
| 950 | 1099 | // self.refreshVodData(isAblumVideo: isAblumVideo) |
| 951 | 1100 | } | ... | ... |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveZFPlayerControlView.swift
| ... | ... | @@ -11,6 +11,9 @@ import ZFPlayer |
| 11 | 11 | //标清 2 ,高清 3 ,超清 4 |
| 12 | 12 | typealias CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock = (_ gaoqing:Int)->Void |
| 13 | 13 | typealias CNLiveVodPlayerPayBlock = (_ vodPlayModel : CNLiveVodPlayModel)->Void |
| 14 | +typealias CNLiveVodPlayerControlLandscapeXuanjiUpdateBlock = (_ jishuIndex:Int,_ albumModel:CNLiveVodAlbumListModel)->Void | |
| 15 | +typealias CNLiveVodPlayerControlLandscapePauseBlock = ()->Void | |
| 16 | + | |
| 14 | 17 | |
| 15 | 18 | class CNLiveZFPlayerControlView:ZFPlayerControlView{ |
| 16 | 19 | |
| ... | ... | @@ -25,8 +28,11 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{ |
| 25 | 28 | } |
| 26 | 29 | } |
| 27 | 30 | |
| 31 | + var pausePlayer:CNLiveVodPlayerControlLandscapePauseBlock? | |
| 28 | 32 | var controlGaoqingUpdateBlock:CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock? |
| 29 | 33 | var vodPlayerPayBlock:CNLiveVodPlayerPayBlock? |
| 34 | + var controlXuanjiUpdateBlock:CNLiveVodPlayerControlLandscapeXuanjiUpdateBlock? | |
| 35 | + | |
| 30 | 36 | |
| 31 | 37 | lazy var beiSuBtn: UIButton = { |
| 32 | 38 | let closeBtn = UIButton(type: .custom) |
| ... | ... | @@ -65,6 +71,11 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{ |
| 65 | 71 | let bottomNavView = CNLiveVodLandscapeGaoqingView() |
| 66 | 72 | return bottomNavView |
| 67 | 73 | }() |
| 74 | + lazy var xuanjiBgView :CNLiveVodLandscapeXuanjiView = { | |
| 75 | + let bottomNavView = CNLiveVodLandscapeXuanjiView() | |
| 76 | + return bottomNavView | |
| 77 | + }() | |
| 78 | + | |
| 68 | 79 | |
| 69 | 80 | lazy var payBgView :CNLiveVodPayView = { |
| 70 | 81 | let bottomNavView = CNLiveVodPayView() |
| ... | ... | @@ -128,6 +139,18 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{ |
| 128 | 139 | self.controlGaoqingUpdateBlock?(gaoqing) |
| 129 | 140 | } |
| 130 | 141 | |
| 142 | + self.addSubview(self.xuanjiBgView) | |
| 143 | + xuanjiBgView.snp.makeConstraints { make in | |
| 144 | + make.left.right.top.bottom.equalToSuperview() | |
| 145 | + } | |
| 146 | + self.xuanjiBgView.isHidden = true | |
| 147 | + self.xuanjiBgView.xuanjiUpdateBlock = {[weak self] index,albumModel in | |
| 148 | + guard let self = self else { return } | |
| 149 | + //jishuIndex:Int,_ albumModel:CNLiveVodAlbumListModel | |
| 150 | + self.xuanjiBgView.isHidden = true | |
| 151 | + self.controlXuanjiUpdateBlock?(index,albumModel) | |
| 152 | + } | |
| 153 | + | |
| 131 | 154 | self.addSubview(self.payBgView) |
| 132 | 155 | payBgView.snp.makeConstraints { make in |
| 133 | 156 | make.left.right.top.bottom.equalToSuperview() |
| ... | ... | @@ -166,14 +189,17 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{ |
| 166 | 189 | |
| 167 | 190 | @objc func beiSuBtnAction(){ |
| 168 | 191 | self.beiSuBgView.isHidden = false |
| 192 | +// self.pausePlayer?() | |
| 169 | 193 | } |
| 170 | 194 | |
| 171 | 195 | @objc func gaoqingBtnAction(){ |
| 172 | 196 | self.gaoqingBgView.isHidden = false |
| 197 | +// self.pausePlayer?() | |
| 173 | 198 | } |
| 174 | 199 | |
| 175 | 200 | @objc func xuanjiBtnAction(){ |
| 176 | - print("xuanji") | |
| 201 | + self.xuanjiBgView.isHidden = false | |
| 202 | +// self.pausePlayer?() | |
| 177 | 203 | } |
| 178 | 204 | |
| 179 | 205 | } | ... | ... |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/HengPing/CNLiveVodLandscapeXuanjiView.swift
| ... | ... | @@ -4,5 +4,356 @@ |
| 4 | 4 | // |
| 5 | 5 | // Created by zx on 2025/3/28. |
| 6 | 6 | // |
| 7 | +// 横屏选集 | |
| 7 | 8 | |
| 8 | 9 | import Foundation |
| 10 | + | |
| 11 | +//专辑选择某一集 | |
| 12 | +typealias CNLiveVodPlayerLandscapeXuanjiUpdateBlock = (_ jishuIndex:Int,_ albumModel:CNLiveVodAlbumListModel)->Void | |
| 13 | +//看点选择某一集 | |
| 14 | +typealias CNLiveVodPlayerLandscapeXuanjiKanDianSelectBlock = (_ kanDianIndex:Int,_ vodPlayBlockListListModel:CNLiveVodPlayBlockListListModel)->Void | |
| 15 | + | |
| 16 | +class CNLiveVodLandscapeXuanjiView:UIView, UITableViewDataSource, UITableViewDelegate{//, UICollectionViewDelegate, UICollectionViewDataSource{ | |
| 17 | + | |
| 18 | + var currSeleIdx = 0 | |
| 19 | +// var selectBlock:CNLiveVodAlbumListCellSelectBlock? | |
| 20 | + var xuanjiUpdateBlock:CNLiveVodPlayerLandscapeXuanjiUpdateBlock? | |
| 21 | + var vodPlayerLandscapeXuanjiKanDianSelectBlock:CNLiveVodPlayerLandscapeXuanjiKanDianSelectBlock? | |
| 22 | +// //实时热榜的列表 | |
| 23 | +// lazy var albumListArr: NSMutableArray = { | |
| 24 | +// var albumListArr = NSMutableArray() | |
| 25 | +// return albumListArr | |
| 26 | +// }() | |
| 27 | +// let kCNLiveVodAlbumListCollectionCellIdentifier = "kCNLiveVodAlbumListCollectionCellIdentifier" | |
| 28 | +// | |
| 29 | +// lazy var realHotCollectionView: UICollectionView = { | |
| 30 | +// let layout = UICollectionViewFlowLayout() | |
| 31 | +// layout.scrollDirection = .horizontal | |
| 32 | +// layout.itemSize = CGSizeMake(50, 50) | |
| 33 | +// layout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0) | |
| 34 | +// layout.minimumLineSpacing = 13.5 | |
| 35 | +// let cv = UICollectionView(frame: .zero, collectionViewLayout: layout) | |
| 36 | +// cv.delegate = self | |
| 37 | +// cv.dataSource = self | |
| 38 | +// cv.backgroundColor = .red//.clear | |
| 39 | +// cv.showsHorizontalScrollIndicator = false | |
| 40 | +// cv.register(CNLiveVodAlbumListCollectionCell.self, forCellWithReuseIdentifier: kCNLiveVodAlbumListCollectionCellIdentifier) | |
| 41 | +// return cv | |
| 42 | +// }() | |
| 43 | + | |
| 44 | + let kCNLiveVodXuanjiKandianCellIdentifier = "kCNLiveVodXuanjiKandianCellIdentifier" | |
| 45 | + | |
| 46 | + lazy var kandianTableView : UITableView = { | |
| 47 | + let tableView = UITableView(frame: .zero, style: .plain) | |
| 48 | + tableView.dataSource = self | |
| 49 | + tableView.delegate = self | |
| 50 | + tableView.separatorStyle = .none | |
| 51 | + tableView.register(CNLiveVodXuanjiKandianCell.self, forCellReuseIdentifier: kCNLiveVodXuanjiKandianCellIdentifier) | |
| 52 | + tableView.backgroundColor = .clear | |
| 53 | + return tableView | |
| 54 | + }() | |
| 55 | + lazy var tableViewBgView :UIView = { | |
| 56 | + let bottomNavView = UIView() | |
| 57 | + bottomNavView.isUserInteractionEnabled = true | |
| 58 | + return bottomNavView | |
| 59 | + }() | |
| 60 | + | |
| 61 | + | |
| 62 | + // | |
| 63 | + var _vodAlbumListBaseModel : CNLiveVodAlbumListBaseModel? | |
| 64 | + var vodAlbumListBaseModel : CNLiveVodAlbumListBaseModel? { | |
| 65 | + get{ | |
| 66 | + _vodAlbumListBaseModel | |
| 67 | + } | |
| 68 | + set{ | |
| 69 | + _vodAlbumListBaseModel = newValue! | |
| 70 | + self.setupNewUI(model: vodAlbumListBaseModel!) | |
| 71 | + } | |
| 72 | + } | |
| 73 | + | |
| 74 | +// lazy var kanDianListArr :NSMutableArray = { | |
| 75 | +// let kanDianListArr = NSMutableArray() | |
| 76 | +// return kanDianListArr | |
| 77 | +// }() | |
| 78 | + var _kanDianListArr : NSMutableArray? | |
| 79 | + var kanDianListArr : NSMutableArray? { | |
| 80 | + get{ | |
| 81 | + _kanDianListArr | |
| 82 | + } | |
| 83 | + set{ | |
| 84 | + _kanDianListArr = newValue! | |
| 85 | + self.setupNewUI(kanDianListArr: _kanDianListArr!) | |
| 86 | + } | |
| 87 | + } | |
| 88 | + | |
| 89 | + | |
| 90 | + //MARK: - 懒加载 | |
| 91 | + lazy var titleLabel: UILabel = { | |
| 92 | + let titleLbl = UILabel() | |
| 93 | + titleLbl.font = Font_14 | |
| 94 | + titleLbl.textColor = HexColor("#FFFFFF") | |
| 95 | + titleLbl.text = "选集" | |
| 96 | + return titleLbl | |
| 97 | + }() | |
| 98 | + | |
| 99 | + lazy var bgScrollView :UIScrollView = { | |
| 100 | + let bgScrollView = UIScrollView() | |
| 101 | + bgScrollView.showsVerticalScrollIndicator = false | |
| 102 | + return bgScrollView | |
| 103 | + }() | |
| 104 | + | |
| 105 | + | |
| 106 | + override init(frame: CGRect) { | |
| 107 | + super.init(frame: frame) | |
| 108 | + self.backgroundColor = HexColor("#000000", alpha: 0.7) | |
| 109 | + self.isUserInteractionEnabled = true | |
| 110 | + self.initUI() | |
| 111 | + } | |
| 112 | + | |
| 113 | + required init?(coder: NSCoder) { | |
| 114 | + fatalError("init(coder:) has not been implemented") | |
| 115 | + } | |
| 116 | +// var footerRefreshView: MJRefreshAutoNormalFooter! | |
| 117 | + var page = 1//当前页数 | |
| 118 | + | |
| 119 | + func initUI(){ | |
| 120 | + | |
| 121 | + self.addSubview(self.titleLabel) | |
| 122 | + titleLabel.snp.makeConstraints { make in | |
| 123 | + make.top.equalToSuperview().offset(31) | |
| 124 | + make.centerX.equalToSuperview() | |
| 125 | + } | |
| 126 | + | |
| 127 | + let leftPadding:CGFloat = 158.0 | |
| 128 | + let topPadding:CGFloat = 25.0 | |
| 129 | + let WH:CGFloat = 50.0 | |
| 130 | + let padding:CGFloat = 13.5 | |
| 131 | + let maxH = max(KSreenHeight, KSreenWidth) | |
| 132 | + var containerWidth: CGFloat = maxH-158.0*2 | |
| 133 | + // 计算不包括最后一个方块间距时一行能放置的方块数量 | |
| 134 | + let maxBlocksWithoutLastSpacing = Int(containerWidth / (WH + padding)) | |
| 135 | + let hangMaxNum = maxBlocksWithoutLastSpacing//一行几块 | |
| 136 | + containerWidth = CGFloat(hangMaxNum)*(WH+padding)-padding | |
| 137 | + | |
| 138 | + self.addSubview(self.bgScrollView) | |
| 139 | + bgScrollView.snp.makeConstraints { make in | |
| 140 | + make.top.equalTo(self.titleLabel.snp.bottom).offset(topPadding) | |
| 141 | + make.centerX.equalToSuperview() | |
| 142 | + make.width.equalTo(containerWidth) | |
| 143 | + make.bottom.equalToSuperview().offset(-50) | |
| 144 | + } | |
| 145 | + bgScrollView.backgroundColor = .clear | |
| 146 | + | |
| 147 | + self.addSubview(self.tableViewBgView) | |
| 148 | + tableViewBgView.snp.makeConstraints { make in | |
| 149 | + make.top.bottom.left.right.equalToSuperview() | |
| 150 | + } | |
| 151 | + tableViewBgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapAction))) | |
| 152 | + | |
| 153 | + tableViewBgView.addSubview(self.kandianTableView) | |
| 154 | + kandianTableView.snp.makeConstraints { make in | |
| 155 | + make.top.equalTo(self.titleLabel.snp.bottom).offset(topPadding) | |
| 156 | + make.centerX.equalToSuperview() | |
| 157 | + make.width.equalTo(containerWidth) | |
| 158 | + make.bottom.equalToSuperview().offset(-50) | |
| 159 | + } | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + } | |
| 164 | + | |
| 165 | + //看点列表 | |
| 166 | + func setupNewUI(kanDianListArr:NSMutableArray){ | |
| 167 | +// CNLiveVodPlayblockListListModel | |
| 168 | + self.bgScrollView.isHidden = true | |
| 169 | + self.kandianTableView.isHidden = false | |
| 170 | + self.kandianTableView.reloadData() | |
| 171 | + } | |
| 172 | + // MARK: - UITableViewDelegate | |
| 173 | + func numberOfSections(in tableView: UITableView) -> Int { | |
| 174 | + return 1 | |
| 175 | + } | |
| 176 | + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| 177 | + return self.kanDianListArr?.count ?? 0 | |
| 178 | + } | |
| 179 | + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| 180 | + | |
| 181 | + if let listModel = self.kanDianListArr?[indexPath.row] as? CNLiveVodPlayBlockListListModel{ | |
| 182 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVodXuanjiKandianCellIdentifier) as? CNLiveVodXuanjiKandianCell | |
| 183 | + else { | |
| 184 | + let cell = CNLiveVodXuanjiKandianCell() | |
| 185 | + return cell | |
| 186 | + } | |
| 187 | + if self.currSeleIdx == indexPath.row{ | |
| 188 | + cell.isSelect = true | |
| 189 | + }else{ | |
| 190 | + cell.isSelect = false | |
| 191 | + } | |
| 192 | + cell.vodPlayBlockListListModel = listModel | |
| 193 | + | |
| 194 | + cell.vodXuanjiKandianCellClickBlock = {[weak self] vodPlayBlockListListModel in | |
| 195 | + guard let self = self else { return } | |
| 196 | + self.vodPlayerLandscapeXuanjiKanDianSelectBlock?(indexPath.row,vodPlayBlockListListModel ?? CNLiveVodPlayBlockListListModel()) | |
| 197 | + self.currSeleIdx = indexPath.row | |
| 198 | + self.kandianTableView.reloadData() | |
| 199 | + self.isHidden = true | |
| 200 | + } | |
| 201 | + return cell | |
| 202 | + } | |
| 203 | + return UITableViewCell() | |
| 204 | + } | |
| 205 | + | |
| 206 | + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | |
| 207 | + let imgH:CGFloat = 65.0 | |
| 208 | + return imgH+10.0 | |
| 209 | + } | |
| 210 | + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
| 211 | + if let listModel = self.kanDianListArr?[indexPath.row] as? CNLiveVodPlayBlockListListModel{ | |
| 212 | + self.vodPlayerLandscapeXuanjiKanDianSelectBlock?(indexPath.row,listModel) | |
| 213 | + } | |
| 214 | + } | |
| 215 | + | |
| 216 | + //专辑列表 | |
| 217 | + func setupNewUI(model:CNLiveVodAlbumListBaseModel){ | |
| 218 | +// self.albumListArr = NSMutableArray(array: model.list) | |
| 219 | +// self.realHotCollectionView.reloadData() | |
| 220 | + | |
| 221 | + self.bgScrollView.isHidden = false | |
| 222 | + self.kandianTableView.isHidden = true | |
| 223 | + | |
| 224 | + let WH:CGFloat = 50.0 | |
| 225 | + let padding:CGFloat = 13.5 | |
| 226 | + let maxH = max(KSreenHeight, KSreenWidth) | |
| 227 | + let minH = max(KSreenHeight, KSreenWidth) | |
| 228 | + var containerWidth: CGFloat = maxH-158.0*2 | |
| 229 | + // 计算不包括最后一个方块间距时一行能放置的方块数量 | |
| 230 | + let maxBlocksWithoutLastSpacing = Int(containerWidth / (WH + padding)) | |
| 231 | + let hangMaxNum = maxBlocksWithoutLastSpacing//一行几块 | |
| 232 | + containerWidth = CGFloat(hangMaxNum)*(WH+padding)-padding | |
| 233 | + //lieIndex 当前是contents的第0列还是第1列 | |
| 234 | + var lieIndex = 0 | |
| 235 | + //hangIndex 当前是第几行,1...n | |
| 236 | + var hangIndex = 1 | |
| 237 | + | |
| 238 | + var maxContentHeight:CGFloat = self.bgScrollView.height | |
| 239 | + for i in 0..<model.list.count{ | |
| 240 | + let listMdl = model.list[i] | |
| 241 | + let rowH = WH+padding | |
| 242 | + let imgX = CGFloat(lieIndex)*(WH+padding) | |
| 243 | + let imgY = rowH*CGFloat(hangIndex-1) | |
| 244 | + | |
| 245 | + let imgBottom = imgY+WH | |
| 246 | + if imgBottom > maxContentHeight{ | |
| 247 | + maxContentHeight = imgBottom | |
| 248 | + } | |
| 249 | + self.bgScrollView.contentSize = CGSize(width: containerWidth, height: maxContentHeight) | |
| 250 | + let expandBtn = UIButton.init(type: .custom) | |
| 251 | + expandBtn.frame = CGRect(x: imgX, y: imgY, width: WH, height: WH) | |
| 252 | + | |
| 253 | + if i == self.currSeleIdx{ | |
| 254 | + expandBtn.backgroundColor = HexColor("#D3E4FF") | |
| 255 | + expandBtn.layer.borderWidth = 0.65 | |
| 256 | + expandBtn.layer.borderColor = HexColor("#478BFF")?.cgColor | |
| 257 | + expandBtn.isSelected = true | |
| 258 | + }else{ | |
| 259 | + expandBtn.backgroundColor = HexColor("#000000", alpha: 0.5) | |
| 260 | + expandBtn.layer.borderWidth = 0 | |
| 261 | + expandBtn.layer.borderColor = HexColor("#000000")?.cgColor | |
| 262 | + expandBtn.isSelected = false | |
| 263 | + } | |
| 264 | + expandBtn.setTitle("\(i+1)", for: .normal) | |
| 265 | + expandBtn.setTitle("\(i+1)", for: .selected) | |
| 266 | + expandBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal) | |
| 267 | + expandBtn.setTitleColor(HexColor("#478BFF"), for: .selected) | |
| 268 | + expandBtn.titleLabel?.font = Font_18 | |
| 269 | + expandBtn.layer.cornerRadius = 12 | |
| 270 | + expandBtn.clipsToBounds = true | |
| 271 | + expandBtn.tag = 100+i | |
| 272 | + expandBtn.addTarget(self, action: #selector(xuanjiBtnAction), for: .touchUpInside) | |
| 273 | + self.bgScrollView.addSubview(expandBtn) | |
| 274 | + | |
| 275 | + let layerView = UIImageView() | |
| 276 | + layerView.image = UIImage(named: "home_player_pay") | |
| 277 | + layerView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) | |
| 278 | + expandBtn.addSubview(layerView) | |
| 279 | + | |
| 280 | + if listMdl.product?.check == true { | |
| 281 | + //免费或者付过费了 | |
| 282 | + layerView.isHidden = true | |
| 283 | + } else { | |
| 284 | + if listMdl.product?.productType == "4" { | |
| 285 | + //这里表示可以进行试听 | |
| 286 | + layerView.isHidden = true | |
| 287 | + } else { | |
| 288 | + //需要付费 | |
| 289 | + layerView.isHidden = false | |
| 290 | + | |
| 291 | + //分转元,没有小数点 | |
| 292 | + let fenString = listMdl.product!.iosRmb | |
| 293 | + // 将字符串转换为整数 | |
| 294 | + // 使用guard语句确保字符串可以转换为整数 | |
| 295 | + guard let fen = Int(fenString) else { | |
| 296 | + print("无法将字符串转换为整数") | |
| 297 | + return | |
| 298 | + } | |
| 299 | + // 计算元值(整数除法,自动舍去小数部分) | |
| 300 | + var yuan = fen / 100 | |
| 301 | + if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元 | |
| 302 | + yuan = 1 | |
| 303 | + } | |
| 304 | + // 将结果转换为字符串 | |
| 305 | + let yuanString = String(yuan) | |
| 306 | + | |
| 307 | + } | |
| 308 | + } | |
| 309 | + | |
| 310 | + if lieIndex < hangMaxNum-1{ | |
| 311 | + lieIndex = lieIndex+1 | |
| 312 | + }else{ | |
| 313 | + lieIndex = 0 | |
| 314 | + hangIndex += 1 | |
| 315 | + } | |
| 316 | + } | |
| 317 | + | |
| 318 | + } | |
| 319 | + | |
| 320 | +// func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | |
| 321 | +// self.albumListArr.count | |
| 322 | +// } | |
| 323 | +// | |
| 324 | +// func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
| 325 | +// | |
| 326 | +// let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveVodAlbumListCollectionCellIdentifier, for: indexPath) as! CNLiveVodAlbumListCollectionCell | |
| 327 | +// if self.currSeleIdx == indexPath.row{ | |
| 328 | +// //当前cell选中 | |
| 329 | +// cell.isJiShuSelected = true | |
| 330 | +// }else{ | |
| 331 | +// //不选中 | |
| 332 | +// cell.isJiShuSelected = false | |
| 333 | +// } | |
| 334 | +// cell.num = indexPath.row | |
| 335 | +// cell.vodAlbumListModel = self.albumListArr[indexPath.row] as? CNLiveVodAlbumListModel | |
| 336 | +// return cell | |
| 337 | +// } | |
| 338 | +// func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | |
| 339 | +// if let vodAlbumListModel = self.albumListArr[indexPath.row] as? CNLiveVodAlbumListModel{ | |
| 340 | +// //点击某集,刷新页面 | |
| 341 | +// self.selectBlock?(vodAlbumListModel, indexPath.row, self.albumListArr) | |
| 342 | +// self.currSeleIdx = indexPath.row | |
| 343 | +// self.realHotCollectionView.reloadData() | |
| 344 | +// | |
| 345 | +// } | |
| 346 | +// } | |
| 347 | + | |
| 348 | + @objc func xuanjiBtnAction(btn:UIButton){ | |
| 349 | + let index = btn.tag-100 | |
| 350 | + if let listModel = self.vodAlbumListBaseModel?.list[index] as? CNLiveVodAlbumListModel{ | |
| 351 | + self.xuanjiUpdateBlock?(index,listModel) | |
| 352 | + } | |
| 353 | + } | |
| 354 | + @objc func tapAction(){ | |
| 355 | + self.isHidden = true | |
| 356 | + } | |
| 357 | + | |
| 358 | +} | |
| 359 | + | ... | ... |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/HengPing/CNLiveVodXuanjiKandianCell.swift
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveVodXuanjiKandianCell.swift | |
| 3 | +// metaCode | |
| 4 | +// | |
| 5 | +// Created by zx on 2025/4/9. | |
| 6 | +// 选集-看点列表 | |
| 7 | + | |
| 8 | +import Foundation | |
| 9 | + | |
| 10 | +typealias CNLiveVodXuanjiKandianCellClickBlock = (_ model:CNLiveVodPlayBlockListListModel?)->Void | |
| 11 | + | |
| 12 | +class CNLiveVodXuanjiKandianCell:UITableViewCell{ | |
| 13 | + var isSelect:Bool = false | |
| 14 | + | |
| 15 | + var vodXuanjiKandianCellClickBlock : CNLiveVodXuanjiKandianCellClickBlock? | |
| 16 | + //slideModel | |
| 17 | + var _vodPlayBlockListListModel : CNLiveVodPlayBlockListListModel? | |
| 18 | + var vodPlayBlockListListModel : CNLiveVodPlayBlockListListModel? { | |
| 19 | + get{ | |
| 20 | + _vodPlayBlockListListModel | |
| 21 | + } | |
| 22 | + set{ | |
| 23 | + _vodPlayBlockListListModel = newValue! | |
| 24 | + self.setupNewUI(model: _vodPlayBlockListListModel!) | |
| 25 | + } | |
| 26 | + } | |
| 27 | + | |
| 28 | + //MARK: - 懒加载 | |
| 29 | + lazy var totalBtn: UIButton = { | |
| 30 | + let expandBtn = UIButton(type: .custom) | |
| 31 | + expandBtn.backgroundColor = HexColor("#D3E4FF")//nor EEEEEE,sele #D3E4FF | |
| 32 | + expandBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal) | |
| 33 | + expandBtn.setTitleColor(HexColor("#478BFF"), for: .selected) | |
| 34 | + expandBtn.layer.cornerRadius = 9 | |
| 35 | + expandBtn.clipsToBounds = true | |
| 36 | +// expandBtn.isUserInteractionEnabled = false | |
| 37 | + expandBtn.addTarget(self, action: #selector(totalBtnAction), for: .touchUpInside) | |
| 38 | + return expandBtn | |
| 39 | + }() | |
| 40 | + lazy var titleLabel: UILabel = { | |
| 41 | + let titleLabel = UILabel.init() | |
| 42 | + titleLabel.textColor = .white | |
| 43 | + titleLabel.textAlignment = .left | |
| 44 | + titleLabel.font = Font_18 | |
| 45 | + return titleLabel | |
| 46 | + }() | |
| 47 | + lazy var timeTitleLabel: UILabel = { | |
| 48 | + let titleLabel = UILabel.init() | |
| 49 | + titleLabel.textColor = .white | |
| 50 | + titleLabel.textAlignment = .left | |
| 51 | + titleLabel.font = Font_18 | |
| 52 | + return titleLabel | |
| 53 | + }() | |
| 54 | + //付费角标 | |
| 55 | + lazy var payIconView :UIImageView = { | |
| 56 | + let layerView = UIImageView() | |
| 57 | + layerView.image = UIImage(named: "home_player_pay") | |
| 58 | + layerView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) | |
| 59 | + return layerView | |
| 60 | + }() | |
| 61 | + | |
| 62 | + | |
| 63 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | |
| 64 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | |
| 65 | + self.selectionStyle = .none | |
| 66 | + | |
| 67 | + setupUI() | |
| 68 | + } | |
| 69 | + | |
| 70 | + required init?(coder aDecoder: NSCoder) { | |
| 71 | + fatalError("init(coder:) has not been implemented") | |
| 72 | + } | |
| 73 | + | |
| 74 | + private func setupUI() { | |
| 75 | + self.backgroundColor = .clear | |
| 76 | + contentView.backgroundColor = .clear | |
| 77 | + | |
| 78 | + self.contentView.addSubview(self.totalBtn) | |
| 79 | + totalBtn.snp.makeConstraints { make in | |
| 80 | + make.left.right.equalToSuperview() | |
| 81 | + make.top.equalToSuperview() | |
| 82 | + make.bottom.equalToSuperview().offset(-10) | |
| 83 | + } | |
| 84 | + | |
| 85 | + self.totalBtn.addSubview(self.timeTitleLabel) | |
| 86 | + timeTitleLabel.snp.makeConstraints { make in | |
| 87 | + make.centerY.equalToSuperview() | |
| 88 | + make.right.equalToSuperview().offset(-30) | |
| 89 | + } | |
| 90 | + | |
| 91 | + self.totalBtn.addSubview(self.titleLabel) | |
| 92 | + titleLabel.snp.makeConstraints { make in | |
| 93 | + make.left.equalTo(25) | |
| 94 | + make.centerY.equalToSuperview() | |
| 95 | + make.right.lessThanOrEqualTo(self.timeTitleLabel.snp.left).offset(-10) | |
| 96 | + } | |
| 97 | + | |
| 98 | + self.totalBtn.addSubview(self.payIconView) | |
| 99 | + payIconView.snp.makeConstraints { make in | |
| 100 | + make.top.equalToSuperview() | |
| 101 | + make.right.equalToSuperview() | |
| 102 | + make.width.equalTo(26) | |
| 103 | + make.height.equalTo(15) | |
| 104 | + } | |
| 105 | + | |
| 106 | + } | |
| 107 | + | |
| 108 | + func setupNewUI(model:CNLiveVodPlayBlockListListModel){ | |
| 109 | + | |
| 110 | + self.titleLabel.text = model.title | |
| 111 | + if let formattedTime = convertSecondsToFormattedTime(secondsString: model.duration) { | |
| 112 | + print(formattedTime) // 输出: "05:59" | |
| 113 | + self.timeTitleLabel.text = formattedTime | |
| 114 | + } else { | |
| 115 | + print("Invalid seconds string") | |
| 116 | + self.timeTitleLabel.text = "00:00" | |
| 117 | + } | |
| 118 | + | |
| 119 | + self.totalBtn.isSelected = isSelect | |
| 120 | + if isSelect{ | |
| 121 | + //当前选中 | |
| 122 | + self.titleLabel.textColor = HexColor("#478BFF") | |
| 123 | + self.timeTitleLabel.textColor = HexColor("#478BFF") | |
| 124 | + self.totalBtn.backgroundColor = HexColor("#D3E4FF") | |
| 125 | + }else{ | |
| 126 | + //未选中 | |
| 127 | + self.titleLabel.textColor = HexColor("#FFFFFF") | |
| 128 | + self.timeTitleLabel.textColor = HexColor("#FFFFFF") | |
| 129 | + self.totalBtn.backgroundColor = HexColor("#000000", alpha: 0.5) | |
| 130 | + | |
| 131 | + } | |
| 132 | + if model.product?.check == true { | |
| 133 | + //免费或者付过费了 | |
| 134 | + payIconView.isHidden = true | |
| 135 | + } else { | |
| 136 | + if model.product?.productType == "4" { | |
| 137 | + //这里表示可以进行试听 | |
| 138 | + payIconView.isHidden = true | |
| 139 | + } else { | |
| 140 | + //需要付费 | |
| 141 | + payIconView.isHidden = false | |
| 142 | + | |
| 143 | + //分转元,没有小数点 | |
| 144 | + let fenString = model.product!.iosRmb | |
| 145 | + // 将字符串转换为整数 | |
| 146 | + // 使用guard语句确保字符串可以转换为整数 | |
| 147 | + guard let fen = Int(fenString) else { | |
| 148 | + print("无法将字符串转换为整数") | |
| 149 | + return | |
| 150 | + } | |
| 151 | + // 计算元值(整数除法,自动舍去小数部分) | |
| 152 | + var yuan = fen / 100 | |
| 153 | + if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元 | |
| 154 | + yuan = 1 | |
| 155 | + } | |
| 156 | + // 将结果转换为字符串 | |
| 157 | + let yuanString = String(yuan) | |
| 158 | + | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 162 | + } | |
| 163 | + func convertSecondsToFormattedTime(secondsString: String) -> String? { | |
| 164 | + if let seconds = Int(secondsString) { | |
| 165 | + let hours = seconds / 3600 | |
| 166 | + let minutes = (seconds % 3600) / 60 | |
| 167 | + let secondsRemainder = seconds % 60 | |
| 168 | + | |
| 169 | + if hours == 0 { | |
| 170 | + // 如果小时为0,则返回mm:ss格式 | |
| 171 | + return String(format: "%02d:%02d", minutes, secondsRemainder) | |
| 172 | + } else { | |
| 173 | + // 如果小时不为0,则返回hh:mm:ss格式 | |
| 174 | + return String(format: "%02d:%02d:%02d", hours, minutes, secondsRemainder) | |
| 175 | + } | |
| 176 | + } | |
| 177 | + return nil // 如果字符串不能转换为整数,则返回nil | |
| 178 | + } | |
| 179 | + @objc func totalBtnAction(btn: UIButton){ | |
| 180 | + self.vodXuanjiKandianCellClickBlock?(self.vodPlayBlockListListModel) | |
| 181 | + | |
| 182 | + } | |
| 183 | + | |
| 184 | +} | ... | ... |