| | |
| | | |
| | | class ActivityListViewModel:RefreshModel<ActivityListModel>{ |
| | | |
| | | var cityCode = BehaviorRelay<Int?>(value:nil) |
| | | var content = BehaviorRelay<String>(value: "") |
| | | var heat = BehaviorRelay<SortType?>(value:nil) |
| | | var registerCondition = BehaviorRelay<RegisterAcitivyType?>(value:nil) |
| | | var cityCode = BehaviorRelay<Int?>(value:nil) |
| | | var content = BehaviorRelay<String>(value: "") |
| | | var heat = BehaviorRelay<SortType?>(value:nil) |
| | | var registerCondition = BehaviorRelay<RegisterAcitivyType?>(value:nil) |
| | | |
| | | override func api() -> (Observable<BaseResponse<[ActivityListModel]>>)? { |
| | | return Services.queryCompetitionList(cityCode: cityCode.value, content: content.value, heat: heat.value, registerCondition: registerCondition.value?.rawValue) |
| | | } |
| | | override func api() -> (Observable<BaseResponse<[ActivityListModel]>>)? { |
| | | return Services.queryCompetitionList(cityCode: cityCode.value, content: content.value, heat: heat.value, registerCondition: registerCondition.value?.rawValue) |
| | | } |
| | | } |
| | | |
| | | class ActivityListVC: BaseVC { |
| | | @IBOutlet weak var view_top: UIView! |
| | | @IBOutlet weak var tf_search: QMUITextField! |
| | | @IBOutlet weak var btn_holdCity: QMUIButton! |
| | | @IBOutlet weak var btn_joinCondition: QMUIButton! |
| | | @IBOutlet weak var btn_hotFilter: QMUIButton! |
| | | @IBOutlet weak var tableView: BaseTableView! |
| | | @IBOutlet weak var view_top: UIView! |
| | | @IBOutlet weak var tf_search: QMUITextField! |
| | | @IBOutlet weak var btn_holdCity: QMUIButton! |
| | | @IBOutlet weak var btn_joinCondition: QMUIButton! |
| | | @IBOutlet weak var btn_hotFilter: QMUIButton! |
| | | @IBOutlet weak var tableView: BaseTableView! |
| | | |
| | | private var courseSubTypeView:CourseSubTypeView? |
| | | private var cityChooseSubTypeView:CityChooseSubTypeView? |
| | | private var courseSubTypeView:CourseSubTypeView? |
| | | private var cityChooseSubTypeView:CityChooseSubTypeView? |
| | | |
| | | private var viewModel = ActivityListViewModel() |
| | | private var selectSignupConditionModel:NormalSimpleModel? |
| | | private var cityModel:HomeStoreModel? |
| | | private var viewModel = ActivityListViewModel() |
| | | private var selectSignupConditionModel:NormalSimpleModel? |
| | | private var cityModel:HomeStoreModel? |
| | | |
| | | init(cityModel:HomeStoreModel? = nil){ |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.cityModel = cityModel |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "活动列表" |
| | | if cityModel != nil{ |
| | | btn_holdCity.setTitle(cityModel!.city, for: .normal) |
| | | viewModel.cityCode.accept(cityModel!.cityCode) |
| | | } |
| | | viewModel.configure(tableView,needMore: false) |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | override func setUI() { |
| | | tableView.delegate = self |
| | | tableView.dataSource = self |
| | | tf_search.delegate = self |
| | | tableView.separatorStyle = .none |
| | | tableView.register(UINib(nibName: "ActivityInfoTCell", bundle: nil), forCellReuseIdentifier: "_ActivityInfoTCell") |
| | | // tableView.jq_setEmptyView() |
| | | |
| | | btn_holdCity.imagePosition = .right |
| | | btn_holdCity.spacingBetweenImageAndTitle = 5 |
| | | |
| | | btn_joinCondition.imagePosition = .right |
| | | btn_joinCondition.spacingBetweenImageAndTitle = 5 |
| | | |
| | | btn_hotFilter.imagePosition = .right |
| | | btn_hotFilter.spacingBetweenImageAndTitle = 5 |
| | | } |
| | | init(cityModel:HomeStoreModel? = nil){ |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.cityModel = cityModel |
| | | } |
| | | |
| | | override func setRx() { |
| | | tf_search.rx.text.orEmpty.changed.bind(to: viewModel.content).disposed(by: disposeBag) |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | |
| | | } |
| | | |
| | | @IBAction func searchAction(_ sender: Any) { |
| | | tf_search.resignFirstResponder() |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | @IBAction func holdCityAction(_ sender: QMUIButton) { |
| | | view.endEditing(true) |
| | | guard !sender.isSelected else {return} |
| | | hiddenMenu() |
| | | sender.isSelected = true |
| | | cityChooseSubTypeView = CityChooseSubTypeView.show(inView: self.view, afterView: view_top) { [weak self] m in |
| | | sender.setTitle(m.name, for: .normal) |
| | | self?.viewModel.cityCode.accept(m.code) |
| | | self?.viewModel.beginRefresh() |
| | | sender.isSelected = false |
| | | } closeClouse: { |
| | | sender.isSelected = false |
| | | } |
| | | } |
| | | |
| | | @IBAction func signupConditionAction(_ sender: QMUIButton) { |
| | | view.endEditing(true) |
| | | guard !sender.isSelected else {return} |
| | | hiddenMenu() |
| | | sender.isSelected = true |
| | | var items = Array<NormalSimpleModel>() |
| | | items.append(NormalSimpleModel(id: 1, name: "全部用户参与")) |
| | | items.append(NormalSimpleModel(id: 2, name: "仅限年度会员参与")) |
| | | items.append(NormalSimpleModel(id: 3, name: "仅限运动营成员参与")) |
| | | courseSubTypeView = CourseSubTypeView.show(inView: self.view, afterView: btn_joinCondition, items: items,selectModel: selectSignupConditionModel) { [weak self] m in |
| | | sender.setTitle(m.name, for: .normal) |
| | | sender.isSelected = false |
| | | self?.selectSignupConditionModel = m |
| | | self?.viewModel.registerCondition.accept(RegisterAcitivyType(rawValue: m.id)) |
| | | self?.viewModel.beginRefresh() |
| | | } closeClouse: { |
| | | sender.isSelected = false |
| | | } |
| | | } |
| | | |
| | | @IBAction func hotFliterAction(_ sender: UIButton) { |
| | | view.endEditing(true) |
| | | sender.isSelected = !sender.isSelected |
| | | let sortType = sender.isSelected ? SortType.desc:SortType.asc |
| | | sender.setImage(sortType.img, for: .normal) |
| | | viewModel.heat.accept(sortType) |
| | | viewModel.beginRefresh() |
| | | } |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "活动列表" |
| | | if cityModel != nil{ |
| | | btn_holdCity.setTitle(cityModel!.city, for: .normal) |
| | | viewModel.cityCode.accept(cityModel!.cityCode) |
| | | } |
| | | viewModel.configure(tableView,needMore: false) |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | @IBAction func signupAction(_ sender: UIButton) { |
| | | view.endEditing(true) |
| | | let vc = ActivitySignupListVC() |
| | | push(vc: vc) |
| | | } |
| | | override func setUI() { |
| | | tableView.delegate = self |
| | | tableView.dataSource = self |
| | | tf_search.delegate = self |
| | | tableView.separatorStyle = .none |
| | | tableView.register(UINib(nibName: "ActivityInfoTCell", bundle: nil), forCellReuseIdentifier: "_ActivityInfoTCell") |
| | | // tableView.jq_setEmptyView() |
| | | |
| | | private func hiddenMenu(){ |
| | | btn_holdCity.isSelected = false |
| | | btn_joinCondition.isSelected = false |
| | | courseSubTypeView?.removeFromSuperview() |
| | | cityChooseSubTypeView?.removeFromSuperview() |
| | | } |
| | | btn_holdCity.imagePosition = .right |
| | | btn_holdCity.spacingBetweenImageAndTitle = 5 |
| | | |
| | | btn_joinCondition.imagePosition = .right |
| | | btn_joinCondition.spacingBetweenImageAndTitle = 5 |
| | | |
| | | btn_hotFilter.imagePosition = .right |
| | | btn_hotFilter.spacingBetweenImageAndTitle = 5 |
| | | } |
| | | |
| | | override func setRx() { |
| | | tf_search.rx.text.orEmpty.changed.bind(to: viewModel.content).disposed(by: disposeBag) |
| | | |
| | | } |
| | | |
| | | @IBAction func searchAction(_ sender: Any) { |
| | | tf_search.resignFirstResponder() |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | @IBAction func holdCityAction(_ sender: QMUIButton) { |
| | | view.endEditing(true) |
| | | guard !sender.isSelected else {return} |
| | | hiddenMenu() |
| | | sender.isSelected = true |
| | | cityChooseSubTypeView = CityChooseSubTypeView.show(inView: self.view, afterView: view_top) { [weak self] m in |
| | | sender.setTitle(m.name, for: .normal) |
| | | self?.viewModel.cityCode.accept(m.code) |
| | | self?.viewModel.beginRefresh() |
| | | sender.isSelected = false |
| | | } closeClouse: { |
| | | sender.isSelected = false |
| | | } |
| | | } |
| | | |
| | | @IBAction func signupConditionAction(_ sender: QMUIButton) { |
| | | view.endEditing(true) |
| | | guard !sender.isSelected else {return} |
| | | hiddenMenu() |
| | | sender.isSelected = true |
| | | var items = Array<NormalSimpleModel>() |
| | | items.append(NormalSimpleModel(id: 1, name: "全部用户参与")) |
| | | items.append(NormalSimpleModel(id: 2, name: "仅限年度会员参与")) |
| | | items.append(NormalSimpleModel(id: 3, name: "仅限运动营成员参与")) |
| | | courseSubTypeView = CourseSubTypeView.show(inView: self.view, afterView: btn_joinCondition, items: items,selectModel: selectSignupConditionModel) { [weak self] m in |
| | | sender.setTitle(m.name, for: .normal) |
| | | sender.isSelected = false |
| | | self?.selectSignupConditionModel = m |
| | | self?.viewModel.registerCondition.accept(RegisterAcitivyType(rawValue: m.id)) |
| | | self?.viewModel.beginRefresh() |
| | | } closeClouse: { |
| | | sender.isSelected = false |
| | | } |
| | | } |
| | | |
| | | @IBAction func hotFliterAction(_ sender: UIButton) { |
| | | view.endEditing(true) |
| | | sender.isSelected = !sender.isSelected |
| | | let sortType = sender.isSelected ? SortType.desc:SortType.asc |
| | | sender.setImage(sortType.img, for: .normal) |
| | | viewModel.heat.accept(sortType) |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | @IBAction func signupAction(_ sender: UIButton) { |
| | | view.endEditing(true) |
| | | let vc = ActivitySignupListVC() |
| | | push(vc: vc) |
| | | } |
| | | |
| | | private func hiddenMenu(){ |
| | | btn_holdCity.isSelected = false |
| | | btn_joinCondition.isSelected = false |
| | | courseSubTypeView?.removeFromSuperview() |
| | | cityChooseSubTypeView?.removeFromSuperview() |
| | | } |
| | | } |
| | | |
| | | extension ActivityListVC:UITableViewDelegate{ |
| | | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| | | let model = viewModel.dataSource.value[indexPath.row] |
| | | let vc = ActivityDetailVC(id: model.id) |
| | | push(vc: vc) |
| | | } |
| | | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| | | let model = viewModel.dataSource.value[indexPath.row] |
| | | let vc = ActivityDetailVC(id: model.id) |
| | | push(vc: vc) |
| | | } |
| | | } |
| | | |
| | | extension ActivityListVC:UITableViewDataSource{ |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let model = viewModel.dataSource.value[indexPath.row] |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_ActivityInfoTCell") as! ActivityInfoTCell |
| | | cell.activityListModel = model |
| | | cell.label_state.isHidden = true |
| | | return cell |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return viewModel.dataSource.value.count |
| | | } |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let model = viewModel.dataSource.value[indexPath.row] |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_ActivityInfoTCell") as! ActivityInfoTCell |
| | | cell.activityListModel = model |
| | | cell.label_state.isHidden = true |
| | | return cell |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return viewModel.dataSource.value.count |
| | | } |
| | | } |
| | | |
| | | extension ActivityListVC:QMUITextFieldDelegate{ |
| | | func textFieldShouldReturn(_ textField: UITextField) -> Bool { |
| | | textField.resignFirstResponder() |
| | | viewModel.beginRefresh() |
| | | return true |
| | | } |
| | | func textFieldShouldReturn(_ textField: UITextField) -> Bool { |
| | | textField.resignFirstResponder() |
| | | viewModel.beginRefresh() |
| | | return true |
| | | } |
| | | } |