From ca2a4ce89064be715e90ae60dc305c26e7dd5719 Mon Sep 17 00:00:00 2001 From: younger_times <841720330@qq.com> Date: 星期五, 14 七月 2023 18:52:34 +0800 Subject: [PATCH] 新增 --- WanPai/Root/Activity/VC/ActivitySignupListVC.swift | 4 WanPai/Model/CommonModels.swift | 18 ++ WanPai/Config/Enums.swift | 32 +++ WanPai/Root/Other/View/StoresChooseView.swift | 104 ++++++++++- WanPai/Root/Activity/VC/ActivityDetailVC.swift | 15 + WanPai/Root/Activity/VC/ActivityListVC.swift | 89 ++++++++- WanPai/Network/Services.swift | 58 ++++++ WanPai/Root/Activity/TCell/ActivityInfoTCell.xib | 17 + WanPai/Root/Activity/VC/ActivitySignupListSubVC.swift | 43 ++-- WanPai/Root/Activity/VC/ActivityListVC.xib | 16 WanPai/Root/Home/VC/HomeVC.swift | 7 WanPai/Root/Course/View/CityChooseSubTypeView.swift | 24 ++ WanPai/ViewModel/RefreshModel.swift | 5 WanPai/Root/Course/View/CityChooseSubTypeView.xib | 14 + WanPai/Root/Other/View/StoresChooseView.xib | 8 WanPai/Network/NetworkRequest.swift | 2 WanPai/Info.plist | 4 WanPai/Root/Activity/TCell/ActivityInfoTCell.swift | 30 +++ 18 files changed, 413 insertions(+), 77 deletions(-) diff --git a/WanPai/Config/Enums.swift b/WanPai/Config/Enums.swift index 56fc823..1f444ff 100644 --- a/WanPai/Config/Enums.swift +++ b/WanPai/Config/Enums.swift @@ -177,3 +177,35 @@ } } } + +enum RegisterAcitivyType:Int,HandyJSONEnum{ + /// 全部用户 + case allUser = 1 + /// 仅限年度会员参与 + case vip = 2 + ///仅限学员参与 + case student = 3 + + var strTitle:String{ + switch self { + case .allUser:return "全部用户" + case .vip:return "仅限年度会员参与" + case .student:return "仅限学员参与" + } + } +} + + + /// 我的报名活动赛事 +enum SignupType:Int,HandyJSONEnum{ + ///全部 + case all = 0 + ///未开始 + case prepare = 1 + /// 进行中 + case ongoing = 2 + /// 已结束 + case over = 3 + /// 已取消 + case cancel = 4 +} diff --git a/WanPai/Info.plist b/WanPai/Info.plist index 5ea97eb..8b96522 100644 --- a/WanPai/Info.plist +++ b/WanPai/Info.plist @@ -18,6 +18,10 @@ <string>weixin</string> <string>weixinULAPI</string> <string>weixinURLParamsAPI</string> + <string>baidumap</string> + <string>iosamap</string> + <string>qqmap</string> + <string>googlemap</string> </array> <key>NSAppTransportSecurity</key> <dict> diff --git a/WanPai/Model/CommonModels.swift b/WanPai/Model/CommonModels.swift index e292e03..62dcd5c 100644 --- a/WanPai/Model/CommonModels.swift +++ b/WanPai/Model/CommonModels.swift @@ -88,3 +88,21 @@ var phone = "" var img = "" } + +struct ActivityListModel:HandyJSON{ + var age: String = "" + var cityName: String = "" + var coverDrawing: String = "" + var heat: Int = 0 + var id: Int = 0 + var introduction: String = "" + var name: String = "" + var registerCondition:RegisterAcitivyType = .allUser + var registerEndTime: String = "" +} + + +struct CityProfileModel:HandyJSON { + var code = "" + var name = "" +} diff --git a/WanPai/Network/NetworkRequest.swift b/WanPai/Network/NetworkRequest.swift index b49525b..b344554 100644 --- a/WanPai/Network/NetworkRequest.swift +++ b/WanPai/Network/NetworkRequest.swift @@ -197,7 +197,7 @@ sharedSessionManager.request(params.url.absoluteString, method: method, parameters:params.done(), encoding: newEncoding, headers:headers).validate().responseData{response in LogInfo("请求地址:\(params.url)") LogInfo("请求参数:\(params.params)") - SVProgressHUD.dismiss() + SVProgressHUD.dismiss(withDelay: 0.5) guard response.error == nil else { LogError("\(response.error!)") diff --git a/WanPai/Network/Services.swift b/WanPai/Network/Services.swift index f335cf9..13f5891 100644 --- a/WanPai/Network/Services.swift +++ b/WanPai/Network/Services.swift @@ -182,6 +182,48 @@ } } +// MARK: -- 活动赛事相关 +extension Services{ + + /// 获取赛事列表 + class func queryCompetitionList(cityCode:Int?,content:String?,heat:SortType?,registerCondition:Int?)->Observable<BaseResponse<[ActivityListModel]>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/competition/base/competition/queryCompetitionList") + .append(key: "cityCode", value: cityCode) + .append(key: "content", value: content) + .append(key: "heat", value: heat?.rawValue) + .append(key: "registerCondition", value: registerCondition) + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + /// 获取赛事详情 + class func queryCompetitionDetail(id:Int)->Observable<BaseResponse<SimpleModel>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/competition/base/competition/queryCompetitionInfo") + .append(key: "id", value: id) + .append(key: "lat", value: locationTool.currentLocation?.coordinate.latitude.string) + .append(key: "lon", value: locationTool.currentLocation?.coordinate.longitude.string) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + /// 获取已报名赛事列表 + class func queryMyCompetitionList(page:Int,pageSize:Int = 20,type:SignupType)->Observable<BaseResponse<[ActivityListModel]>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/competition/api/competition/queryMyCompetitionList") + .append(key: "pageNo", value: page) + .append(key: "pageSize", value: pageSize) + .append(key: "type", value: type.rawValue) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + ///获取所有开通城市 + class func queryAllCity()->Observable<BaseResponse<String>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "other/base/store/queryAllCity") + return NetworkRequest.request(params: params, method: .post, progress: true) + } +} + // MARK: -- 其他 extension Services{ class func queryProtocol(_ type:AgreentType,progress:Bool = true)->Observable<BaseResponse<String>>{ @@ -204,6 +246,22 @@ .append(key: "payType", value: paytype.rawValue) return NetworkRequest.request(params: params, method: .post, progress: true) } + + /// 获取省市数据 + class func queryProvinceAndCity(pcode:String? = nil)->Observable<BaseResponse<[CityProfileModel]>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/other/base/store/queryProvinceAndCity") + .append(key: "pcode", value: pcode) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + /// 获取城市code获取门店 + class func queryStoreAtCity(cityCode:String)->Observable<BaseResponse<[CityProfileModel]>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/other//base/store/queryStoreByCityCode") + .append(key: "cityCode", value: cityCode) + return NetworkRequest.request(params: params, method: .post, progress: true) + } } extension Services{ diff --git a/WanPai/Root/Activity/TCell/ActivityInfoTCell.swift b/WanPai/Root/Activity/TCell/ActivityInfoTCell.swift index fad3068..d1a3fa3 100644 --- a/WanPai/Root/Activity/TCell/ActivityInfoTCell.swift +++ b/WanPai/Root/Activity/TCell/ActivityInfoTCell.swift @@ -6,15 +6,41 @@ // import UIKit +import JQTools class ActivityInfoTCell: UITableViewCell { + var activityListModel:ActivityListModel?{ + didSet{ + if let m = activityListModel{ + img_profile.sd_setImage(with: URL(string: m.coverDrawing)!) + label_title.text = m.name + + var temp = [String]() + temp.append(m.cityName) + temp.append(m.registerCondition.strTitle) + + label_limit.text = temp.joined(separator: "|") + label_info.text = m.introduction + label_duetime.text = "截止报名:" + m.registerEndTime + label_ageScope.text = m.age + label_hot.text = "\(m.heat)" + } + } + } + @IBOutlet weak var label_state: UILabel! - + @IBOutlet weak var img_profile: UIImageView! + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var label_limit: UILabel! + @IBOutlet weak var label_info: UILabel! + @IBOutlet weak var label_duetime: UILabel! + @IBOutlet weak var label_ageScope: UILabel! + @IBOutlet weak var label_hot: UILabel! + override func awakeFromNib() { super.awakeFromNib() selectionStyle = .none - } override func layoutSubviews() { diff --git a/WanPai/Root/Activity/TCell/ActivityInfoTCell.xib b/WanPai/Root/Activity/TCell/ActivityInfoTCell.xib index 94f12c0..01f5c63 100644 --- a/WanPai/Root/Activity/TCell/ActivityInfoTCell.xib +++ b/WanPai/Root/Activity/TCell/ActivityInfoTCell.xib @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <device id="retina6_12" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/> <capability name="Named colors" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/> @@ -19,7 +19,7 @@ <rect key="frame" x="0.0" y="0.0" width="489" height="185"/> <autoresizingMask key="autoresizingMask"/> <subviews> - <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="lCa-en-qcl"> + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="lCa-en-qcl"> <rect key="frame" x="15" y="21" width="105" height="140"/> <color key="backgroundColor" systemColor="systemGray6Color"/> <constraints> @@ -82,7 +82,7 @@ <constraint firstAttribute="height" constant="0.40000000000000002" id="bBX-ct-nwS"/> </constraints> </view> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sdT-Zi-Mxo"> + <button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sdT-Zi-Mxo"> <rect key="frame" x="390" y="130" width="86" height="31"/> <color key="backgroundColor" name="FE6E0D"/> <constraints> @@ -155,7 +155,14 @@ </tableViewCellContentView> <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> <connections> + <outlet property="img_profile" destination="lCa-en-qcl" id="MfP-5h-Hkk"/> + <outlet property="label_ageScope" destination="ymb-ff-rLX" id="YkH-bf-Rmd"/> + <outlet property="label_duetime" destination="9O5-p4-WaJ" id="tD2-3p-hTr"/> + <outlet property="label_hot" destination="dC6-S9-Yzg" id="zUF-7s-2vR"/> + <outlet property="label_info" destination="6i5-yn-dMM" id="ZED-zE-MUS"/> + <outlet property="label_limit" destination="Pj9-n0-bRl" id="qmE-VE-BLo"/> <outlet property="label_state" destination="dDz-PN-B0q" id="MxD-ut-Nvh"/> + <outlet property="label_title" destination="rom-jP-xgQ" id="9sb-b0-rvH"/> </connections> <point key="canvasLocation" x="168.70229007633588" y="70.070422535211264"/> </tableViewCell> @@ -163,7 +170,7 @@ <resources> <image name="icon_hot" width="15" height="19"/> <namedColor name="FE6E0D"> - <color red="0.99599999189376831" green="0.4309999942779541" blue="0.050999999046325684" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + <color red="0.99199998378753662" green="0.53299999237060547" blue="0.0080000003799796104" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> </namedColor> <systemColor name="systemGray6Color"> <color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> diff --git a/WanPai/Root/Activity/VC/ActivityDetailVC.swift b/WanPai/Root/Activity/VC/ActivityDetailVC.swift index 0e7ef8c..5b08866 100644 --- a/WanPai/Root/Activity/VC/ActivityDetailVC.swift +++ b/WanPai/Root/Activity/VC/ActivityDetailVC.swift @@ -8,10 +8,25 @@ import UIKit class ActivityDetailVC: BaseVC { + private var id:Int! + + + required init(id:Int) { + super.init(nibName: nil, bundle: nil) + self.id = id + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } override func viewDidLoad() { super.viewDidLoad() title = "活动详情" + + Services.queryCompetitionDetail(id: id).subscribe(onNext: {data in + + }).disposed(by: disposeBag) } @IBAction func joinAction(_ sender: UIButton) { diff --git a/WanPai/Root/Activity/VC/ActivityListVC.swift b/WanPai/Root/Activity/VC/ActivityListVC.swift index 348d580..6702618 100644 --- a/WanPai/Root/Activity/VC/ActivityListVC.swift +++ b/WanPai/Root/Activity/VC/ActivityListVC.swift @@ -7,6 +7,20 @@ import UIKit import QMUIKit +import RxSwift +import RxCocoa + +class ActivityListViewModel:RefreshModel<ActivityListModel>{ + + var city = 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: city.value, content: content.value, heat: heat.value, registerCondition: registerCondition.value?.rawValue) + } +} class ActivityListVC: BaseVC { @IBOutlet weak var view_top: UIView! @@ -14,17 +28,26 @@ @IBOutlet weak var btn_holdCity: QMUIButton! @IBOutlet weak var btn_joinCondition: QMUIButton! @IBOutlet weak var btn_hotFilter: QMUIButton! - @IBOutlet weak var tableView: UITableView! + @IBOutlet weak var tableView: BaseTableView! + + private var courseSubTypeView:CourseSubTypeView? + private var cityChooseSubTypeView:CityChooseSubTypeView? + + private var viewModel = ActivityListViewModel() override func viewDidLoad() { super.viewDidLoad() title = "赛事活动列表" + viewModel.configure(tableView,needMore: false) + viewModel.beginRefresh() } override func setUI() { tableView.delegate = self tableView.dataSource = self + tf_search.delegate = self tableView.register(UINib(nibName: "ActivityInfoTCell", bundle: nil), forCellReuseIdentifier: "_ActivityInfoTCell") + tableView.jq_setEmptyView() btn_holdCity.imagePosition = .right btn_holdCity.spacingBetweenImageAndTitle = 5 @@ -35,55 +58,93 @@ 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) { - guard !btn_holdCity.isSelected else {return} - btn_holdCity.isSelected = true - CityChooseSubTypeView.show(inView: self.view, afterView: view_top) { text in - + guard !sender.isSelected else {return} + hiddenMenu() + sender.isSelected = true + cityChooseSubTypeView = CityChooseSubTypeView.show(inView: self.view, afterView: view_top) { text in + sender.setTitle(text, for: .normal) + sender.isSelected = false } closeClouse: { - self.btn_holdCity.isSelected = false + sender.isSelected = false } } @IBAction func signupConditionAction(_ sender: QMUIButton) { guard !sender.isSelected else {return} + hiddenMenu() sender.isSelected = true - let items = Array<NormalSimpleModel>() - CourseSubTypeView.show(inView: self.view, afterView: btn_joinCondition, items: items) { m in + 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) { [weak self] m in + sender.setTitle(m.name, for: .normal) sender.isSelected = false - + self?.viewModel.registerCondition.accept(RegisterAcitivyType(rawValue: m.id)) + self?.viewModel.beginRefresh() } closeClouse: { sender.isSelected = false } } + @IBAction func hotFliterAction(_ sender: UIButton) { + 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) { 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 vc = ActivityDetailVC() + 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 return cell } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 5 + return viewModel.dataSource.value.count + } +} + +extension ActivityListVC:QMUITextFieldDelegate{ + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + textField.resignFirstResponder() + viewModel.beginRefresh() + return true } } diff --git a/WanPai/Root/Activity/VC/ActivityListVC.xib b/WanPai/Root/Activity/VC/ActivityListVC.xib index 5119a68..1340dd4 100644 --- a/WanPai/Root/Activity/VC/ActivityListVC.xib +++ b/WanPai/Root/Activity/VC/ActivityListVC.xib @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <device id="retina6_12" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/> <capability name="Named colors" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/> @@ -108,11 +108,13 @@ <rect key="frame" x="240" y="0.0" width="60" height="52"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> - <state key="normal" title="热度" image="icon_aes"> + <state key="normal" title="热度" image="icon_sort_normal"> <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> </state> - <state key="selected" image="icon_des"/> <state key="highlighted" image="icon_sort_normal"/> + <connections> + <action selector="hotFliterAction:" destination="-1" eventType="touchUpInside" id="4YK-dp-Pvn"/> + </connections> </button> </subviews> </stackView> @@ -143,7 +145,7 @@ </userDefinedRuntimeAttribute> </userDefinedRuntimeAttributes> </view> - <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="oPv-XK-by8"> + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="oPv-XK-by8" customClass="BaseTableView" customModule="WanPai" customModuleProvider="target"> <rect key="frame" x="0.0" y="174" width="393" height="644"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/> </tableView> @@ -181,14 +183,12 @@ </view> </objects> <resources> - <image name="icon_aes" width="27" height="30"/> - <image name="icon_des" width="27" height="30"/> <image name="icon_down_arrow" width="20" height="14"/> <image name="icon_down_arrow_s" width="20" height="14"/> <image name="icon_search" width="17" height="17"/> <image name="icon_sort_normal" width="27" height="30"/> <namedColor name="FE6E0D"> - <color red="0.99599999189376831" green="0.4309999942779541" blue="0.050999999046325684" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + <color red="0.99199998378753662" green="0.53299999237060547" blue="0.0080000003799796104" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> </namedColor> <systemColor name="systemBackgroundColor"> <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> diff --git a/WanPai/Root/Activity/VC/ActivitySignupListSubVC.swift b/WanPai/Root/Activity/VC/ActivitySignupListSubVC.swift index bd94e44..06dcc65 100644 --- a/WanPai/Root/Activity/VC/ActivitySignupListSubVC.swift +++ b/WanPai/Root/Activity/VC/ActivitySignupListSubVC.swift @@ -7,28 +7,31 @@ import UIKit import JQTools +import RxSwift +import RxCocoa + +class ActivitySignupViewModel:RefreshModel<ActivityListModel>{ + var type = BehaviorRelay<SignupType>(value: .all) + override func api() -> (Observable<BaseResponse<[ActivityListModel]>>)? { + return Services.queryMyCompetitionList(page: page,pageSize: 20, type: type.value) + } +} class ActivitySignupListSubVC: BaseVC { + + var viewModel = ActivitySignupViewModel() - enum SignupType:Int { - case all = 0 - case ongoing - case over - case prepare - case cancel - } - - var signupType:SignupType! - - lazy private var tableView:UITableView = { - let tableView = UITableView(frame: .zero, style: .plain) + lazy private var tableView:BaseTableView = { + let tableView = BaseTableView(frame: .zero, style: .plain) + tableView.delegate = self + tableView.dataSource = self + tableView.register(UINib(nibName: "ActivityInfoTCell", bundle: nil), forCellReuseIdentifier: "_ActivityInfoTCell") return tableView }() - init(type:SignupType) { super.init(nibName: nil, bundle: nil) - self.signupType = type + viewModel.type.accept(type) } required init?(coder: NSCoder) { @@ -37,14 +40,15 @@ override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .jq_randomColor + view.backgroundColor = .white + + tableView.jq_setEmptyView() + viewModel.configure(tableView) + viewModel.beginRefresh() } override func setUI() { view.addSubview(tableView) - tableView.delegate = self - tableView.dataSource = self - tableView.register(UINib(nibName: "ActivityInfoTCell", bundle: nil), forCellReuseIdentifier: "_ActivityInfoTCell") tableView.snp.makeConstraints { make in make.edges.equalToSuperview() } @@ -53,6 +57,7 @@ extension ActivitySignupListSubVC:UITableViewDelegate{ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let model = viewModel.dataSource.value[indexPath.row] let vc = ActivitySignupDetailVC() push(vc: vc) } @@ -65,6 +70,6 @@ } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 5 + return viewModel.dataSource.value.count } } diff --git a/WanPai/Root/Activity/VC/ActivitySignupListVC.swift b/WanPai/Root/Activity/VC/ActivitySignupListVC.swift index 251b6a0..ae132f4 100644 --- a/WanPai/Root/Activity/VC/ActivitySignupListVC.swift +++ b/WanPai/Root/Activity/VC/ActivitySignupListVC.swift @@ -88,11 +88,11 @@ } func totalPagesOfpageViewController(_ pageViewConteoller: FFPageViewController) -> UInt { - return 5 + return pageMenu.numberOfItems } func pageViewController(_ pageViewConteoller: FFPageViewController, controllerForPage page: Int) -> UIViewController { - let vc = ActivitySignupListSubVC(type: ActivitySignupListSubVC.SignupType(rawValue: page)!) + let vc = ActivitySignupListSubVC(type:SignupType(rawValue: page)!) return vc } diff --git a/WanPai/Root/Course/View/CityChooseSubTypeView.swift b/WanPai/Root/Course/View/CityChooseSubTypeView.swift index a587f1f..364cbb5 100644 --- a/WanPai/Root/Course/View/CityChooseSubTypeView.swift +++ b/WanPai/Root/Course/View/CityChooseSubTypeView.swift @@ -10,6 +10,7 @@ class CityChooseSubTypeView: UIView,JQNibView{ @IBOutlet weak var cons_viewHeight: NSLayoutConstraint! + @IBOutlet weak var label_city: UILabel! private var closeClouse:(()->Void)? private var clouse:((String)->Void)? @@ -18,10 +19,11 @@ cons_viewHeight.constant = 100 alpha = 0 layoutIfNeeded() + startLocation() } - - - static func show(inView:UIView,afterView:UIView,clouse:@escaping (String)->Void,closeClouse:@escaping ()->Void){ + + @discardableResult + static func show(inView:UIView,afterView:UIView,clouse:@escaping (String)->Void,closeClouse:@escaping ()->Void)->CityChooseSubTypeView{ let subTypeView = CityChooseSubTypeView.jq_loadNibView() subTypeView.closeClouse = closeClouse subTypeView.clouse = clouse @@ -39,6 +41,7 @@ subTypeView.layoutIfNeeded() } } + return subTypeView } @@ -52,4 +55,19 @@ self.closeClouse!() } } + + private func startLocation(){ + locationTool.startLocation { location in + locationTool.geocoder(location) { [weak self] marks, error in + self?.label_city.text = marks?.last?.locality ?? "定位失败" + locationTool.stopLocation() + } + } errorClouse: { error in + locationTool.stopLocation() + } + } + + @IBAction func reLocationAction(_ sender: Any) { + startLocation() + } } diff --git a/WanPai/Root/Course/View/CityChooseSubTypeView.xib b/WanPai/Root/Course/View/CityChooseSubTypeView.xib index ac64cab..70eccf1 100644 --- a/WanPai/Root/Course/View/CityChooseSubTypeView.xib +++ b/WanPai/Root/Course/View/CityChooseSubTypeView.xib @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <device id="retina6_12" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/> <capability name="Named colors" minToolsVersion="9.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> @@ -24,8 +24,8 @@ <color key="textColor" red="0.23921568627450979" green="0.24313725490196078" blue="0.27058823529411763" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="--" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VXl-8W-S4W"> - <rect key="frame" x="85.666666666666671" y="14" width="13" height="17"/> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="定位中" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VXl-8W-S4W"> + <rect key="frame" x="85.666666666666671" y="14" width="43.000000000000014" height="17"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <color key="textColor" name="FE6E0D"/> <nil key="highlightedColor"/> @@ -37,6 +37,9 @@ <state key="normal" title="重新定位" image="btn_local"> <color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> </state> + <connections> + <action selector="reLocationAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="fWo-Ur-i0U"/> + </connections> </button> <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="TJg-Td-Jbc"> <rect key="frame" x="0.0" y="52" width="393" height="48"/> @@ -79,6 +82,7 @@ <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> <connections> <outlet property="cons_viewHeight" destination="eEu-f9-Ced" id="DiD-Kz-VSh"/> + <outlet property="label_city" destination="VXl-8W-S4W" id="75K-gD-yyi"/> </connections> <point key="canvasLocation" x="72" y="21"/> </view> @@ -86,7 +90,7 @@ <resources> <image name="btn_local" width="14" height="14"/> <namedColor name="FE6E0D"> - <color red="0.99599999189376831" green="0.4309999942779541" blue="0.050999999046325684" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + <color red="0.99199998378753662" green="0.53299999237060547" blue="0.0080000003799796104" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> </namedColor> <systemColor name="systemBackgroundColor"> <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> diff --git a/WanPai/Root/Home/VC/HomeVC.swift b/WanPai/Root/Home/VC/HomeVC.swift index 157e4e1..bfc5aea 100644 --- a/WanPai/Root/Home/VC/HomeVC.swift +++ b/WanPai/Root/Home/VC/HomeVC.swift @@ -19,7 +19,7 @@ let storeId = BehaviorRelay<Int>(value: 0) override func api() -> (Observable<BaseResponse<[HomeStoreConfigModel]>>)? { - return Services.homeStoreConfig(storeId: 1) + return Services.homeStoreConfig(storeId: storeId.value) } } @@ -138,7 +138,10 @@ @IBAction func chooseStoresAction(_ sender: TapBtn) { - StoresChooseView.show() + StoresChooseView.show { [weak self] storeId in + self?.viewModel.storeId.accept(storeId.int!) + self?.viewModel.beginRefresh() + } } override var preferredStatusBarStyle: UIStatusBarStyle{ diff --git a/WanPai/Root/Other/View/StoresChooseView.swift b/WanPai/Root/Other/View/StoresChooseView.swift index 12b9ef8..100138b 100644 --- a/WanPai/Root/Other/View/StoresChooseView.swift +++ b/WanPai/Root/Other/View/StoresChooseView.swift @@ -1,17 +1,33 @@ -// -// StoresChooseView.swift -// WanPai -// -// Created by 杨锴 on 2023/6/9. -// + // + // StoresChooseView.swift + // WanPai + // + // Created by 杨锴 on 2023/6/9. + // import UIKit import JQTools +import RxSwift class StoresChooseView: UIView,JQNibView{ @IBOutlet weak var view_container: UIView! @IBOutlet weak var label_currently: UILabel! + @IBOutlet weak var label_province: UILabel! + @IBOutlet weak var label_city: UILabel! + + + private var provinceModel:CityProfileModel? + private var cityModel:CityProfileModel? + private var storeModel:CityProfileModel? + + private var provincesModel = [CityProfileModel]() + private var citysModel = [CityProfileModel]() + private var storesModel = [CityProfileModel]() + + + private var clouse:((String)->Void)! + private let disposeBag = DisposeBag() override func awakeFromNib() { super.awakeFromNib() @@ -20,15 +36,36 @@ layoutIfNeeded() } - static func show(){ + static func show(_ clouse:@escaping (String)->Void){ let storesView = StoresChooseView.jq_loadNibView() + storesView.clouse = clouse storesView.frame = screnDelegate?.window?.frame ?? .zero screnDelegate?.window?.addSubview(storesView) UIView.animate(withDuration: 0.4) { storesView.view_container.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) storesView.alpha = 1 + }completion: { _ in + storesView.getData() } + } + + private func getData(_ provinceId:String? = nil){ + Services.queryProvinceAndCity(pcode: provinceId).subscribe(onNext: { [weak self] data in + guard let weakSelf = self else { return } + if provinceId == nil{ + weakSelf.provincesModel = data.data ?? [] + }else{ + weakSelf.citysModel = data.data ?? [] + } + }).disposed(by: disposeBag) + } + + private func getStore(_ cityCode:String){ + Services.queryStoreAtCity(cityCode: cityCode).subscribe(onNext: { [weak self] data in + guard let weakSelf = self else { return } + weakSelf.storesModel = data.data ?? [] + }).disposed(by: disposeBag) } private func close(){ @@ -39,20 +76,63 @@ self.removeFromSuperview() } } - - @IBAction func tapChooseAction(_ sender: TapBtn) { - JQ_MenuView().show(self, tapView: sender, items: ["1","2","3","3","3","3","3","3","3","3"], menuWidth: sender.jq_width, tableHei: 200) { index, str in - + + @IBAction func provinceAction(_ sender: TapBtn) { + guard provincesModel.count != 0 else { + alertError(msg: "省级获取失败,正在重新获取") + getData() + return + } + + let names = provincesModel.map({$0.name}) + JQ_MenuView().show(self, tapView: sender, items: names, menuWidth: sender.jq_width, tableHei: 200) { [weak self] index, str in + guard let weakSelf = self else { return } + weakSelf.provinceModel = weakSelf.provincesModel[index] + weakSelf.label_province.text = weakSelf.provinceModel?.name ?? "" + weakSelf.getData(weakSelf.provinceModel!.code) } } - + + @IBAction func cityAction(_ sender: TapBtn) { + guard provinceModel != nil else {alertError(msg: "请先选择省份");return} + guard citysModel.count != 0 else {alertError(msg: "当前城市未开通");return} + JQ_MenuView().show(self, tapView: sender, items: citysModel.map({$0.name}), menuWidth: sender.jq_width, tableHei: 200) { [weak self] index, str in + guard let weakSelf = self else { return } + weakSelf.cityModel = weakSelf.citysModel[index] + weakSelf.label_city.text = weakSelf.cityModel?.name ?? "" + weakSelf.getStore(weakSelf.cityModel!.code) + } + } + + + @IBAction func storeAction(_ sender: TapBtn) { + guard provincesModel.count != 0 else { + alertError(msg: "请先选择省份");return + } + + guard citysModel.count != 0 else { + alertError(msg: "请先选城市");return + } + + JQ_MenuView().show(self, tapView: sender, items: storesModel.map({$0.name}), menuWidth: sender.jq_width, tableHei: 200) { [weak self] index, str in + guard let weakSelf = self else { return } + weakSelf.storeModel = weakSelf.storesModel[index] + weakSelf.label_currently.text = weakSelf.storeModel?.name ?? "" + } + } + @IBAction func closeAction(_ sender: UIButton) { close() } @IBAction func completeAction(_ sender: UIButton) { + guard storeModel != nil else { + alertError(msg: "请选择门店名称");return + } + close() + clouse?(storeModel!.code) } } diff --git a/WanPai/Root/Other/View/StoresChooseView.xib b/WanPai/Root/Other/View/StoresChooseView.xib index 9b4abaf..9694317 100644 --- a/WanPai/Root/Other/View/StoresChooseView.xib +++ b/WanPai/Root/Other/View/StoresChooseView.xib @@ -58,7 +58,7 @@ </userDefinedRuntimeAttribute> </userDefinedRuntimeAttributes> <connections> - <action selector="tapChooseAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="F2e-Ck-cxo"/> + <action selector="storeAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="dox-kC-YBa"/> </connections> </view> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Gtx-K4-ldi"> @@ -138,7 +138,7 @@ </userDefinedRuntimeAttribute> </userDefinedRuntimeAttributes> <connections> - <action selector="tapChooseAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="rX9-r7-Idz"/> + <action selector="provinceAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="vef-S3-5AI"/> </connections> </view> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="省" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TQ0-7y-gmP"> @@ -186,7 +186,7 @@ </userDefinedRuntimeAttribute> </userDefinedRuntimeAttributes> <connections> - <action selector="tapChooseAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="n7R-6I-v9d"/> + <action selector="cityAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="5vF-hp-RTX"/> </connections> </view> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="市" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bpE-eg-Ouo"> @@ -242,7 +242,9 @@ <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="ea6-eG-h1P" secondAttribute="trailing" constant="45" id="plg-Gp-drS"/> </constraints> <connections> + <outlet property="label_city" destination="flf-S9-xVu" id="v3g-jV-5QT"/> <outlet property="label_currently" destination="sjM-7I-k3g" id="zoR-nM-OxD"/> + <outlet property="label_province" destination="LHk-zb-Nvv" id="MLz-S0-HOJ"/> <outlet property="view_container" destination="ea6-eG-h1P" id="BWb-nv-CLC"/> </connections> <point key="canvasLocation" x="139.69465648854961" y="20.422535211267608"/> diff --git a/WanPai/ViewModel/RefreshModel.swift b/WanPai/ViewModel/RefreshModel.swift index 2f3c03a..b9a04d8 100644 --- a/WanPai/ViewModel/RefreshModel.swift +++ b/WanPai/ViewModel/RefreshModel.swift @@ -116,6 +116,7 @@ class CustomRefreshFooter:MJRefreshAutoNormalFooter{ static func refreshing(with refreshingBlock: @escaping MJRefreshComponentAction) -> MJRefreshAutoNormalFooter? { let refrehFooter = MJRefreshAutoNormalFooter(refreshingBlock: refreshingBlock) + refrehFooter.isRefreshingTitleHidden = true return refrehFooter } } @@ -130,18 +131,20 @@ case .refreshing: self.base.reloadData() self.base.mj_footer?.resetNoMoreData() - self.base.mj_header?.endRefreshing() + self.base.mj_header?.beginRefreshing() case .completedLoadWithNoMoreData: DispatchQueue.main.async { self.base.reloadData() } self.base.mj_footer?.endRefreshingWithNoMoreData() + self.base.mj_header?.endRefreshing() case .completedLoad: DispatchQueue.main.async { self.base.reloadData() } self.base.mj_footer?.endRefreshing() + self.base.mj_header?.endRefreshing() default: DispatchQueue.main.async { self.base.reloadData() -- Gitblit v1.7.1