|
@@ -7,7 +7,7 @@
|
|
|
|
|
|
import BFFramework
|
|
import BFFramework
|
|
class MVHomeController: MVBaseController {
|
|
class MVHomeController: MVBaseController {
|
|
- //视频播放列表
|
|
|
|
|
|
+ // 视频播放列表
|
|
private var viewListView: MVBanner = {
|
|
private var viewListView: MVBanner = {
|
|
let videoListView = MVBanner(frame: .zero, margin: 30, lineSpacing: 0, minScale: MVBanner.Scale(scale: 1))
|
|
let videoListView = MVBanner(frame: .zero, margin: 30, lineSpacing: 0, minScale: MVBanner.Scale(scale: 1))
|
|
videoListView.backgroundColor = UIColor.white
|
|
videoListView.backgroundColor = UIColor.white
|
|
@@ -53,7 +53,7 @@ class MVHomeController: MVBaseController {
|
|
// 标签分类
|
|
// 标签分类
|
|
lazy var categoryCollectionView: UICollectionView = {
|
|
lazy var categoryCollectionView: UICollectionView = {
|
|
let flowLayout = UICollectionViewFlowLayout()
|
|
let flowLayout = UICollectionViewFlowLayout()
|
|
- flowLayout.sectionInset = UIEdgeInsets.init(top: 0, left: 11, bottom: 0, right: 11)
|
|
|
|
|
|
+ flowLayout.sectionInset = UIEdgeInsets(top: 0, left: 11, bottom: 0, right: 11)
|
|
flowLayout.minimumLineSpacing = 0
|
|
flowLayout.minimumLineSpacing = 0
|
|
flowLayout.minimumInteritemSpacing = 10
|
|
flowLayout.minimumInteritemSpacing = 10
|
|
flowLayout.scrollDirection = .horizontal
|
|
flowLayout.scrollDirection = .horizontal
|
|
@@ -77,26 +77,21 @@ class MVHomeController: MVBaseController {
|
|
var mVideos: Array = Array<MVHotVideoModel>.init()
|
|
var mVideos: Array = Array<MVHotVideoModel>.init()
|
|
|
|
|
|
var mAllVideos: Array = Array<PQVideoListModel>.init()
|
|
var mAllVideos: Array = Array<PQVideoListModel>.init()
|
|
-
|
|
|
|
var lastBnnerSelectIndex: IndexPath = IndexPath.init(row: 0, section: 0)
|
|
var lastBnnerSelectIndex: IndexPath = IndexPath.init(row: 0, section: 0)
|
|
-
|
|
|
|
//是否点击的再创作
|
|
//是否点击的再创作
|
|
var isCreateVideo:Bool = false
|
|
var isCreateVideo:Bool = false
|
|
-
|
|
|
|
deinit {
|
|
deinit {
|
|
PQNotification.removeObserver(self)
|
|
PQNotification.removeObserver(self)
|
|
}
|
|
}
|
|
- //登录成功后自动跳转到系统相册
|
|
|
|
- @objc func loginSuccesss() {
|
|
|
|
|
|
|
|
- if(isCreateVideo){
|
|
|
|
|
|
+ // 登录成功后自动跳转到系统相册
|
|
|
|
+ @objc func loginSuccesss() {
|
|
|
|
+ if isCreateVideo {
|
|
isCreateVideo = false
|
|
isCreateVideo = false
|
|
createVideo(indexPath: lastBnnerSelectIndex)
|
|
createVideo(indexPath: lastBnnerSelectIndex)
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
navigationController?.pushViewController(PQStuckPointMaterialController(), animated: true)
|
|
navigationController?.pushViewController(PQStuckPointMaterialController(), animated: true)
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@objc func enterBackground() {
|
|
@objc func enterBackground() {
|
|
@@ -116,19 +111,20 @@ class MVHomeController: MVBaseController {
|
|
|
|
|
|
PQNotification.addObserver(self, selector: #selector(enterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
|
PQNotification.addObserver(self, selector: #selector(enterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
|
PQNotification.addObserver(self, selector: #selector(willEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
|
|
PQNotification.addObserver(self, selector: #selector(willEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
super.viewWillDisappear(animated)
|
|
super.viewWillDisappear(animated)
|
|
controlPlayrPasueOrResume(isPause: true)
|
|
controlPlayrPasueOrResume(isPause: true)
|
|
}
|
|
}
|
|
-
|
|
|
|
- func getData(){
|
|
|
|
-
|
|
|
|
- if(mVideos.count > 0){
|
|
|
|
|
|
+
|
|
|
|
+ func getData() {
|
|
|
|
+ if mVideos.count > 0 {
|
|
BFLog(message: "已经请求过数据")
|
|
BFLog(message: "已经请求过数据")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- MVHomeViewModel.getHomeHotVideos {[weak self] hotVideos, _ in
|
|
|
|
|
|
+ MVHomeViewModel.getHomeHotVideos { [weak self] hotVideos, _ in
|
|
BFLog(message: "hotVideos count is :\(hotVideos.count)")
|
|
BFLog(message: "hotVideos count is :\(hotVideos.count)")
|
|
|
|
|
|
self?.mVideos = hotVideos
|
|
self?.mVideos = hotVideos
|
|
@@ -143,21 +139,18 @@ class MVHomeController: MVBaseController {
|
|
}
|
|
}
|
|
BFLog(message: " self?.mAllVideos count is \(String(describing: self?.mAllVideos.count))")
|
|
BFLog(message: " self?.mAllVideos count is \(String(describing: self?.mAllVideos.count))")
|
|
}
|
|
}
|
|
-
|
|
|
|
self?.viewListView.reloadData()
|
|
self?.viewListView.reloadData()
|
|
-
|
|
|
|
//自动播放第一个视频 确保 reloaddata 完成
|
|
//自动播放第一个视频 确保 reloaddata 完成
|
|
self?.playVideo(page: 0)
|
|
self?.playVideo(page: 0)
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
override func viewDidLoad() {
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
super.viewDidLoad()
|
|
-
|
|
|
|
|
|
+
|
|
addNotification(self, selector: #selector(loginSuccesss), name: cLoginSuccesssNotiKey, object: nil)
|
|
addNotification(self, selector: #selector(loginSuccesss), name: cLoginSuccesssNotiKey, object: nil)
|
|
addNotification(self, selector: #selector(loginSuccesss), name: cBandingPhoneSuccessKey, object: nil)
|
|
addNotification(self, selector: #selector(loginSuccesss), name: cBandingPhoneSuccessKey, object: nil)
|
|
-
|
|
|
|
|
|
+
|
|
// view.addSubview(mineBtn)
|
|
// view.addSubview(mineBtn)
|
|
view.addSubview(stuckPointBtn)
|
|
view.addSubview(stuckPointBtn)
|
|
view.addSubview(settingBtn)
|
|
view.addSubview(settingBtn)
|
|
@@ -169,12 +162,12 @@ class MVHomeController: MVBaseController {
|
|
viewListView.reloadData()
|
|
viewListView.reloadData()
|
|
|
|
|
|
addLayout()
|
|
addLayout()
|
|
-
|
|
|
|
|
|
+
|
|
manager?.startListening()
|
|
manager?.startListening()
|
|
manager?.listener = { [weak self] status in
|
|
manager?.listener = { [weak self] status in
|
|
-
|
|
|
|
|
|
+
|
|
if status == .reachable(.wwan) || status == .reachable(.ethernetOrWiFi) {
|
|
if status == .reachable(.wwan) || status == .reachable(.ethernetOrWiFi) {
|
|
- BFLog(message: "来网了")
|
|
|
|
|
|
+ BFLog(message: "来网了")
|
|
self?.getData()
|
|
self?.getData()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -249,28 +242,26 @@ class MVHomeController: MVBaseController {
|
|
}
|
|
}
|
|
|
|
|
|
@objc func btnClick(sender: UIButton) {
|
|
@objc func btnClick(sender: UIButton) {
|
|
-
|
|
|
|
-
|
|
|
|
switch sender.tag {
|
|
switch sender.tag {
|
|
case 1000:
|
|
case 1000:
|
|
- if(enableLogin()){
|
|
|
|
|
|
+ if enableLogin() {
|
|
navigationController?.pushViewController(MVMineController(), animated: true)
|
|
navigationController?.pushViewController(MVMineController(), animated: true)
|
|
}
|
|
}
|
|
case 2000:
|
|
case 2000:
|
|
- if(enableLogin()){
|
|
|
|
- navigationController?.pushViewController(PQStuckPointMaterialController(), animated: true)
|
|
|
|
|
|
+ if enableLogin() {
|
|
|
|
+ let nav = UINavigationController(rootViewController: PQStuckPointMaterialController())
|
|
|
|
+ nav.modalPresentationStyle = .overFullScreen
|
|
|
|
+ present(nav, animated: true, completion: nil)
|
|
}
|
|
}
|
|
-
|
|
|
|
case 3000:
|
|
case 3000:
|
|
navigationController?.pushViewController(MVSettingController(), animated: true)
|
|
navigationController?.pushViewController(MVSettingController(), animated: true)
|
|
-
|
|
|
|
default:
|
|
default:
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- //判断是否可登录
|
|
|
|
- func enableLogin() -> Bool{
|
|
|
|
|
|
+
|
|
|
|
+ // 判断是否可登录
|
|
|
|
+ func enableLogin() -> Bool {
|
|
// 无网
|
|
// 无网
|
|
if !isNetConnected() {
|
|
if !isNetConnected() {
|
|
let remindData: PQBaseModel = PQBaseModel()
|
|
let remindData: PQBaseModel = PQBaseModel()
|
|
@@ -293,42 +284,37 @@ class MVHomeController: MVBaseController {
|
|
present(vc, animated: true, completion: nil)
|
|
present(vc, animated: true, completion: nil)
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// 用户被封禁
|
|
// 用户被封禁
|
|
BFLog(message: "userStatus is \(BFLoginUserInfo.shared.userStatus)")
|
|
BFLog(message: "userStatus is \(BFLoginUserInfo.shared.userStatus)")
|
|
if BFLoginUserInfo.shared.userStatus == "3" {
|
|
if BFLoginUserInfo.shared.userStatus == "3" {
|
|
-
|
|
|
|
- PQBandingPhoneRemindView.accountBlockRemindView(remindTitle:"无法上传视频")
|
|
|
|
|
|
+ PQBandingPhoneRemindView.accountBlockRemindView(remindTitle: "无法上传视频")
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// 未绑定手机号
|
|
// 未绑定手机号
|
|
BFLog(message: "phoneNumber is \(BFLoginUserInfo.shared.phoneNumber)")
|
|
BFLog(message: "phoneNumber is \(BFLoginUserInfo.shared.phoneNumber)")
|
|
if BFLoginUserInfo.shared.phoneNumber.count <= 0 || BFLoginUserInfo.shared.phoneNumber == "<null>" {
|
|
if BFLoginUserInfo.shared.phoneNumber.count <= 0 || BFLoginUserInfo.shared.phoneNumber == "<null>" {
|
|
-
|
|
|
|
let remindView = PQBandingPhoneRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
let remindView = PQBandingPhoneRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
remindView.tag = cBandinPhoneTag
|
|
remindView.tag = cBandinPhoneTag
|
|
remindView.bandingPhoneRemindHandle = { [weak self] sender in
|
|
remindView.bandingPhoneRemindHandle = { [weak self] sender in
|
|
if sender.tag == 2 {
|
|
if sender.tag == 2 {
|
|
-
|
|
|
|
addNotification(self!, selector: #selector(self?.loginSuccesss), name: cBandingPhoneSuccessKey, object: nil)
|
|
addNotification(self!, selector: #selector(self?.loginSuccesss), name: cBandingPhoneSuccessKey, object: nil)
|
|
self?.navigationController?.pushViewController(PQBandingPhoneController(), animated: true)
|
|
self?.navigationController?.pushViewController(PQBandingPhoneController(), animated: true)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- remindView.remindBlock = { [weak self] sender, webUrl in
|
|
|
|
- let detail = PQBaseWebViewController()
|
|
|
|
-
|
|
|
|
- detail.baseUrl = webUrl
|
|
|
|
- self?.navigationController?.pushViewController(detail, animated: true)
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- self.view.addSubview(remindView)
|
|
|
|
|
|
+ remindView.remindBlock = { [weak self] _, webUrl in
|
|
|
|
+ let detail = PQBaseWebViewController()
|
|
|
|
+
|
|
|
|
+ detail.baseUrl = webUrl
|
|
|
|
+ self?.navigationController?.pushViewController(detail, animated: true)
|
|
|
|
+ }
|
|
|
|
+ view.addSubview(remindView)
|
|
|
|
|
|
- return false
|
|
|
|
|
|
+ return false
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return true
|
|
return true
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// 再创作视频
|
|
// 再创作视频
|
|
@@ -374,7 +360,6 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
}
|
|
}
|
|
|
|
|
|
func playVideo(page: Int){
|
|
func playVideo(page: Int){
|
|
-
|
|
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
let cell: MVBannerCell? = self.viewListView.collectionView.cellForItem(at: IndexPath(row: page, section: 0)) as? MVBannerCell
|
|
let cell: MVBannerCell? = self.viewListView.collectionView.cellForItem(at: IndexPath(row: page, section: 0)) as? MVBannerCell
|
|
let showProtocal: String? = getUserDefaults(key: cShowProtocal) as? String
|
|
let showProtocal: String? = getUserDefaults(key: cShowProtocal) as? String
|
|
@@ -387,27 +372,26 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
let hotVideoIndex = self.mVideos.firstIndex(where: { (items) -> Bool in
|
|
let hotVideoIndex = self.mVideos.firstIndex(where: { (items) -> Bool in
|
|
items.categoryName == videoInfo.categoryName
|
|
items.categoryName == videoInfo.categoryName
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+
|
|
BFLog(message: "播放的视频分类为:\(String(describing: self.mVideos[hotVideoIndex ?? 0].categoryName)) page is :\(page)")
|
|
BFLog(message: "播放的视频分类为:\(String(describing: self.mVideos[hotVideoIndex ?? 0].categoryName)) page is :\(page)")
|
|
- //设置选中状态
|
|
|
|
|
|
+ // 设置选中状态
|
|
for hot in self.mVideos {
|
|
for hot in self.mVideos {
|
|
hot.isSelected = false
|
|
hot.isSelected = false
|
|
}
|
|
}
|
|
self.mVideos[hotVideoIndex ?? 0].isSelected = true
|
|
self.mVideos[hotVideoIndex ?? 0].isSelected = true
|
|
|
|
|
|
self.categoryCollectionView.reloadData()
|
|
self.categoryCollectionView.reloadData()
|
|
- self.categoryCollectionView.scrollToItem(at: IndexPath(row: hotVideoIndex ?? 0, section: 0), at: .centeredHorizontally, animated: true)
|
|
|
|
|
|
+ self.categoryCollectionView.scrollToItem(at: IndexPath(row: hotVideoIndex ?? 0, section: 0), at: .centeredHorizontally, animated: true)
|
|
|
|
|
|
self.lastBnnerSelectIndex = IndexPath(row: page, section: 0)
|
|
self.lastBnnerSelectIndex = IndexPath(row: page, section: 0)
|
|
-
|
|
|
|
-
|
|
|
|
- }else{
|
|
|
|
|
|
+
|
|
|
|
+ } else {
|
|
BFLog(message: "播放不成功: cell:\(String(describing: cell)) mVideos:\(self.mVideos.count) showProtocal: is \(String(describing: showProtocal))")
|
|
BFLog(message: "播放不成功: cell:\(String(describing: cell)) mVideos:\(self.mVideos.count) showProtocal: is \(String(describing: showProtocal))")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//控制播放器的暂停或恢复
|
|
//控制播放器的暂停或恢复
|
|
func controlPlayrPasueOrResume(isPause:Bool){
|
|
func controlPlayrPasueOrResume(isPause:Bool){
|
|
let cell: MVBannerCell? = viewListView.collectionView.cellForItem(at: lastBnnerSelectIndex) as? MVBannerCell
|
|
let cell: MVBannerCell? = viewListView.collectionView.cellForItem(at: lastBnnerSelectIndex) as? MVBannerCell
|
|
@@ -421,11 +405,10 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
func pageControl(currentPage page: Int) {
|
|
func pageControl(currentPage page: Int) {
|
|
BFLog(message: "page is \(page)")
|
|
BFLog(message: "page is \(page)")
|
|
playVideo(page: page)
|
|
playVideo(page: page)
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|