Commit fd27edb4 ilCode

完成比赛筛选

1 个父辈 57fa5f79
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
5E720D062C2B9D7500D30A16 /* HadoopProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E720D052C2B9D7500D30A16 /* HadoopProvider.swift */; }; 5E720D062C2B9D7500D30A16 /* HadoopProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E720D052C2B9D7500D30A16 /* HadoopProvider.swift */; };
5E720D082C2B9FBE00D30A16 /* HadoopRequestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E720D072C2B9FBE00D30A16 /* HadoopRequestModel.swift */; }; 5E720D082C2B9FBE00D30A16 /* HadoopRequestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E720D072C2B9FBE00D30A16 /* HadoopRequestModel.swift */; };
5E720D0A2C2BB24200D30A16 /* ScoreTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E720D092C2BB24200D30A16 /* ScoreTools.swift */; }; 5E720D0A2C2BB24200D30A16 /* ScoreTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E720D092C2BB24200D30A16 /* ScoreTools.swift */; };
5E720D0C2C2C200700D30A16 /* HadoopMatchFilterGroupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E720D0B2C2C200700D30A16 /* HadoopMatchFilterGroupModel.swift */; };
5E9165D82C1D3F45004A3C5E /* UserProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E9165D72C1D3F45004A3C5E /* UserProvider.swift */; }; 5E9165D82C1D3F45004A3C5E /* UserProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E9165D72C1D3F45004A3C5E /* UserProvider.swift */; };
5E9165DA2C1D9A09004A3C5E /* ServerApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E9165D92C1D9A09004A3C5E /* ServerApi.swift */; }; 5E9165DA2C1D9A09004A3C5E /* ServerApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E9165D92C1D9A09004A3C5E /* ServerApi.swift */; };
5E93B4882C1A7DA200CD6536 /* BaseTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E93B4872C1A7DA200CD6536 /* BaseTableViewCell.swift */; }; 5E93B4882C1A7DA200CD6536 /* BaseTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E93B4872C1A7DA200CD6536 /* BaseTableViewCell.swift */; };
...@@ -90,6 +91,7 @@ ...@@ -90,6 +91,7 @@
5EC03E4E2C1155720068A5CB /* CacheTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC03E4D2C1155720068A5CB /* CacheTools.swift */; }; 5EC03E4E2C1155720068A5CB /* CacheTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC03E4D2C1155720068A5CB /* CacheTools.swift */; };
5EC03E502C118A420068A5CB /* AppInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC03E4F2C118A420068A5CB /* AppInfo.swift */; }; 5EC03E502C118A420068A5CB /* AppInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC03E4F2C118A420068A5CB /* AppInfo.swift */; };
5EC03E532C118FA00068A5CB /* ScoreProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC03E522C118FA00068A5CB /* ScoreProvider.swift */; }; 5EC03E532C118FA00068A5CB /* ScoreProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC03E522C118FA00068A5CB /* ScoreProvider.swift */; };
5EC3AD932C2CEB7200DCFB26 /* RaceTypeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC3AD922C2CEB7200DCFB26 /* RaceTypeModel.swift */; };
5EC6E64A2C211735006F778C /* RefreshHeaderAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC6E6482C211735006F778C /* RefreshHeaderAnimator.swift */; }; 5EC6E64A2C211735006F778C /* RefreshHeaderAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC6E6482C211735006F778C /* RefreshHeaderAnimator.swift */; };
5EC6E64E2C2192C9006F778C /* MatchInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC6E64D2C2192C9006F778C /* MatchInfoCell.swift */; }; 5EC6E64E2C2192C9006F778C /* MatchInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EC6E64D2C2192C9006F778C /* MatchInfoCell.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
...@@ -122,6 +124,7 @@ ...@@ -122,6 +124,7 @@
5E720D052C2B9D7500D30A16 /* HadoopProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HadoopProvider.swift; sourceTree = "<group>"; }; 5E720D052C2B9D7500D30A16 /* HadoopProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HadoopProvider.swift; sourceTree = "<group>"; };
5E720D072C2B9FBE00D30A16 /* HadoopRequestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HadoopRequestModel.swift; sourceTree = "<group>"; }; 5E720D072C2B9FBE00D30A16 /* HadoopRequestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HadoopRequestModel.swift; sourceTree = "<group>"; };
5E720D092C2BB24200D30A16 /* ScoreTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScoreTools.swift; sourceTree = "<group>"; }; 5E720D092C2BB24200D30A16 /* ScoreTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScoreTools.swift; sourceTree = "<group>"; };
5E720D0B2C2C200700D30A16 /* HadoopMatchFilterGroupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HadoopMatchFilterGroupModel.swift; sourceTree = "<group>"; };
5E9165D72C1D3F45004A3C5E /* UserProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserProvider.swift; sourceTree = "<group>"; }; 5E9165D72C1D3F45004A3C5E /* UserProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserProvider.swift; sourceTree = "<group>"; };
5E9165D92C1D9A09004A3C5E /* ServerApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerApi.swift; sourceTree = "<group>"; }; 5E9165D92C1D9A09004A3C5E /* ServerApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerApi.swift; sourceTree = "<group>"; };
5E93B4872C1A7DA200CD6536 /* BaseTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTableViewCell.swift; sourceTree = "<group>"; }; 5E93B4872C1A7DA200CD6536 /* BaseTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTableViewCell.swift; sourceTree = "<group>"; };
...@@ -184,6 +187,7 @@ ...@@ -184,6 +187,7 @@
5EC03E4D2C1155720068A5CB /* CacheTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CacheTools.swift; sourceTree = "<group>"; }; 5EC03E4D2C1155720068A5CB /* CacheTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CacheTools.swift; sourceTree = "<group>"; };
5EC03E4F2C118A420068A5CB /* AppInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfo.swift; sourceTree = "<group>"; }; 5EC03E4F2C118A420068A5CB /* AppInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfo.swift; sourceTree = "<group>"; };
5EC03E522C118FA00068A5CB /* ScoreProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScoreProvider.swift; sourceTree = "<group>"; }; 5EC03E522C118FA00068A5CB /* ScoreProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScoreProvider.swift; sourceTree = "<group>"; };
5EC3AD922C2CEB7200DCFB26 /* RaceTypeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RaceTypeModel.swift; sourceTree = "<group>"; };
5EC6E6482C211735006F778C /* RefreshHeaderAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshHeaderAnimator.swift; sourceTree = "<group>"; }; 5EC6E6482C211735006F778C /* RefreshHeaderAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshHeaderAnimator.swift; sourceTree = "<group>"; };
5EC6E64D2C2192C9006F778C /* MatchInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchInfoCell.swift; sourceTree = "<group>"; }; 5EC6E64D2C2192C9006F778C /* MatchInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchInfoCell.swift; sourceTree = "<group>"; };
EA8E48B8C50E8D94161797C6 /* Pods-AoleiSports.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AoleiSports.release.xcconfig"; path = "Target Support Files/Pods-AoleiSports/Pods-AoleiSports.release.xcconfig"; sourceTree = "<group>"; }; EA8E48B8C50E8D94161797C6 /* Pods-AoleiSports.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AoleiSports.release.xcconfig"; path = "Target Support Files/Pods-AoleiSports/Pods-AoleiSports.release.xcconfig"; sourceTree = "<group>"; };
...@@ -421,6 +425,8 @@ ...@@ -421,6 +425,8 @@
5E5A69D82C2ACA9B0063B726 /* HadoopMatchFilterView.swift */, 5E5A69D82C2ACA9B0063B726 /* HadoopMatchFilterView.swift */,
5E720D052C2B9D7500D30A16 /* HadoopProvider.swift */, 5E720D052C2B9D7500D30A16 /* HadoopProvider.swift */,
5E720D072C2B9FBE00D30A16 /* HadoopRequestModel.swift */, 5E720D072C2B9FBE00D30A16 /* HadoopRequestModel.swift */,
5E720D0B2C2C200700D30A16 /* HadoopMatchFilterGroupModel.swift */,
5EC3AD922C2CEB7200DCFB26 /* RaceTypeModel.swift */,
); );
path = Discover; path = Discover;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -628,6 +634,7 @@ ...@@ -628,6 +634,7 @@
5E9A1A312C0EF51600321AC5 /* UINavigationController+GKExtension.swift in Sources */, 5E9A1A312C0EF51600321AC5 /* UINavigationController+GKExtension.swift in Sources */,
5E47C9772C1FD7F6002EA39E /* InfoModel.swift in Sources */, 5E47C9772C1FD7F6002EA39E /* InfoModel.swift in Sources */,
5E93B48E2C1A98BE00CD6536 /* RegisterController.swift in Sources */, 5E93B48E2C1A98BE00CD6536 /* RegisterController.swift in Sources */,
5E720D0C2C2C200700D30A16 /* HadoopMatchFilterGroupModel.swift in Sources */,
5E6CF0222C1305DD00BF3CF5 /* AoleiSports.xcdatamodeld in Sources */, 5E6CF0222C1305DD00BF3CF5 /* AoleiSports.xcdatamodeld in Sources */,
5E1E66B02C194337009339F0 /* LayoutTools.swift in Sources */, 5E1E66B02C194337009339F0 /* LayoutTools.swift in Sources */,
5E93B4922C1AA0D200CD6536 /* UIViewController+Ext.swift in Sources */, 5E93B4922C1AA0D200CD6536 /* UIViewController+Ext.swift in Sources */,
...@@ -656,6 +663,7 @@ ...@@ -656,6 +663,7 @@
5E9A1A262C0EF51600321AC5 /* Bundle+GKExtension.swift in Sources */, 5E9A1A262C0EF51600321AC5 /* Bundle+GKExtension.swift in Sources */,
5EB4F8B22C23D1B300A3667D /* DateTools.swift in Sources */, 5EB4F8B22C23D1B300A3667D /* DateTools.swift in Sources */,
5E9A1A2E2C0EF51600321AC5 /* GKPushAnimatedTransition.swift in Sources */, 5E9A1A2E2C0EF51600321AC5 /* GKPushAnimatedTransition.swift in Sources */,
5EC3AD932C2CEB7200DCFB26 /* RaceTypeModel.swift in Sources */,
5E66B2D72C1BE2ED00590452 /* UIImage+Ext.swift in Sources */, 5E66B2D72C1BE2ED00590452 /* UIImage+Ext.swift in Sources */,
5E9A1A302C0EF51600321AC5 /* UIImage+GKExtension.swift in Sources */, 5E9A1A302C0EF51600321AC5 /* UIImage+GKExtension.swift in Sources */,
5E65F8972C22CAF40082D374 /* UserDefaultTools.swift in Sources */, 5E65F8972C22CAF40082D374 /* UserDefaultTools.swift in Sources */,
......
...@@ -10,7 +10,6 @@ import UIKit ...@@ -10,7 +10,6 @@ import UIKit
/// 大数据研究页面 /// 大数据研究页面
class HadoopController: BaseController { class HadoopController: BaseController {
var provider: HadoopProvider<HadoopTarget>? var provider: HadoopProvider<HadoopTarget>?
var matchCount = 0
private lazy var leftBtn: UIButton = { private lazy var leftBtn: UIButton = {
let btn = UIButton() let btn = UIButton()
...@@ -63,11 +62,7 @@ class HadoopController: BaseController { ...@@ -63,11 +62,7 @@ class HadoopController: BaseController {
}() }()
private lazy var filterView: HadoopMatchFilterView = { private lazy var filterView: HadoopMatchFilterView = {
let view = HadoopMatchFilterView() let view = HadoopMatchFilterView(provider: provider)
view.dataSource = [
["赛事类型选择:": ["全部", "竞足", "北单", "欧洲杯"]],
["联赛选择:": ["全部", "欧洲杯", "日佳"]]
]
return view return view
}() }()
...@@ -84,10 +79,31 @@ class HadoopController: BaseController { ...@@ -84,10 +79,31 @@ class HadoopController: BaseController {
handleRefresh() handleRefresh()
} }
override func handleRefresh() {
super.handleRefresh()
provider?.bigDataListRequest(completion: { logicResult in
if case .failure(let err) = logicResult {
if case AsError.netErr(let message) = err {
self.showEmpty(type: .netErr, message: message)
} else {
self.showEmpty(type: .other, message: err.localizedDescription)
}
self.emptyStateDeal()
}
})
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return gk_statusBarStyle
}
}
extension HadoopController {
private func initProvider() { private func initProvider() {
provider = HadoopProvider(vc: self, showErr: false) provider = HadoopProvider(vc: self, showErr: false)
provider?.bigDataList provider?.matchList
.asObservable() .asObservable()
.subscribe(onNext: { tmpModels in .subscribe(onNext: { tmpModels in
self.matchListView.reloadData() self.matchListView.reloadData()
...@@ -108,49 +124,11 @@ class HadoopController: BaseController { ...@@ -108,49 +124,11 @@ class HadoopController: BaseController {
self.header.update(predictData: tmpPredictData) self.header.update(predictData: tmpPredictData)
}) })
.disposed(by: disposeBag) .disposed(by: disposeBag)
provider?.matchTotalCount
.asObservable()
.subscribe(onNext: { tmpCount in
self.matchCount = tmpCount
// 确保tableView已经被添加到视图层次结构中并且可见
if self.matchListView.window != nil {
self.matchListView.reloadSections(IndexSet(integer: 0), with: .none)
} else {
DispatchQueue.main.async {
self.matchListView.reloadSections(IndexSet(integer: 0), with: .none)
}
}
})
.disposed(by: disposeBag)
provider?.comList
.asObservable()
.subscribe(onNext: { tmpComList in
self.filterView.update(comList: tmpComList)
})
.disposed(by: disposeBag)
}
override func handleRefresh() {
super.handleRefresh()
provider?.bigDataListRequest(completion: { logicResult in
if case .failure(let err) = logicResult {
if case AsError.netErr(let message) = err {
self.showEmpty(type: .netErr, message: message)
} else {
self.showEmpty(type: .other, message: err.localizedDescription)
}
self.emptyStateDeal()
}
})
} }
private func emptyStateDeal(isShow: Bool = true) { private func emptyStateDeal(isShow: Bool = true) {
leftBtn.isSelected = isShow leftBtn.isSelected = isShow
rightLab.isHidden = (provider?.bigDataList.value.isEmpty ?? true) rightLab.isHidden = (provider?.matchList.value.isEmpty ?? true)
gk_statusBarStyle = leftBtn.isSelected ? .darkContent : .lightContent gk_statusBarStyle = leftBtn.isSelected ? .darkContent : .lightContent
gk_navBarAlpha = leftBtn.isSelected ? 1 : 0 gk_navBarAlpha = leftBtn.isSelected ? 1 : 0
} }
...@@ -159,11 +137,11 @@ class HadoopController: BaseController { ...@@ -159,11 +137,11 @@ class HadoopController: BaseController {
//MARK: - UITableViewDataSource && UITableViewDelegate //MARK: - UITableViewDataSource && UITableViewDelegate
extension HadoopController: UITableViewDataSource, UITableViewDelegate { extension HadoopController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return provider?.bigDataList.value.count ?? 0 return provider?.matchList.value.count ?? 0
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let model = provider?.bigDataList.value[indexPath.row] let model = provider?.matchList.value[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: HustleScoreCell.reuseIdentifier, for: indexPath) as! HustleScoreCell let cell = tableView.dequeueReusableCell(withIdentifier: HustleScoreCell.reuseIdentifier, for: indexPath) as! HustleScoreCell
cell.model = model cell.model = model
return cell return cell
...@@ -171,10 +149,10 @@ extension HadoopController: UITableViewDataSource, UITableViewDelegate { ...@@ -171,10 +149,10 @@ extension HadoopController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: MatchFilterHeaderView.reuseIdentifier) as? MatchFilterHeaderView let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: MatchFilterHeaderView.reuseIdentifier) as? MatchFilterHeaderView
header?.setProvider(provider)
header?.rightBtn.rx.tap.subscribe(onNext: { header?.rightBtn.rx.tap.subscribe(onNext: {
self.filterView.showInView(self.view) self.filterView.showInView(self.view)
}).disposed(by: disposeBag) }).disposed(by: disposeBag)
header?.update(matchCount: matchCount)
return header return header
} }
...@@ -197,7 +175,7 @@ extension HadoopController: UITableViewDataSource, UITableViewDelegate { ...@@ -197,7 +175,7 @@ extension HadoopController: UITableViewDataSource, UITableViewDelegate {
extension HadoopController: UIScrollViewDelegate { extension HadoopController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
if provider?.bigDataList.value.isEmpty ?? true { if provider?.matchList.value.isEmpty ?? true {
emptyStateDeal() emptyStateDeal()
} else { } else {
var isShow = true var isShow = true
...@@ -210,8 +188,4 @@ extension HadoopController: UIScrollViewDelegate { ...@@ -210,8 +188,4 @@ extension HadoopController: UIScrollViewDelegate {
emptyStateDeal(isShow: isShow) emptyStateDeal(isShow: isShow)
} }
} }
override var preferredStatusBarStyle: UIStatusBarStyle {
return gk_statusBarStyle
}
} }
//
// HadoopMatchFilterGroupModel.swift
// AoleiSports
//
// Created by ilCode on 2024/6/26.
//
import Foundation
// 大数据赛事筛选分组模型
struct HadoopMatchFilterGroupModel {
enum GroupType {
// 赛事类型选择
case raceType
// 联赛类型选择
case comType
}
let type: GroupType
let title: String?
var raceItems: [RaceTypeModel]?
var comItems: [HadoopComModel]?
static func assembleNewGroupModels(oriGroupModels: [HadoopMatchFilterGroupModel], newComModels: [HadoopComModel]) -> [HadoopMatchFilterGroupModel] {
if newComModels.isEmpty { return [] }
var tmpNewComList: [HadoopComModel] = []
let allComModel = Mapper<HadoopComModel>().map(JSON: ["competition_id": HadoopComModel.allId, "competition_name": "全部", "isSelected": true])
tmpNewComList.append(allComModel!)
tmpNewComList.append(contentsOf: newComModels)
var tmpTypeGroupModel: HadoopMatchFilterGroupModel
var tmpComGroupModel: HadoopMatchFilterGroupModel
if oriGroupModels.isEmpty {
let typeNames = ["全部", "竞足", "单场", "欧洲杯"]
let types = [RaceTypeModel.RaceType.all, .jz, .dc, .euroCup]
var tmpRaceModels: [RaceTypeModel] = []
typeNames.enumerated().forEach { (index, value) in
let raceType = types[index]
let model = RaceTypeModel(raceType: raceType, itemName: value, isSelected: raceType == .all)
tmpRaceModels.append(model)
}
tmpTypeGroupModel = HadoopMatchFilterGroupModel(type: .raceType, title: "赛事类型选择:", raceItems: tmpRaceModels, comItems: nil)
tmpComGroupModel = HadoopMatchFilterGroupModel(type: .comType, title: "联赛选择:", raceItems: nil, comItems: tmpNewComList)
} else {
tmpTypeGroupModel = oriGroupModels.first!
tmpComGroupModel = oriGroupModels.last!
}
return [tmpTypeGroupModel, tmpComGroupModel]
}
}
...@@ -21,10 +21,11 @@ enum HadoopTarget: TargetType { ...@@ -21,10 +21,11 @@ enum HadoopTarget: TargetType {
} }
class HadoopProvider<Target: TargetType>: BaseMoyaProvider<Target> { class HadoopProvider<Target: TargetType>: BaseMoyaProvider<Target> {
var bigDataList = BehaviorRelay<[HadoopMatchModel]>(value: []) var oriMatchList = BehaviorRelay<[HadoopMatchModel]>(value: [])
var predictData = BehaviorRelay<(Int, String)>(value: (0, "0")) var predictData = BehaviorRelay<(Int, String)>(value: (0, "0"))
var matchTotalCount = BehaviorRelay<Int>(value: 0) var matchTotalCount = BehaviorRelay<Int>(value: 0)
var comList = BehaviorRelay<[HadoopComModel]>(value: []) var comList = BehaviorRelay<[HadoopComModel]>(value: [])
var matchList = BehaviorRelay<[HadoopMatchModel]>(value: [])
func bigDataListRequest(completion: @escaping (Result<Bool, AsError>) -> Void) { func bigDataListRequest(completion: @escaping (Result<Bool, AsError>) -> Void) {
moyaPost(api: APIs.kBigDataList, target: HadoopTarget.bigDataList) { midResult in moyaPost(api: APIs.kBigDataList, target: HadoopTarget.bigDataList) { midResult in
...@@ -35,11 +36,12 @@ class HadoopProvider<Target: TargetType>: BaseMoyaProvider<Target> { ...@@ -35,11 +36,12 @@ class HadoopProvider<Target: TargetType>: BaseMoyaProvider<Target> {
let requestModel = HadoopRequestModel(JSON: midSuccessResult) let requestModel = HadoopRequestModel(JSON: midSuccessResult)
if let tmpReult = requestModel?.result, !tmpReult.isEmpty { if let tmpReult = requestModel?.result, !tmpReult.isEmpty {
self.bigDataList.accept(tmpReult) self.oriMatchList.accept(tmpReult)
self.matchList.accept(tmpReult)
} }
if let predictData = requestModel?.predictData, if let predictData = requestModel?.predictData,
let predictResult = predictData.predictResult, let predictResult = predictData.predictResult,
let totalCount = predictResult["total_count"] as? Int, let totalCount = predictResult["total_count"] as? Int,
let predict = predictResult["predict"] as? [String : Any], let predict = predictResult["predict"] as? [String : Any],
let rate = predict["rate"] as? String { let rate = predict["rate"] as? String {
......
...@@ -56,14 +56,19 @@ struct PredictTopModel: Mappable { ...@@ -56,14 +56,19 @@ struct PredictTopModel: Mappable {
} }
struct HadoopComModel: Mappable { struct HadoopComModel: Mappable {
// 全部特殊id
static let allId = -999
var comId: Int? var comId: Int?
var comName: String? var comName: String?
var isSelected: Bool?
init?(map: ObjectMapper.Map) { } init?(map: ObjectMapper.Map) { }
mutating func mapping(map: ObjectMapper.Map) { mutating func mapping(map: ObjectMapper.Map) {
comId <- map["competition_id"] comId <- map["competition_id"]
comName <- map["competition_name"] comName <- map["competition_name"]
isSelected <- map["isSelected"]
} }
} }
......
...@@ -7,17 +7,26 @@ ...@@ -7,17 +7,26 @@
import UIKit import UIKit
// 筛选分组悬浮头
class MatchFilterHeaderView: UITableViewHeaderFooterView { class MatchFilterHeaderView: UITableViewHeaderFooterView {
static let reuseIdentifier = "MatchFilterHeaderView" static let reuseIdentifier = "MatchFilterHeaderView"
let disposeBag = DisposeBag() let disposeBag = DisposeBag()
var provider: HadoopProvider<HadoopTarget>?
private lazy var leftLabel: UILabel = {
private lazy var totalLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.textColor = kMainTitleColor label.textColor = kMainTitleColor
label.font = kFontSize(14) label.font = kFontSize(14)
return label return label
}() }()
private lazy var filterLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor.colorWith(hexString: "AA947A")
label.font = kBoldFontSize(12)
return label
}()
lazy var rightBtn: UIButton = { lazy var rightBtn: UIButton = {
let btn = UIButton() let btn = UIButton()
btn.setTitle("筛选比赛", for: .normal) btn.setTitle("筛选比赛", for: .normal)
...@@ -26,7 +35,7 @@ class MatchFilterHeaderView: UITableViewHeaderFooterView { ...@@ -26,7 +35,7 @@ class MatchFilterHeaderView: UITableViewHeaderFooterView {
btn.setImage(R.image.hadoop_match_filter(), for: .normal) btn.setImage(R.image.hadoop_match_filter(), for: .normal)
btn.adjustImage(position: .left, spacing: 5) btn.adjustImage(position: .left, spacing: 5)
btn.contentHorizontalAlignment = .right btn.contentHorizontalAlignment = .right
return btn return btn
}() }()
override init(reuseIdentifier: String?) { override init(reuseIdentifier: String?) {
...@@ -35,14 +44,19 @@ class MatchFilterHeaderView: UITableViewHeaderFooterView { ...@@ -35,14 +44,19 @@ class MatchFilterHeaderView: UITableViewHeaderFooterView {
let bgView = UIView() let bgView = UIView()
bgView.backgroundColor = kMainBgColor bgView.backgroundColor = kMainBgColor
backgroundView = bgView backgroundView = bgView
contentView.addSubview(leftLabel) contentView.addSubview(totalLabel)
contentView.addSubview(filterLabel)
contentView.addSubview(rightBtn) contentView.addSubview(rightBtn)
leftLabel.snp.makeConstraints { make in totalLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview() make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(10) make.left.equalToSuperview().offset(10)
} }
filterLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalTo(totalLabel.snp.right).offset(10)
}
rightBtn.snp.makeConstraints { make in rightBtn.snp.makeConstraints { make in
make.centerY.equalToSuperview() make.centerY.equalToSuperview()
make.right.equalToSuperview().offset(-10) make.right.equalToSuperview().offset(-10)
...@@ -53,7 +67,21 @@ class MatchFilterHeaderView: UITableViewHeaderFooterView { ...@@ -53,7 +67,21 @@ class MatchFilterHeaderView: UITableViewHeaderFooterView {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
func update(matchCount: Int) { func setProvider(_ provider: HadoopProvider<HadoopTarget>?) {
leftLabel.text = "共\(matchCount)场比赛" self.provider = provider
self.provider?.matchTotalCount
.asObservable()
.subscribe(onNext: { tmpCount in
self.totalLabel.text = "共\(tmpCount)场比赛"
})
.disposed(by: disposeBag)
self.provider?.matchList
.asObservable()
.subscribe(onNext: { tmpModels in
self.filterLabel.text = self.provider?.matchTotalCount.value == tmpModels.count ? "" : "(已筛选\(tmpModels.count)场)"
})
.disposed(by: disposeBag)
} }
} }
//
// RaceTypeModel.swift
// AoleiSports
//
// Created by ilCode on 2024/6/27.
//
import Foundation
// 赛事类型模型
struct RaceTypeModel {
enum RaceType {
case all // 全部
case jz // 竞足
case dc // 单场
case euroCup // 欧洲杯
}
let raceType: RaceType
let itemName: String?
var isSelected: Bool?
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!