|
@@ -26,6 +26,8 @@ class PQSelecteMusicView: UIView {
|
|
|
|
|
|
// 点击播放一个歌,回调
|
|
// 点击播放一个歌,回调
|
|
var didSelectItemHandle:((_ isPlaying:Bool) -> Void)?
|
|
var didSelectItemHandle:((_ isPlaying:Bool) -> Void)?
|
|
|
|
+ // 当前选择的分类
|
|
|
|
+ var currentSelectTag:PQStuckPointMusicTagsModel?
|
|
|
|
|
|
lazy var avPlayer: AVPlayer = {
|
|
lazy var avPlayer: AVPlayer = {
|
|
let avPlayer = AVPlayer()
|
|
let avPlayer = AVPlayer()
|
|
@@ -159,15 +161,17 @@ class PQSelecteMusicView: UIView {
|
|
func requestPageListData(isRefresh: Bool = true, isHotPage _: Bool = false, tagId: Int64) {
|
|
func requestPageListData(isRefresh: Bool = true, isHotPage _: Bool = false, tagId: Int64) {
|
|
if isRefresh {
|
|
if isRefresh {
|
|
pageNum = 1
|
|
pageNum = 1
|
|
|
|
+ musicDatas = []
|
|
}
|
|
}
|
|
PQStuckPointViewModel.stuckPointMusicPageList(tagId: tagId, pageNum: pageNum, videoCount: 0, imageCount: 0, totalDuration: 0) { [weak self] musicInfo, _ in
|
|
PQStuckPointViewModel.stuckPointMusicPageList(tagId: tagId, pageNum: pageNum, videoCount: 0, imageCount: 0, totalDuration: 0) { [weak self] musicInfo, _ in
|
|
-
|
|
|
|
|
|
+ BFLog(message: "请求音乐列表 pageNum\(String(describing: self?.pageNum)) tagId \(tagId) 返回条数\(musicInfo.count)")
|
|
if musicInfo.count > 0 {
|
|
if musicInfo.count > 0 {
|
|
self?.pageNum = (self?.pageNum ?? 0) + 1
|
|
self?.pageNum = (self?.pageNum ?? 0) + 1
|
|
|
|
+
|
|
|
|
+ self?.musicDatas = self!.musicDatas + musicInfo
|
|
|
|
+ self?.selectMusicCollection.reloadData()
|
|
}
|
|
}
|
|
|
|
|
|
- self?.musicDatas = musicInfo
|
|
|
|
- self?.selectMusicCollection.reloadData()
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -263,7 +267,12 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ //自动请求下一页数据
|
|
|
|
+ if(indexPath.row == musicDatas.count - 5){
|
|
|
|
+ // 请求这个分类的歌单
|
|
|
|
+ requestPageListData(isRefresh: false, tagId: currentSelectTag?.tagId ?? 0)
|
|
|
|
+ }
|
|
return cell
|
|
return cell
|
|
}
|
|
}
|
|
let itemData: Any = catageryDatas[indexPath.item]
|
|
let itemData: Any = catageryDatas[indexPath.item]
|
|
@@ -310,11 +319,17 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
}
|
|
}
|
|
catageryDatas[indexPath.item].isSelected = true
|
|
catageryDatas[indexPath.item].isSelected = true
|
|
categoryCollection.reloadData()
|
|
categoryCollection.reloadData()
|
|
|
|
+ currentSelectTag = catageryDatas[indexPath.item]
|
|
|
|
+ // 请求这个分类的歌单
|
|
|
|
+ requestPageListData(isRefresh: true, tagId: currentSelectTag?.tagId ?? 0)
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- func collectionView(_: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {}
|
|
|
|
|
|
+ func collectionView(_: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// 分类 cell
|
|
// 分类 cell
|