|
@@ -44,14 +44,15 @@ class MVMineProductController: PQBaseViewController {
|
|
|
}()
|
|
|
|
|
|
lazy var emptyView: MVProductEmptyView = {
|
|
|
- let emptyView = MVProductEmptyView.init(frame: CGRect.init(x: 0, y: headH, width: collectionView.frame.width, height: collectionView.frame.height - headH))
|
|
|
- emptyView.btnClickHandle = {[weak self] sender in
|
|
|
+ let emptyView = MVProductEmptyView(frame: CGRect(x: 0, y: headH, width: collectionView.frame.width, height: collectionView.frame.height - headH))
|
|
|
+ emptyView.btnClickHandle = { [weak self] _ in
|
|
|
let vc = PQStuckPointMaterialController()
|
|
|
self?.navigationController?.pushViewController(vc, animated: true)
|
|
|
}
|
|
|
emptyView.isHidden = true
|
|
|
return emptyView
|
|
|
}()
|
|
|
+
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
view.addSubview(collectionView)
|
|
@@ -60,10 +61,19 @@ class MVMineProductController: PQBaseViewController {
|
|
|
leftBackButton()
|
|
|
loadRequestData()
|
|
|
setTitle(title: BFLoginUserInfo.shared.nickName, color: UIColor(white: 0, alpha: 0))
|
|
|
- MVMineViewModel.userInfoData { [weak self] count, _ in
|
|
|
+ MVMineViewModel.userInfoData { [weak self] count, avatarUrl, nickName, msg in
|
|
|
if count != nil {
|
|
|
BFLoginUserInfo.shared.videos = "\(count ?? 0)"
|
|
|
- self?.headInfoView.updateProducts()
|
|
|
+ }
|
|
|
+ if avatarUrl != nil, (avatarUrl?.count ?? 0) > 0 {
|
|
|
+ BFLoginUserInfo.shared.avatarUrl = avatarUrl ?? ""
|
|
|
+ }
|
|
|
+ if nickName != nil, (nickName?.count ?? 0) > 0 {
|
|
|
+ BFLoginUserInfo.shared.nickName = nickName ?? ""
|
|
|
+ }
|
|
|
+ if msg == nil {
|
|
|
+ saveUserDefaults(key: cUserInfoStorageKey, value: BFLoginUserInfo.shared.toString())
|
|
|
+ self?.headInfoView.addData()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -118,7 +128,7 @@ extension MVMineProductController: UICollectionViewDelegate, UICollectionViewDat
|
|
|
let cell = MVMineProductCell.productCell(collectionView: collectionView, indexPath: indexPath)
|
|
|
cell.videoData = itemData
|
|
|
cell.btnClickHandle = { [weak self] sender, videoData in
|
|
|
- self?.btnClickHandle(sender: sender, videoData: videoData)
|
|
|
+ self?.btnClickHandle(sender: sender, videoData: videoData, indexPath: indexPath)
|
|
|
}
|
|
|
return cell
|
|
|
}
|
|
@@ -156,33 +166,63 @@ extension MVMineProductController: UICollectionViewDelegate, UICollectionViewDat
|
|
|
/// - 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()
|
|
|
- cShowHUB(superView: nil, msg: "删除成功")
|
|
|
- if (self?.itemsList.count ?? 0) <= 0 {
|
|
|
- self?.loadRequestData()
|
|
|
+ func btnClickHandle(sender: UIButton, videoData: PQVideoListModel?, indexPath: IndexPath) {
|
|
|
+ switch sender.tag {
|
|
|
+ case 1:
|
|
|
+ let seleView = PQSelectedOprationView.showSelectedOprationView(itemList: ["删除视频"]) { sender in
|
|
|
+ if sender.tag == 1 {
|
|
|
+ if !isNetConnected() {
|
|
|
+ cShowHUB(superView: nil, msg: "没有网络连接")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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()
|
|
|
+ cShowHUB(superView: nil, msg: "删除成功")
|
|
|
+ if (self?.itemsList.count ?? 0) <= 0 {
|
|
|
+ self?.loadRequestData()
|
|
|
+ }
|
|
|
+ var videos: Int = (Int(BFLoginUserInfo.shared.videos) ?? 0) - 1
|
|
|
+ if videos < 0 {
|
|
|
+ videos = 0
|
|
|
+ }
|
|
|
+ BFLoginUserInfo.shared.videos = "\(videos)"
|
|
|
+ self?.headInfoView.updateProducts()
|
|
|
+ } else {
|
|
|
+ cShowHUB(superView: nil, msg: "删除失败")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ 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")
|
|
|
+ case 2:
|
|
|
+ PQBaseViewModel.videoDetailInfo(videoId: videoData?.uniqueId ?? "") { [weak self] videoList, _, msg in
|
|
|
+ if (videoList?.count ?? 0) > 0, msg == nil, !(videoList?.first?.first?.transcodeStatus == 2 || videoList?.first?.first?.auditStatus == 1 || videoList?.first?.first?.transcodeStatus == 1) {
|
|
|
+ let tempVideoData = videoList?.first?.first
|
|
|
+ videoData?.transcodeStatus = videoList?.first?.first?.transcodeStatus ?? 0
|
|
|
+ videoData?.auditStatus = videoList?.first?.first?.auditStatus ?? 0
|
|
|
+ videoData?.transcodeStatus = videoList?.first?.first?.transcodeStatus ?? 0
|
|
|
+ self?.collectionView.reloadData()
|
|
|
+ self?.collectionView(self!.collectionView, didSelectItemAt: indexPath)
|
|
|
+ } else {
|
|
|
+ cShowHUB(superView: nil, msg: "请稍后再刷新")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break
|
|
|
}
|
|
|
- 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")
|
|
|
}
|
|
|
|
|
|
@objc func btnClick(sender _: UIButton) {}
|