Commit fad828e05677424a1f1e061eb7f25e1bc7be5e05

Authored by liushiyu
1 parent 184f9c53

提交播放相关问题

metaCode.xcodeproj/project.pbxproj
... ... @@ -161,7 +161,6 @@
161 161 793CAF522A58FCA200882EF4 /* CNLiveMineExchangeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 793CAF512A58FCA200882EF4 /* CNLiveMineExchangeViewController.swift */; };
162 162 794294A72B4D18EC008AAFA0 /* CNLiveShortVideoContentListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794294A62B4D18EC008AAFA0 /* CNLiveShortVideoContentListView.swift */; };
163 163 794294AA2B4D4381008AAFA0 /* CNLiveShortVideoCommentListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794294A92B4D4381008AAFA0 /* CNLiveShortVideoCommentListView.swift */; };
164   - 794294AC2B4D44C0008AAFA0 /* CNLiveShortVideoCommentLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794294AB2B4D44C0008AAFA0 /* CNLiveShortVideoCommentLayout.swift */; };
165 164 794BC1652AF9E70D00A68C74 /* CNLiveShopOrderSendViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794BC1642AF9E70D00A68C74 /* CNLiveShopOrderSendViewController.swift */; };
166 165 794FF1052B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794FF1042B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift */; };
167 166 794FF1072B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794FF1062B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift */; };
... ... @@ -427,7 +426,6 @@
427 426 793CAF512A58FCA200882EF4 /* CNLiveMineExchangeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineExchangeViewController.swift; sourceTree = "<group>"; };
428 427 794294A62B4D18EC008AAFA0 /* CNLiveShortVideoContentListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShortVideoContentListView.swift; sourceTree = "<group>"; };
429 428 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>"; };
431 429 794BC1642AF9E70D00A68C74 /* CNLiveShopOrderSendViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopOrderSendViewController.swift; sourceTree = "<group>"; };
432 430 794FF1042B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopOrderSearchViewController.swift; sourceTree = "<group>"; };
433 431 794FF1062B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopOrderSearchListViewController.swift; sourceTree = "<group>"; };
... ... @@ -1033,7 +1031,6 @@
1033 1031 isa = PBXGroup;
1034 1032 children = (
1035 1033 796308742B4B90700090D22A /* CNLiveShortVideoHomeModel.swift */,
1036   - 794294AB2B4D44C0008AAFA0 /* CNLiveShortVideoCommentLayout.swift */,
1037 1034 );
1038 1035 path = Model;
1039 1036 sourceTree = "<group>";
... ... @@ -1895,7 +1892,6 @@
1895 1892 191733152B109FD7007BCC04 /* CNLivePlayerTopNaviView.swift in Sources */,
1896 1893 794FF1052B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift in Sources */,
1897 1894 798A44EC2A302DBE00815935 /* CNLiveMineAddInfoViewController.swift in Sources */,
1898   - 794294AC2B4D44C0008AAFA0 /* CNLiveShortVideoCommentLayout.swift in Sources */,
1899 1895 791C1C882AFB6FD7003E6362 /* CNLiveShopOrderExpressFirmViewController.swift in Sources */,
1900 1896 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */,
1901 1897 794BC1652AF9E70D00A68C74 /* CNLiveShopOrderSendViewController.swift in Sources */,
... ...
metaCode/Classes/Main/HomePage/View/ShopCoupon/CNLiveShopCouponCreateBottomView.swift
... ... @@ -19,7 +19,7 @@ class CNLiveShopCouponCreateBottomView:UIView{
19 19 /// 代理
20 20 weak var delegate:CNLiveShopCouponButtonClickDelegate?
21 21  
22   - private lazy var cancelBtn: UIButton = {
  22 + lazy var cancelsBtn: UIButton = {
23 23  
24 24 let button = UIButton(type: .custom)
25 25 button.backgroundColor = UIColor.white
... ... @@ -55,13 +55,13 @@ class CNLiveShopCouponCreateBottomView:UIView{
55 55 override init(frame: CGRect) {
56 56 super.init(frame: frame)
57 57  
58   - self.addSubview(self.cancelBtn)
  58 + self.addSubview(self.cancelsBtn)
59 59 self.addSubview(self.saveBtn)
60 60 self.saveBtn.snp.makeConstraints { make in
61 61 make.top.right.bottom.equalTo(self)
62 62 make.width.equalTo(245)
63 63 }
64   - self.cancelBtn.snp.makeConstraints { make in
  64 + self.cancelsBtn.snp.makeConstraints { make in
65 65 make.left.top.bottom.equalTo(self)
66 66 make.right.equalTo(self.saveBtn.snp.left)
67 67 }
... ...
metaCode/Classes/Main/ShopPage/View/CNLiveShopBodyCustomView.swift
... ... @@ -60,7 +60,7 @@ class ShopBodyOrderRefundView: UIView, UITextViewDelegate {
60 60 return contentTextView
61 61 }()
62 62  
63   - lazy var cancelBtn: UIButton = {
  63 + lazy var cancelsBtn: UIButton = {
64 64 let cancelBtn = UIButton.init(type: .custom)
65 65 cancelBtn.setTitle("取消", for: .normal)
66 66 cancelBtn.setTitleColor(HexColor("#ffffff"), for: .normal)
... ... @@ -117,8 +117,8 @@ class ShopBodyOrderRefundView: UIView, UITextViewDelegate {
117 117 make.right.equalToSuperview().offset(-adapt_length(length: 15))
118 118 make.bottom.equalToSuperview().offset(-adapt_length(length: 12))
119 119 }
120   - alertView.addSubview(cancelBtn)
121   - cancelBtn.snp.makeConstraints { make in
  120 + alertView.addSubview(cancelsBtn)
  121 + cancelsBtn.snp.makeConstraints { make in
122 122 make.left.equalToSuperview().offset((KSreenWidth-adapt_length(length: 228))/3)
123 123 make.bottom.equalToSuperview().offset(-adapt_length(length: 15))
124 124 make.width.equalTo(adapt_length(length: 84))
... ...
metaCode/Classes/Main/VideoPage/Controller/CNLiveShortVideoViewController.swift
... ... @@ -31,9 +31,13 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
31 31 tableView.tableFooterView = UIView.init()
32 32 tableView.separatorStyle = .none
33 33 tableView.scrollsToTop = false
  34 + if #available(iOS 11.0, *) {
  35 + tableView.contentInsetAdjustmentBehavior = .never;
  36 + } else {
  37 + self.automaticallyAdjustsScrollViewInsets = false;
  38 + }
34 39 tableView.showsVerticalScrollIndicator = false
35 40 tableView.showsHorizontalScrollIndicator = false
36   - tableView.contentInsetAdjustmentBehavior = .never;
37 41 tableView.register(CNLiveShortVideoListTableViewCell.self, forCellReuseIdentifier: kVideoBodyListViewCellIdentifier)
38 42 return tableView
39 43 }()
... ... @@ -50,6 +54,13 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
50 54 return controlView
51 55 }()
52 56  
  57 + lazy var headerRefreshView: UIRefreshControl = {
  58 + let headerRefreshView = UIRefreshControl()
  59 + headerRefreshView.tintColor = .white
  60 + headerRefreshView.addTarget(self, action: #selector(headerRefresh), for: .valueChanged)
  61 + return headerRefreshView
  62 + }()
  63 +
53 64 lazy var dataArray: NSMutableArray = {
54 65 let dataArray = NSMutableArray.init()
55 66 return dataArray
... ... @@ -62,7 +73,6 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
62 73 var aid: String! = ""
63 74 var pageNum: NSInteger! = 1
64 75 var currentIndex: NSInteger! = 0
65   - var headerRefreshView: CNLiveHeaderRefresh!
66 76 var footerRefreshView: CNLiveFooterRefresh!
67 77 var playerManager = ZFIJKPlayerManager.init()
68 78 // var playerManager = ZFAVPlayerManager.init()
... ... @@ -115,16 +125,13 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
115 125 guard let self = self else { return }
116 126 self.player.currentPlayerManager.replay()
117 127 }
118   - player.playerPrepareToPlay = {[weak self] asset, assetURL in
  128 + player.playerReadyToPlay = {[weak self] asset, assetURL in
119 129 guard let self = self else { return }
120 130 self.controlView.videoPlayer((self.player)!, currentTime: self.player.currentTime, totalTime: self.player.totalTime)
121 131 let index = self.dataURLArray.index(of: assetURL.absoluteString)
122 132 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 133 if (homeModel.product!.albumProductType != "0") {
127   - self.player.stopCurrentPlayingCell()
  134 + (self.player)!.stopCurrentPlayingCell()
128 135 }
129 136 }
130 137 // 更新另一个控制层的时间
... ... @@ -148,11 +155,7 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
148 155 }
149 156  
150 157 func addRefreshView() {
151   - headerRefreshView = CNLiveHeaderRefresh(refreshingBlock: { [weak self] in
152   - guard let self = self else { return }
153   - self.pageNum = 1
154   - self.requestData {}
155   - })
  158 + self.tableView.refreshControl = headerRefreshView
156 159 footerRefreshView = CNLiveFooterRefresh(refreshingBlock: { [weak self] in
157 160 guard let self = self else { return }
158 161 self.player.stopCurrentPlayingCell()
... ... @@ -161,6 +164,11 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
161 164 })
162 165 }
163 166  
  167 + @objc func headerRefresh() {
  168 + self.pageNum = 1
  169 + self.requestData {}
  170 + }
  171 +
164 172 override func viewWillLayoutSubviews() {
165 173 super.viewWillLayoutSubviews()
166 174 self.backBtn.frame = CGRectMake(15, CGRectGetMaxY(UIApplication.shared.statusBarFrame), 45, 45)
... ... @@ -173,16 +181,22 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
173 181 if self.pageNum == 1 {
174 182 self.dataArray.removeAllObjects()
175 183 self.dataURLArray.removeAllObjects()
  184 + if self.currentIndex == 0 {
  185 + self.tableView.setContentOffset(CGPoint.zero, animated: false)
  186 + }
176 187 }
177 188 let listArray = (result as! [Any]).first as! [CNLiveAlbumListModel]
178 189 self.dataArray.addObjects(from: listArray)
179 190 let urlArray = (result as! [Any]).last as! [String]
180 191 self.dataURLArray.addObjects(from: urlArray)
181   - if self.tableView.mj_header != nil && self.tableView.mj_footer != nil {
  192 + if self.tableView.mj_footer != nil {
182 193 self.tableView.mj_footer?.endRefreshing()
183   - self.tableView.mj_header?.endRefreshing()
184 194 }
  195 + self.tableView.refreshControl?.endRefreshing()
185 196 self.tableView.reloadData()
  197 + DispatchQueue.main.async {
  198 + self.tableView.contentOffset = CGPoint.zero
  199 + }
186 200 let hasNextPage = (result as! [Any])[1] as! Bool
187 201 if listArray.count == 0 && urlArray.count == 0 {
188 202 if !hasNextPage {
... ... @@ -190,9 +204,6 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
190 204 self.tableView.reloadData()
191 205 }
192 206 } else {
193   - if self.tableView.mj_header == nil {
194   - self.tableView.mj_header = headerRefreshView
195   - }
196 207 if self.tableView.mj_footer == nil {
197 208 self.tableView.mj_footer = footerRefreshView
198 209 }
... ... @@ -201,10 +212,11 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
201 212 self.playTheIndex(index: self.currentIndex)
202 213 }
203 214 } else {
204   - if self.tableView.mj_header != nil && self.tableView.mj_footer != nil {
  215 + if self.tableView.mj_footer != nil {
205 216 self.tableView.mj_footer?.endRefreshing()
206   - self.tableView.mj_header?.endRefreshing()
207 217 }
  218 + self.tableView.contentOffset = CGPoint.zero
  219 + self.tableView.refreshControl?.endRefreshing()
208 220 if self.dataArray.count == 0 {
209 221 self.tableView.reloadEmptyDataSet()
210 222 }
... ... @@ -268,12 +280,20 @@ extension CNLiveShortVideoViewController {
268 280 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 281 if respStatue == .success {
270 282 viewcell.homeModel.tool!.liked = !viewcell.homeModel.tool!.liked
  283 + if viewcell.homeModel.tool!.liked {
  284 + viewcell.homeModel.tool?.likesNum = "\(Int(viewcell.homeModel.tool!.likesNum)! + 1)"
  285 + } else {
  286 + viewcell.homeModel.tool?.likesNum = "\(Int(viewcell.homeModel.tool!.likesNum)! - 1)"
  287 + }
  288 + button.setTitle(viewcell.homeModel.tool?.likesNum, for: .normal)
271 289 button.isSelected = viewcell.homeModel.tool!.liked
272 290 }
273 291 }
274 292 }
275 293 func commentActionMethod(viewcell: CNLiveShortVideoListTableViewCell, button: UIButton) {
276   -
  294 + CNLiveShortVideoCommentListView.showVideoCommentListView(pid: viewcell.homeModel.pid, contentSid: viewcell.homeModel.icon!.id, result: { commentModel in
  295 +
  296 + })
277 297 }
278 298 func shareActionMethod(viewcell: CNLiveShortVideoListTableViewCell, button: UIButton) {
279 299  
... ... @@ -323,8 +343,8 @@ extension CNLiveShortVideoViewController {
323 343 guard let cell = tableView.dequeueReusableCell(withIdentifier: kVideoBodyListViewCellIdentifier) as? CNLiveShortVideoListTableViewCell else {
324 344 return CNLiveShortVideoListTableViewCell()
325 345 }
326   - cell.setupWithData(model: dataArray[indexPath.row] as! CNLiveAlbumListModel)
327 346 cell.delegate = self
  347 + cell.setupWithData(model: dataArray[indexPath.row] as! CNLiveAlbumListModel)
328 348 return cell
329 349 }
330 350  
... ...
metaCode/Classes/Main/VideoPage/Model/CNLiveShortVideoCommentLayout.swift deleted 100644 → 0
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
... ... @@ -6,17 +6,31 @@
6 6 //
7 7  
8 8 import Foundation
9   -
  9 +import YYText
  10 +import CNLiveBusinessTools
10 11 //!!!: 评论相关 model
11 12 class ShortVideoHomeCommentModel: BaseModel {
12 13 var total_hd: Int? = 0 //总数
13   - var hasNext: String? = ""
  14 + var hasNext: Bool? = false
14 15 var comments = [ShortVideoHomeCommentListModel]()
15 16 }
16 17  
17 18 class ShortVideoHomeCommentListModel: BaseModel {
18 19 var comment = ShortVideoHomeCommentFListModel()
19 20 var replyData = ShortVideoHomeCommentRListModel()
  21 +
  22 + var cell_h: CGFloat! = 0.0
  23 + var tableView_h: CGFloat! = 0.0
  24 + override func didFinishMapping() {
  25 + super.didFinishMapping()
  26 + cell_h += comment.cellH
  27 + cell_h += 10
  28 + for replyModel in replyData.replys {
  29 + tableView_h += replyModel.cellH
  30 + }
  31 + cell_h += tableView_h
  32 + }
  33 +
20 34 }
21 35 //评论数据
22 36 class ShortVideoHomeCommentFListModel: BaseModel {
... ... @@ -37,6 +51,26 @@ class ShortVideoHomeCommentFListModel: BaseModel {
37 51 var praiseCount: Int? = 0
38 52 var isPraised: Bool? = false
39 53 var icon: String? = ""
  54 +
  55 + var iconSize: CGSize = CGSize(width: 50, height: 50)
  56 + var textLayout: YYTextLayout!
  57 + var cellH: CGFloat! = 0
  58 +
  59 + override func didFinishMapping() {
  60 + super.didFinishMapping()
  61 +
  62 + let modifier = CNLiveShortVideoMateCodeLinePositionModifier(font: medium_adapt_font(pointSize: 16), paddingTop: 5, paddingBottom: 5, lineHeightMultiple: 2)
  63 + let comment = CNLiveBusinessTools.replaceQQemoji(withCustomText: self.content ?? "")
  64 + let attributes = NSMutableAttributedString(attributedString: comment)
  65 + attributes.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.white, range: NSRange(location: 0, length: comment.length))
  66 + attributes.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 16), range: NSRange(location: 0, length: comment.length))
  67 + let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80, height: CGFloat(HUGE)))
  68 + textContainer.linePositionModifier = modifier;
  69 + let textLayout = YYTextLayout(container: textContainer, text: attributes)
  70 + self.textLayout = textLayout
  71 + self.cellH = 70 + (textLayout?.textBoundingRect.size.height ?? 0)
  72 + }
  73 +
40 74 }
41 75 //回复数据
42 76 class ShortVideoHomeCommentRListModel: BaseModel {
... ... @@ -62,4 +96,76 @@ class ShortVideoHomeCommentRListItemModel: BaseModel {
62 96 var content: String? = ""
63 97 var level: Int? = 0
64 98 var icon: String? = ""
  99 +
  100 + var textLayout: YYTextLayout!
  101 + var cellH: CGFloat! = 0
  102 +
  103 + override func didFinishMapping() {
  104 + super.didFinishMapping()
  105 +
  106 + let modifier = CNLiveShortVideoMateCodeLinePositionModifier(font: semibold_adapt_font(pointSize: 14), paddingTop: 0, paddingBottom: 0, lineHeightMultiple: 1.5)
  107 + let comment = CNLiveBusinessTools.replaceQQemoji(withCustomText: content ?? "")
  108 + let attributes = NSMutableAttributedString(attributedString: comment)
  109 + attributes.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.white, range: NSRange(location: 0, length: comment.length))
  110 + attributes.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 16), range: NSRange(location: 0, length: comment.length))
  111 + let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80-40, height: CGFloat(HUGE)))
  112 + textContainer.linePositionModifier = modifier;
  113 + let textLayout = YYTextLayout(container: textContainer, text: attributes)
  114 + self.textLayout = textLayout
  115 + self.cellH = 70 + (textLayout?.textBoundingRect.size.height ?? 0)
  116 + }
  117 +}
  118 +
  119 +class CNLiveShortVideoMateCodeLinePositionModifier: NSObject, YYTextLinePositionModifier {
  120 +
  121 + var font: UIFont // 基准字体 (例如 Heiti SC/PingFang SC)
  122 + var paddingTop: CGFloat // 文本顶部留白
  123 + var paddingBottom: CGFloat // 文本底部留白
  124 + var lineHeightMultiple: CGFloat // 行距倍数
  125 +
  126 + init(font: UIFont, paddingTop: CGFloat, paddingBottom: CGFloat, lineHeightMultiple: CGFloat) {
  127 + self.font = font
  128 + self.paddingTop = paddingTop
  129 + self.paddingBottom = paddingBottom
  130 + self.lineHeightMultiple = lineHeightMultiple
  131 + super.init()
  132 +
  133 + if #available(iOS 9.0, *) {
  134 + self.lineHeightMultiple = 1.34 // for PingFang SC
  135 + } else {
  136 + self.lineHeightMultiple = 1.3125 // for Heiti SC
  137 + }
  138 + }
  139 +
  140 + func modifyLines(_ lines: [YYTextLine], fromText text: NSAttributedString, in container: YYTextContainer) {
  141 + let ascent = font.pointSize * 0.86
  142 + let lineHeight = font.pointSize * lineHeightMultiple
  143 +
  144 + for item in lines {
  145 + let line = item as YYTextLine
  146 + var position = line.position
  147 + position.y = paddingTop + ascent + CGFloat(line.row) * lineHeight
  148 + line.position = position
  149 + }
  150 + }
  151 +
  152 + func copy(with zone: NSZone? = nil) -> Any {
  153 + let one = CNLiveShortVideoMateCodeLinePositionModifier(
  154 + font: font,
  155 + paddingTop: paddingTop,
  156 + paddingBottom: paddingBottom,
  157 + lineHeightMultiple: lineHeightMultiple
  158 + )
  159 + return one
  160 + }
  161 +
  162 + func heightForLineCount(_ lineCount: UInt) -> CGFloat {
  163 + if lineCount == 0 {
  164 + return 0
  165 + }
  166 + let ascent = font.pointSize * 0.86
  167 + let descent = font.pointSize * 0.14
  168 + let lineHeight = font.pointSize * lineHeightMultiple
  169 + return paddingTop + paddingBottom + ascent + descent + CGFloat(lineCount - 1) * lineHeight
  170 + }
65 171 }
... ...
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoCommentListView.swift
... ... @@ -6,7 +6,516 @@
6 6 //
7 7  
8 8 import Foundation
  9 +import EmptyDataSet_Swift
  10 +import MJRefresh
  11 +import CNLiveCustomUI
  12 +import Kingfisher
  13 +import YYText
  14 +import APButton
  15 +typealias CloseCommentListResultBlock = (_ commentModel: Any) ->Void
  16 +class CNLiveShortVideoCommentListView: UIView, UITableViewDelegate, UITableViewDataSource, EmptyDataSetSource, EmptyDataSetDelegate {
  17 +
  18 + lazy var grayMaskView: UIView = {
  19 + let grayMaskView = UIView()
  20 + grayMaskView.backgroundColor = UIColor.black.withAlphaComponent(0.2)
  21 + return grayMaskView
  22 + }()
  23 +
  24 + lazy var contentView: UIView = {
  25 + let view = UIView.init()
  26 + view.backgroundColor = HexColor("#010101")
  27 + return view
  28 + }()
  29 +
  30 + lazy var closeButton: UIButton = {
  31 + let button = UIButton(type: .custom)
  32 + button.setImage(UIImage(named: "short_video_close"), for: .normal)
  33 + button.backgroundColor = .clear
  34 + button.addTarget(self, action: #selector(closeMethod), for: .touchUpInside)
  35 + return button
  36 + }()
  37 +
  38 + lazy var titleLabel: UILabel = {
  39 + let label = UILabel()
  40 + label.textColor = UIColor.white
  41 + label.font = semibold_adapt_font(pointSize: 19)
  42 + label.textAlignment = .left
  43 + label.text = "0条评论"
  44 + label.numberOfLines = 1
  45 + label.lineBreakMode = .byTruncatingTail
  46 + return label
  47 + }()
  48 +
  49 + lazy var sendButton: UIButton = {
  50 + let button = UIButton(type: .custom)
  51 + button.backgroundColor = HexColor("#f8f8f8")
  52 + button.setTitle("我来说一下...", for: .normal)
  53 + button.layer.cornerRadius = 20
  54 + button.layer.masksToBounds = true
  55 + button.titleLabel?.font = medium_adapt_font(pointSize: 15)
  56 + button.setTitleColor(UIColor.lightGray, for: .normal)
  57 + button.addTarget(self, action: #selector(sendCommentAction), for: .touchUpInside)
  58 + return button
  59 + }()
  60 +
  61 + lazy var emjButton: UIButton = {
  62 + let button = UIButton(type: .custom)
  63 + button.setImage(UIImage(named: "short_video_commet_emoji"), for: .normal)
  64 + button.backgroundColor = .clear
  65 + button.layer.cornerRadius = 20
  66 + button.layer.masksToBounds = true
  67 + button.addTarget(self, action: #selector(sendCommentAction), for: .touchUpInside)
  68 + return button
  69 + }()
  70 +
  71 +
  72 + lazy var lineLabel: UILabel = {
  73 + let lineLabel = UILabel.init()
  74 + lineLabel.backgroundColor = HexColor("#686868")
  75 + return lineLabel
  76 + }()
  77 +
  78 + let kShortVideoCommentListTableViewCellIdentifier = "kShortVideoCommentListTableViewCellIdentifier"
  79 + lazy var tableView : UITableView = {
  80 + let tableView = UITableView(frame: .zero, style: .plain)
  81 + tableView.dataSource = self
  82 + tableView.delegate = self
  83 + tableView.emptyDataSetSource = self
  84 + tableView.emptyDataSetDelegate = self
  85 + tableView.estimatedSectionFooterHeight = 0
  86 + tableView.estimatedSectionHeaderHeight = 0
  87 + tableView.backgroundColor = HexColor("#010101")
  88 + tableView.tableFooterView = UIView.init()
  89 + tableView.separatorStyle = .none
  90 + tableView.scrollsToTop = false
  91 + tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: get_system_tabbar_ui_offsetHeight(), right: 0)
  92 + tableView.contentInsetAdjustmentBehavior = .never;
  93 + tableView.register(CNLiveShortVideoCommentListTableViewCell.self, forCellReuseIdentifier: kShortVideoCommentListTableViewCellIdentifier)
  94 + return tableView
  95 + }()
  96 +
  97 + lazy var dataArray: NSMutableArray = {
  98 + let array = NSMutableArray()
  99 + return array
  100 + }()
  101 +
  102 + var videoId: String!
  103 + var contentSid: String!
  104 + var pageNum: NSInteger! = 0
  105 + var footerRefreshView: CNLiveFooterRefresh!
  106 + var resultBlock: CloseCommentListResultBlock!
  107 +
  108 + func requestDataSource() {
  109 + CNLiveShortVideoViewModel.requestCommentList(pid: self.videoId, page: self.pageNum) {[weak self] result, respStatue in
  110 + guard let self = self else { return }
  111 + if respStatue == .success {
  112 + if self.pageNum == 0 {
  113 + self.dataArray.removeAllObjects()
  114 + }
  115 + let listArray = (result as! ShortVideoHomeCommentModel).comments
  116 + self.dataArray.addObjects(from: listArray)
  117 + self.titleLabel.text = "\((result as! ShortVideoHomeCommentModel).total_hd ?? 0)条评论"
  118 + if self.tableView.mj_footer != nil {
  119 + self.tableView.mj_footer?.endRefreshing()
  120 + }
  121 + self.tableView.mj_header?.endRefreshing()
  122 + self.tableView.reloadData()
  123 + let hasNextPage = (result as! ShortVideoHomeCommentModel).hasNext!
  124 + if !hasNextPage {
  125 + self.tableView.mj_footer?.endRefreshingWithNoMoreData()
  126 + self.tableView.reloadData()
  127 + } else {
  128 + if self.tableView.mj_footer == nil {
  129 + self.tableView.mj_footer = footerRefreshView
  130 + }
  131 + }
  132 + } else {
  133 + if self.tableView.mj_footer != nil {
  134 + self.tableView.mj_footer?.endRefreshing()
  135 + }
  136 + self.tableView.mj_header?.endRefreshing()
  137 + if self.dataArray.count == 0 {
  138 + self.tableView.reloadEmptyDataSet()
  139 + }
  140 + }
  141 + }
  142 + }
  143 +
  144 + func addRefreshView() {
  145 + self.tableView.mj_header = CNLiveHeaderRefresh(refreshingBlock: { [weak self] in
  146 + guard let self = self else { return }
  147 + self.pageNum = 0
  148 + self.requestDataSource()
  149 + })
  150 + footerRefreshView = CNLiveFooterRefresh(refreshingBlock: { [weak self] in
  151 + guard let self = self else { return }
  152 + self.pageNum += 1
  153 + self.requestDataSource()
  154 + })
  155 + }
  156 +
  157 + init(frame: CGRect, pid: String, toSid: String) {
  158 + super.init(frame: frame)
  159 +
  160 + videoId = pid
  161 + contentSid = toSid
  162 + addRefreshView()
  163 + requestDataSource()
  164 + addSubview(grayMaskView)
  165 + grayMaskView.snp.makeConstraints { make in
  166 + make.edges.equalToSuperview()
  167 + }
  168 + grayMaskView.addSubview(contentView)
  169 + contentView.snp.makeConstraints { make in
  170 + make.top.equalTo(250)
  171 + make.right.left.bottom.equalToSuperview()
  172 + }
  173 + contentView.addSubview(emjButton)
  174 + emjButton.snp.makeConstraints { make in
  175 + make.right.equalToSuperview().offset(-10)
  176 + make.bottom.equalToSuperview().offset(-(10+get_system_tabbar_ui_offsetHeight()))
  177 + make.size.equalTo(40)
  178 + }
  179 + contentView.addSubview(sendButton)
  180 + sendButton.snp.makeConstraints { make in
  181 + make.left.equalToSuperview().offset(10)
  182 + make.right.equalTo(emjButton.snp.left).offset(-10)
  183 + make.bottom.equalToSuperview().offset(-(10+get_system_tabbar_ui_offsetHeight()))
  184 + make.height.equalTo(40)
  185 + }
  186 + contentView.addSubview(closeButton)
  187 + closeButton.snp.makeConstraints { make in
  188 + make.right.equalToSuperview().offset(-15)
  189 + make.top.equalToSuperview().offset(15)
  190 + make.size.equalTo(30)
  191 + }
  192 + contentView.addSubview(titleLabel)
  193 + titleLabel.snp.makeConstraints { make in
  194 + make.top.left.equalToSuperview().offset(20)
  195 + make.right.equalTo(closeButton.snp.left).offset(-10)
  196 + }
  197 + contentView.addSubview(lineLabel)
  198 + lineLabel.snp.makeConstraints { make in
  199 + make.top.equalTo(closeButton.snp.bottom).offset(15)
  200 + make.centerX.equalToSuperview()
  201 + make.left.equalToSuperview().offset(10)
  202 + make.right.equalToSuperview().offset(-10)
  203 + make.height.equalTo(1)
  204 + }
  205 + contentView.addSubview(tableView)
  206 + tableView.snp.makeConstraints { make in
  207 + make.left.right.equalToSuperview()
  208 + make.top.equalTo(lineLabel.snp.bottom).offset(10)
  209 + make.bottom.equalTo(sendButton.snp.top).offset(-5)
  210 + }
  211 + }
  212 +
  213 + required init?(coder: NSCoder) {
  214 + fatalError("init(coder:) has not been implemented")
  215 + }
  216 +
  217 + @objc func closeMethod() {
  218 + removeFromSuperview()
  219 + }
  220 +
  221 + @objc func sendCommentAction(button: UIButton) {
  222 +
  223 + CNLiveContentToolTextView.showCommentViewForCustom(withCommType: .comment, fromNick: "", firstRespFace: button == self.emjButton, successBlcok: {[weak self] commentString, toolbarView in
  224 + guard let self = self else { return }
  225 + print("评论内容\(commentString ?? "")")
  226 + CNLiveShortVideoViewModel.requestCommentWithSend(videoId: self.videoId, comment: commentString ?? "", isAuthor: UserInfoManager.shared.userInfo.uid == self.contentSid) { result, respStatue in
  227 + if respStatue == .success {
  228 + showMessage(message: result as! String)
  229 + self.tableView.mj_header?.beginRefreshing()
  230 + }
  231 + }
  232 + }, dissBlock: { toolbarView in
  233 +
  234 + })
  235 + }
  236 +
  237 + static public func showVideoCommentListView(pid: String,contentSid: String,result: @escaping CloseCommentListResultBlock) {
  238 +
  239 + let commentView = CNLiveShortVideoCommentListView.init(frame: CGRect.zero, pid: pid, toSid: contentSid)
  240 + commentView.resultBlock = result
  241 +
  242 + let delegate = UIApplication.shared.delegate as! AppDelegate
  243 + delegate.window?.addSubview(commentView)
  244 + commentView.snp.makeConstraints { make in
  245 + make.edges.equalToSuperview()
  246 + }
  247 + delegate.window?.layoutIfNeeded()
  248 + commentView.alpha = 0
  249 + UIView.animate(withDuration: 0.1) {
  250 + commentView.alpha = 1
  251 + } completion: { _ in}
  252 + }
  253 +}
  254 +
  255 +extension CNLiveShortVideoCommentListView {
  256 + func numberOfSections(in tableView: UITableView) -> Int {
  257 + return 1
  258 + }
  259 + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  260 + return dataArray.count
  261 + }
  262 + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  263 + guard let cell = tableView.dequeueReusableCell(withIdentifier: kShortVideoCommentListTableViewCellIdentifier) as? CNLiveShortVideoCommentListTableViewCell else {
  264 + return CNLiveShortVideoCommentListTableViewCell()
  265 + }
  266 + cell.setupWithDataSource(commentData: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).comment, replyData: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).replyData, tableView_h: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).tableView_h)
  267 + return cell
  268 + }
  269 + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  270 + let model: ShortVideoHomeCommentListModel = dataArray[indexPath.row] as! ShortVideoHomeCommentListModel
  271 + return model.cell_h
  272 + }
  273 + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  274 + let model: ShortVideoHomeCommentFListModel = ((dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).comment)
  275 + self.resultBlock(model)
  276 + }
  277 + func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? {
  278 + return UIImage(named: "short_video_default")
  279 + }
  280 +}
  281 +
  282 +class CNLiveShortVideoCommentListTableViewCell: UITableViewCell, UITableViewDelegate, UITableViewDataSource {
  283 +
  284 + lazy var iconView: UIImageView = {
  285 + let imageView = UIImageView.init()
  286 + imageView.image = UIImage(named: "short_video_default")
  287 + imageView.contentMode = .scaleAspectFill
  288 + imageView.layer.cornerRadius = 20
  289 + imageView.layer.masksToBounds = true
  290 + imageView.clipsToBounds = true
  291 + return imageView
  292 + }()
  293 +
  294 + lazy var titleLabel: UILabel = {
  295 + let titleLabel = UILabel.init()
  296 + titleLabel.textColor = .white
  297 + titleLabel.lineBreakMode = .byTruncatingTail
  298 + titleLabel.numberOfLines = 2
  299 + titleLabel.font = medium_adapt_font(pointSize: 12)
  300 + return titleLabel
  301 + }()
  302 +
  303 + lazy var commentLabel: YYLabel = {
  304 + let commentLabel = YYLabel()
  305 + commentLabel.textColor = .white
  306 + commentLabel.displaysAsynchronously = true
  307 + commentLabel.clearContentsBeforeAsynchronouslyDisplay = false
  308 + commentLabel.fadeOnAsynchronouslyDisplay = false
  309 + commentLabel.font = medium_adapt_font(pointSize: 16)
  310 + commentLabel.numberOfLines = 0
  311 + commentLabel.textAlignment = .left
  312 + commentLabel.textVerticalAlignment = .center
  313 + commentLabel.textContainerInset = UIEdgeInsets.zero
  314 + commentLabel.isUserInteractionEnabled = true
  315 + return commentLabel
  316 + }()
  317 +
  318 + lazy var timeLabel: UILabel = {
  319 + let timeLabel = UILabel.init()
  320 + timeLabel.textColor = .white
  321 + timeLabel.font = light_adapt_font(pointSize: 13)
  322 + return timeLabel
  323 + }()
  324 +
  325 + lazy var replyButton: UIButton = {
  326 + let replyButton = APButton()
  327 + replyButton.setTitleColor(.white, for: .normal)
  328 + replyButton.activityIndicator.color = .white
  329 + replyButton.backgroundColor = .clear
  330 + replyButton.setTitle("回复", for: .normal)
  331 + replyButton.titleLabel?.font = medium_adapt_font(pointSize: 13)
  332 + replyButton.addTarget(self, action: #selector(replyMethod), for: .touchUpInside)
  333 + return replyButton
  334 + }()
  335 +
  336 + lazy var likeButton: QMUIButton = {
  337 + let button = QMUIButton()
  338 + button.imagePosition = .left
  339 + button.spacingBetweenImageAndTitle = 2.5
  340 + button.setTitleColor(UIColor.white, for: .normal)
  341 + button.setTitle("0", for: .normal)
  342 + button.imageView?.contentMode = .scaleAspectFit
  343 + button.setImage(UIImage(named: "short_video_zan_nomal"), for: .normal)
  344 + button.setImage(UIImage(named: "short_video_zan_select"), for: .selected)
  345 + button.titleLabel?.font = regular_adapt_font(pointSize: 14)
  346 + button.addTarget(self, action: #selector(likeActionMethod), for: .touchUpInside)
  347 + return button
  348 + }()
  349 +
  350 + let kShortVideoReplyListTableViewCellIdentifier = "kShortVideoReplyListTableViewCellIdentifier"
  351 + lazy var tableView : UITableView = {
  352 + let tableView = UITableView(frame: .zero, style: .plain)
  353 + tableView.dataSource = self
  354 + tableView.delegate = self
  355 + tableView.estimatedSectionFooterHeight = 0
  356 + tableView.estimatedSectionHeaderHeight = 0
  357 + tableView.backgroundColor = HexColor("#010101")
  358 + tableView.tableFooterView = UIView.init()
  359 + tableView.separatorStyle = .none
  360 + tableView.scrollsToTop = false
  361 + tableView.register(CNLiveShortVideoCommentListTableViewCell.self, forCellReuseIdentifier: kShortVideoReplyListTableViewCellIdentifier)
  362 + return tableView
  363 + }()
  364 +
  365 + var commentModel: ShortVideoHomeCommentFListModel!
  366 + var replyModel: ShortVideoHomeCommentRListModel!
  367 + var replyItemModel: ShortVideoHomeCommentRListItemModel!
  368 +
  369 + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  370 + super.init(style: style, reuseIdentifier: reuseIdentifier)
  371 + contentView.backgroundColor = .clear
  372 + backgroundColor = .clear
  373 + selectionStyle = .none
  374 + let isReply = reuseIdentifier == kShortVideoReplyListTableViewCellIdentifier
  375 +
  376 + contentView.addSubview(iconView)
  377 + iconView.snp.makeConstraints { make in
  378 + make.top.equalToSuperview().offset(10)
  379 + make.left.equalToSuperview().offset(isReply ? 0 : 10)
  380 + make.size.equalTo(40)
  381 + }
  382 + contentView.addSubview(titleLabel)
  383 + titleLabel.snp.makeConstraints { make in
  384 + make.left.equalTo(iconView.snp.right).offset(10)
  385 + make.top.equalToSuperview().offset(10)
  386 + make.right.equalToSuperview().offset(-10)
  387 + make.height.equalTo(20)
  388 + }
  389 + contentView.addSubview(commentLabel)
  390 + commentLabel.snp.makeConstraints { make in
  391 + make.top.equalTo(titleLabel.snp.bottom).offset(10)
  392 + make.left.equalTo(titleLabel.snp.left)
  393 + make.right.equalToSuperview().offset(-10)
  394 + make.height.equalTo(20)
  395 + }
  396 + contentView.addSubview(likeButton)
  397 + likeButton.snp.makeConstraints { make in
  398 + if isReply {
  399 + make.right.equalToSuperview()
  400 + } else {
  401 + make.right.equalToSuperview().offset(-10)
  402 + }
  403 + make.height.equalTo(20)
  404 + make.width.equalTo(30)
  405 + make.top.equalTo(commentLabel.snp.bottom).offset(10)
  406 + }
  407 + contentView.addSubview(timeLabel)
  408 + timeLabel.snp.makeConstraints { make in
  409 + make.top.equalTo(commentLabel.snp.bottom).offset(10)
  410 + make.left.equalTo(titleLabel.snp.left)
  411 + make.height.equalTo(20)
  412 + }
  413 + contentView.addSubview(replyButton)
  414 + replyButton.snp.makeConstraints { make in
  415 + make.left.equalTo(timeLabel.snp.right).offset(10)
  416 + make.height.equalTo(20)
  417 + make.width.equalTo(40)
  418 + make.top.equalTo(commentLabel.snp.bottom).offset(10)
  419 + }
  420 + contentView.addSubview(tableView)
  421 + tableView.snp.makeConstraints { make in
  422 + make.left.equalToSuperview().offset(60)
  423 + make.right.equalToSuperview()
  424 + make.top.equalTo(timeLabel.snp.bottom).offset(10)
  425 + make.height.equalTo(0.01)
  426 + }
  427 + }
  428 +
  429 + func setupWithDataSource(commentData: ShortVideoHomeCommentFListModel, replyData: ShortVideoHomeCommentRListModel, tableView_h: CGFloat) {
  430 + replyModel = replyData
  431 + commentModel = commentData
  432 + iconView.kf.indicatorType = .activity
  433 + iconView.kf.setImage(with: URL(string: commentData.icon!), placeholder: UIImage(named: "short_video_default"))
  434 + titleLabel.text = commentData.nick
  435 + likeButton.isSelected = commentData.isPraised!
  436 + likeButton.setTitle(commentData.praise, for: .normal)
  437 + timeLabel.text = commentData.created_at
  438 + DispatchQueue.main.async {[weak self] in
  439 + guard let self = self else { return }
  440 + self.commentLabel.textLayout = commentData.textLayout
  441 + self.commentLabel.snp.remakeConstraints { make in
  442 + make.top.equalTo(self.titleLabel.snp.bottom).offset(10)
  443 + make.left.equalTo(self.iconView.snp.right).offset(10)
  444 + make.right.equalToSuperview().offset(-10)
  445 + make.height.equalTo(commentData.textLayout.textBoundingRect.size.height)
  446 + }
  447 + }
  448 + if replyData.replys.count > 0 {
  449 + tableView.reloadData()
  450 + tableView.snp.remakeConstraints { make in
  451 + make.left.equalToSuperview().offset(60)
  452 + make.right.equalToSuperview()
  453 + make.top.equalTo(timeLabel.snp.bottom).offset(10)
  454 + make.height.equalTo(tableView_h)
  455 + }
  456 + }
  457 + }
  458 +
  459 + func setupWithReplyModel( replyModel: ShortVideoHomeCommentRListItemModel) {
  460 + iconView.kf.indicatorType = .activity
  461 + iconView.kf.setImage(with: URL(string: replyModel.fromFace!), placeholder: UIImage(named: "short_video_default"))
  462 + titleLabel.text = replyModel.fromNick
  463 + likeButton.isSelected = replyModel.isPraised!
  464 + likeButton.setTitle("\(replyModel.praiseCount ?? 0)", for: .normal)
  465 + timeLabel.text = replyModel.created_at
  466 + DispatchQueue.main.async {[weak self] in
  467 + guard let self = self else { return }
  468 + self.commentLabel.textLayout = replyModel.textLayout
  469 + self.commentLabel.snp.remakeConstraints { make in
  470 + make.top.equalTo(self.titleLabel.snp.bottom).offset(10)
  471 + make.left.equalTo(self.iconView.snp.right).offset(10)
  472 + make.right.equalToSuperview().offset(-10)
  473 + make.height.equalTo(replyModel.textLayout.textBoundingRect.size.height)
  474 + }
  475 + }
  476 + }
  477 +
  478 + @objc func likeActionMethod() {
  479 +
  480 + }
  481 +
  482 + @objc func replyMethod() {
  483 + CNLiveContentToolTextView.showCommentViewForCustom(withCommType: .reply, fromNick: commentModel == nil ? replyItemModel.fromNick : commentModel.nick, firstRespFace: false, successBlcok: {[weak self] commentString, toolbarView in
  484 + guard let self = self else { return }
  485 + CNLiveShortVideoViewModel.requestCommentWithReply(commentId: self.commentModel.commentId!, comment: commentString ?? "", toSid: commentModel.uid!, fromSid: UserInfoManager.shared.userInfo.uid, level: "1") { result, respStatue in
  486 + if respStatue == .success {
  487 + showMessage(message: result as! String)
  488 + var replyItemModel = ShortVideoHomeCommentRListItemModel()
  489 +
  490 + }
  491 + }
  492 + }, dissBlock: { toolbarView in
  493 +
  494 + })
  495 + }
  496 +
  497 + required init?(coder: NSCoder) {
  498 + fatalError("init(coder:) has not been implemented")
  499 + }
  500 +}
9 501  
10   -class CNLiveShortVideoCommentListView: UIView {
  502 +extension CNLiveShortVideoCommentListTableViewCell {
11 503  
  504 + func numberOfSections(in tableView: UITableView) -> Int {
  505 + return 1
  506 + }
  507 + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  508 + return replyModel == nil ? 0 : replyModel.replys.count
  509 + }
  510 + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  511 + guard let cell = tableView.dequeueReusableCell(withIdentifier: kShortVideoReplyListTableViewCellIdentifier) as? CNLiveShortVideoCommentListTableViewCell else {
  512 + return CNLiveShortVideoCommentListTableViewCell()
  513 + }
  514 + cell.setupWithReplyModel(replyModel: replyModel.replys[indexPath.row] )
  515 + return cell
  516 + }
  517 + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  518 + let model: ShortVideoHomeCommentRListItemModel = replyModel.replys[indexPath.row]
  519 + return model.cellH
  520 + }
12 521 }
... ...
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoContentListView.swift
... ... @@ -37,7 +37,6 @@ class CNLiveShortVideoContentListView: UIView, UITableViewDelegate, UITableViewD
37 37 label.textAlignment = .left
38 38 label.numberOfLines = 1
39 39 label.lineBreakMode = .byTruncatingTail
40   - label.text = "爱得供养"
41 40 return label
42 41 }()
43 42  
... ...
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoListTableViewCell.swift
... ... @@ -28,6 +28,7 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
28 28 label.font = semibold_adapt_font(pointSize: 19)
29 29 label.textAlignment = .left
30 30 label.numberOfLines = 1
  31 + label.isHidden = true
31 32 label.lineBreakMode = .byTruncatingTail
32 33 return label
33 34 }()
... ... @@ -38,6 +39,7 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
38 39 label.font = regular_adapt_font(pointSize: 15)
39 40 label.textAlignment = .left
40 41 label.numberOfLines = 3
  42 + label.isHidden = true
41 43 label.lineBreakMode = .byTruncatingTail
42 44 return label
43 45 }()
... ... @@ -74,6 +76,7 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
74 76 button.layer.masksToBounds = true
75 77 button.layer.borderColor = UIColor.white.cgColor
76 78 button.layer.borderWidth = 1
  79 + button.isHidden = true
77 80 button.backgroundColor = .clear
78 81 button.addTarget(self, action: #selector(iconMothod), for: .touchUpInside)
79 82 return button
... ... @@ -84,6 +87,7 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
84 87 button.setImage(UIImage(named: "short_video_guan_zhu"), for: .normal)
85 88 button.layer.cornerRadius = 10
86 89 button.layer.masksToBounds = true
  90 + button.isHidden = true
87 91 button.backgroundColor = .clear
88 92 button.activityIndicator.color = .white
89 93 button.addTarget(self, action: #selector(faviMothod), for: .touchUpInside)
... ... @@ -102,7 +106,8 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
102 106 let button = ImageButton(type: .custom)
103 107 button.setImage(UIImage(named: "short_video_zan_nomal"), for: .normal)
104 108 button.setImage(UIImage(named: "short_video_zan_select"), for: .selected)
105   - button.setTitle("22.8w", for: .normal)
  109 + button.setTitle("0", for: .normal)
  110 + button.isHidden = true
106 111 button.setTitleColor(.white, for: .normal)
107 112 button.titleLabel?.font = light_adapt_font(pointSize: 15)
108 113 button.addTarget(self, action: #selector(likeMothod), for: .touchUpInside)
... ... @@ -112,7 +117,8 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
112 117 lazy var commentBtn: ImageButton = {
113 118 let button = ImageButton(type: .custom)
114 119 button.setImage(UIImage(named: "short_video_comment"), for: .normal)
115   - button.setTitle("232.8w", for: .normal)
  120 + button.setTitle("0", for: .normal)
  121 + button.isHidden = true
116 122 button.setTitleColor(.white, for: .normal)
117 123 button.titleLabel?.font = light_adapt_font(pointSize: 15)
118 124 button.addTarget(self, action: #selector(commentMothod), for: .touchUpInside)
... ... @@ -122,7 +128,8 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
122 128 lazy var shareBtn: ImageButton = {
123 129 let button = ImageButton(type: .custom)
124 130 button.setImage(UIImage(named: "short_video_share"), for: .normal)
125   - button.setTitle("0.8w", for: .normal)
  131 + button.setTitle("0", for: .normal)
  132 + button.isHidden = true
126 133 button.setTitleColor(.white, for: .normal)
127 134 button.titleLabel?.font = light_adapt_font(pointSize: 15)
128 135 button.addTarget(self, action: #selector(shareMothod), for: .touchUpInside)
... ... @@ -181,6 +188,8 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
181 188 descLabel.text = model.title
182 189 listBtn.setTitle(model.albumMsgModel?.albumName, for: .normal)
183 190  
  191 + hiddenView(isHidden: homeModel.product!.albumProductType != "0")
  192 +
184 193 let imageV: UIImageView = payView.viewWithTag(1000) as! UIImageView
185 194 imageV.kf.indicatorType = .activity
186 195 imageV.kf.setImage(with: URL(string: model.poster))
... ... @@ -188,6 +197,37 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
188 197 titleL.text = model.title
189 198 let timeL: UILabel = payView.viewWithTag(1002) as! UILabel
190 199 timeL.text = model.duration
  200 + let payButton: APButton = payView.viewWithTag(1003) as! APButton
  201 + if model.product?.albumProductType != "0" {
  202 + payButton.setTitle("\(model.product!.point)积分解锁全集", for: .normal)
  203 + }
  204 +// if model.product?.albumProductType == "2" {
  205 +// payButton.setTitle("\(Double(model.product!.iosOriginalRmb)!/100.0)元解锁全集", for: .normal)
  206 +// }
  207 + }
  208 +
  209 + open func hiddenView(isHidden: Bool) {
  210 + if (isHidden) {
  211 + self.commentBtn.isHidden = true
  212 + self.faviBtn.isHidden = true
  213 + self.shareBtn.isHidden = true
  214 + self.likeBtn.isHidden = true
  215 + self.iconBtn.isHidden = true
  216 + self.titleLabel.isHidden = true
  217 + self.descLabel.isHidden = true
  218 + self.tipsLabel.isHidden = false
  219 + self.payView.isHidden = false
  220 + } else {
  221 + self.commentBtn.isHidden = false
  222 + self.faviBtn.isHidden = false
  223 + self.shareBtn.isHidden = false
  224 + self.likeBtn.isHidden = false
  225 + self.iconBtn.isHidden = false
  226 + self.titleLabel.isHidden = false
  227 + self.descLabel.isHidden = false
  228 + self.tipsLabel.isHidden = true
  229 + self.payView.isHidden = true
  230 + }
191 231 }
192 232  
193 233 override func layoutSubviews() {
... ... @@ -262,29 +302,7 @@ class CNLiveShortVideoListTableViewCell: UITableViewCell {
262 302 }
263 303 }
264 304  
265   - open func hiddenView(isHidden: Bool) {
266   - if (isHidden) {
267   - self.commentBtn.isHidden = true
268   - self.faviBtn.isHidden = true
269   - self.shareBtn.isHidden = true
270   - self.likeBtn.isHidden = true
271   - self.iconBtn.isHidden = true
272   - self.titleLabel.isHidden = true
273   - self.descLabel.isHidden = true
274   - self.tipsLabel.isHidden = false
275   - self.payView.isHidden = false
276   - } else {
277   - self.commentBtn.isHidden = false
278   - self.faviBtn.isHidden = false
279   - self.shareBtn.isHidden = false
280   - self.likeBtn.isHidden = false
281   - self.iconBtn.isHidden = false
282   - self.titleLabel.isHidden = false
283   - self.descLabel.isHidden = false
284   - self.tipsLabel.isHidden = true
285   - self.payView.isHidden = true
286   - }
287   - }
  305 +
288 306  
289 307 @objc func likeMothod(button: UIButton) {
290 308 self.delegate.likeActionMethod(viewcell: self, button: button)
... ... @@ -380,12 +398,11 @@ extension CNLiveShortVideoListTableViewCell {
380 398 }
381 399  
382 400 let payButton = APButton()
383   - payButton.setTitle("840积分解锁全42集", for: .normal)
384 401 payButton.setTitleColor(.white, for: .normal)
385 402 payButton.layer.cornerRadius = 20
386 403 payButton.activityIndicator.color = .white
387 404 payButton.layer.masksToBounds = true
388   - payButton.viewWithTag(1003)
  405 + payButton.tag = 1003
389 406 payButton.backgroundColor = HexColor("#67C5FF")
390 407 payButton.titleLabel?.font = medium_adapt_font(pointSize: 15)
391 408 payButton.addTarget(self, action: #selector(payMethod), for: .touchUpInside)
... ...
metaCode/Classes/Main/VideoPage/ViewModel/CNLiveShortVideoViewModel.swift
... ... @@ -7,7 +7,7 @@
7 7  
8 8 import Foundation
9 9 import CNLiveRequestBastKit
10   -
  10 +import QMUIKit
11 11 typealias resultShortVideoBlock = (_ result: Any,_ respStatue :CNLiveMineResponseType) -> Void
12 12 class CNLiveShortVideoViewModel: NSObject {
13 13  
... ... @@ -46,6 +46,9 @@ class CNLiveShortVideoViewModel: NSObject {
46 46 for item in array {
47 47 let listModel = dictionaryToModel(item as! [String : Any], CNLiveAlbumListModel.self,"") as! CNLiveAlbumListModel
48 48 listModel.albumMsgModel = result as? CNLiveAlbumMsgModel
  49 + /////测试使用 临时的
  50 + listModel.product?.albumProductType = "0"
  51 +
49 52 tempArray.add(listModel)
50 53 tempUrlArray.add(listModel.videoUrl as String)
51 54 }
... ... @@ -132,17 +135,17 @@ class CNLiveShortVideoViewModel: NSObject {
132 135 static func requestRankWithLike(contentId: String, contentTitle: String, contentSid: String, support: Bool,tagName: String,reultShortVideoBlock: @escaping resultShortVideoBlock) {
133 136 let param = NSMutableDictionary()
134 137 param.setValue(contentId, forKey: "contentId")
135   - param.setValue(APPId_wjj, forKey: "appId")
  138 + param.setValue(APPId, forKey: "appId")
136 139 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
137   - param.setValue(contentId, forKey: "contentTitle")
  140 + param.setValue(contentTitle, forKey: "contentTitle")
138 141 param.setValue(contentSid, forKey: "contentSid")
139 142 param.setValue(support ? "1":"0", forKey: "support")
140 143 param.setValue("false", forKey: "isRank")
141 144 param.setValue("1", forKey: "isUgc")
142 145 param.setValue(tagName, forKey: "contentTag")
143 146 let custom_param = NSMutableDictionary()
144   - custom_param.setValue(APPId_wjj, forKey: "appId")
145   - custom_param.setValue(APPKey_wjj, forKey: "appKey")
  147 + custom_param.setValue(APPId, forKey: "appId")
  148 + custom_param.setValue(APPKey, forKey: "appKey")
146 149 CNLiveNetworking.setAllowRequestDefaultArgument(true)
147 150 CNLiveNetworking.setupShowDataResult(false)
148 151 CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
... ... @@ -179,16 +182,19 @@ class CNLiveShortVideoViewModel: NSObject {
179 182 static func requestCommentList(pid: String,page: NSInteger,reultShortVideoBlock: @escaping resultShortVideoBlock) {
180 183 let param = NSMutableDictionary()
181 184 param.setValue(pid, forKey: "topicId")
  185 + param.setValue("i", forKey: "plat")
  186 + param.setValue(APPId, forKey: "appId")
182 187 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
183 188 param.setValue("\(page)", forKey: "seqId")
184 189 param.setValue("10", forKey: "count")
185 190 let custom_param = NSMutableDictionary()
186   - custom_param.setValue(APPId_wjj, forKey: "appId")
187   - custom_param.setValue(APPKey_wjj, forKey: "appKey")
  191 + custom_param.setValue(APPId, forKey: "appId")
  192 + custom_param.setValue(APPKey, forKey: "appKey")
188 193 CNLiveNetworking.setAllowRequestDefaultArgument(true)
189 194 CNLiveNetworking.setupShowDataResult(false)
  195 + CNLiveNetworking.setupShowResult(true)
190 196 CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
191   - CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseCMSClassUrl+"/ugcApi/ugcVideoList", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
  197 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/loadUgcComments", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
192 198 hiddenLoading()
193 199 if (error == nil) {
194 200 let resp = result as! NSDictionary
... ... @@ -225,17 +231,20 @@ class CNLiveShortVideoViewModel: NSObject {
225 231 static func requestCommentWithSend(videoId: String, comment: String, isAuthor: Bool,reultShortVideoBlock: @escaping resultShortVideoBlock) {
226 232 let param = NSMutableDictionary()
227 233 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")
  234 + param.setValue(APPId, forKey: "appId")
  235 + param.setValue("i", forKey: "plat")
  236 + param.setValue(comment.qmui_trim, forKey: "comment")
  237 + param.setValue(isAuthor ? "1" : "0", forKey: "isAuthor")
231 238 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
232 239 let custom_param = NSMutableDictionary()
233   - custom_param.setValue(APPId_wjj, forKey: "appId")
234   - custom_param.setValue(APPKey_wjj, forKey: "appKey")
  240 + custom_param.setValue(APPId, forKey: "appId")
  241 + custom_param.setValue(APPKey, forKey: "appKey")
235 242 CNLiveNetworking.setAllowRequestDefaultArgument(true)
236 243 CNLiveNetworking.setupShowDataResult(false)
  244 + CNLiveNetworking.setupDSRequest(false)
  245 + CNLiveNetworking.setupShowResult(true)
237 246 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
  247 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/insertComment", param: param as? [AnyHashable : Any], cacheType: .networkOnly) { task, result, error in
239 248 hiddenLoading()
240 249 if (error == nil) {
241 250 let resp = result as! NSDictionary
... ... @@ -270,15 +279,15 @@ class CNLiveShortVideoViewModel: NSObject {
270 279 static func requestCommentWithReply(commentId: String, comment: String, toSid: String, fromSid: String, level: String,reultShortVideoBlock: @escaping resultShortVideoBlock) {
271 280 let param = NSMutableDictionary()
272 281 param.setValue(commentId, forKey: "commentId")
273   - param.setValue(APPId_wjj, forKey: "appId")
  282 + param.setValue(APPId, forKey: "appId")
274 283 param.setValue(comment, forKey: "comment")
275 284 param.setValue(toSid, forKey: "toSid")
276 285 param.setValue(fromSid, forKey: "fromSid")
277 286 param.setValue(level, forKey: "level")
278 287 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
279 288 let custom_param = NSMutableDictionary()
280   - custom_param.setValue(APPId_wjj, forKey: "appId")
281   - custom_param.setValue(APPKey_wjj, forKey: "appKey")
  289 + custom_param.setValue(APPId, forKey: "appId")
  290 + custom_param.setValue(APPKey, forKey: "appKey")
282 291 CNLiveNetworking.setAllowRequestDefaultArgument(true)
283 292 CNLiveNetworking.setupShowDataResult(false)
284 293 CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
... ... @@ -314,15 +323,15 @@ class CNLiveShortVideoViewModel: NSObject {
314 323 static func requestcommentWithReplyList(commentId: String,page: NSInteger,reultShortVideoBlock: @escaping resultShortVideoBlock) {
315 324 let param = NSMutableDictionary()
316 325 param.setValue(commentId, forKey: "commentId")
317   - param.setValue("\(page)", forKey: "seqId")
  326 + param.setValue("\(page)", forKey: "seqId")//从 0 开始
318 327 param.setValue("10", forKey: "count")
319 328 let custom_param = NSMutableDictionary()
320   - custom_param.setValue(APPId_wjj, forKey: "appId")
321   - custom_param.setValue(APPKey_wjj, forKey: "appKey")
  329 + custom_param.setValue(APPId, forKey: "appId")
  330 + custom_param.setValue(APPKey, forKey: "appKey")
322 331 CNLiveNetworking.setAllowRequestDefaultArgument(true)
323 332 CNLiveNetworking.setupShowDataResult(false)
324 333 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
  334 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseTokenUrl+"/commentServices/commentForUgc/loadReplys", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
326 335 hiddenLoading()
327 336 if (error == nil) {
328 337 let resp = result as! NSDictionary
... ... @@ -365,12 +374,12 @@ class CNLiveShortVideoViewModel: NSObject {
365 374 static func requestCommentDelete(videoId: String, commentId: String, reultShortVideoBlock: @escaping resultShortVideoBlock) {
366 375 let param = NSMutableDictionary()
367 376 param.setValue(commentId, forKey: "commentId")
368   - param.setValue(APPId_wjj, forKey: "appId")
  377 + param.setValue(APPId, forKey: "appId")
369 378 param.setValue(videoId, forKey: "topicId")
370 379 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
371 380 let custom_param = NSMutableDictionary()
372   - custom_param.setValue(APPId_wjj, forKey: "appId")
373   - custom_param.setValue(APPKey_wjj, forKey: "appKey")
  381 + custom_param.setValue(APPId, forKey: "appId")
  382 + custom_param.setValue(APPKey, forKey: "appKey")
374 383 CNLiveNetworking.setAllowRequestDefaultArgument(true)
375 384 CNLiveNetworking.setupShowDataResult(false)
376 385 CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
... ... @@ -405,12 +414,12 @@ class CNLiveShortVideoViewModel: NSObject {
405 414 static func requestCommentReplyDelete(replyId: String, commentId: String, reultShortVideoBlock: @escaping resultShortVideoBlock) {
406 415 let param = NSMutableDictionary()
407 416 param.setValue(commentId, forKey: "commentId")
408   - param.setValue(APPId_wjj, forKey: "appId")
  417 + param.setValue(APPId, forKey: "appId")
409 418 param.setValue(replyId, forKey: "replyId")
410 419 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
411 420 let custom_param = NSMutableDictionary()
412   - custom_param.setValue(APPId_wjj, forKey: "appId")
413   - custom_param.setValue(APPKey_wjj, forKey: "appKey")
  421 + custom_param.setValue(APPId, forKey: "appId")
  422 + custom_param.setValue(APPKey, forKey: "appKey")
414 423 CNLiveNetworking.setAllowRequestDefaultArgument(true)
415 424 CNLiveNetworking.setupShowDataResult(false)
416 425 CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
... ...
metaCode/Supporting Files/Assets.xcassets/Video/short_video_commet_emoji.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "c_topic_chat_emoji@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "c_topic_chat_emoji@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/Video/short_video_commet_emoji.imageset/c_topic_chat_emoji@2x.png 0 → 100644

2.58 KB

metaCode/Supporting Files/Assets.xcassets/Video/short_video_commet_emoji.imageset/c_topic_chat_emoji@3x.png 0 → 100644

6.47 KB