|
@@ -11,19 +11,27 @@ import UIKit
|
|
|
class MVMineProductController: PQBaseViewController {
|
|
|
var itemsList: [PQVideoListModel] = Array<PQVideoListModel>.init()
|
|
|
var pageNum: Int = 1
|
|
|
+ let margin: CGFloat = 14
|
|
|
+ let headH: CGFloat = cDefaultMargin * 9
|
|
|
+
|
|
|
+ lazy var headInfoView: MVMineHeadInfoView = {
|
|
|
+ let headInfoView = MVMineHeadInfoView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: headH), margin: 0)
|
|
|
+ return headInfoView
|
|
|
+ }()
|
|
|
+
|
|
|
lazy var flowLayout: PQCollectionViewFlowlayout = {
|
|
|
let flowLayout = PQCollectionViewFlowlayout()
|
|
|
flowLayout.columnCount = 2
|
|
|
flowLayout.sectionInset = .zero
|
|
|
- flowLayout.minimumLineSpacing = cDefaultMargin
|
|
|
- flowLayout.minimumInteritemSpacing = cDefaultMargin
|
|
|
- flowLayout.headerH = 0
|
|
|
+ flowLayout.minimumLineSpacing = cDefaultMargin / 2
|
|
|
+ flowLayout.minimumInteritemSpacing = cDefaultMargin / 2
|
|
|
+ flowLayout.headerH = headH
|
|
|
return flowLayout
|
|
|
}()
|
|
|
|
|
|
lazy var collectionView: UICollectionView = {
|
|
|
let width = (cScreenWidth - 30) / 2
|
|
|
- let proCollectView = UICollectionView(frame: CGRect(x: cDefaultMargin, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth - cDefaultMargin * 2, height: view.frame.height - cDevice_iPhoneNavBarAndStatusBarHei - cSafeAreaHeight), collectionViewLayout: flowLayout)
|
|
|
+ let proCollectView = UICollectionView(frame: CGRect(x: margin, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth - margin * 2, height: view.frame.height - cDevice_iPhoneNavBarAndStatusBarHei - cSafeAreaHeight), collectionViewLayout: flowLayout)
|
|
|
proCollectView.register(MVMineProductCell.self, forCellWithReuseIdentifier: String(describing: MVMineProductCell.self))
|
|
|
proCollectView.showsVerticalScrollIndicator = false
|
|
|
proCollectView.delegate = self
|
|
@@ -38,8 +46,10 @@ class MVMineProductController: PQBaseViewController {
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
view.addSubview(collectionView)
|
|
|
+ collectionView.addSubview(headInfoView)
|
|
|
leftBackButton()
|
|
|
loadRequestData()
|
|
|
+ setTitle(title: BFLoginUserInfo.shared.nickName, color: UIColor(white: 0, alpha: 0))
|
|
|
}
|
|
|
|
|
|
/// 请求网络数据
|
|
@@ -78,11 +88,67 @@ extension MVMineProductController: UICollectionViewDelegate, UICollectionViewDat
|
|
|
let itemData = itemsList[indexPath.item]
|
|
|
let cell = MVMineProductCell.productCell(collectionView: collectionView, indexPath: indexPath)
|
|
|
cell.videoData = itemData
|
|
|
- cell.btnClickHandle = { [weak self] _, _ in
|
|
|
-// self?.btnClickHandle(sender: sender, videoData: videoData)
|
|
|
+ cell.btnClickHandle = { [weak self] sender, videoData in
|
|
|
+ self?.btnClickHandle(sender: sender, videoData: videoData)
|
|
|
}
|
|
|
return cell
|
|
|
}
|
|
|
|
|
|
- func collectionView(_: UICollectionView, didSelectItemAt _: IndexPath) {}
|
|
|
+ private func collectionView(collectionView _: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
+ if itemsList[indexPath.item].auditStatus != 5 || itemsList[indexPath.item].transcodeStatus != 3 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let playVC = MVPlayViewController()
|
|
|
+ playVC.itemsList = itemsList
|
|
|
+ playVC.currentIndex = indexPath
|
|
|
+ playVC.pageNum = pageNum
|
|
|
+ navigationController?.pushViewController(playVC, animated: true)
|
|
|
+ }
|
|
|
+
|
|
|
+ func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
|
|
+ BFLog(message: "scrollView.contentOffset.y = \(scrollView.contentOffset.y)")
|
|
|
+ if scrollView.contentOffset.y <= 0 {
|
|
|
+ navTitleLabel?.textColor = UIColor(white: 0, alpha: 0)
|
|
|
+ } else if scrollView.contentOffset.y >= headH {
|
|
|
+ navTitleLabel?.textColor = UIColor(white: 0, alpha: 1)
|
|
|
+ } else {
|
|
|
+ var alpha: CGFloat = (scrollView.contentOffset.y / headH)
|
|
|
+ if alpha < 0 {
|
|
|
+ alpha = 0
|
|
|
+ }
|
|
|
+ if alpha > 1 {
|
|
|
+ alpha = 1
|
|
|
+ }
|
|
|
+ navTitleLabel?.textColor = UIColor(white: 0, alpha: alpha)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 处理按钮点击事件
|
|
|
+ /// - Parameters:
|
|
|
+ /// - sender: <#sender description#>
|
|
|
+ /// - videoData: <#videoData description#>
|
|
|
+ func btnClickHandle(sender _: UIButton, videoData: PQVideoListModel?) {
|
|
|
+ let seleView = PQSelectedOprationView.showSelectedOprationView(itemList: ["删除视频"]) { sender in
|
|
|
+ if sender.tag == 1 {
|
|
|
+ PQBaseViewModel.deleteVideo(videoId: Int(videoData?.uniqueId ?? "0") ?? 0) { [weak self] isSuccess, videoId, _ in
|
|
|
+ if isSuccess {
|
|
|
+ self?.itemsList.removeAll(where: { tempVideo in
|
|
|
+ tempVideo.uniqueId == "\(videoId)"
|
|
|
+ })
|
|
|
+ self?.flowLayout.findList = self?.itemsList as! [PQVideoListModel]
|
|
|
+ self?.collectionView.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ seleView.contentView.backgroundColor = UIColor.hexColor(hexadecimal: "#F2F2F2")
|
|
|
+ seleView.cancelBtn.backgroundColor = UIColor.white
|
|
|
+ seleView.cancelBtn.setTitleColor(UIColor.black, for: .normal)
|
|
|
+ seleView.cancelBtn.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
|
|
|
+ let firstBtn: UIButton? = seleView.contentView.subviews[1] as? UIButton
|
|
|
+ firstBtn?.backgroundColor = UIColor.white
|
|
|
+ firstBtn?.setTitleColor(UIColor.hexColor(hexadecimal: "#FF0000"), for: .normal)
|
|
|
+ firstBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
|
|
|
+ seleView.contentView.subviews[2].backgroundColor = UIColor.hexColor(hexadecimal: "#F2F2F2")
|
|
|
+ }
|
|
|
}
|