Commit 35b40aa77db8368e95b4f1071cd06d6d6179b882
1 parent
5b496349
专辑单集是否付费判断;
开屏广告;
Showing
23 changed files
with
602 additions
and
15 deletions
metaCode.xcodeproj/project.pbxproj
| @@ -201,6 +201,10 @@ | @@ -201,6 +201,10 @@ | ||
| 201 | 196A55F92D963AE700B06DB7 /* CNLiveVodLandscapeGaoqingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */; }; | 201 | 196A55F92D963AE700B06DB7 /* CNLiveVodLandscapeGaoqingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */; }; |
| 202 | 196A55FB2D9BE7DC00B06DB7 /* CNLiveVodPayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55FA2D9BE7DC00B06DB7 /* CNLiveVodPayView.swift */; }; | 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 | 196A55FD2DA66AEE00B06DB7 /* CNLiveVodXuanjiKandianCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55FC2DA66AED00B06DB7 /* CNLiveVodXuanjiKandianCell.swift */; }; |
| 204 | + 196A55FF2DB766BC00B06DB7 /* LaunchAdManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55FE2DB766BC00B06DB7 /* LaunchAdManager.swift */; }; | ||
| 205 | + 196A56012DB7717B00B06DB7 /* CNOSAdImgDownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A56002DB7717B00B06DB7 /* CNOSAdImgDownloadManager.swift */; }; | ||
| 206 | + 196A56032DB7720A00B06DB7 /* CNLiveLaunchAdController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A56022DB7720A00B06DB7 /* CNLiveLaunchAdController.swift */; }; | ||
| 207 | + 196A56062DB7752900B06DB7 /* CNLiveAdViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A56052DB7752900B06DB7 /* CNLiveAdViewModel.swift */; }; | ||
| 204 | 197325D22BB11C18002E41A3 /* DatabaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 197325D12BB11C18002E41A3 /* DatabaseManager.swift */; }; | 208 | 197325D22BB11C18002E41A3 /* DatabaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 197325D12BB11C18002E41A3 /* DatabaseManager.swift */; }; |
| 205 | 1975636E2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1975636D2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift */; }; | 209 | 1975636E2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1975636D2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift */; }; |
| 206 | 197563712C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 197563702C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift */; }; | 210 | 197563712C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 197563702C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift */; }; |
| @@ -605,6 +609,10 @@ | @@ -605,6 +609,10 @@ | ||
| 605 | 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodLandscapeGaoqingView.swift; sourceTree = "<group>"; }; | 609 | 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodLandscapeGaoqingView.swift; sourceTree = "<group>"; }; |
| 606 | 196A55FA2D9BE7DC00B06DB7 /* CNLiveVodPayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodPayView.swift; sourceTree = "<group>"; }; | 610 | 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>"; }; | 611 | 196A55FC2DA66AED00B06DB7 /* CNLiveVodXuanjiKandianCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodXuanjiKandianCell.swift; sourceTree = "<group>"; }; |
| 612 | + 196A55FE2DB766BC00B06DB7 /* LaunchAdManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchAdManager.swift; sourceTree = "<group>"; }; | ||
| 613 | + 196A56002DB7717B00B06DB7 /* CNOSAdImgDownloadManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNOSAdImgDownloadManager.swift; sourceTree = "<group>"; }; | ||
| 614 | + 196A56022DB7720A00B06DB7 /* CNLiveLaunchAdController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveLaunchAdController.swift; sourceTree = "<group>"; }; | ||
| 615 | + 196A56052DB7752900B06DB7 /* CNLiveAdViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveAdViewModel.swift; sourceTree = "<group>"; }; | ||
| 608 | 197325D12BB11C18002E41A3 /* DatabaseManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseManager.swift; sourceTree = "<group>"; }; | 616 | 197325D12BB11C18002E41A3 /* DatabaseManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseManager.swift; sourceTree = "<group>"; }; |
| 609 | 1975636D2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVitaeWorkDetailController.swift; sourceTree = "<group>"; }; | 617 | 1975636D2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVitaeWorkDetailController.swift; sourceTree = "<group>"; }; |
| 610 | 197563702C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVitaeWorkCell.swift; sourceTree = "<group>"; }; | 618 | 197563702C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVitaeWorkCell.swift; sourceTree = "<group>"; }; |
| @@ -1500,6 +1508,17 @@ | @@ -1500,6 +1508,17 @@ | ||
| 1500 | path = HengPing; | 1508 | path = HengPing; |
| 1501 | sourceTree = "<group>"; | 1509 | sourceTree = "<group>"; |
| 1502 | }; | 1510 | }; |
| 1511 | + 196A56042DB7720F00B06DB7 /* AD */ = { | ||
| 1512 | + isa = PBXGroup; | ||
| 1513 | + children = ( | ||
| 1514 | + 196A55FE2DB766BC00B06DB7 /* LaunchAdManager.swift */, | ||
| 1515 | + 196A56002DB7717B00B06DB7 /* CNOSAdImgDownloadManager.swift */, | ||
| 1516 | + 196A56022DB7720A00B06DB7 /* CNLiveLaunchAdController.swift */, | ||
| 1517 | + 196A56052DB7752900B06DB7 /* CNLiveAdViewModel.swift */, | ||
| 1518 | + ); | ||
| 1519 | + path = AD; | ||
| 1520 | + sourceTree = "<group>"; | ||
| 1521 | + }; | ||
| 1503 | 197325D02BB11BFD002E41A3 /* DatabaseManager */ = { | 1522 | 197325D02BB11BFD002E41A3 /* DatabaseManager */ = { |
| 1504 | isa = PBXGroup; | 1523 | isa = PBXGroup; |
| 1505 | children = ( | 1524 | children = ( |
| @@ -1847,6 +1866,7 @@ | @@ -1847,6 +1866,7 @@ | ||
| 1847 | 7963988B2A260C0100D045EB /* Other */ = { | 1866 | 7963988B2A260C0100D045EB /* Other */ = { |
| 1848 | isa = PBXGroup; | 1867 | isa = PBXGroup; |
| 1849 | children = ( | 1868 | children = ( |
| 1869 | + 196A56042DB7720F00B06DB7 /* AD */, | ||
| 1850 | 790D01992A2DCAE400C5978D /* CNLiveViewController.swift */, | 1870 | 790D01992A2DCAE400C5978D /* CNLiveViewController.swift */, |
| 1851 | 7963988D2A260C0100D045EB /* AppDelegate.swift */, | 1871 | 7963988D2A260C0100D045EB /* AppDelegate.swift */, |
| 1852 | ); | 1872 | ); |
| @@ -2433,12 +2453,14 @@ | @@ -2433,12 +2453,14 @@ | ||
| 2433 | 790D01A52A2DF65E00C5978D /* CNLiveLoginPickerView.swift in Sources */, | 2453 | 790D01A52A2DF65E00C5978D /* CNLiveLoginPickerView.swift in Sources */, |
| 2434 | 191733042B0F216E007BCC04 /* NSDictionary+CNLiveExtensions.swift in Sources */, | 2454 | 191733042B0F216E007BCC04 /* NSDictionary+CNLiveExtensions.swift in Sources */, |
| 2435 | 192ED48A2C5771930057244C /* CNLiveVitaeAddWorkSecCell.swift in Sources */, | 2455 | 192ED48A2C5771930057244C /* CNLiveVitaeAddWorkSecCell.swift in Sources */, |
| 2456 | + 196A55FF2DB766BC00B06DB7 /* LaunchAdManager.swift in Sources */, | ||
| 2436 | 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDB.swift in Sources */, | 2457 | 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDB.swift in Sources */, |
| 2437 | 79282A3C2A2EDC2500B5F8CF /* NSString+CNLiveExtensions.swift in Sources */, | 2458 | 79282A3C2A2EDC2500B5F8CF /* NSString+CNLiveExtensions.swift in Sources */, |
| 2438 | 19D2CE632AE8B65D00691757 /* CNLiveDownSlideTool.swift in Sources */, | 2459 | 19D2CE632AE8B65D00691757 /* CNLiveDownSlideTool.swift in Sources */, |
| 2439 | 790B1FB82A41B6A60074CF00 /* CNLiveMineMessageViewController.swift in Sources */, | 2460 | 790B1FB82A41B6A60074CF00 /* CNLiveMineMessageViewController.swift in Sources */, |
| 2440 | 1917333C2B27FE75007BCC04 /* CNLiveShopClassilyManageHeaderView.swift in Sources */, | 2461 | 1917333C2B27FE75007BCC04 /* CNLiveShopClassilyManageHeaderView.swift in Sources */, |
| 2441 | 191733252B146078007BCC04 /* CNLivePlayerSlider.swift in Sources */, | 2462 | 191733252B146078007BCC04 /* CNLivePlayerSlider.swift in Sources */, |
| 2463 | + 196A56032DB7720A00B06DB7 /* CNLiveLaunchAdController.swift in Sources */, | ||
| 2442 | 194134982C292199004FC047 /* CNLiveIdentityRepositoryController.swift in Sources */, | 2464 | 194134982C292199004FC047 /* CNLiveIdentityRepositoryController.swift in Sources */, |
| 2443 | 19BB202B2AF382150094D962 /* CNLiveAdaptTool.swift in Sources */, | 2465 | 19BB202B2AF382150094D962 /* CNLiveAdaptTool.swift in Sources */, |
| 2444 | 1941347C2C180030004FC047 /* UIImage_extension.swift in Sources */, | 2466 | 1941347C2C180030004FC047 /* UIImage_extension.swift in Sources */, |
| @@ -2641,6 +2663,7 @@ | @@ -2641,6 +2663,7 @@ | ||
| 2641 | 195650C92D769CEA00818FC8 /* CNLiveVodTrailersCell.swift in Sources */, | 2663 | 195650C92D769CEA00818FC8 /* CNLiveVodTrailersCell.swift in Sources */, |
| 2642 | 191733362B27EFD4007BCC04 /* CNLiveShopClassilyManageViewController.swift in Sources */, | 2664 | 191733362B27EFD4007BCC04 /* CNLiveShopClassilyManageViewController.swift in Sources */, |
| 2643 | 799172322AF08D1B00DC01A8 /* CNLiveShopOrderViewController.swift in Sources */, | 2665 | 799172322AF08D1B00DC01A8 /* CNLiveShopOrderViewController.swift in Sources */, |
| 2666 | + 196A56062DB7752900B06DB7 /* CNLiveAdViewModel.swift in Sources */, | ||
| 2644 | 1917332D2B15DB20007BCC04 /* CNLivePlayerKVOModel.swift in Sources */, | 2667 | 1917332D2B15DB20007BCC04 /* CNLivePlayerKVOModel.swift in Sources */, |
| 2645 | 1917333F2B284C93007BCC04 /* CNLiveShopCouponCreateViewController.swift in Sources */, | 2668 | 1917333F2B284C93007BCC04 /* CNLiveShopCouponCreateViewController.swift in Sources */, |
| 2646 | 1917335C2B3283FF007BCC04 /* CNLiveCouponGoodsListSearchView.swift in Sources */, | 2669 | 1917335C2B3283FF007BCC04 /* CNLiveCouponGoodsListSearchView.swift in Sources */, |
| @@ -2756,6 +2779,7 @@ | @@ -2756,6 +2779,7 @@ | ||
| 2756 | 1969E1AD2C92E98700E4185E /* CNHomeWebViewController.swift in Sources */, | 2779 | 1969E1AD2C92E98700E4185E /* CNHomeWebViewController.swift in Sources */, |
| 2757 | 1938BD342B4B968300390A34 /* CNLiveHomePageDuanJuCell.swift in Sources */, | 2780 | 1938BD342B4B968300390A34 /* CNLiveHomePageDuanJuCell.swift in Sources */, |
| 2758 | 192FDB062D8D0B7E00F8723D /* CNLiveVodShopBottomView.swift in Sources */, | 2781 | 192FDB062D8D0B7E00F8723D /* CNLiveVodShopBottomView.swift in Sources */, |
| 2782 | + 196A56012DB7717B00B06DB7 /* CNOSAdImgDownloadManager.swift in Sources */, | ||
| 2759 | 192ED4872C575EC90057244C /* CNLiveVitaeAddWorkFirCell.swift in Sources */, | 2783 | 192ED4872C575EC90057244C /* CNLiveVitaeAddWorkFirCell.swift in Sources */, |
| 2760 | 191733522B2C4CEA007BCC04 /* CNLivePickerSelectDateTools.swift in Sources */, | 2784 | 191733522B2C4CEA007BCC04 /* CNLivePickerSelectDateTools.swift in Sources */, |
| 2761 | 1917333A2B27FDF3007BCC04 /* CNLiveShopClassilyManageTableViewCell.swift in Sources */, | 2785 | 1917333A2B27FDF3007BCC04 /* CNLiveShopClassilyManageTableViewCell.swift in Sources */, |
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
| @@ -1143,7 +1143,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -1143,7 +1143,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 1143 | vodAlbumListModel = vodAlbumListMdl | 1143 | vodAlbumListModel = vodAlbumListMdl |
| 1144 | } | 1144 | } |
| 1145 | } | 1145 | } |
| 1146 | - self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: vodModel.product, mdlContentId: vodModel.contentId, isAblumVideo: isAblumVideo, albumSelectIndex: index, albumListArray: albumListArr, kanDianSelectIndex: -1, kanDianListArray: NSMutableArray(), isPlayAblumOrKandian: isAblumVideo, xuanjiBgViewCurrSeleIdx: 0, xuanjiBgViewKanDianListArr: NSMutableArray(), modelTitle: vodModel.title, mdlActiveId: vodModel.contentId, mdlModel: vodModel.modelId, yuanString: yuanString, payVodAlbumListModel: vodAlbumListModel, vodAlbumListBaseModel: vodAlbumListBaseModel) | 1146 | + self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: vodModel.product, mdlContentId: vodModel.contentId, isAblumVideo: isAblumVideo, albumSelectIndex: index, albumListArray: albumListArr, kanDianSelectIndex: -1, kanDianListArray: NSMutableArray(), isPlayAblumOrKandian: isAblumVideo, xuanjiBgViewCurrSeleIdx: 0, xuanjiBgViewKanDianListArr: NSMutableArray(), modelTitle: vodModel.title, mdlActiveId: vodModel.activityId, mdlModel: vodModel.modelId, yuanString: yuanString, payVodAlbumListModel: vodAlbumListModel, vodAlbumListBaseModel: vodAlbumListBaseModel) |
| 1147 | 1147 | ||
| 1148 | // if isPayZhuanJi{ | 1148 | // if isPayZhuanJi{ |
| 1149 | // //已经付费 | 1149 | // //已经付费 |
metaCode/Classes/Main/HuBiLieHomePage/Util/CNLivePlayerTool.swift
| @@ -9,9 +9,42 @@ import Foundation | @@ -9,9 +9,42 @@ import Foundation | ||
| 9 | 9 | ||
| 10 | class CNLivePlayerTool:NSObject{ | 10 | class CNLivePlayerTool:NSObject{ |
| 11 | 11 | ||
| 12 | - //判断 专辑/单集 是否付费 | 12 | + //判断 专辑/单集 是否需要付费 |
| 13 | class func isPaid(product:CNLiveAlbumProductModel?) -> Bool{ | 13 | class func isPaid(product:CNLiveAlbumProductModel?) -> Bool{ |
| 14 | var isPaid:Bool = false | 14 | var isPaid:Bool = false |
| 15 | + if product?.check == true{ | ||
| 16 | + //付过费/免费 | ||
| 17 | + isPaid = false | ||
| 18 | + }else{ | ||
| 19 | + if product?.albumProductType.count ?? 0 > 0{ | ||
| 20 | + //专辑 | ||
| 21 | + if product?.albumProductType == "2" || product?.albumProductType == "5"{ | ||
| 22 | + //人民币 ,专辑付费 | ||
| 23 | + isPaid = true | ||
| 24 | + }else{ | ||
| 25 | + //免费 | ||
| 26 | + } | ||
| 27 | + }else{ | ||
| 28 | + //单集 | ||
| 29 | + if product?.productType.count ?? 0 > 0{ | ||
| 30 | + //单集 | ||
| 31 | + if product?.productType == "2" || product?.productType == "5"{ | ||
| 32 | + //人民币付费 / 专辑付费 | ||
| 33 | + isPaid = true | ||
| 34 | + }else{ | ||
| 35 | + //免费 | ||
| 36 | + } | ||
| 37 | + }else{ | ||
| 38 | + //免费 | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + return isPaid | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + //判断 专辑/单集 是否需要展示付费icon角标 | ||
| 46 | + class func isShowPaidIcon(product:CNLiveAlbumProductModel?) -> Bool{ | ||
| 47 | + var isPaid:Bool = false | ||
| 15 | if product?.albumProductType.count ?? 0 > 0{ | 48 | if product?.albumProductType.count ?? 0 > 0{ |
| 16 | //专辑 | 49 | //专辑 |
| 17 | if product?.albumProductType == "2" || product?.albumProductType == "5"{ | 50 | if product?.albumProductType == "2" || product?.albumProductType == "5"{ |
| @@ -36,7 +69,6 @@ class CNLivePlayerTool:NSObject{ | @@ -36,7 +69,6 @@ class CNLivePlayerTool:NSObject{ | ||
| 36 | } | 69 | } |
| 37 | return isPaid | 70 | return isPaid |
| 38 | } | 71 | } |
| 39 | - | ||
| 40 | 72 | ||
| 41 | class func vidGetPlayerUrl(contentId:String){ | 73 | class func vidGetPlayerUrl(contentId:String){ |
| 42 | 74 |
metaCode/Classes/Main/HuBiLieHomePage/View/Home/Home/CNLiveHomeLanmuCell.swift
| @@ -79,6 +79,7 @@ class CNLiveHomeLanmuCell:UITableViewCell{ | @@ -79,6 +79,7 @@ class CNLiveHomeLanmuCell:UITableViewCell{ | ||
| 79 | 79 | ||
| 80 | } | 80 | } |
| 81 | @objc func iconImgViewAction(ges: UITapGestureRecognizer){ | 81 | @objc func iconImgViewAction(ges: UITapGestureRecognizer){ |
| 82 | + showLoading(message: "") | ||
| 82 | let imageView = ges.view as! UIImageView | 83 | let imageView = ges.view as! UIImageView |
| 83 | let index = imageView.tag-1000 | 84 | let index = imageView.tag-1000 |
| 84 | if let slideModel = self.slideModel?.contents[index]{ | 85 | if let slideModel = self.slideModel?.contents[index]{ |
metaCode/Classes/Main/HuBiLieHomePage/View/Home/Home/CNLiveHomeOneBigTwoSmallCell.swift
| @@ -392,7 +392,7 @@ class CNLiveHomeOneBigTwoSmallCell:UITableViewCell{ | @@ -392,7 +392,7 @@ class CNLiveHomeOneBigTwoSmallCell:UITableViewCell{ | ||
| 392 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) | 392 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) |
| 393 | imageView.addSubview(payIconView) | 393 | imageView.addSubview(payIconView) |
| 394 | 394 | ||
| 395 | - let isPaid = CNLivePlayerTool.isPaid(product: contMdl.product) | 395 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: contMdl.product) |
| 396 | if isPaid{ | 396 | if isPaid{ |
| 397 | payIconView.isHidden = false | 397 | payIconView.isHidden = false |
| 398 | }else{ | 398 | }else{ |
metaCode/Classes/Main/HuBiLieHomePage/View/Home/Home/CNLiveHomeTwoDuanjuCell.swift
| @@ -112,7 +112,7 @@ class CNLiveHomeTwoDuanjuCell:UITableViewCell{ | @@ -112,7 +112,7 @@ class CNLiveHomeTwoDuanjuCell:UITableViewCell{ | ||
| 112 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) | 112 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) |
| 113 | imageView.addSubview(payIconView) | 113 | imageView.addSubview(payIconView) |
| 114 | 114 | ||
| 115 | - let isPaid = CNLivePlayerTool.isPaid(product: contMdl.product) | 115 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: contMdl.product) |
| 116 | if isPaid{ | 116 | if isPaid{ |
| 117 | payIconView.isHidden = false | 117 | payIconView.isHidden = false |
| 118 | }else{ | 118 | }else{ |
metaCode/Classes/Main/HuBiLieHomePage/View/Home/Home/CNLiveHomeTwoHengTuCell.swift
| @@ -135,7 +135,7 @@ class CNLiveHomeTwoHengTuCell: UITableViewCell { | @@ -135,7 +135,7 @@ class CNLiveHomeTwoHengTuCell: UITableViewCell { | ||
| 135 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) | 135 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) |
| 136 | imageView.addSubview(payIconView) | 136 | imageView.addSubview(payIconView) |
| 137 | 137 | ||
| 138 | - let isPaid = CNLivePlayerTool.isPaid(product: mdl.product) | 138 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: mdl.product) |
| 139 | if isPaid{ | 139 | if isPaid{ |
| 140 | payIconView.isHidden = false | 140 | payIconView.isHidden = false |
| 141 | }else{ | 141 | }else{ |
| @@ -202,7 +202,7 @@ class CNLiveHomeTwoHengTuCell: UITableViewCell { | @@ -202,7 +202,7 @@ class CNLiveHomeTwoHengTuCell: UITableViewCell { | ||
| 202 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) | 202 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) |
| 203 | imageView.addSubview(payIconView) | 203 | imageView.addSubview(payIconView) |
| 204 | 204 | ||
| 205 | - let isPaid = CNLivePlayerTool.isPaid(product: mdl.product) | 205 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: mdl.product) |
| 206 | if isPaid{ | 206 | if isPaid{ |
| 207 | payIconView.isHidden = false | 207 | payIconView.isHidden = false |
| 208 | }else{ | 208 | }else{ |
metaCode/Classes/Main/HuBiLieHomePage/View/Home/Lanmu/CNLiveHomeLanmuThreeImgCell.swift
| @@ -62,7 +62,7 @@ class CNLiveHomeLanmuThreeImgCell: UITableViewCell { | @@ -62,7 +62,7 @@ class CNLiveHomeLanmuThreeImgCell: UITableViewCell { | ||
| 62 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) | 62 | payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15) |
| 63 | imageView.addSubview(payIconView) | 63 | imageView.addSubview(payIconView) |
| 64 | 64 | ||
| 65 | - let isPaid = CNLivePlayerTool.isPaid(product: mdl.product) | 65 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: mdl.product) |
| 66 | if isPaid{ | 66 | if isPaid{ |
| 67 | payIconView.isHidden = false | 67 | payIconView.isHidden = false |
| 68 | }else{ | 68 | }else{ |
metaCode/Classes/Main/HuBiLieHomePage/View/Home/Search/CNLiveHomeSearchResultJuJiCell.swift
| @@ -98,7 +98,7 @@ class CNLiveHomeSearchResultJuJiCell: UITableViewCell { | @@ -98,7 +98,7 @@ class CNLiveHomeSearchResultJuJiCell: UITableViewCell { | ||
| 98 | 98 | ||
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | - let isPaid = CNLivePlayerTool.isPaid(product: model.product) | 101 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: model.product) |
| 102 | if isPaid{ | 102 | if isPaid{ |
| 103 | payIconView.isHidden = false | 103 | payIconView.isHidden = false |
| 104 | }else{ | 104 | }else{ |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodAlbumListCollectionCell.swift
| @@ -63,7 +63,7 @@ class CNLiveVodAlbumListCollectionCell: UICollectionViewCell { | @@ -63,7 +63,7 @@ class CNLiveVodAlbumListCollectionCell: UICollectionViewCell { | ||
| 63 | 63 | ||
| 64 | func setupNewUI(model:CNLiveVodAlbumListModel){ | 64 | func setupNewUI(model:CNLiveVodAlbumListModel){ |
| 65 | 65 | ||
| 66 | - let isPaid = CNLivePlayerTool.isPaid(product: model.product) | 66 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: model.product) |
| 67 | if isPaid{ | 67 | if isPaid{ |
| 68 | self.payIconView.isHidden = false | 68 | self.payIconView.isHidden = false |
| 69 | }else{ | 69 | }else{ |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodTrailerExpandCell.swift
| @@ -99,7 +99,7 @@ class CNLiveVodTrailerExpandCell:UITableViewCell{ | @@ -99,7 +99,7 @@ class CNLiveVodTrailerExpandCell:UITableViewCell{ | ||
| 99 | self.subTitleLabel.text = model.subTitle | 99 | self.subTitleLabel.text = model.subTitle |
| 100 | self.iconImgView.kf.setImage(with: URL(string: model.img)) | 100 | self.iconImgView.kf.setImage(with: URL(string: model.img)) |
| 101 | 101 | ||
| 102 | - let isPaid = CNLivePlayerTool.isPaid(product: model.product) | 102 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: model.product) |
| 103 | if isPaid{ | 103 | if isPaid{ |
| 104 | self.payIconView.isHidden = false | 104 | self.payIconView.isHidden = false |
| 105 | }else{ | 105 | }else{ |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodTrailersCollectionCell.swift
| @@ -105,7 +105,7 @@ class CNLiveVodTrailersCollectionCell: UICollectionViewCell { | @@ -105,7 +105,7 @@ class CNLiveVodTrailersCollectionCell: UICollectionViewCell { | ||
| 105 | self.titleLabel.text = model.title | 105 | self.titleLabel.text = model.title |
| 106 | self.subTitleLabel.text = model.subTitle | 106 | self.subTitleLabel.text = model.subTitle |
| 107 | 107 | ||
| 108 | - let isPaid = CNLivePlayerTool.isPaid(product: model.product) | 108 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: model.product) |
| 109 | if isPaid{ | 109 | if isPaid{ |
| 110 | payIconView.isHidden = false | 110 | payIconView.isHidden = false |
| 111 | }else{ | 111 | }else{ |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/HengPing/CNLiveVodPayView.swift
| @@ -17,7 +17,7 @@ class CNLiveVodPayView:UIView,UIGestureRecognizerDelegate{ | @@ -17,7 +17,7 @@ class CNLiveVodPayView:UIView,UIGestureRecognizerDelegate{ | ||
| 17 | let titleLbl = UILabel() | 17 | let titleLbl = UILabel() |
| 18 | titleLbl.font = Font_12 | 18 | titleLbl.font = Font_12 |
| 19 | titleLbl.textColor = HexColor("#FFFFFF") | 19 | titleLbl.textColor = HexColor("#FFFFFF") |
| 20 | - titleLbl.text = "应版权方要求,本专辑所有用户均需付费" | 20 | + titleLbl.text = "应版权方要求,本内容所有用户均需付费" |
| 21 | return titleLbl | 21 | return titleLbl |
| 22 | }() | 22 | }() |
| 23 | lazy var payBtn: UIButton = { | 23 | lazy var payBtn: UIButton = { |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/HengPing/CNLiveVodXuanjiKandianCell.swift
| @@ -154,7 +154,7 @@ class CNLiveVodXuanjiKandianCell:UITableViewCell{ | @@ -154,7 +154,7 @@ class CNLiveVodXuanjiKandianCell:UITableViewCell{ | ||
| 154 | // | 154 | // |
| 155 | // } | 155 | // } |
| 156 | // } | 156 | // } |
| 157 | - let isPaid = CNLivePlayerTool.isPaid(product: model.product) | 157 | + let isPaid = CNLivePlayerTool.isShowPaidIcon(product: model.product) |
| 158 | if isPaid{ | 158 | if isPaid{ |
| 159 | payIconView.isHidden = false | 159 | payIconView.isHidden = false |
| 160 | }else{ | 160 | }else{ |
metaCode/Classes/Other/AD/CNLiveAdViewModel.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveAdViewModel.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2025/4/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import CNLiveRequestBastKit | ||
| 10 | +import CNLiveBusinessTools | ||
| 11 | + | ||
| 12 | +class CNLiveAdViewModel:NSObject,URLSessionTaskDelegate{ | ||
| 13 | + static let shared = CNLiveAdViewModel() | ||
| 14 | + | ||
| 15 | + func getAdData(resultBlock: @escaping downSlideResultBlock){ | ||
| 16 | + let param = NSMutableDictionary() | ||
| 17 | + param.setValue("IOS", forKey: "deviceType") | ||
| 18 | + param.setValue("C", forKey: "type") | ||
| 19 | + param.setValue("apple", forKey: "app_channel_id") | ||
| 20 | + let kAppBundleID = Bundle.main.bundleIdentifier ?? "" | ||
| 21 | + let uuid : String = UIDevice.current.identifierForVendor?.uuidString.replacingOccurrences(of: "-", with: "") ?? "" | ||
| 22 | + let ver : String = Bundle.main.infoDictionary?["CFBundleVersion"] as! String | ||
| 23 | + let p : Dictionary = ["platform_id":kAppBundleID,"uuid":uuid,"plat":"i","ver":ver,"appId":APPId,"timestamp":String(NSNumber(floatLiteral: Date().timeIntervalSince1970).intValue),"clientPlat":"i","frmId":"ios"] | ||
| 24 | + | ||
| 25 | + param.setValue(kAppBundleID, forKey: "platform_id") | ||
| 26 | + param.setValue(uuid, forKey: "uuid") | ||
| 27 | + param.setValue("i", forKey: "plat") | ||
| 28 | + param.setValue(ver, forKey: "ver") | ||
| 29 | + param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId") | ||
| 30 | + param.setValue(String(NSNumber(floatLiteral: Date().timeIntervalSince1970).intValue), forKey: "timestamp") | ||
| 31 | + param.setValue("i", forKey: "clientPlat") | ||
| 32 | + param.setValue("ios", forKey: "frmId") | ||
| 33 | + | ||
| 34 | + let signStr = CNLiveBusinessTools.signvalue(param as! [AnyHashable : Any]) | ||
| 35 | + let string1 = "\(signStr)&key=\(CNLiveMCEnvironmentManager.shared.appKey_wjj)" | ||
| 36 | + let signString1 = CNLiveBusinessTools.sha1(string1).uppercased() | ||
| 37 | + param.setValue(signString1, forKey: "sign") | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + let adUrl = APPBaseWjjUrl+"/Daren/common/getNewestVersion.action" | ||
| 41 | + let videourl = "\(adUrl)?\(signStr)&sign=\(signString1)" | ||
| 42 | + print("111111URL:\(videourl)") | ||
| 43 | + | ||
| 44 | + // 创建一个可变URL请求 | ||
| 45 | + let urlRequest = NSMutableURLRequest(url: URL(string: videourl)!) | ||
| 46 | + urlRequest.httpMethod = "POST" | ||
| 47 | + urlRequest.timeoutInterval = 60 | ||
| 48 | + | ||
| 49 | + let config = URLSessionConfiguration.default | ||
| 50 | + config.requestCachePolicy = .reloadIgnoringLocalCacheData | ||
| 51 | + | ||
| 52 | + let urlSession = URLSession(configuration: config, delegate: self, delegateQueue: OperationQueue.current) | ||
| 53 | + let task = urlSession.dataTask(with: urlRequest as URLRequest) { data, response, error in | ||
| 54 | + if let urlResponse = response as? HTTPURLResponse, urlResponse.statusCode == 301 || urlResponse.statusCode == 302 { | ||
| 55 | + // do something ... | ||
| 56 | + resultBlock("", .failed) | ||
| 57 | + }else if let urlResponse = response as? HTTPURLResponse, urlResponse.statusCode == 200 || urlResponse.statusCode == 0{ | ||
| 58 | + do { | ||
| 59 | + if let jsonResult = try JSONSerialization.jsonObject(with: data ?? Data(), options: []) as? [String: Any]{ | ||
| 60 | + resultBlock(jsonResult["data"], .success) | ||
| 61 | + }else{ | ||
| 62 | + resultBlock("", .failed) | ||
| 63 | + } | ||
| 64 | + } catch { | ||
| 65 | + print("JSON 解析错误") | ||
| 66 | + resultBlock("", .failed) | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + task.resume() | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) { | ||
| 75 | + print("\(response.statusCode)") // 302 | ||
| 76 | + print("\(response.allHeaderFields["Location"] as? String ?? "无重定向地址")") // 重定向地址URL | ||
| 77 | + | ||
| 78 | + // 根据业务需求决定是否使用新的请求继续任务 | ||
| 79 | + // completionHandler(request) // 使用新的请求继续任务 | ||
| 80 | + // completionHandler(nil) // 不使用新的请求,取消重定向 | ||
| 81 | + | ||
| 82 | + // 在这个例子中,我们简单地取消重定向(即不使用新的请求) | ||
| 83 | + completionHandler(nil) | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + | ||
| 87 | +} |
metaCode/Classes/Other/AD/CNLiveLaunchAdController.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveLaunchAdController.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2025/4/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import YYImage | ||
| 10 | + | ||
| 11 | +class CNLiveLaunchAdController:UIViewController,URLSessionTaskDelegate{ | ||
| 12 | + | ||
| 13 | + lazy var bgView :YYAnimatedImageView = { | ||
| 14 | + let bottomNavView = YYAnimatedImageView(frame: self.view.bounds) | ||
| 15 | + bottomNavView.contentMode = .scaleToFill | ||
| 16 | + let tap = UITapGestureRecognizer(target: self, action: #selector(singleTap)) | ||
| 17 | + bottomNavView.addGestureRecognizer(tap) | ||
| 18 | + return bottomNavView | ||
| 19 | + }() | ||
| 20 | + | ||
| 21 | + lazy var skipBtn: UIButton = { | ||
| 22 | + var height:CGFloat = 149.0 | ||
| 23 | + if keyWindow?.safeAreaInsets.bottom ?? 0 > 0.0{ | ||
| 24 | + height = 149.0 + get_system_tabbar_ui_offsetHeight() | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + let closeBtn = UIButton(type: .custom) | ||
| 28 | + closeBtn.frame = CGRect(x: KSreenWidth - 79, y: KSreenHeight-height, width: 69, height: 32) | ||
| 29 | + closeBtn.backgroundColor = UIColor(red: 51, green: 51, blue: 51, alpha: 0.2) | ||
| 30 | + closeBtn.layer.cornerRadius = 16 | ||
| 31 | + closeBtn.layer.masksToBounds = true | ||
| 32 | + closeBtn.titleLabel?.font = Font_13 | ||
| 33 | + closeBtn.addTarget(self, action: #selector(skipAction), for: .touchUpInside) | ||
| 34 | + closeBtn.contentHorizontalAlignment = .center | ||
| 35 | + return closeBtn | ||
| 36 | + }() | ||
| 37 | + | ||
| 38 | + lazy var advImg :UIImageView = { | ||
| 39 | + let iconImgView = UIImageView(frame: CGRect(x: KSreenWidth-35, y: KStatusBarHeight+5, width: 21, height: 12)) | ||
| 40 | + iconImgView.image = UIImage(named: "Launch_AdTip") | ||
| 41 | + return iconImgView | ||
| 42 | + }() | ||
| 43 | + | ||
| 44 | + var clicked = false | ||
| 45 | + | ||
| 46 | + // 定时器管理属性(必须强引用) | ||
| 47 | + var timer: DispatchSourceTimer? | ||
| 48 | + | ||
| 49 | + /// 清理旧广告图片及配置 | ||
| 50 | + func deleteOldImage() { | ||
| 51 | + // 1. 安全获取旧图片URL(处理空值) | ||
| 52 | + let oldUrl = UserDefaults.standard.string(forKey: "wjjAdv_imageUrl") ?? "" | ||
| 53 | + | ||
| 54 | + // 2. 存在有效URL时执行清理 | ||
| 55 | + if !oldUrl.isEmpty { | ||
| 56 | + // 3. 检查图片缓存是否存在 | ||
| 57 | + if let cachedImage = CNOSAdImgDownloadManager.getOSImage(with: oldUrl) { | ||
| 58 | + // 4. 异步执行资源清理(避免阻塞主线程) | ||
| 59 | + DispatchQueue.global(qos: .utility).async { | ||
| 60 | + CNOSAdImgDownloadManager.clearOSImage(with: oldUrl) | ||
| 61 | + print("🗑 成功清理旧广告图片: \(oldUrl)") | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + // 5. 原子化操作用户配置(线程安全) | ||
| 67 | + UserDefaults.standard.perform {_ in | ||
| 68 | + // 6. 使用removeObject替代空字符串更符合语义 | ||
| 69 | + UserDefaults.standard.removeObject(forKey: "wjjAdv_imageUrl") | ||
| 70 | + | ||
| 71 | + // 7. 清理相关配置(根据业务需求添加) | ||
| 72 | + UserDefaults.standard.removeObject(forKey: "wjjAdv_duration") | ||
| 73 | + UserDefaults.standard.removeObject(forKey: "wjjAdv_isOpenExternal") | ||
| 74 | + UserDefaults.standard.removeObject(forKey: "wjjAdv_linkUrl") | ||
| 75 | + UserDefaults.standard.removeObject(forKey: "wjjAdv_Id") | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + // 8. 使用现代化同步方法(iOS 12+) | ||
| 79 | + if #available(iOS 12.0, *) { | ||
| 80 | + UserDefaults.standard.synchronize() | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + override func viewDidLoad() { | ||
| 86 | + super.viewDidLoad() | ||
| 87 | + | ||
| 88 | + CNLiveAdViewModel.shared.getAdData { result, status in | ||
| 89 | + if status == .success{ | ||
| 90 | + if let tempAdv = result as? NSDictionary{ | ||
| 91 | + if let adv = tempAdv["openScreenAdv"] as? NSDictionary{ | ||
| 92 | + let modifyStatus = adv["modifyStatus"] as? Int | ||
| 93 | + let oldModifyStatus = UserDefaults.standard.integer(forKey: "wjjAdv_modifyStatus") | ||
| 94 | + let imageUrl = UserDefaults.standard.string(forKey: "wjjAdv_imageUrl") | ||
| 95 | + let localImage = CNOSAdImgDownloadManager.getOSImage(with: imageUrl) | ||
| 96 | + | ||
| 97 | + if (modifyStatus==oldModifyStatus && (modifyStatus != 0) && ((imageUrl?.count ?? 0 == 0) || (localImage != nil))) { | ||
| 98 | + print("无变化") | ||
| 99 | + } else { | ||
| 100 | + var advImgUrl: String? | ||
| 101 | + if #available(iOS 11.0, *) { | ||
| 102 | + if isiPhoneXSeries{ | ||
| 103 | + advImgUrl = adv["iosImg1"] as? String | ||
| 104 | + print("isiPhoneXSeries") | ||
| 105 | + } else { | ||
| 106 | + advImgUrl = adv["iosImg2"] as? String | ||
| 107 | + } | ||
| 108 | + } else { | ||
| 109 | + advImgUrl = adv["iosImg2"] as? String | ||
| 110 | + } | ||
| 111 | + advImgUrl = advImgUrl?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) | ||
| 112 | + | ||
| 113 | + if advImgUrl?.count ?? 0 > 0{ | ||
| 114 | + if let newImage = CNOSAdImgDownloadManager.getOSImage(with: advImgUrl!) { | ||
| 115 | + UserDefaults.standard.set(adv["duration"] as? Int ?? 0, forKey: "wjjAdv_duration")//时长 | ||
| 116 | + UserDefaults.standard.set(adv["wjjAdv"] as? Bool ?? false, forKey: "wjjAdv_isOpenExternal")//是否外部 | ||
| 117 | + let linkUrl = adv["url"] as? String ?? "" | ||
| 118 | + UserDefaults.standard.set(linkUrl, forKey: "wjjAdv_linkUrl")//点击链接 | ||
| 119 | + UserDefaults.standard.set(adv["id"] as? String ?? "", forKey: "wjjAdv_Id")//id | ||
| 120 | + UserDefaults.standard.set(modifyStatus, forKey: "wjjAdv_modifyStatus")//版本号 | ||
| 121 | + UserDefaults.standard.set(advImgUrl, forKey: "wjjAdv_imageUrl")//图片url | ||
| 122 | + UserDefaults.standard.synchronize() | ||
| 123 | + } else { | ||
| 124 | + //下载 | ||
| 125 | + CNOSAdImgDownloadManager.downloadOSAdImg(with: advImgUrl!) { | ||
| 126 | + if let oldImageUrl = UserDefaults.standard.string(forKey: "wjjAdv_imageUrl"), oldImageUrl != advImgUrl! { | ||
| 127 | + self.deleteOldImage() | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + UserDefaults.standard.set(adv["duration"] as? Int ?? 0, forKey: "wjjAdv_duration")//时长 | ||
| 131 | + UserDefaults.standard.set(adv["wjjAdv"] as? Bool ?? false, forKey: "wjjAdv_isOpenExternal")//是否外部 | ||
| 132 | + let linkUrl = adv["url"] as? String ?? "" | ||
| 133 | + UserDefaults.standard.set(linkUrl, forKey: "wjjAdv_linkUrl")//点击链接 | ||
| 134 | + UserDefaults.standard.set(adv["id"] as? String ?? "", forKey: "wjjAdv_Id")//id | ||
| 135 | + UserDefaults.standard.set(modifyStatus, forKey: "wjjAdv_modifyStatus")//版本号 | ||
| 136 | + UserDefaults.standard.set(advImgUrl, forKey: "wjjAdv_imageUrl")//图片url | ||
| 137 | + UserDefaults.standard.synchronize() | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + } else { | ||
| 141 | + // 无广告 | ||
| 142 | + self.deleteOldImage() | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + } else { | ||
| 147 | + // 无广告 | ||
| 148 | + self.deleteOldImage() | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + // 判断本地是否存在广告图片 | ||
| 154 | + if let newImage = CNOSAdImgDownloadManager.getOSImage(with: UserDefaults.standard.string(forKey: "wjjAdv_imageUrl")){ | ||
| 155 | + // 显示广告 | ||
| 156 | +// let yyImage = newImage as? YYImage | ||
| 157 | + | ||
| 158 | + bgView.isUserInteractionEnabled = true | ||
| 159 | + bgView.addSubview(advImg) | ||
| 160 | + bgView.addSubview(skipBtn) | ||
| 161 | + bgView.image = newImage//yyImage | ||
| 162 | + let duration = UserDefaults.standard.integer(forKey: "wjjAdv_duration") | ||
| 163 | + if duration > 0 { | ||
| 164 | + var second = duration > 1000 ? duration / 1000 : duration | ||
| 165 | + second += 1 | ||
| 166 | + skipBtn.setTitle("跳过 \(second)", for: .normal) | ||
| 167 | + | ||
| 168 | + let queue = DispatchQueue.global(qos: .default) | ||
| 169 | + // 2. 创建定时器源(自动配置队列) | ||
| 170 | + timer = DispatchSource.makeTimerSource(flags: .strict, queue: queue) | ||
| 171 | + // 3. 配置定时器参数(立即触发,间隔1秒,零误差) | ||
| 172 | + timer?.schedule(deadline: .now(), repeating: .seconds(1)) | ||
| 173 | + // 4. 设置事件处理器(使用弱引用避免循环引用) | ||
| 174 | + timer?.setEventHandler { [weak self] in | ||
| 175 | + guard let self = self else { return } | ||
| 176 | + | ||
| 177 | + // 定时器触发逻辑 | ||
| 178 | + if !self.clicked { | ||
| 179 | + second -= 1 | ||
| 180 | + if second == 0 { | ||
| 181 | + self.enterMainUI() | ||
| 182 | + timer?.cancel() | ||
| 183 | + } else { | ||
| 184 | + DispatchQueue.main.async { | ||
| 185 | + self.skipBtn.setTitle("跳过 \(second)", for: .normal) | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + timer?.resume() | ||
| 191 | + } else { | ||
| 192 | + // 显示主页面 | ||
| 193 | + self.enterMainUI() | ||
| 194 | + } | ||
| 195 | + view.addSubview(bgView) | ||
| 196 | + }else { | ||
| 197 | + | ||
| 198 | + self.enterMainUI() | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + } | ||
| 202 | + func enterMainUI(){ | ||
| 203 | + // 显示主页面 | ||
| 204 | + DispatchQueue.main.async { | ||
| 205 | + let tabbarVC = CNLiveBaseTabBarViewController.init() | ||
| 206 | + let delegate = UIApplication.shared.delegate as! AppDelegate | ||
| 207 | + delegate.window?.rootViewController = tabbarVC | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + | ||
| 212 | + @objc func skipAction(){ | ||
| 213 | + self.clicked = true | ||
| 214 | + self.enterMainUI() | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + @objc func singleTap(){ | ||
| 218 | + //暂时点击不跳转 | ||
| 219 | +// var idStr = "" | ||
| 220 | +// if let tempId = UserDefaults.standard.object(forKey: "wjjAdv_Id") as? String{ | ||
| 221 | +// idStr = tempId | ||
| 222 | +// } | ||
| 223 | +// let channel = "kp_\(idStr)" | ||
| 224 | +// self.clicked = true | ||
| 225 | +// let tempAdvLinkUrl = UserDefaults.standard.object(forKey: "wjjAdv_linkUrl") as? String | ||
| 226 | +// //"http://wjjh5.cnlive.com/cnSpecialBlockList.html?channelName=tg_sxzgzt&id=1&isShowTitle=true&isWjjReport=true&pageId=10155" | ||
| 227 | +// let advLinkUrl = tempAdvLinkUrl?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)//去除掉首尾的空白字符和换行字符 | ||
| 228 | +// self.enterMainUI() | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + deinit { | ||
| 232 | + print("lauchAdVC deinit") | ||
| 233 | + } | ||
| 234 | +} |
metaCode/Classes/Other/AD/CNOSAdImgDownloadManager.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNOSAdImgDownloadManager.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2025/4/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import SDWebImage | ||
| 10 | +import YYImage | ||
| 11 | + | ||
| 12 | +final class CNOSAdImgDownloadManager { | ||
| 13 | + static let shared = CNOSAdImgDownloadManager() | ||
| 14 | + private var cache: SDImageCache! | ||
| 15 | + | ||
| 16 | + private init() { | ||
| 17 | + let paths = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask) | ||
| 18 | + let cachePath = paths.first!.appendingPathComponent("CNLiveOpenScreen").path | ||
| 19 | + cache = SDImageCache(namespace: "AdImage", diskCacheDirectory: cachePath) | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + /// 下载广告图片 | ||
| 23 | + static func downloadOSAdImg(with url: String?, success: (() -> Void)? = nil) { | ||
| 24 | + guard let validURL = url?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), | ||
| 25 | + let imageURL = URL(string: validURL) else { | ||
| 26 | + return | ||
| 27 | + } | ||
| 28 | + SDWebImageDownloader.shared.downloadImage(with: imageURL, options: [.ignoreCachedResponse]) { receivedSize, expectedSize, targetURL in | ||
| 29 | + | ||
| 30 | + } completed: { image, data, error, finished in | ||
| 31 | + guard error == nil, finished, let image = image else { | ||
| 32 | + return | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + let ocUrl: NSString = NSString(string: url ?? "") | ||
| 36 | + if let md5Key = ocUrl.md5(){ | ||
| 37 | + shared.cache.store(image, forKey: md5Key, completion: { | ||
| 38 | + success?() | ||
| 39 | + }) | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /// 获取缓存图片 | ||
| 45 | + static func getOSImage(with url: String?) -> UIImage? { | ||
| 46 | + let ocUrl: NSString = NSString(string: url ?? "") | ||
| 47 | + if let md5Key = ocUrl.md5(){ | ||
| 48 | + return shared.cache.imageFromCache(forKey: md5Key)// as? YYImage | ||
| 49 | + } | ||
| 50 | + return shared.cache.imageFromCache(forKey: "")// as? YYImage | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /// 清除指定图片缓存 | ||
| 54 | + static func clearOSImage(with url: String?) { | ||
| 55 | + let ocUrl: NSString = NSString(string: url ?? "") | ||
| 56 | + if let md5Key = ocUrl.md5(){ | ||
| 57 | + shared.cache.removeImage(forKey: md5Key, withCompletion: nil) | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | +} | ||
| 61 | + |
metaCode/Classes/Other/AD/LaunchAdManager.swift
0 → 100644
| 1 | +// | ||
| 2 | +// LaunchAdManager.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2025/4/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import UIKit | ||
| 10 | + | ||
| 11 | +final class LaunchAdManager { | ||
| 12 | + static let shared = LaunchAdManager() | ||
| 13 | + private var adViewController: LaunchAdViewController? | ||
| 14 | + private var adDataTask: URLSessionDataTask? | ||
| 15 | + | ||
| 16 | + /// 预加载广告资源 :ml-citation{ref="1,3" data="citationList"} | ||
| 17 | + func loadAd() { | ||
| 18 | + let adURL = URL(string: "https://wjj.ys2.cnliveimg.com/769/img/2/2025/01/22/173751152842250414939.jpg")! | ||
| 19 | + | ||
| 20 | + adDataTask?.cancel() | ||
| 21 | + adDataTask = URLSession.shared.dataTask(with: adURL) { [weak self] data, _, _ in | ||
| 22 | + guard let data = data else { return } | ||
| 23 | + DispatchQueue.main.async { | ||
| 24 | + self?.cacheAdImage(UIImage(data: data)) | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + adDataTask?.resume() | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /// 显示广告页(在AppDelegate中调用) | ||
| 31 | + func showAdIfNeeded(in window: UIWindow?) { | ||
| 32 | +// guard !UserSessionManager.shared.isLoggedIn() else { | ||
| 33 | +// window?.switchToMainUI() | ||
| 34 | +// return | ||
| 35 | +// } | ||
| 36 | + | ||
| 37 | + adViewController = LaunchAdViewController() | ||
| 38 | + window?.rootViewController = adViewController | ||
| 39 | + window?.makeKeyAndVisible() | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + private func cacheAdImage(_ image: UIImage?) { | ||
| 43 | + // 实现广告图片缓存逻辑(可扩展为文件存储) | ||
| 44 | + UserDefaults.standard.set(image?.pngData(), forKey: "cachedAdImage") | ||
| 45 | + } | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +// MARK: - 广告页控制器实现 | ||
| 49 | +private class LaunchAdViewController: UIViewController { | ||
| 50 | + private let countdownSeconds = 5 | ||
| 51 | + private var remainingSeconds = 5 | ||
| 52 | + private var timer: Timer? | ||
| 53 | + | ||
| 54 | + override func viewDidLoad() { | ||
| 55 | + super.viewDidLoad() | ||
| 56 | + setupUI() | ||
| 57 | + startCountdown() | ||
| 58 | + loadCachedAd() | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + private func setupUI() { | ||
| 62 | + view.backgroundColor = .white | ||
| 63 | + let skipButton = UIButton(type: .system) | ||
| 64 | + skipButton.setTitle("跳过 \(countdownSeconds)s", for: .normal) | ||
| 65 | + skipButton.addTarget(self, action: #selector(skipAd), for: .touchUpInside) | ||
| 66 | + // 布局代码略... | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @objc private func skipAd() { | ||
| 70 | + timer?.invalidate() | ||
| 71 | + switchToMainUI() | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + private func startCountdown() { | ||
| 75 | + timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { [weak self] _ in | ||
| 76 | + guard let self = self else { return } | ||
| 77 | + self.remainingSeconds -= 1 | ||
| 78 | + if self.remainingSeconds <= 0 { | ||
| 79 | + self.switchToMainUI() | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + private func loadCachedAd() { | ||
| 85 | + if let data = UserDefaults.standard.data(forKey: "cachedAdImage") { | ||
| 86 | + let imageView = UIImageView(image: UIImage(data: data)) | ||
| 87 | + imageView.contentMode = .scaleAspectFill | ||
| 88 | + view.addSubview(imageView) | ||
| 89 | + // 布局代码略... | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + fileprivate func switchToMainUI() { | ||
| 94 | + UIView.transition(with: view.window!, | ||
| 95 | + duration: 0.3, | ||
| 96 | + options: .transitionCrossDissolve, | ||
| 97 | + animations: { | ||
| 98 | + self.view.window?.switchToMainUI() | ||
| 99 | + }) | ||
| 100 | + } | ||
| 101 | +} | ||
| 102 | + | ||
| 103 | +// MARK: - 登录状态管理(UserDefaults方案) | ||
| 104 | +final class UserSessionManager { | ||
| 105 | + static let shared = UserSessionManager() | ||
| 106 | + private init() {} | ||
| 107 | + | ||
| 108 | + func isLoggedIn() -> Bool { | ||
| 109 | + return UserDefaults.standard.bool(forKey: "isLoggedIn") | ||
| 110 | + } | ||
| 111 | +} | ||
| 112 | + | ||
| 113 | +// MARK: - 窗口切换扩展 | ||
| 114 | +extension UIWindow { | ||
| 115 | + func switchToMainUI() { | ||
| 116 | + rootViewController = CNLiveBaseTabBarViewController.init() | ||
| 117 | + makeKeyAndVisible() | ||
| 118 | + } | ||
| 119 | +} |
metaCode/Classes/Other/AppDelegate.swift
| @@ -69,7 +69,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | @@ -69,7 +69,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | ||
| 69 | window = UIWindow.init(frame: UIScreen.main.bounds) | 69 | window = UIWindow.init(frame: UIScreen.main.bounds) |
| 70 | window?.backgroundColor = KVCBackgroupColor | 70 | window?.backgroundColor = KVCBackgroupColor |
| 71 | let is_login = UserDefaults.standard.bool(forKey: "is_login") | 71 | let is_login = UserDefaults.standard.bool(forKey: "is_login") |
| 72 | - window?.rootViewController = is_login ? CNLiveBaseTabBarViewController.init() : UINavigationController(rootViewController: CNLiveLoginViewController.init()) | 72 | + //CNLiveBaseTabBarViewController.init() |
| 73 | + window?.rootViewController = is_login ? CNLiveLaunchAdController.init() : UINavigationController(rootViewController: CNLiveLoginViewController.init()) | ||
| 73 | window?.makeKeyAndVisible() | 74 | window?.makeKeyAndVisible() |
| 74 | if is_login{ | 75 | if is_login{ |
| 75 | //获取用户信息 /api/identityApi/getUserMsg | 76 | //获取用户信息 /api/identityApi/getUserMsg |
metaCode/Supporting Files/Assets.xcassets/LauchAd/Contents.json
0 → 100644
metaCode/Supporting Files/Assets.xcassets/LauchAd/Launch_AdTip.imageset/Contents.json
0 → 100644
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "idiom" : "universal", | ||
| 5 | + "scale" : "1x" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "filename" : "Launch_AdTip@2x.png", | ||
| 9 | + "idiom" : "universal", | ||
| 10 | + "scale" : "2x" | ||
| 11 | + }, | ||
| 12 | + { | ||
| 13 | + "filename" : "Launch_AdTip@3x.png", | ||
| 14 | + "idiom" : "universal", | ||
| 15 | + "scale" : "3x" | ||
| 16 | + } | ||
| 17 | + ], | ||
| 18 | + "info" : { | ||
| 19 | + "author" : "xcode", | ||
| 20 | + "version" : 1 | ||
| 21 | + } | ||
| 22 | +} |
metaCode/Supporting Files/Assets.xcassets/LauchAd/Launch_AdTip.imageset/Launch_AdTip@2x.png
0 → 100644
906 Bytes
metaCode/Supporting Files/Assets.xcassets/LauchAd/Launch_AdTip.imageset/Launch_AdTip@3x.png
0 → 100644
2.02 KB