123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import UIKit
- import BFCommonKit
- class PQStuckPointMusicSearchController: PQStuckPointMusicContentController {
-
- var selectedTotalDuration: Float64 = 0
-
- var selectedDataCount: Int = 0
-
- var selectedImageDataCount: Int = 0
-
- var pageNum: Int = 1
-
- var searchWord: String?
-
- var lastSelectedIndex: IndexPath?
-
- var hotList: [Any] = Array<Any>.init()
- override func viewDidLoad() {
- super.viewDidLoad()
- emptyData?.title = "没有搜索到相关音乐"
- emptyData?.emptyImageName = "pic_search_empty"
- emptyRemindView.remindLab.font = UIFont.systemFont(ofSize: 14)
- emptyRemindView.remindLab.textColor = UIColor.hexColor(hexadecimal: "#999999")
- emptyRemindView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 200)
- emptyRemindView.emptyData = emptyData
- refreshHandle = { [weak self] _, _ in
- self?.loadRequestData(isRefresh: false)
- }
- }
-
-
-
- func loadSearchData(keyword: String?) {
- if keyword == nil || (keyword?.count ?? 0) <= 0 {
- cShowHUB(superView: nil, msg: "请先输入搜索内容")
- return
- }
- BFLog(message: "背景音乐--开始搜索背景音乐")
- if keyword != searchWord || (keyword == searchWord && itemList.count <= 0) {
- showEmptyView()
- itemList.removeAll()
- collectionView.reloadData()
- pageNum = 0
- searchWord = keyword
- loadRequestData()
- }
- }
-
- @objc func loadRequestData(isRefresh: Bool = true) {
- pageNum = pageNum + 1
- PQBaseViewModel.searchBGMListData(searchWord, pageNum, 20, videoCount: selectedDataCount - selectedImageDataCount, imageCount: selectedImageDataCount, totalDuration: selectedTotalDuration) { [weak self] bgmList, msg in
-
- BFLog(message: "背景音乐--搜索背景音乐成功")
- if bgmList.count <= 0 {
- self?.pageNum = (self?.pageNum ?? 0) - 1
- }
-
- if bgmList.count <= 0, (self?.itemList.count ?? 0) <= 0, (self?.hotList.count ?? 0) > 0 {
- if !(self?.hotList.first is PQEmptyModel){
- self?.hotList.insert(PQEmptyModel(), at: 0)
- }
-
- self?.configMusicListData(isRefresh: true, musicListData: self?.hotList ?? [])
- } else {
- self?.configMusicListData(isRefresh: isRefresh, musicListData: bgmList)
- }
-
- PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_searchSyncedUpMusic, pageSource: .sp_stuck_searchSyncedUpMusic, extParams: ["searchText": self?.searchWord ?? "", "searchResultNumber": bgmList.count, "isSuccess": msg == nil], remindmsg: "卡点视频数据上报-(点击上报:用户在搜索框输入文字然后按回车)")
- }
- }
-
-
- func clearData() {
- BFLog(message: "背景音乐--清空背景音乐搜索数据")
- hotList.forEach { item in
- if item is PQVoiceModel {
- (item as? PQVoiceModel)?.isSelected = false
- (item as? PQVoiceModel)?.isPlaying = false
- }
- }
- itemList.removeAll()
- searchWord = nil
- pageNum = 0
- lastSelectedIndex = nil
- collectionView.reloadData()
- }
- }
|