Commit 184f9c5314f29af3a8ebe5addad2ac4332c17df7

Authored by liushiyu
1 parent 70545b57

专辑跳转方法添加

... ... @@ -49,20 +49,23 @@ target 'metaCode' do
49 49 #播放器
50 50 pod 'ZFPlayer', :git => 'https://gitee.com/mirrors/ZFPlayer.git'
51 51 pod 'ZFPlayer/ControlView', :git => 'https://gitee.com/mirrors/ZFPlayer.git'
52   -# pod 'ZFPlayer/AVPlayer', :git => 'https://gitee.com/mirrors/ZFPlayer.git'
  52 + pod 'ZFPlayer/AVPlayer', :git => 'https://gitee.com/mirrors/ZFPlayer.git'
53 53 pod 'ZFPlayer/ijkplayer', :git => 'https://gitee.com/mirrors/ZFPlayer.git'
54   - #支付
55   - #pod 'CNLivePayCostModule'
56 54 #分享
57 55 #pod 'CNLiveShareToolKit'
  56 + #网家家输入组件
  57 + pod 'CNLiveCustomUI/CNLiveContentToolTextView'
  58 + #业务工具库
  59 + pod 'CNLiveBusinessTools'
58 60  
59 61 #图片浏览器
60   - pod 'SKPhotoBrowser'
  62 + pod 'SKPhotoBrowser', :git => 'https://gitee.com/mirrors/SKPhotoBrowser.git'
61 63  
62 64 #视频播放器
63 65 pod 'PLPlayerKit'
64 66 #UI框架
65   - pod 'QMUIKit'
  67 +# pod 'QMUIKit'
  68 + pod 'YYWebImage', :git => 'https://gitee.com/mirrors/YYWebImage.git'
66 69  
67 70 target 'metaCodeTests' do
68 71 inherit! :search_paths
... ...
metaCode.xcodeproj/project.pbxproj
... ... @@ -158,9 +158,10 @@
158 158 7939B0732B47F12F005AE981 /* CNLiveShortVideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7939B0722B47F12F005AE981 /* CNLiveShortVideoViewController.swift */; };
159 159 7939B0752B47F1B9005AE981 /* CNLiveShortVideoListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7939B0742B47F1B9005AE981 /* CNLiveShortVideoListTableViewCell.swift */; };
160 160 7939B0772B47F88A005AE981 /* CNLiveShortVideoControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7939B0762B47F88A005AE981 /* CNLiveShortVideoControlView.swift */; };
161   - 7939B0792B47FC33005AE981 /* CNLiveShortVideoCustomControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7939B0782B47FC33005AE981 /* CNLiveShortVideoCustomControlView.swift */; };
162 161 793CAF522A58FCA200882EF4 /* CNLiveMineExchangeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 793CAF512A58FCA200882EF4 /* CNLiveMineExchangeViewController.swift */; };
163 162 794294A72B4D18EC008AAFA0 /* CNLiveShortVideoContentListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794294A62B4D18EC008AAFA0 /* CNLiveShortVideoContentListView.swift */; };
  163 + 794294AA2B4D4381008AAFA0 /* CNLiveShortVideoCommentListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794294A92B4D4381008AAFA0 /* CNLiveShortVideoCommentListView.swift */; };
  164 + 794294AC2B4D44C0008AAFA0 /* CNLiveShortVideoCommentLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794294AB2B4D44C0008AAFA0 /* CNLiveShortVideoCommentLayout.swift */; };
164 165 794BC1652AF9E70D00A68C74 /* CNLiveShopOrderSendViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794BC1642AF9E70D00A68C74 /* CNLiveShopOrderSendViewController.swift */; };
165 166 794FF1052B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794FF1042B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift */; };
166 167 794FF1072B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794FF1062B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift */; };
... ... @@ -196,6 +197,7 @@
196 197 799172362AF08D4500DC01A8 /* CNLiveShopBaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 799172352AF08D4500DC01A8 /* CNLiveShopBaseModel.swift */; };
197 198 799172382AF090CD00DC01A8 /* CNLiveShopBodyListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 799172372AF090CD00DC01A8 /* CNLiveShopBodyListView.swift */; };
198 199 7991723A2AF091E100DC01A8 /* CNLiveShopOrderListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 799172392AF091E100DC01A8 /* CNLiveShopOrderListViewController.swift */; };
  200 + 7999415C2B4E8E8E0014C721 /* CNLiveRefresh.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7999415B2B4E8E8E0014C721 /* CNLiveRefresh.swift */; };
199 201 79A212C02B0B5C5400BFA8E3 /* CNLiveShopCouponManagerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A212BF2B0B5C5400BFA8E3 /* CNLiveShopCouponManagerViewController.swift */; };
200 202 79A212C22B0B5D0700BFA8E3 /* CNLiveShopBodyCouponManagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A212C12B0B5D0700BFA8E3 /* CNLiveShopBodyCouponManagerView.swift */; };
201 203 79A267832AF8D7BC0088D9F6 /* CNLiveShopBodyCustomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A267822AF8D7BC0088D9F6 /* CNLiveShopBodyCustomView.swift */; };
... ... @@ -422,9 +424,10 @@
422 424 7939B0722B47F12F005AE981 /* CNLiveShortVideoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShortVideoViewController.swift; sourceTree = "<group>"; };
423 425 7939B0742B47F1B9005AE981 /* CNLiveShortVideoListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShortVideoListTableViewCell.swift; sourceTree = "<group>"; };
424 426 7939B0762B47F88A005AE981 /* CNLiveShortVideoControlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShortVideoControlView.swift; sourceTree = "<group>"; };
425   - 7939B0782B47FC33005AE981 /* CNLiveShortVideoCustomControlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShortVideoCustomControlView.swift; sourceTree = "<group>"; };
426 427 793CAF512A58FCA200882EF4 /* CNLiveMineExchangeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineExchangeViewController.swift; sourceTree = "<group>"; };
427 428 794294A62B4D18EC008AAFA0 /* CNLiveShortVideoContentListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShortVideoContentListView.swift; sourceTree = "<group>"; };
  429 + 794294A92B4D4381008AAFA0 /* CNLiveShortVideoCommentListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShortVideoCommentListView.swift; sourceTree = "<group>"; };
  430 + 794294AB2B4D44C0008AAFA0 /* CNLiveShortVideoCommentLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShortVideoCommentLayout.swift; sourceTree = "<group>"; };
428 431 794BC1642AF9E70D00A68C74 /* CNLiveShopOrderSendViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopOrderSendViewController.swift; sourceTree = "<group>"; };
429 432 794FF1042B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopOrderSearchViewController.swift; sourceTree = "<group>"; };
430 433 794FF1062B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopOrderSearchListViewController.swift; sourceTree = "<group>"; };
... ... @@ -460,6 +463,7 @@
460 463 799172352AF08D4500DC01A8 /* CNLiveShopBaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopBaseModel.swift; sourceTree = "<group>"; };
461 464 799172372AF090CD00DC01A8 /* CNLiveShopBodyListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopBodyListView.swift; sourceTree = "<group>"; };
462 465 799172392AF091E100DC01A8 /* CNLiveShopOrderListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopOrderListViewController.swift; sourceTree = "<group>"; };
  466 + 7999415B2B4E8E8E0014C721 /* CNLiveRefresh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveRefresh.swift; sourceTree = "<group>"; };
463 467 79A212BF2B0B5C5400BFA8E3 /* CNLiveShopCouponManagerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopCouponManagerViewController.swift; sourceTree = "<group>"; };
464 468 79A212C12B0B5D0700BFA8E3 /* CNLiveShopBodyCouponManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopBodyCouponManagerView.swift; sourceTree = "<group>"; };
465 469 79A267822AF8D7BC0088D9F6 /* CNLiveShopBodyCustomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopBodyCustomView.swift; sourceTree = "<group>"; };
... ... @@ -1029,6 +1033,7 @@
1029 1033 isa = PBXGroup;
1030 1034 children = (
1031 1035 796308742B4B90700090D22A /* CNLiveShortVideoHomeModel.swift */,
  1036 + 794294AB2B4D44C0008AAFA0 /* CNLiveShortVideoCommentLayout.swift */,
1032 1037 );
1033 1038 path = Model;
1034 1039 sourceTree = "<group>";
... ... @@ -1038,12 +1043,19 @@
1038 1043 children = (
1039 1044 7939B0742B47F1B9005AE981 /* CNLiveShortVideoListTableViewCell.swift */,
1040 1045 7939B0762B47F88A005AE981 /* CNLiveShortVideoControlView.swift */,
1041   - 7939B0782B47FC33005AE981 /* CNLiveShortVideoCustomControlView.swift */,
1042 1046 794294A62B4D18EC008AAFA0 /* CNLiveShortVideoContentListView.swift */,
  1047 + 794294A92B4D4381008AAFA0 /* CNLiveShortVideoCommentListView.swift */,
1043 1048 );
1044 1049 path = View;
1045 1050 sourceTree = "<group>";
1046 1051 };
  1052 + 794294A82B4D3018008AAFA0 /* Share */ = {
  1053 + isa = PBXGroup;
  1054 + children = (
  1055 + );
  1056 + path = Share;
  1057 + sourceTree = "<group>";
  1058 + };
1047 1059 79579CAA2AAAE905006E5B38 /* Database */ = {
1048 1060 isa = PBXGroup;
1049 1061 children = (
... ... @@ -1131,6 +1143,7 @@
1131 1143 796398922A260C0100D045EB /* Config */ = {
1132 1144 isa = PBXGroup;
1133 1145 children = (
  1146 + 794294A82B4D3018008AAFA0 /* Share */,
1134 1147 79E496E42AB936E200127BF8 /* Tool */,
1135 1148 79579CAA2AAAE905006E5B38 /* Database */,
1136 1149 7CD675512A29C04B008354C1 /* CNLiveConfigstant.swift */,
... ... @@ -1190,6 +1203,7 @@
1190 1203 children = (
1191 1204 798A44F52A3077ED00815935 /* CNLiveHotButton.swift */,
1192 1205 798A44FA2A30999900815935 /* CNLiveAlertTool.swift */,
  1206 + 7999415B2B4E8E8E0014C721 /* CNLiveRefresh.swift */,
1193 1207 );
1194 1208 path = CustomView;
1195 1209 sourceTree = "<group>";
... ... @@ -1707,7 +1721,6 @@
1707 1721 19BB1FF02AF0E5B30094D962 /* CNLiveShopDetailModel.swift in Sources */,
1708 1722 1938BD382B4BDC2500390A34 /* CNLiveAlbumImageCell.swift in Sources */,
1709 1723 796398942A260C0100D045EB /* AppDelegate.swift in Sources */,
1710   - 7939B0792B47FC33005AE981 /* CNLiveShortVideoCustomControlView.swift in Sources */,
1711 1724 1917330D2B1096AB007BCC04 /* CNLivePlayerViewController.swift in Sources */,
1712 1725 1917330F2B10989C007BCC04 /* CNLivePlayerView.swift in Sources */,
1713 1726 7989B5C72A4BDC7200A19B10 /* CNLiveMineEarnListViewController.swift in Sources */,
... ... @@ -1873,6 +1886,7 @@
1873 1886 7C4931312A2F142F000E44B4 /* CNHomePageBackgroupView.swift in Sources */,
1874 1887 19BB1FF22AF21A950094D962 /* CNLliveShopDetailBannerCell.swift in Sources */,
1875 1888 790D018B2A2D8B3300C5978D /* CNLiveLoginViewController.swift in Sources */,
  1889 + 7999415C2B4E8E8E0014C721 /* CNLiveRefresh.swift in Sources */,
1876 1890 19CC4D562ADD19C200308E2A /* String+Extension.swift in Sources */,
1877 1891 7905BB492AB0588B0089BC50 /* CNLiveMineAuthResultViewController.swift in Sources */,
1878 1892 19565EC22AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift in Sources */,
... ... @@ -1881,6 +1895,7 @@
1881 1895 191733152B109FD7007BCC04 /* CNLivePlayerTopNaviView.swift in Sources */,
1882 1896 794FF1052B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift in Sources */,
1883 1897 798A44EC2A302DBE00815935 /* CNLiveMineAddInfoViewController.swift in Sources */,
  1898 + 794294AC2B4D44C0008AAFA0 /* CNLiveShortVideoCommentLayout.swift in Sources */,
1884 1899 791C1C882AFB6FD7003E6362 /* CNLiveShopOrderExpressFirmViewController.swift in Sources */,
1885 1900 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */,
1886 1901 794BC1652AF9E70D00A68C74 /* CNLiveShopOrderSendViewController.swift in Sources */,
... ... @@ -1889,6 +1904,7 @@
1889 1904 790D01852A2D89E100C5978D /* UIColor+CNLiveExtensions.swift in Sources */,
1890 1905 19FA20192AE22D98001F7186 /* CNLiveDownSlideTodayRecommendCell.swift in Sources */,
1891 1906 790B1FB42A4153E90074CF00 /* CNLiveMineBaseModel.swift in Sources */,
  1907 + 794294AA2B4D4381008AAFA0 /* CNLiveShortVideoCommentListView.swift in Sources */,
1892 1908 7978A8432A396632007C86B8 /* CNLiveMineViewModel.swift in Sources */,
1893 1909 191733022B0C4EAB007BCC04 /* CNLiveSelUplSingleImageView.swift in Sources */,
1894 1910 798A44EE2A305AAC00815935 /* CNLiveBaseNavigationController.swift in Sources */,
... ...
metaCode/Classes/CustomView/CNLiveRefresh.swift 0 → 100644
  1 +//
  2 +// CNLiveHeaderRefresh.swift
  3 +// metaCode
  4 +//
  5 +// Created by open on 2024/1/10.
  6 +//
  7 +
  8 +import Foundation
  9 +import MJRefresh
  10 +
  11 +class CNLiveHeaderRefresh: MJRefreshNormalHeader {
  12 +
  13 + override func prepare() {
  14 + super.prepare()
  15 + self.loadingView?.color = .white
  16 + self.arrowView!.isHidden = true
  17 + self.stateLabel?.isHidden = true
  18 + self.lastUpdatedTimeLabel?.isHidden = true
  19 + }
  20 +}
  21 +
  22 +class CNLiveFooterRefresh: MJRefreshAutoNormalFooter {
  23 + override func prepare() {
  24 + super.prepare()
  25 + self.stateLabel?.textColor = .white
  26 + self.loadingView?.color = .white
  27 + }
  28 +}
... ...
metaCode/Classes/Environment/CNLiveEnvironment.swift
... ... @@ -33,6 +33,8 @@ let APPBaseWjjBUrl: String = CNLiveEnvironmentManager.shared.base_wjj_b_url
33 33 let APPBaseWjjShopUrl: String = CNLiveEnvironmentManager.shared.base_mjj_shop_url
34 34 /// cms接口
35 35 let APPBaseCMSUrl: String = CNLiveEnvironmentManager.shared.base_cms_url
  36 +/// 用户云接口
  37 +let APPBaseTokenUrl: String = CNLiveEnvironmentManager.shared.img_token_url
36 38 /// cms_api接口
37 39 let APPBaseCMSClassUrl: String = CNLiveEnvironmentManager.shared.base_cms_class_url
38 40 ///当前APP的环境
... ...
metaCode/Classes/Main/HomePages/Controller/AuthController/CNLiveAuthViewController.swift
... ... @@ -96,16 +96,16 @@ class CNLiveAuthViewController:CNLiveBaseViewController,UITableViewDelegate,UITa
96 96 // MARK: - UITableViewDelegate
97 97 func numberOfSections(in tableView: UITableView) -> Int {
98 98 if self.isHaveDuanJU{
99   - 2
  99 + return 2
100 100 }else{
101   - 1
  101 + return 1
102 102 }
103 103 }
104 104 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
105 105 if self.isHaveDuanJU && section == 0{
106   - 1
  106 + return 1
107 107 }else{
108   - self.dataArray.count
  108 + return self.dataArray.count
109 109 }
110 110 }
111 111  
... ...
metaCode/Classes/Main/HomePages/ViewModel/CNLiveHomePageViewModel.swift
... ... @@ -92,7 +92,6 @@ class CNLiveHomePageViewModel:NSObject{
92 92 let param = NSMutableDictionary()
93 93 param.setValue(aid, forKey: "aid")
94 94 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
95   -
96 95 CNLiveNetworking.setAllowRequestDefaultArgument(true)
97 96 CNLiveNetworking.setupShowDataResult(false)
98 97 CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseCMSUrl+"/contentApi/getAlbumMsg", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
... ... @@ -118,7 +117,6 @@ class CNLiveHomePageViewModel:NSObject{
118 117 let param = NSMutableDictionary()
119 118 param.setValue(aid, forKey: "aid")
120 119 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
121   -
122 120 CNLiveNetworking.setAllowRequestDefaultArgument(true)
123 121 CNLiveNetworking.setupShowDataResult(false)
124 122 CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseCMSUrl+"/ugcApi/albumList", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
... ... @@ -136,8 +134,7 @@ class CNLiveHomePageViewModel:NSObject{
136 134 }
137 135  
138 136 resultBlock(listArr,.success)
139   - }
140   - else{
  137 + }else{
141 138 resultBlock(NSNull(),.failed)
142 139 }
143 140 }
... ...
metaCode/Classes/Main/MinePage/Controller/CNLiveMineViewController.swift
... ... @@ -193,7 +193,7 @@ extension CNLiveMineViewController {
193 193 self.navigationController?.pushViewController(CNLiveShopCouponManagerViewController.init(), animated: true)
194 194 }
195 195 if indexPath.row == 4 {
196   - self.navigationController?.pushViewController(CNLiveShortVideoViewController.init(), animated: true)
  196 + self.navigationController?.pushViewController(CNLiveShortVideoViewController.init(aid: "cms_ugc_10504077_1704334474587"), animated: true)
197 197 }
198 198 }
199 199  
... ...
metaCode/Classes/Main/VideoPage/Controller/CNLiveShortVideoViewController.swift
... ... @@ -8,7 +8,10 @@
8 8 import Foundation
9 9 import ZFPlayer
10 10 import APButton
11   -class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource, CNLiveShortVideoListTableViewCellDelegate {
  11 +import EmptyDataSet_Swift
  12 +import MJRefresh
  13 +
  14 +class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource, CNLiveShortVideoListTableViewCellDelegate, EmptyDataSetSource, EmptyDataSetDelegate {
12 15  
13 16 var player: ZFPlayerController!
14 17 let kVideoBodyListViewCellIdentifier = "kVideoBodyListViewCellIdentifier"
... ... @@ -16,6 +19,8 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
16 19 let tableView = UITableView(frame: .zero, style: .plain)
17 20 tableView.dataSource = self
18 21 tableView.delegate = self
  22 + tableView.emptyDataSetSource = self
  23 + tableView.emptyDataSetDelegate = self
19 24 tableView.isPagingEnabled = true
20 25 tableView.estimatedRowHeight = 0
21 26 tableView.estimatedSectionFooterHeight = 0
... ... @@ -26,6 +31,8 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
26 31 tableView.tableFooterView = UIView.init()
27 32 tableView.separatorStyle = .none
28 33 tableView.scrollsToTop = false
  34 + tableView.showsVerticalScrollIndicator = false
  35 + tableView.showsHorizontalScrollIndicator = false
29 36 tableView.contentInsetAdjustmentBehavior = .never;
30 37 tableView.register(CNLiveShortVideoListTableViewCell.self, forCellReuseIdentifier: kVideoBodyListViewCellIdentifier)
31 38 return tableView
... ... @@ -51,16 +58,52 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
51 58 let dataArray = NSMutableArray.init()
52 59 return dataArray
53 60 }()
54   -
  61 +
  62 + var aid: String! = ""
  63 + var pageNum: NSInteger! = 1
  64 + var currentIndex: NSInteger! = 0
  65 + var headerRefreshView: CNLiveHeaderRefresh!
  66 + var footerRefreshView: CNLiveFooterRefresh!
55 67 var playerManager = ZFIJKPlayerManager.init()
56 68 // var playerManager = ZFAVPlayerManager.init()
57 69  
  70 + /// 初始化播放器
  71 + /// - Parameters:
  72 + /// - aid: 专辑 id
  73 + /// - page: 当前页数
  74 + /// - currentIndex: 当前点击的索引
  75 + /// - dataArray: 当前请求的数据
  76 + init(aid: String,page: NSInteger, currentIndex: NSInteger, dataArray: [CNLiveAlbumListModel]) {
  77 + self.aid = aid
  78 + self.pageNum = page
  79 + self.currentIndex = currentIndex
  80 + super.init(nibName:nil, bundle:nil)
  81 + self.dataArray.addObjects(from: dataArray)
  82 + dataArray.forEach {[weak self] listModel in
  83 + guard let self = self else { return }
  84 + self.dataURLArray.add(listModel.videoUrl)
  85 + }
  86 + }
  87 +
  88 + /// 初始化播放器
  89 + /// - Parameter aid: 专辑 id
  90 + init(aid: String) {
  91 + self.aid = aid
  92 + super.init(nibName:nil, bundle:nil)
  93 + }
  94 +
  95 + required init?(coder: NSCoder) {
  96 + fatalError("init(coder:) has not been implemented")
  97 + }
  98 +
58 99 override func viewDidLoad() {
59 100 super.viewDidLoad()
60 101 view.backgroundColor = .black
61 102 view.addSubview(tableView)
62 103 view.addSubview(backBtn)
63   - requestData()
  104 +
  105 + requestData {}
  106 + addRefreshView()
64 107  
65 108 player = ZFPlayerController(scrollView: tableView, playerManager: playerManager, containerViewTag: 100)
66 109 player.disableGestureTypes = [.pan, .pinch]
... ... @@ -74,17 +117,14 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
74 117 }
75 118 player.playerPrepareToPlay = {[weak self] asset, assetURL in
76 119 guard let self = self else { return }
  120 + self.controlView.videoPlayer((self.player)!, currentTime: self.player.currentTime, totalTime: self.player.totalTime)
77 121 let index = self.dataURLArray.index(of: assetURL.absoluteString)
78   - let homeModel = self.dataArray[index] as! ShortVideoHomeTestModel
79   - if (homeModel.isMoney!) {
80   - let indexPath = IndexPath(row: index, section: 0)
81   - let cell: CNLiveShortVideoListTableViewCell = self.tableView.cellForRow(at: indexPath) as! CNLiveShortVideoListTableViewCell
82   - cell.hiddenView(isHidden: true)
  122 + let homeModel = self.dataArray[index] as! CNLiveAlbumListModel
  123 + let indexPath = IndexPath(row: index, section: 0)
  124 + let cell: CNLiveShortVideoListTableViewCell = self.tableView.cellForRow(at: indexPath) as! CNLiveShortVideoListTableViewCell
  125 + cell.hiddenView(isHidden: homeModel.product!.albumProductType != "0")
  126 + if (homeModel.product!.albumProductType != "0") {
83 127 self.player.stopCurrentPlayingCell()
84   - } else {
85   - let indexPath = IndexPath(row: index, section: 0)
86   - let cell: CNLiveShortVideoListTableViewCell = self.tableView.cellForRow(at: indexPath) as! CNLiveShortVideoListTableViewCell
87   - cell.hiddenView(isHidden: false)
88 128 }
89 129 }
90 130 // 更新另一个控制层的时间
... ... @@ -103,42 +143,72 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
103 143 if self.player.playingIndexPath != nil {
104 144 return
105 145 }
106   - if indexPath.row == (self.dataArray.count) - 1 {
107   - // 加载下一页数据
108   - self.requestData()
109   - self.tableView.reloadData()
110   - }
111 146 self.playVideo(at: indexPath)
112 147 }
113 148 }
114 149  
  150 + func addRefreshView() {
  151 + headerRefreshView = CNLiveHeaderRefresh(refreshingBlock: { [weak self] in
  152 + guard let self = self else { return }
  153 + self.pageNum = 1
  154 + self.requestData {}
  155 + })
  156 + footerRefreshView = CNLiveFooterRefresh(refreshingBlock: { [weak self] in
  157 + guard let self = self else { return }
  158 + self.player.stopCurrentPlayingCell()
  159 + self.pageNum += 1
  160 + self.requestData {}
  161 + })
  162 + }
  163 +
115 164 override func viewWillLayoutSubviews() {
116 165 super.viewWillLayoutSubviews()
117 166 self.backBtn.frame = CGRectMake(15, CGRectGetMaxY(UIApplication.shared.statusBarFrame), 45, 45)
118 167 }
119 168  
120   - func loadRequest() {
121   - dataArray.removeAllObjects()
122   - DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in
123   - guard let strongSelf = self else { return }
124   - // 下拉时一定要停止当前播放,以防有新数据,播放位置会错位
125   - strongSelf.player.stopCurrentPlayingCell()
126   - strongSelf.requestData()
127   - strongSelf.tableView.reloadData()
128   - strongSelf.player.zf_filterShouldPlayCellWhileScrolled { [weak self] indexPath in
129   - guard let strongSelf = self else { return }
130   - strongSelf.playVideo(at: indexPath)
131   - }
132   - }
133   - }
134   -
135   - func requestData() {
136   - CNLiveShortVideoViewModel.requstWithShortVideo { [weak self] result, respStatue in
  169 + func requestData(resultBlock: @escaping () -> Void) {
  170 + CNLiveShortVideoViewModel.requstWithShortVideo(aid: self.aid, page: self.pageNum) { [weak self] result, respStatue in
137 171 guard let self = self else { return }
138   - self.dataArray.addObjects(from: (result as! [Any]).first as! [Any])
139   - self.dataURLArray.addObjects(from: (result as! [Any]).last as! [Any])
140   - self.tableView.reloadData()
141   - self.playTheIndex(index: 0)
  172 + if respStatue == .success {
  173 + if self.pageNum == 1 {
  174 + self.dataArray.removeAllObjects()
  175 + self.dataURLArray.removeAllObjects()
  176 + }
  177 + let listArray = (result as! [Any]).first as! [CNLiveAlbumListModel]
  178 + self.dataArray.addObjects(from: listArray)
  179 + let urlArray = (result as! [Any]).last as! [String]
  180 + self.dataURLArray.addObjects(from: urlArray)
  181 + if self.tableView.mj_header != nil && self.tableView.mj_footer != nil {
  182 + self.tableView.mj_footer?.endRefreshing()
  183 + self.tableView.mj_header?.endRefreshing()
  184 + }
  185 + self.tableView.reloadData()
  186 + let hasNextPage = (result as! [Any])[1] as! Bool
  187 + if listArray.count == 0 && urlArray.count == 0 {
  188 + if !hasNextPage {
  189 + self.tableView.mj_footer?.endRefreshingWithNoMoreData()
  190 + self.tableView.reloadData()
  191 + }
  192 + } else {
  193 + if self.tableView.mj_header == nil {
  194 + self.tableView.mj_header = headerRefreshView
  195 + }
  196 + if self.tableView.mj_footer == nil {
  197 + self.tableView.mj_footer = footerRefreshView
  198 + }
  199 + }
  200 + if self.pageNum == 1 {
  201 + self.playTheIndex(index: self.currentIndex)
  202 + }
  203 + } else {
  204 + if self.tableView.mj_header != nil && self.tableView.mj_footer != nil {
  205 + self.tableView.mj_footer?.endRefreshing()
  206 + self.tableView.mj_header?.endRefreshing()
  207 + }
  208 + if self.dataArray.count == 0 {
  209 + self.tableView.reloadEmptyDataSet()
  210 + }
  211 + }
142 212 }
143 213 }
144 214  
... ... @@ -152,12 +222,6 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
152 222 guard let self = self else { return }
153 223 self.playVideo(at: indexPath)
154 224 }
155   - // 如果是最后一行,去请求新数据
156   - if index == dataArray.count - 1 {
157   - // 加载下一页数据
158   - requestData()
159   - tableView.reloadData()
160   - }
161 225 }
162 226  
163 227 override var shouldAutorotate: Bool {
... ... @@ -181,10 +245,10 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
181 245 }
182 246  
183 247 func playVideo(at indexPath: IndexPath) {
184   - let data: ShortVideoHomeTestModel = dataArray[indexPath.row] as! ShortVideoHomeTestModel
185   - self.player.playTheIndexPath(indexPath, assetURL: URL(string: data.videoUrl!)!)
  248 + let data: CNLiveAlbumListModel = dataArray[indexPath.row] as! CNLiveAlbumListModel
  249 + self.player.playTheIndexPath(indexPath, assetURL: URL(string: data.videoUrl)!)
186 250 controlView.resetControlView()
187   - controlView.showCoverView(withUrl: data.poster!)
  251 + controlView.showCoverView(withUrl: data.poster)
188 252 }
189 253  
190 254 deinit {
... ... @@ -201,7 +265,12 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
201 265 extension CNLiveShortVideoViewController {
202 266  
203 267 func likeActionMethod(viewcell: CNLiveShortVideoListTableViewCell, button: UIButton) {
204   - button.isSelected = !button.isSelected
  268 + CNLiveShortVideoViewModel.requestRankWithLike(contentId: viewcell.homeModel.pid, contentTitle: viewcell.homeModel.title, contentSid: viewcell.homeModel.icon!.id, support: viewcell.homeModel.tool!.liked, tagName: viewcell.homeModel.tagName) {result, respStatue in
  269 + if respStatue == .success {
  270 + viewcell.homeModel.tool!.liked = !viewcell.homeModel.tool!.liked
  271 + button.isSelected = viewcell.homeModel.tool!.liked
  272 + }
  273 + }
205 274 }
206 275 func commentActionMethod(viewcell: CNLiveShortVideoListTableViewCell, button: UIButton) {
207 276  
... ... @@ -216,8 +285,10 @@ extension CNLiveShortVideoViewController {
216 285  
217 286 }
218 287 func listActionMethod(viewcell: CNLiveShortVideoListTableViewCell, button: UIButton) {
219   - CNLiveShortVideoContentListView.showVideoContentListView(result: { videoId in
220   -
  288 + CNLiveShortVideoContentListView.showVideoContentListView(title: viewcell.homeModel.albumMsgModel!.albumName,dataArray: dataArray, result: {[weak self] listModel in
  289 + guard let self = self else { return }
  290 + let index = self.dataArray.index(of: listModel) as NSInteger
  291 + self.playTheIndex(index: index)
221 292 })
222 293 }
223 294 func payActionMethod(viewcell: CNLiveShortVideoListTableViewCell, button: UIButton) {
... ... @@ -227,8 +298,8 @@ extension CNLiveShortVideoViewController {
227 298 guard let self = self else { return }
228 299 payButton.stopAnimating()
229 300 for item in self.dataArray {
230   - let homeModel = item as! ShortVideoHomeTestModel
231   - homeModel.isMoney = false
  301 + let homeModel = item as! CNLiveAlbumListModel
  302 + homeModel.product!.albumProductType = "0"
232 303 self.tableView.reloadData()
233 304 }
234 305 let index = self.dataArray.index(of: viewcell.homeModel as Any)
... ... @@ -252,7 +323,7 @@ extension CNLiveShortVideoViewController {
252 323 guard let cell = tableView.dequeueReusableCell(withIdentifier: kVideoBodyListViewCellIdentifier) as? CNLiveShortVideoListTableViewCell else {
253 324 return CNLiveShortVideoListTableViewCell()
254 325 }
255   - cell.setupWithData(model: dataArray[indexPath.row] as! ShortVideoHomeTestModel)
  326 + cell.setupWithData(model: dataArray[indexPath.row] as! CNLiveAlbumListModel)
256 327 cell.delegate = self
257 328 return cell
258 329 }
... ... @@ -261,6 +332,10 @@ extension CNLiveShortVideoViewController {
261 332 self.playVideo(at: indexPath)
262 333 }
263 334  
  335 + func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? {
  336 + return UIImage(named: "short_video_default")
  337 + }
  338 +
264 339 func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
265 340 scrollView.zf_scrollViewDidEndDecelerating()
266 341 }
... ... @@ -285,3 +360,4 @@ extension CNLiveShortVideoViewController {
285 360 self.playVideo(at: indexPath)
286 361 }
287 362 }
  363 +
... ...
metaCode/Classes/Main/VideoPage/Model/CNLiveShortVideoCommentLayout.swift 0 → 100644
  1 +//
  2 +// CNLiveShortVideoCommentLayout.swift
  3 +// metaCode
  4 +//
  5 +// Created by open on 2024/1/9.
  6 +//
  7 +
  8 +import Foundation
... ...
metaCode/Classes/Main/VideoPage/Model/CNLiveShortVideoHomeModel.swift
... ... @@ -7,51 +7,59 @@
7 7  
8 8 import Foundation
9 9  
10   -class ShortVideoHomeTestModel: BaseModel {
11   - var activityEndTime: String? = ""
12   - var address: String? = ""
13   - var colours: String? = ""
14   - var contentId: String? = ""
15   - var coordinate: String? = ""
16   - var duration: String? = ""
17   - var h5Url: String? = ""
18   - var shortTitle: String? = ""
19   - var height: Int? = 0
20   - var isMoney: Bool? = false
21   - var identity: Int? = 0
22   - var isHorizontalScreen: Int? = 0
23   - var model: String? = ""
24   - var number: String? = ""
  10 +//!!!: 评论相关 model
  11 +class ShortVideoHomeCommentModel: BaseModel {
  12 + var total_hd: Int? = 0 //总数
  13 + var hasNext: String? = ""
  14 + var comments = [ShortVideoHomeCommentListModel]()
  15 +}
  16 +
  17 +class ShortVideoHomeCommentListModel: BaseModel {
  18 + var comment = ShortVideoHomeCommentFListModel()
  19 + var replyData = ShortVideoHomeCommentRListModel()
  20 +}
  21 +//评论数据
  22 +class ShortVideoHomeCommentFListModel: BaseModel {
  23 + var commentId: String? = ""
25 24 var pid: String? = ""
26   - var poster: String? = ""
27   - var productId: String? = ""
28   - var productType: String? = ""
29   - var shareUrl: String? = ""
30   - var source: Int? = 0
31   - var sourceDescribe: String? = ""
32   - var sourceName: String? = ""
33   - var subTitle: String? = ""
34   - var supervision: String? = ""
35   - var tagId: String? = ""
36   - var tagName: String? = ""
37   - var thirdUrl: String? = ""
38   - var time: Int? = 0
39   - var timeString: String? = ""
40   - var title: String? = ""
41   - var videoType: Int? = 0
42   - var videoUrl: String? = ""
43   - var width: Int? = 0
44   - var showStatue: Int? = 0
45   - var witnessId: String? = ""
46   - var statue: String? = ""
47   - var pids: [String]? = []
48   - var icon = ShortVideoHomeTestIconModel()
  25 + var uid: String? = ""
  26 + var nick: String? = ""
  27 + var facepath: String? = ""
  28 + var content: String? = ""
  29 + var created_at: String? = ""
  30 + var praise: String? = ""
  31 + var plat: String? = ""
  32 + var isOffical: Bool? = false
  33 + var model: String? = ""
  34 + var spId: String? = ""
  35 + var seqId: Int? = 0
  36 + var topicId: String? = ""
  37 + var praiseCount: Int? = 0
  38 + var isPraised: Bool? = false
  39 + var icon: String? = ""
  40 +}
  41 +//回复数据
  42 +class ShortVideoHomeCommentRListModel: BaseModel {
  43 + var total_hd: Int? = 0 //总数
  44 + var replys = [ShortVideoHomeCommentRListItemModel]()
49 45 }
50 46  
51   -class ShortVideoHomeTestIconModel: BaseModel {
52   - var face: String? = ""
53   - var focused: Bool? = false
54   - var idField: String? = ""
55   - var name: String? = ""
56   - var type: String? = ""
  47 +class ShortVideoHomeCommentRListItemModel: BaseModel {
  48 + var praiseCount: Int? = 0
  49 + var isPraised: Bool? = false
  50 + var commentId: String? = ""
  51 + var replyId: String? = ""
  52 + var topicId: String? = ""
  53 + var created_at: String? = ""
  54 + var plat: String? = ""
  55 + var fromFace: String? = ""
  56 + var fromSid: String? = ""
  57 + var fromNick: String? = ""
  58 + var toSid: String? = ""
  59 + var toNick: String? = ""
  60 + var toFace: String? = ""
  61 + var seqId: Int? = 0
  62 + var content: String? = ""
  63 + var level: Int? = 0
  64 + var icon: String? = ""
57 65 }
... ...
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoCommentListView.swift 0 → 100644
  1 +//
  2 +// CNLiveShortVideoCommentListView.swift
  3 +// metaCode
  4 +//
  5 +// Created by open on 2024/1/9.
  6 +//
  7 +
  8 +import Foundation
  9 +
  10 +class CNLiveShortVideoCommentListView: UIView {
  11 +
  12 +}
... ...
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoContentListView.swift
... ... @@ -7,9 +7,21 @@
7 7  
8 8 import Foundation
9 9  
10   -typealias CloseVideoListResultBlock = (_ videoId: Any) ->Void
  10 +typealias CloseVideoListResultBlock = (_ listModel: Any) ->Void
11 11 class CNLiveShortVideoContentListView: UIView, UITableViewDelegate, UITableViewDataSource {
12 12  
  13 + lazy var grayMaskView: UIView = {
  14 + let grayMaskView = UIView()
  15 + grayMaskView.backgroundColor = UIColor.black.withAlphaComponent(0.2)
  16 + return grayMaskView
  17 + }()
  18 +
  19 + lazy var contentView: UIView = {
  20 + let view = UIView.init()
  21 + view.backgroundColor = HexColor("#010101")
  22 + return view
  23 + }()
  24 +
13 25 lazy var closeButton: UIButton = {
14 26 let button = UIButton(type: .custom)
15 27 button.setImage(UIImage(named: "short_video_close"), for: .normal)
... ... @@ -41,7 +53,7 @@ class CNLiveShortVideoContentListView: UIView, UITableViewDelegate, UITableViewD
41 53 tableView.dataSource = self
42 54 tableView.delegate = self
43 55 tableView.rowHeight = 90
44   - tableView.estimatedRowHeight = 0
  56 + tableView.estimatedRowHeight = 90
45 57 tableView.estimatedSectionFooterHeight = 0
46 58 tableView.estimatedSectionHeaderHeight = 0
47 59 tableView.backgroundColor = HexColor("#010101")
... ... @@ -54,21 +66,38 @@ class CNLiveShortVideoContentListView: UIView, UITableViewDelegate, UITableViewD
54 66 return tableView
55 67 }()
56 68  
  69 + lazy var dataSource: NSMutableArray = {
  70 + let array = NSMutableArray()
  71 + return array
  72 + }()
  73 +
  74 + var resultBlock: CloseVideoListResultBlock!
  75 +
57 76 override init(frame: CGRect) {
58 77 super.init(frame: frame)
59 78  
60   - addSubview(closeButton)
  79 + addSubview(grayMaskView)
  80 + grayMaskView.snp.makeConstraints { make in
  81 + make.edges.equalToSuperview()
  82 + }
  83 +
  84 + grayMaskView.addSubview(contentView)
  85 + contentView.snp.makeConstraints { make in
  86 + make.top.equalTo(250)
  87 + make.right.left.bottom.equalToSuperview()
  88 + }
  89 + contentView.addSubview(closeButton)
61 90 closeButton.snp.makeConstraints { make in
62 91 make.right.equalToSuperview().offset(-15)
63 92 make.top.equalToSuperview().offset(15)
64 93 make.size.equalTo(30)
65 94 }
66   - addSubview(titleLabel)
  95 + contentView.addSubview(titleLabel)
67 96 titleLabel.snp.makeConstraints { make in
68 97 make.top.left.equalToSuperview().offset(20)
69 98 make.right.equalTo(closeButton.snp.left).offset(-10)
70 99 }
71   - addSubview(lineLabel)
  100 + contentView.addSubview(lineLabel)
72 101 lineLabel.snp.makeConstraints { make in
73 102 make.top.equalTo(closeButton.snp.bottom).offset(15)
74 103 make.centerX.equalToSuperview()
... ... @@ -76,32 +105,41 @@ class CNLiveShortVideoContentListView: UIView, UITableViewDelegate, UITableViewD
76 105 make.right.equalToSuperview().offset(-10)
77 106 make.height.equalTo(1)
78 107 }
79   - addSubview(tableView)
  108 + contentView.addSubview(tableView)
80 109 tableView.snp.makeConstraints { make in
81 110 make.bottom.left.right.equalToSuperview()
82 111 make.top.equalTo(lineLabel.snp.bottom).offset(10)
83 112 }
84 113 }
85 114  
  115 + func setupWithDataSource(title: String,dataArray: NSMutableArray) {
  116 + dataSource = dataArray
  117 + titleLabel.text = title
  118 + self.tableView.reloadData()
  119 + }
  120 +
86 121 required init?(coder: NSCoder) {
87 122 fatalError("init(coder:) has not been implemented")
88 123 }
89 124  
  125 + deinit {
  126 + print("弹出界面销毁")
  127 + }
90 128  
91 129 @objc func closeMethod() {
92 130 removeFromSuperview()
93 131 }
94 132  
95   - static public func showVideoContentListView(result: @escaping CloseVideoListResultBlock) {
  133 + static public func showVideoContentListView(title: String,dataArray: NSMutableArray,result: @escaping CloseVideoListResultBlock) {
96 134  
97 135 let pickerView = CNLiveShortVideoContentListView.init(frame: CGRect.zero)
98   - pickerView.backgroundColor = HexColor("#010101")
  136 + pickerView.resultBlock = result
  137 + pickerView.setupWithDataSource(title: title,dataArray: dataArray)
99 138  
100 139 let delegate = UIApplication.shared.delegate as! AppDelegate
101 140 delegate.window?.addSubview(pickerView)
102 141 pickerView.snp.makeConstraints { make in
103   - make.top.equalTo(250)
104   - make.right.left.bottom.equalToSuperview()
  142 + make.edges.equalToSuperview()
105 143 }
106 144 delegate.window?.layoutIfNeeded()
107 145 pickerView.alpha = 0
... ... @@ -117,65 +155,85 @@ extension CNLiveShortVideoContentListView {
117 155 return 1
118 156 }
119 157 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
120   - return 20
  158 + return dataSource.count
121 159 }
122 160 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
123 161 guard let cell = tableView.dequeueReusableCell(withIdentifier: kVideoContentListViewCellIdentifier) as? CNLiveShortVideoContentListTableViewCell else {
124 162 return CNLiveShortVideoContentListTableViewCell()
125 163 }
  164 + cell.setupWithDataModel(listModel: dataSource[indexPath.row] as! CNLiveAlbumListModel)
126 165 return cell
127 166 }
128   -
  167 + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  168 + self.resultBlock(dataSource[indexPath.row] as! CNLiveAlbumListModel)
  169 + closeMethod()
  170 + }
129 171 }
130 172  
131 173 class CNLiveShortVideoContentListTableViewCell: UITableViewCell {
132 174  
133   - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
134   - super.init(style: style, reuseIdentifier: reuseIdentifier)
135   - contentView.backgroundColor = .clear
136   - backgroundColor = .clear
137   - selectionStyle = .none
138   -
  175 + lazy var iconView: UIImageView = {
139 176 let imageView = UIImageView.init()
140   - imageView.image = UIImage(named: "mine_auth_result_header_failer")
  177 + imageView.image = UIImage(named: "short_video_default")
141 178 imageView.contentMode = .scaleAspectFill
142 179 imageView.layer.cornerRadius = 5
143 180 imageView.layer.masksToBounds = true
144 181 imageView.clipsToBounds = true
145   - contentView.addSubview(imageView)
146   - imageView.snp.makeConstraints { make in
147   - make.left.top.equalToSuperview().offset(20)
148   - make.width.equalTo(50)
149   - make.height.equalTo(70)
150   - }
151   -
152   - let paragraphStyle = NSMutableParagraphStyle()
153   - paragraphStyle.lineSpacing = 6
  182 + return imageView
  183 + }()
  184 +
  185 + lazy var titleLabel: UILabel = {
154 186 let titleLabel = UILabel.init()
155   - titleLabel.attributedText = NSAttributedString(string: "第四集 我们都不知道,所做的哪一个选择会让命运的齿轮开始转动", attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
156 187 titleLabel.textColor = .white
157 188 titleLabel.lineBreakMode = .byTruncatingTail
158 189 titleLabel.numberOfLines = 2
159 190 titleLabel.font = medium_adapt_font(pointSize: 12)
  191 + return titleLabel
  192 + }()
  193 +
  194 + lazy var timeLabel: UILabel = {
  195 + let timeLabel = UILabel.init()
  196 + timeLabel.textColor = .white
  197 + timeLabel.font = light_adapt_font(pointSize: 13)
  198 + return timeLabel
  199 + }()
  200 +
  201 + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  202 + super.init(style: style, reuseIdentifier: reuseIdentifier)
  203 + contentView.backgroundColor = .clear
  204 + backgroundColor = .clear
  205 + selectionStyle = .none
  206 +
  207 +
  208 + contentView.addSubview(iconView)
  209 + iconView.snp.makeConstraints { make in
  210 + make.left.top.equalToSuperview().offset(20)
  211 + make.width.equalTo(50)
  212 + make.height.equalTo(70)
  213 + }
160 214 contentView.addSubview(titleLabel)
161 215 titleLabel.snp.makeConstraints { make in
162   - make.left.equalTo(imageView.snp.right).offset(10)
  216 + make.left.equalTo(iconView.snp.right).offset(10)
163 217 make.top.equalToSuperview().offset(20)
164 218 make.right.equalToSuperview().offset(-20)
165 219 }
166   -
167   - let timeLabel = UILabel.init()
168   - timeLabel.text = "04:45"
169   - timeLabel.textColor = .white
170   - timeLabel.font = light_adapt_font(pointSize: 13)
171 220 contentView.addSubview(timeLabel)
172 221 timeLabel.snp.makeConstraints { make in
173   - make.left.equalTo(imageView.snp.right).offset(10)
174   - make.bottom.equalTo(imageView.snp.bottom)
  222 + make.left.equalTo(iconView.snp.right).offset(10)
  223 + make.bottom.equalTo(iconView.snp.bottom)
175 224 make.right.equalToSuperview().offset(-20)
176 225 }
177 226 }
178 227  
  228 + func setupWithDataModel(listModel: CNLiveAlbumListModel) {
  229 + iconView.kf.indicatorType = .activity
  230 + iconView.kf.setImage(with: URL(string: listModel.poster), placeholder: UIImage(named: "short_video_default"))
  231 + let paragraphStyle = NSMutableParagraphStyle()
  232 + paragraphStyle.lineSpacing = 6
  233 + titleLabel.attributedText = NSAttributedString(string: listModel.title, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle, ])
  234 + timeLabel.text = listModel.duration
  235 + }
  236 +
179 237 required init?(coder: NSCoder) {
180 238 fatalError("init(coder:) has not been implemented")
181 239 }
... ...
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoCustomControlView.swift deleted 100644 → 0
1   -//
2   -// CNLiveShortVideoCustomControlView.swift
3   -// metaCode
4   -//
5   -// Created by open on 2024/1/5.
6   -//
7   -
8   -import Foundation
9   -import ZFPlayer
10   -
11   -class CNLiveShortVideoCustomControlView: UIView, ZFPlayerMediaControl, ZFSliderViewDelegate {
12   -
13   - var player: ZFPlayerController?
14   -
15   - var topToolView: UIView = {
16   - let view = UIView()
17   - let image = UIImage(named: "ZFPlayer_top_shadow")
18   - view.layer.contents = image?.cgImage
19   - return view
20   - }()
21   -
22   - var titleLabel: UILabel = {
23   - let label = UILabel()
24   - label.textColor = .white
25   - label.font = UIFont.systemFont(ofSize: 15.0)
26   - return label
27   - }()
28   -
29   - var bottomToolView: UIView = {
30   - let view = UIView()
31   - let image = UIImage(named: "ZFPlayer_bottom_shadow")
32   - view.layer.contents = image?.cgImage
33   - return view
34   - }()
35   -
36   - var playOrPauseBtn: UIButton = {
37   - let button = UIButton(type: .custom)
38   - button.setImage(UIImage(named: "new_allPlay_44x44_"), for: .normal)
39   - button.setImage(UIImage(named: "new_allPause_44x44_"), for: .selected)
40   - return button
41   - }()
42   -
43   - var currentTimeLabel: UILabel = {
44   - let label = UILabel()
45   - label.textColor = .white
46   - label.font = UIFont.systemFont(ofSize: 14.0)
47   - label.textAlignment = .center
48   - return label
49   - }()
50   -
51   - var slider: ZFSliderView = {
52   - let slider = ZFSliderView()
53   - slider.maximumTrackTintColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 0.8)
54   - slider.bufferTrackTintColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.5)
55   - slider.minimumTrackTintColor = .white
56   - slider.setThumbImage(UIImage(named: "ZFPlayer_slider"), for: .normal)
57   - slider.sliderHeight = 2
58   - return slider
59   - }()
60   -
61   - var totalTimeLabel: UILabel = {
62   - let label = UILabel()
63   - label.textColor = .white
64   - label.font = UIFont.systemFont(ofSize: 14.0)
65   - label.textAlignment = .center
66   - return label
67   - }()
68   -
69   - var fullScreenBtn: UIButton = {
70   - let button = UIButton(type: .custom)
71   - button.setImage(UIImage(named: "ZFPlayer_fullscreen"), for: .normal)
72   - return button
73   - }()
74   -
75   - var coverImageView: UIImageView = {
76   - let imageView = UIImageView()
77   - imageView.isUserInteractionEnabled = true
78   - imageView.contentMode = .scaleAspectFit
79   - return imageView
80   - }()
81   -
82   - var bottomPgrogress: ZFSliderView = {
83   - let slider = ZFSliderView()
84   - slider.maximumTrackTintColor = .clear
85   - slider.minimumTrackTintColor = .white
86   - slider.bufferTrackTintColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.5)
87   - slider.sliderHeight = 1
88   - slider.isHideSliderBlock = false
89   - return slider
90   - }()
91   -
92   - override init(frame: CGRect) {
93   - super.init(frame: frame)
94   - addSubview(topToolView)
95   - addSubview(bottomToolView)
96   - addSubview(playOrPauseBtn)
97   - topToolView.addSubview(titleLabel)
98   - bottomToolView.addSubview(currentTimeLabel)
99   - bottomToolView.addSubview(slider)
100   - bottomToolView.addSubview(totalTimeLabel)
101   - bottomToolView.addSubview(fullScreenBtn)
102   - addSubview(bottomPgrogress)
103   -// addSubview(activity)
104   -
105   -// autoFadeTimeInterval = 0.2
106   -// autoHiddenTimeInterval = 2.5
107   -
108   - // 设置子控件的响应事件
109   - makeSubViewsAction()
110   -
111   -// resetControlView()
112   - clipsToBounds = true
113   - }
114   -
115   - func makeSubViewsAction() {
116   - playOrPauseBtn.addTarget(self, action: #selector(playPauseButtonClickAction), for: .touchUpInside)
117   - fullScreenBtn.addTarget(self, action: #selector(fullScreenButtonClickAction), for: .touchUpInside)
118   - }
119   -
120   -
121   -
122   - /////////////// ZFSliderViewDelegate
123   - func sliderTouchBegan(_ value: Float) {
124   - slider.isdragging = true
125   - }
126   -
127   - func sliderTouchEnded(_ value: Float) {
128   - guard player?.totalTime ?? 0.0 > 0 else {
129   - slider.isdragging = false
130   - return
131   - }
132   -
133   - player?.seek(toTime: (player?.totalTime ?? 0.0) * TimeInterval(value), completionHandler: {[weak self] finished in
134   - guard let self = self else { return }
135   - if finished {
136   - self.slider.isdragging = false
137   - }
138   - })
139   - }
140   -
141   - func sliderValueChanged(_ value: Float) {
142   - guard player?.totalTime ?? 0.0 > 0 else {
143   - slider.value = 0
144   - return
145   - }
146   -
147   - slider.isdragging = true
148   - let currentTimeString = ZFUtilities.convertTimeSecond(Int((player?.totalTime ?? 0.0) * TimeInterval(value)))
149   - currentTimeLabel.text = currentTimeString
150   - }
151   -
152   - func sliderTapped(_ value: Float) {
153   - guard player?.totalTime ?? 0.0 > 0 else {
154   - slider.isdragging = false
155   - slider.value = 0
156   - return
157   - }
158   -
159   - slider.isdragging = true
160   - player?.seek(toTime: (player?.totalTime ?? 0.0) * TimeInterval(value), completionHandler: { [weak self] finished in
161   - guard let self = self else { return }
162   - if finished {
163   - slider.isdragging = false
164   - player?.currentPlayerManager.play()
165   - }
166   - })
167   - }
168   -
169   - ////////////action
170   - @objc func playPauseButtonClickAction(_ sender: UIButton) {
171   - playOrPause()
172   - }
173   -
174   - @objc func fullScreenButtonClickAction(_ sender: UIButton) {
175   - self.player?.enterFullScreen(!self.player!.isFullScreen, animated: true)
176   - }
177   -
178   - private func playOrPause() {
179   - self.playOrPauseBtn.isSelected = !self.playOrPauseBtn.isSelected
180   - self.playOrPauseBtn.isSelected ? self.player?.currentPlayerManager.play(): self.player?.currentPlayerManager.pause()
181   - }
182   -
183   - private func playBtnSelectedState(selected: Bool) {
184   - self.playOrPauseBtn.isSelected = selected
185   - }
186   -
187   -
188   - ///////private
189   - func resetControlView() {
190   - self.bottomToolView.alpha = 1
191   - self.slider.value = 0
192   - self.slider.bufferValue = 0
193   - self.currentTimeLabel.text = "00:00"
194   - self.totalTimeLabel.text = "00:00"
195   - self.backgroundColor = .clear
196   - self.playOrPauseBtn.isSelected = true
197   - self.titleLabel.text = ""
198   - }
199   -
200   -// func showControlView() {
201   -// self.topToolView.alpha = 1
202   -// self.bottomToolView.alpha = 1
203   -// self.isShow = true
204   -// self.topToolView.zf_y = 0
205   -// self.bottomToolView.zf_y = self.zf_height - self.bottomToolView.zf_height
206   -// self.playOrPauseBtn.alpha = 1
207   -// self.player.statusBarHidden = false
208   -// }
209   -
210   - required init?(coder: NSCoder) {
211   - super.init(coder: coder)
212   - // Initialization code...
213   - }
214   -}
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoListTableViewCell.swift
... ... @@ -29,7 +29,6 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
29 29 label.textAlignment = .left
30 30 label.numberOfLines = 1
31 31 label.lineBreakMode = .byTruncatingTail
32   - label.text = "爱得供养"
33 32 return label
34 33 }()
35 34  
... ... @@ -40,7 +39,6 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
40 39 label.textAlignment = .left
41 40 label.numberOfLines = 3
42 41 label.lineBreakMode = .byTruncatingTail
43   - label.text = "在 Swift 中,CGRect 的属性和方法名通常是小写字母开头的驼峰命名法。确保在 Swift 中使用正确的命名规范和语法。这段 Swift 代码与原始的 Objective-C 代码逻辑相同,只是在语法和命名上进行了一些调整。"
44 42 return label
45 43 }()
46 44  
... ... @@ -50,21 +48,18 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
50 48 label.font = semibold_adapt_font(pointSize: 15)
51 49 label.textAlignment = .center
52 50 label.numberOfLines = 0
53   - label.text = "当前内容需付费观看"
54 51 label.isHidden = true
55 52 return label
56 53 }()
57 54  
58 55 lazy var listBtn: UIButton = {
59 56 let button = UIButton(type: .custom)
60   - button.setTitle("爱的供养·45集", for: .normal)
61 57 button.setTitleColor(.white, for: .normal)
62 58 button.contentHorizontalAlignment = .left
63 59 button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 0)
64 60 button.titleLabel?.textAlignment = .left
65 61 button.titleLabel?.lineBreakMode = .byTruncatingTail
66 62 button.titleLabel?.font = semibold_adapt_font(pointSize: 15)
67   - button.addTarget(self, action: #selector(likeMothod), for: .touchUpInside)
68 63 button.layer.cornerRadius = 10
69 64 button.layer.masksToBounds = true
70 65 button.backgroundColor = HexColor("#414141")
... ... @@ -146,10 +141,11 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
146 141 coverImageView.isUserInteractionEnabled = true
147 142 coverImageView.tag = 100
148 143 coverImageView.contentMode = .scaleAspectFit
  144 + coverImageView.image = UIImage(named: "short_video_default")
149 145 return coverImageView
150 146 }()
151 147  
152   - var homeModel: ShortVideoHomeTestModel!
  148 + var homeModel: CNLiveAlbumListModel!
153 149 weak var delegate: CNLiveShortVideoListTableViewCellDelegate!
154 150  
155 151 override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
... ... @@ -172,10 +168,26 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
172 168 contentView.addSubview(payView)
173 169 }
174 170  
175   - func setupWithData(model: ShortVideoHomeTestModel) {
  171 + func setupWithData(model: CNLiveAlbumListModel) {
176 172 homeModel = model
177 173 coverImageView.kf.indicatorType = .activity
178   - coverImageView.kf.setImage(with: URL(string: model.icon.face!), placeholder: UIImage(named: "short_video_default"))
  174 + coverImageView.kf.setImage(with: URL(string: model.poster), placeholder: UIImage(named: "short_video_default"))
  175 + iconBtn.kf.setImage(with: URL(string: model.icon!.face), for: .normal)
  176 + likeBtn.setTitle(model.tool?.likesNum, for: .normal)
  177 + commentBtn.setTitle(model.tool?.commentsNum, for: .normal)
  178 + shareBtn.setTitle(model.tool?.shareNum, for: .normal)
  179 + likeBtn.isSelected = model.tool!.liked
  180 + titleLabel.text = model.shortTitle
  181 + descLabel.text = model.title
  182 + listBtn.setTitle(model.albumMsgModel?.albumName, for: .normal)
  183 +
  184 + let imageV: UIImageView = payView.viewWithTag(1000) as! UIImageView
  185 + imageV.kf.indicatorType = .activity
  186 + imageV.kf.setImage(with: URL(string: model.poster))
  187 + let titleL: UILabel = payView.viewWithTag(1001) as! UILabel
  188 + titleL.text = model.title
  189 + let timeL: UILabel = payView.viewWithTag(1002) as! UILabel
  190 + timeL.text = model.duration
179 191 }
180 192  
181 193 override func layoutSubviews() {
... ... @@ -321,12 +333,11 @@ extension CNLiveShortVideoListTableViewCell {
321 333 view.layer.masksToBounds = true
322 334  
323 335 let imageView = UIImageView.init()
324   - imageView.image = UIImage(named: "mine_auth_result_header_failer")
325 336 imageView.contentMode = .scaleAspectFill
326 337 imageView.layer.cornerRadius = 5
327 338 imageView.layer.masksToBounds = true
328 339 imageView.clipsToBounds = true
329   - imageView.viewWithTag(1000)
  340 + imageView.tag = 1000
330 341 view.addSubview(imageView)
331 342 imageView.snp.makeConstraints { make in
332 343 make.left.top.equalToSuperview().offset(20)
... ... @@ -334,14 +345,11 @@ extension CNLiveShortVideoListTableViewCell {
334 345 make.height.equalTo(70)
335 346 }
336 347  
337   - let paragraphStyle = NSMutableParagraphStyle()
338   - paragraphStyle.lineSpacing = 6
339 348 let titleLabel = UILabel.init()
340   - titleLabel.attributedText = NSAttributedString(string: "第四集 我们都不知道,所做的哪一个选择会让命运的齿轮开始转动", attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
341 349 titleLabel.textColor = .white
342 350 titleLabel.lineBreakMode = .byTruncatingTail
343 351 titleLabel.numberOfLines = 2
344   - titleLabel.viewWithTag(1001)
  352 + titleLabel.tag = 1001
345 353 titleLabel.font = medium_adapt_font(pointSize: 12)
346 354 view.addSubview(titleLabel)
347 355 titleLabel.snp.makeConstraints { make in
... ... @@ -351,9 +359,8 @@ extension CNLiveShortVideoListTableViewCell {
351 359 }
352 360  
353 361 let timeLabel = UILabel.init()
354   - timeLabel.text = "04:45"
355 362 timeLabel.textColor = .white
356   - timeLabel.viewWithTag(1002)
  363 + timeLabel.tag = 1002
357 364 timeLabel.font = light_adapt_font(pointSize: 13)
358 365 view.addSubview(timeLabel)
359 366 timeLabel.snp.makeConstraints { make in
... ...
metaCode/Classes/Main/VideoPage/ViewModel/CNLiveShortVideoViewModel.swift
... ... @@ -11,21 +11,182 @@ import CNLiveRequestBastKit
11 11 typealias resultShortVideoBlock = (_ result: Any,_ respStatue :CNLiveMineResponseType) -> Void
12 12 class CNLiveShortVideoViewModel: NSObject {
13 13  
14   - /// 这是测试请求短视频数据
15   - static func requstWithShortVideo(reultShortVideoBlock: @escaping resultShortVideoBlock) {
16   -
  14 + /// 获取短视频数据
  15 + /// - Parameters:
  16 + /// - aid: 专辑 id
  17 + /// - reultShortVideoBlock: 返回
  18 + static func requstWithShortVideo(aid: String,page: NSInteger,reultShortVideoBlock: @escaping resultShortVideoBlock) {
17 19 let param = NSMutableDictionary()
18   - param.setValue("10511059", forKey: "creatorId")
19   - param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "userId")
20   - param.setValue("3", forKey: "type")
21   - param.setValue("1", forKey: "page")
  20 + param.setValue(aid, forKey: "aid")
  21 + param.setValue("", forKey: "app_channel_id")
  22 + param.setValue("\(page)", forKey: "page")
22 23 param.setValue("10", forKey: "pageSize")
  24 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  25 + let custom_param = NSMutableDictionary()
  26 + custom_param.setValue(APPId_wjj, forKey: "appId")
  27 + custom_param.setValue(APPKey_wjj, forKey: "appKey")
  28 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  29 + CNLiveNetworking.setupShowDataResult(false)
  30 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  31 + CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseCMSUrl+"/ugcApi/albumList", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  32 + hiddenLoading()
  33 + if (error == nil) {
  34 + let resp = result as! NSDictionary
  35 + let errorCode = "\(resp["errorCode"] ?? "0")"
  36 + if (errorCode == "0") {
  37 + if resp["data"] is NSNull {
  38 + reultShortVideoBlock(NSNull(), .failed)
  39 + } else {
  40 + CNLiveShortVideoViewModel.requstWithAlbumMsgVideo(aid: aid) { result, respStatue in
  41 + if respStatue == .success {
  42 + let resp_dict = resp["data"] as! NSDictionary
  43 + let array = resp_dict["list"] as! NSArray
  44 + let tempArray = NSMutableArray()
  45 + let tempUrlArray = NSMutableArray()
  46 + for item in array {
  47 + let listModel = dictionaryToModel(item as! [String : Any], CNLiveAlbumListModel.self,"") as! CNLiveAlbumListModel
  48 + listModel.albumMsgModel = result as? CNLiveAlbumMsgModel
  49 + tempArray.add(listModel)
  50 + tempUrlArray.add(listModel.videoUrl as String)
  51 + }
  52 + reultShortVideoBlock([tempArray, resp_dict["hasNextPage"], tempUrlArray], .success)
  53 + } else {
  54 + let resp_dict = resp["data"] as! NSDictionary
  55 + let array = resp_dict["list"] as! NSArray
  56 + let tempArray = NSMutableArray()
  57 + let tempUrlArray = NSMutableArray()
  58 + for item in array {
  59 + let listModel = dictionaryToModel(item as! [String : Any], CNLiveAlbumListModel.self,"") as! CNLiveAlbumListModel
  60 + tempArray.add(listModel)
  61 + tempUrlArray.add(listModel.videoUrl as String)
  62 + }
  63 + reultShortVideoBlock([tempArray, resp_dict["hasNextPage"], tempUrlArray], .success)
  64 + }
  65 + }
  66 + }
  67 + } else {
  68 + showMessage(message: resp["errorMessage"] as! String)
  69 + reultShortVideoBlock(NSNull(),.failed)
  70 + }
  71 + } else {
  72 + if CNLiveNetworking.isNetworking() {
  73 + showMessage(message: "请求失败")
  74 + reultShortVideoBlock(NSNull(),.failed)
  75 + } else {
  76 + showMessage(message: "似乎与网络断开链接")
  77 + reultShortVideoBlock(NSNull(),.noNetwork)
  78 + }
  79 + }
  80 + }
  81 + }
  82 +
  83 + /// 获取专辑信息接口
  84 + /// - Parameters:
  85 + /// - aid: 专辑名称
  86 + /// - reultShortVideoBlock: 返回
  87 + static func requstWithAlbumMsgVideo(aid: String,reultShortVideoBlock: @escaping resultShortVideoBlock) {
  88 + let param = NSMutableDictionary()
  89 + param.setValue(aid, forKey: "aid")
  90 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  91 + let custom_param = NSMutableDictionary()
  92 + custom_param.setValue(APPId_wjj, forKey: "appId")
  93 + custom_param.setValue(APPKey_wjj, forKey: "appKey")
  94 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  95 + CNLiveNetworking.setupShowDataResult(false)
  96 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  97 + CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseCMSUrl+"/contentApi/getAlbumMsg", param: param as! [String : Any], cacheType: .networkOnly) { task, result, error in
  98 + hiddenLoading()
  99 + if (error == nil) {
  100 + let resp = result as! NSDictionary
  101 + let errorCode = "\(resp["errorCode"] ?? "0")"
  102 + if (errorCode == "0") {
  103 + if resp["data"] is NSNull {
  104 + reultShortVideoBlock(NSNull(), .failed)
  105 + } else {
  106 + let listModel = dictionaryToModel(resp["data"] as! [String : Any], CNLiveAlbumMsgModel.self,"") as! CNLiveAlbumMsgModel
  107 + reultShortVideoBlock(listModel, .success)
  108 + }
  109 + } else {
  110 + showMessage(message: resp["errorMessage"] as! String)
  111 + reultShortVideoBlock(NSNull(),.failed)
  112 + }
  113 + } else {
  114 + if CNLiveNetworking.isNetworking() {
  115 + showMessage(message: "请求失败")
  116 + reultShortVideoBlock(NSNull(),.failed)
  117 + } else {
  118 + showMessage(message: "似乎与网络断开链接")
  119 + reultShortVideoBlock(NSNull(),.noNetwork)
  120 + }
  121 + }
  122 + }
  123 + }
  124 +
  125 +
  126 + /// 短视频点赞功能
  127 + /// - Parameters:
  128 + /// - contentId: 点赞内容 id
  129 + /// - contentTitle: 点赞的视频标题
  130 + /// - support: 1:点赞 0:取消点赞
  131 + /// - reultShortVideoBlock: 返回
  132 + static func requestRankWithLike(contentId: String, contentTitle: String, contentSid: String, support: Bool,tagName: String,reultShortVideoBlock: @escaping resultShortVideoBlock) {
  133 + let param = NSMutableDictionary()
  134 + param.setValue(contentId, forKey: "contentId")
  135 + param.setValue(APPId_wjj, forKey: "appId")
  136 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  137 + param.setValue(contentId, forKey: "contentTitle")
  138 + param.setValue(contentSid, forKey: "contentSid")
  139 + param.setValue(support ? "1":"0", forKey: "support")
  140 + param.setValue("false", forKey: "isRank")
  141 + param.setValue("1", forKey: "isUgc")
  142 + param.setValue(tagName, forKey: "contentTag")
  143 + let custom_param = NSMutableDictionary()
  144 + custom_param.setValue(APPId_wjj, forKey: "appId")
  145 + custom_param.setValue(APPKey_wjj, forKey: "appKey")
  146 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  147 + CNLiveNetworking.setupShowDataResult(false)
  148 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  149 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/support/supportBySpIdForRank/insert", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  150 + hiddenLoading()
  151 + if (error == nil) {
  152 + let resp = result as! NSDictionary
  153 + let errorCode = "\(resp["errorCode"] ?? "0")"
  154 + if (errorCode == "0") {
  155 + reultShortVideoBlock(support ? "取消点赞成功" : "点赞成功", .success)
  156 + } else {
  157 + showMessage(message: resp["errorMessage"] as! String)
  158 + reultShortVideoBlock(NSNull(),.failed)
  159 + }
  160 + } else {
  161 + if CNLiveNetworking.isNetworking() {
  162 + showMessage(message: "请求失败")
  163 + reultShortVideoBlock(NSNull(),.failed)
  164 + } else {
  165 + showMessage(message: "似乎与网络断开链接")
  166 + reultShortVideoBlock(NSNull(),.noNetwork)
  167 + }
  168 + }
  169 + }
  170 + }
  171 +
  172 + //!!!: 评论相关
  173 +
  174 + /// 获取评论列表数
  175 + /// - Parameters:
  176 + /// - pid: 视频 pid
  177 + /// - page: 页数
  178 + /// - reultShortVideoBlock: 返回
  179 + static func requestCommentList(pid: String,page: NSInteger,reultShortVideoBlock: @escaping resultShortVideoBlock) {
  180 + let param = NSMutableDictionary()
  181 + param.setValue(pid, forKey: "topicId")
  182 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  183 + param.setValue("\(page)", forKey: "seqId")
  184 + param.setValue("10", forKey: "count")
23 185 let custom_param = NSMutableDictionary()
24 186 custom_param.setValue(APPId_wjj, forKey: "appId")
25 187 custom_param.setValue(APPKey_wjj, forKey: "appKey")
26 188 CNLiveNetworking.setAllowRequestDefaultArgument(true)
27 189 CNLiveNetworking.setupShowDataResult(false)
28   - CNLiveNetworking.setupDSRequest(true)
29 190 CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
30 191 CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseCMSClassUrl+"/ugcApi/ugcVideoList", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
31 192 hiddenLoading()
... ... @@ -36,21 +197,149 @@ class CNLiveShortVideoViewModel: NSObject {
36 197 if resp["data"] is NSNull {
37 198 reultShortVideoBlock(NSNull(), .failed)
38 199 } else {
  200 + let listModel = dictionaryToModel(resp["data"] as! [String : Any], ShortVideoHomeCommentModel.self,"") as! ShortVideoHomeCommentModel
  201 + reultShortVideoBlock(listModel, .success)
  202 + }
  203 + } else {
  204 + showMessage(message: resp["errorMessage"] as! String)
  205 + reultShortVideoBlock(NSNull(),.failed)
  206 + }
  207 + } else {
  208 + if CNLiveNetworking.isNetworking() {
  209 + showMessage(message: "请求失败")
  210 + reultShortVideoBlock(NSNull(),.failed)
  211 + } else {
  212 + showMessage(message: "似乎与网络断开链接")
  213 + reultShortVideoBlock(NSNull(),.noNetwork)
  214 + }
  215 + }
  216 + }
  217 + }
  218 +
  219 + /// 发布评论
  220 + /// - Parameters:
  221 + /// - videoId: 视频 id
  222 + /// - comment: 评论内容
  223 + /// - isAuthor: 是否是作者
  224 + /// - reultShortVideoBlock: 返回
  225 + static func requestCommentWithSend(videoId: String, comment: String, isAuthor: Bool,reultShortVideoBlock: @escaping resultShortVideoBlock) {
  226 + let param = NSMutableDictionary()
  227 + param.setValue(videoId, forKey: "topicId")
  228 + param.setValue(APPId_wjj, forKey: "appId")
  229 + param.setValue(comment, forKey: "comment")
  230 + param.setValue(isAuthor ? "1":"0", forKey: "isAuthor")
  231 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  232 + let custom_param = NSMutableDictionary()
  233 + custom_param.setValue(APPId_wjj, forKey: "appId")
  234 + custom_param.setValue(APPKey_wjj, forKey: "appKey")
  235 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  236 + CNLiveNetworking.setupShowDataResult(false)
  237 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  238 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/insertComment", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  239 + hiddenLoading()
  240 + if (error == nil) {
  241 + let resp = result as! NSDictionary
  242 + let errorCode = "\(resp["errorCode"] ?? "0")"
  243 + if (errorCode == "0") {
  244 + reultShortVideoBlock("评论成功", .success)
  245 + } else {
  246 + showMessage(message: resp["errorMessage"] as! String)
  247 + reultShortVideoBlock(NSNull(),.failed)
  248 + }
  249 + } else {
  250 + if CNLiveNetworking.isNetworking() {
  251 + showMessage(message: "请求失败")
  252 + reultShortVideoBlock(NSNull(),.failed)
  253 + } else {
  254 + showMessage(message: "似乎与网络断开链接")
  255 + reultShortVideoBlock(NSNull(),.noNetwork)
  256 + }
  257 + }
  258 + }
  259 + }
  260 +
  261 +
  262 + /// 对评论进行回复
  263 + /// - Parameters:
  264 + /// - commentId: 评论 id
  265 + /// - comment: 评论内容
  266 + /// - toSid: 被回复者ID
  267 + /// - fromSid: 回复者ID
  268 + /// - level: 1:一级评论回复 2:二级评论回复
  269 + /// - reultShortVideoBlock: 返回
  270 + static func requestCommentWithReply(commentId: String, comment: String, toSid: String, fromSid: String, level: String,reultShortVideoBlock: @escaping resultShortVideoBlock) {
  271 + let param = NSMutableDictionary()
  272 + param.setValue(commentId, forKey: "commentId")
  273 + param.setValue(APPId_wjj, forKey: "appId")
  274 + param.setValue(comment, forKey: "comment")
  275 + param.setValue(toSid, forKey: "toSid")
  276 + param.setValue(fromSid, forKey: "fromSid")
  277 + param.setValue(level, forKey: "level")
  278 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  279 + let custom_param = NSMutableDictionary()
  280 + custom_param.setValue(APPId_wjj, forKey: "appId")
  281 + custom_param.setValue(APPKey_wjj, forKey: "appKey")
  282 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  283 + CNLiveNetworking.setupShowDataResult(false)
  284 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  285 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/insertReply", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  286 + hiddenLoading()
  287 + if (error == nil) {
  288 + let resp = result as! NSDictionary
  289 + let errorCode = "\(resp["errorCode"] ?? "0")"
  290 + if (errorCode == "0") {
  291 + reultShortVideoBlock("回复成功", .success)
  292 + } else {
  293 + showMessage(message: resp["errorMessage"] as! String)
  294 + reultShortVideoBlock(NSNull(),.failed)
  295 + }
  296 + } else {
  297 + if CNLiveNetworking.isNetworking() {
  298 + showMessage(message: "请求失败")
  299 + reultShortVideoBlock(NSNull(),.failed)
  300 + } else {
  301 + showMessage(message: "似乎与网络断开链接")
  302 + reultShortVideoBlock(NSNull(),.noNetwork)
  303 + }
  304 + }
  305 + }
  306 + }
  307 +
  308 +
  309 + /// 获取回复数据列表
  310 + /// - Parameters:
  311 + /// - commentId: 评论 id
  312 + /// - page: 页数
  313 + /// - reultShortVideoBlock: 返回
  314 + static func requestcommentWithReplyList(commentId: String,page: NSInteger,reultShortVideoBlock: @escaping resultShortVideoBlock) {
  315 + let param = NSMutableDictionary()
  316 + param.setValue(commentId, forKey: "commentId")
  317 + param.setValue("\(page)", forKey: "seqId")
  318 + param.setValue("10", forKey: "count")
  319 + let custom_param = NSMutableDictionary()
  320 + custom_param.setValue(APPId_wjj, forKey: "appId")
  321 + custom_param.setValue(APPKey_wjj, forKey: "appKey")
  322 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  323 + CNLiveNetworking.setupShowDataResult(false)
  324 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  325 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseCMSClassUrl+"/commentServices/commentForUgc/loadReplys", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  326 + hiddenLoading()
  327 + if (error == nil) {
  328 + let resp = result as! NSDictionary
  329 + let errorCode = "\(resp["errorCode"] ?? "0")"
  330 + if (errorCode == "0") {
  331 + if resp["data"] is NSNull {
  332 + reultShortVideoBlock(NSNull(), .failed)
  333 + } else {
39 334 let resp_dict = resp["data"] as! NSDictionary
40   - let array = resp_dict["list"] as! NSArray
  335 + let resp_reply_dict = resp_dict["replyData"] as! NSDictionary
  336 + let array = resp_reply_dict["replys"] as! NSArray
41 337 let tempArray = NSMutableArray()
42   - let tempUrlArray = NSMutableArray()
43   - var index = 0
44 338 for item in array {
45   - let listModel = dictionaryToModel(item as! [String : Any], ShortVideoHomeTestModel.self,"") as! ShortVideoHomeTestModel
46   - if (index > 2) {
47   - listModel.isMoney = true
48   - }
  339 + let listModel = dictionaryToModel(item as! [String : Any], ShortVideoHomeCommentRListItemModel.self,"") as! ShortVideoHomeCommentRListItemModel
49 340 tempArray.add(listModel)
50   - tempUrlArray.add(listModel.videoUrl! as String)
51   - index += 1
52 341 }
53   - reultShortVideoBlock([tempArray, tempUrlArray], .success)
  342 + reultShortVideoBlock(tempArray, .success)
54 343 }
55 344 } else {
56 345 showMessage(message: resp["errorMessage"] as! String)
... ... @@ -68,4 +357,84 @@ class CNLiveShortVideoViewModel: NSObject {
68 357 }
69 358 }
70 359  
  360 + /// 删除评论
  361 + /// - Parameters:
  362 + /// - videoId: 视频 id
  363 + /// - commentId: 评论 id
  364 + /// - reultShortVideoBlock: 返回
  365 + static func requestCommentDelete(videoId: String, commentId: String, reultShortVideoBlock: @escaping resultShortVideoBlock) {
  366 + let param = NSMutableDictionary()
  367 + param.setValue(commentId, forKey: "commentId")
  368 + param.setValue(APPId_wjj, forKey: "appId")
  369 + param.setValue(videoId, forKey: "topicId")
  370 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  371 + let custom_param = NSMutableDictionary()
  372 + custom_param.setValue(APPId_wjj, forKey: "appId")
  373 + custom_param.setValue(APPKey_wjj, forKey: "appKey")
  374 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  375 + CNLiveNetworking.setupShowDataResult(false)
  376 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  377 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/deleteComment", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  378 + hiddenLoading()
  379 + if (error == nil) {
  380 + let resp = result as! NSDictionary
  381 + let errorCode = "\(resp["errorCode"] ?? "0")"
  382 + if (errorCode == "0") {
  383 + reultShortVideoBlock("删除成功", .success)
  384 + } else {
  385 + showMessage(message: resp["errorMessage"] as! String)
  386 + reultShortVideoBlock(NSNull(),.failed)
  387 + }
  388 + } else {
  389 + if CNLiveNetworking.isNetworking() {
  390 + showMessage(message: "请求失败")
  391 + reultShortVideoBlock(NSNull(),.failed)
  392 + } else {
  393 + showMessage(message: "似乎与网络断开链接")
  394 + reultShortVideoBlock(NSNull(),.noNetwork)
  395 + }
  396 + }
  397 + }
  398 + }
  399 +
  400 + /// 删除回复
  401 + /// - Parameters:
  402 + /// - replyId: 回复 id
  403 + /// - commentId: 评论 id
  404 + /// - reultShortVideoBlock: 返回
  405 + static func requestCommentReplyDelete(replyId: String, commentId: String, reultShortVideoBlock: @escaping resultShortVideoBlock) {
  406 + let param = NSMutableDictionary()
  407 + param.setValue(commentId, forKey: "commentId")
  408 + param.setValue(APPId_wjj, forKey: "appId")
  409 + param.setValue(replyId, forKey: "replyId")
  410 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
  411 + let custom_param = NSMutableDictionary()
  412 + custom_param.setValue(APPId_wjj, forKey: "appId")
  413 + custom_param.setValue(APPKey_wjj, forKey: "appKey")
  414 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  415 + CNLiveNetworking.setupShowDataResult(false)
  416 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  417 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/deleteReply", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  418 + hiddenLoading()
  419 + if (error == nil) {
  420 + let resp = result as! NSDictionary
  421 + let errorCode = "\(resp["errorCode"] ?? "0")"
  422 + if (errorCode == "0") {
  423 + reultShortVideoBlock("删除成功", .success)
  424 + } else {
  425 + showMessage(message: resp["errorMessage"] as! String)
  426 + reultShortVideoBlock(NSNull(),.failed)
  427 + }
  428 + } else {
  429 + if CNLiveNetworking.isNetworking() {
  430 + showMessage(message: "请求失败")
  431 + reultShortVideoBlock(NSNull(),.failed)
  432 + } else {
  433 + showMessage(message: "似乎与网络断开链接")
  434 + reultShortVideoBlock(NSNull(),.noNetwork)
  435 + }
  436 + }
  437 + }
  438 + }
  439 +
71 440 }
... ...