| | |
| | | // |
| | | // YardDetailVC.swift |
| | | // WanPai |
| | | // |
| | | // Created by 无故事王国 on 2023/6/19. |
| | | // |
| | | // |
| | | // YardDetailVC.swift |
| | | // WanPai |
| | | // |
| | | // Created by 无故事王国 on 2023/6/19. |
| | | // |
| | | |
| | | import UIKit |
| | | import QMUIKit |
| | |
| | | |
| | | |
| | | class YardDetailDateManager { |
| | | private static var _sharedInstance: YardDetailDateManager? |
| | | private static var _sharedInstance: YardDetailDateManager? |
| | | |
| | | class func shared() -> YardDetailDateManager { |
| | | guard let instance = _sharedInstance else { |
| | | _sharedInstance = YardDetailDateManager() |
| | | return _sharedInstance! |
| | | } |
| | | return instance |
| | | } |
| | | class func shared() -> YardDetailDateManager { |
| | | guard let instance = _sharedInstance else { |
| | | _sharedInstance = YardDetailDateManager() |
| | | return _sharedInstance! |
| | | } |
| | | return instance |
| | | } |
| | | |
| | | private init() {} // 私有化init方法 |
| | | private init() {} // 私有化init方法 |
| | | |
| | | var dates = BehaviorRelay<[String:[SiteDetailDateTimeModel]]>(value: [:]) |
| | | var dates = BehaviorRelay<[String:[SiteDetailDateTimeModel]]>(value: [:]) |
| | | |
| | | //销毁单例对象 |
| | | class func destroy() { |
| | | _sharedInstance = nil |
| | | } |
| | | //销毁单例对象 |
| | | class func destroy() { |
| | | _sharedInstance = nil |
| | | } |
| | | } |
| | | |
| | | class YardDetailVC: BaseVC { |
| | |
| | | @IBOutlet weak var scrollView: UIScrollView! |
| | | @IBOutlet weak var view_banner: CommonBannerView! |
| | | @IBOutlet weak var btn_calendar: QMUIButton! |
| | | @IBOutlet weak var collectionView: UICollectionView! |
| | | @IBOutlet weak var view_pages: UIView! |
| | | @IBOutlet weak var cons_pagesHei: NSLayoutConstraint! |
| | | @IBOutlet weak var view_coupon: UIView! |
| | | @IBOutlet weak var label_name: UILabel! |
| | | @IBOutlet weak var label_typeName: UILabel! |
| | | @IBOutlet weak var label_address: UILabel! |
| | | @IBOutlet weak var label_cashPrice: UILabel! |
| | | @IBOutlet weak var label_coinPrice: UILabel! |
| | | @IBOutlet weak var label_datetime: UILabel! |
| | | @IBOutlet weak var tf_person: UITextField! |
| | | @IBOutlet weak var tf_phone: QMUITextField! |
| | | @IBOutlet weak var label_selectTimes: UILabel! |
| | | @IBOutlet weak var label_totalHours: UILabel! |
| | | @IBOutlet weak var label_price: UILabel! |
| | | @IBOutlet weak var btn_coupon: UIButton! |
| | | @IBOutlet weak var collectionView: UICollectionView! |
| | | @IBOutlet weak var view_pages: UIView! |
| | | @IBOutlet weak var cons_pagesHei: NSLayoutConstraint! |
| | | @IBOutlet weak var view_coupon: UIView! |
| | | @IBOutlet weak var label_name: UILabel! |
| | | @IBOutlet weak var label_typeName: UILabel! |
| | | @IBOutlet weak var label_address: UILabel! |
| | | @IBOutlet weak var label_cashPrice: UILabel! |
| | | @IBOutlet weak var label_coinPrice: UILabel! |
| | | @IBOutlet weak var label_datetime: UILabel! |
| | | @IBOutlet weak var tf_person: UITextField! |
| | | @IBOutlet weak var tf_phone: QMUITextField! |
| | | @IBOutlet weak var label_selectTimes: UILabel! |
| | | @IBOutlet weak var label_totalHours: UILabel! |
| | | @IBOutlet weak var label_price: UILabel! |
| | | @IBOutlet weak var btn_coupon: UIButton! |
| | | @IBOutlet weak var btn_fullYard: QMUIButton! |
| | | @IBOutlet weak var btn_halfYard: QMUIButton! |
| | | @IBOutlet weak var collection_halfYard: UICollectionView! |
| | |
| | | @IBOutlet weak var view_selectYardType: UIView! |
| | | @IBOutlet weak var web_introduce: WKWebView! |
| | | @IBOutlet weak var cons_webHei: NSLayoutConstraint! |
| | | |
| | | private var coupons = [CouponInfoModel]() |
| | | private var selectCouponModel:CouponInfoModel? |
| | | |
| | | private var coupons = [CouponInfoModel]() |
| | | private var selectCouponModel:CouponInfoModel? |
| | | private let yardCellW = (JQ_ScreenW - 144) / 3 |
| | | private var halfIndex:Int? |
| | | private var yardIndex:Int = 0 //场地 |
| | | |
| | | |
| | | lazy var pageViewController:FFPageViewController = { |
| | | let pageVC = FFPageViewController() |
| | | pageVC.view.backgroundColor = .clear |
| | | pageVC.scrollview.backgroundColor = .clear |
| | | pageVC.prePages = 2 |
| | | pageVC.scrollview.bounces = false |
| | | return pageVC |
| | | }() |
| | | lazy var pageViewController:FFPageViewController = { |
| | | let pageVC = FFPageViewController() |
| | | pageVC.view.backgroundColor = .clear |
| | | pageVC.scrollview.backgroundColor = .clear |
| | | pageVC.prePages = 2 |
| | | pageVC.scrollview.bounces = false |
| | | return pageVC |
| | | }() |
| | | |
| | | private var siteDetailModel:SiteDetailModel! |
| | | private var siteDetailDateTimeModel:SiteDetailDateTimeModel! |
| | | private var siteDetailModel:SiteDetailModel! |
| | | private var siteDetailDateTimeModel:SiteDetailDateTimeModel! |
| | | private let banner = CommonBannerView() |
| | | |
| | | private var id:Int! |
| | | private var cellW:Double! |
| | | private var selectIndex = 0 |
| | | private var weeklys = [Date]() |
| | | private var currentDate:Date?{ |
| | | didSet{ |
| | | if let d = currentDate{ |
| | | selectIndex = currentDate?.jq_nowWeekDay(identifier: .republicOfChina).index ?? 0 |
| | | weeklys = d.jq_currentWeekDates |
| | | collectionView.reloadData() |
| | | } |
| | | } |
| | | } |
| | | private var id:Int! |
| | | private var cellW:Double! |
| | | private var selectIndex = 0 |
| | | private var weeklys = [Date]() |
| | | private var currentDate:Date?{ |
| | | didSet{ |
| | | if let d = currentDate{ |
| | | selectIndex = currentDate?.jq_nowWeekDay(identifier: .republicOfChina).index ?? 0 |
| | | weeklys = d.jq_currentWeekDates |
| | | collectionView.reloadData() |
| | | } |
| | | } |
| | | } |
| | | |
| | | required init(id:Int){ |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.id = id |
| | | } |
| | | required init(id:Int){ |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.id = id |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "预约场地" |
| | | Services.querySiteDetail(id: id).subscribe(onNext: {[weak self] data in |
| | | guard let weakSelf = self else { return } |
| | | if let model = data.data{ |
| | | weakSelf.siteDetailModel = model |
| | | weakSelf.label_name.text = model.name |
| | | weakSelf.label_typeName.text = model.siteTypeName |
| | | weakSelf.label_address.text = String(format: "%@(%@)",model.storeName, model.storeAddress) |
| | | |
| | | weakSelf.label_cashPrice.attributedText = AttributedStringbuilder.build() |
| | | .add(string: "\(model.cashPrice.currency())/", withFont: UIFont.systemFont(ofSize: 18, weight: .medium), withColor: UIColor(hexStr: "#EC0808")) |
| | | .add(string: "半小时", withFont: UIFont.systemFont(ofSize: 14, weight: .medium), withColor: UIColor(hexStr: "#535353")).mutableAttributedString |
| | | |
| | | weakSelf.label_coinPrice.attributedText = AttributedStringbuilder.build() |
| | | .add(string: "\(model.playPaiCoin)币/", withFont: UIFont.systemFont(ofSize: 18, weight: .medium), withColor: UIColor(hexStr: "#EC0808")) |
| | | .add(string: "半小时", withFont: UIFont.systemFont(ofSize: 14, weight: .medium), withColor: UIColor(hexStr: "#535353")).mutableAttributedString |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "预约场地" |
| | | Services.querySiteDetail(id: id).subscribe(onNext: {[weak self] data in |
| | | guard let weakSelf = self else { return } |
| | | if let model = data.data{ |
| | | weakSelf.siteDetailModel = model |
| | | weakSelf.label_name.text = model.name |
| | | weakSelf.label_typeName.text = model.siteTypeName |
| | | weakSelf.label_address.text = String(format: "%@(%@)",model.storeName, model.storeAddress) |
| | | weakSelf.changePrice(cashPrice: model.cashPrice, coin: model.playPaiCoin, typeName: model.typeName) |
| | | weakSelf.view_yardType.isHidden = model.nextName.count == 0 |
| | | weakSelf.view_selectYardType.isHidden = model.ishalf == 2 |
| | | |
| | |
| | | } |
| | | |
| | | weakSelf.view_yardType.isHidden = model.nextName.filter({!$0.isEmpty}).count == 0 |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | override func setRx() { |
| | | YardDetailDateManager.shared().dates.subscribe(onNext: { [weak self] dict in |
| | | guard let weakSelf = self else { return } |
| | | guard weakSelf.siteDetailModel != nil else {return} |
| | | |
| | | if let a = dict.values.first,a.count > 0{ |
| | | let key = dict.keys.first! |
| | | weakSelf.label_price.text = String(format: "%@/%ld币", (Double(a.count) * weakSelf.siteDetailModel.cashPrice).currency(),a.count * weakSelf.siteDetailModel.playPaiCoin) |
| | | let prefix = a.first?.time.components(separatedBy: "-").first |
| | | let suffix = a.last?.time.components(separatedBy: "-").last |
| | | weakSelf.label_selectTimes.text = String(format: "%@ %@-%@",key,prefix ?? "",suffix ?? "") |
| | | weakSelf.label_totalHours.text = String(format: "(合计%.1lf小时)", Double(a.count) * 0.5) |
| | | weakSelf.queryCoupon(price: (Double(a.count) * weakSelf.siteDetailModel.cashPrice)) |
| | | }else{ |
| | | weakSelf.label_selectTimes.text = "未选择" |
| | | weakSelf.label_totalHours.text = "(合计0小时)" |
| | | weakSelf.label_price.text = "¥-/-币" |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | override func setRx() { |
| | | YardDetailDateManager.shared().dates.subscribe(onNext: { [weak self] dict in |
| | | guard let weakSelf = self else { return } |
| | | guard weakSelf.siteDetailModel != nil else {return} |
| | | |
| | | if let a = dict.values.first,a.count > 0{ |
| | | var cashPrice:Double = 0 |
| | | var coinPrice:Int = 0 |
| | | |
| | | if weakSelf.btn_halfYard.isSelected{ |
| | | cashPrice = weakSelf.siteDetailModel.cashPriceOne |
| | | coinPrice = weakSelf.siteDetailModel.playPaiCoinOne |
| | | }else{ |
| | | cashPrice = weakSelf.siteDetailModel.cashPrice |
| | | coinPrice = weakSelf.siteDetailModel.playPaiCoin |
| | | } |
| | | |
| | | let key = dict.keys.first! |
| | | weakSelf.label_price.text = String(format: "%@/%ld币", (Double(a.count) * cashPrice).currency(),a.count * coinPrice) |
| | | let prefix = a.first?.time.components(separatedBy: "-").first |
| | | let suffix = a.last?.time.components(separatedBy: "-").last |
| | | weakSelf.label_selectTimes.text = String(format: "%@ %@-%@",key,prefix ?? "",suffix ?? "") |
| | | weakSelf.label_totalHours.text = String(format: "(合计%.1lf小时)", Double(a.count) * 0.5) |
| | | weakSelf.queryCoupon(price: (Double(a.count) * cashPrice)) |
| | | }else{ |
| | | weakSelf.label_selectTimes.text = "未选择" |
| | | weakSelf.label_totalHours.text = "(合计0小时)" |
| | | weakSelf.label_price.text = "¥-/-币" |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | |
| | | web_introduce.scrollView.rx.observe(CGSize.self, "contentSize").map { (size) -> CGFloat? in |
| | | if let size = size{ |
| | |
| | | self.cons_webHei.constant = height |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | |
| | | override func setUI() { |
| | | view_coupon.isHidden = true |
| | | cellW = (JQ_ScreenW - 68.0) / 7.0 |
| | | btn_calendar.imagePosition = .top |
| | | btn_calendar.spacingBetweenImageAndTitle = 3 |
| | | cons_pagesHei.constant = 150 |
| | | override func setUI() { |
| | | view_coupon.isHidden = true |
| | | cellW = (JQ_ScreenW - 68.0) / 7.0 |
| | | btn_calendar.imagePosition = .top |
| | | btn_calendar.spacingBetweenImageAndTitle = 3 |
| | | cons_pagesHei.constant = 150 |
| | | |
| | | collectionView.register(UINib(nibName: "CalendarItemCCell", bundle: nil), forCellWithReuseIdentifier: "_CalendarItemCCell") |
| | | collectionView.delegate = self |
| | | collectionView.dataSource = self |
| | | collectionView.register(UINib(nibName: "CalendarItemCCell", bundle: nil), forCellWithReuseIdentifier: "_CalendarItemCCell") |
| | | collectionView.delegate = self |
| | | collectionView.dataSource = self |
| | | |
| | | addChild(pageViewController) |
| | | view_pages.insertSubview(pageViewController.view, at: 0) |
| | | pageViewController.didMove(toParent: self) |
| | | addChild(pageViewController) |
| | | view_pages.insertSubview(pageViewController.view, at: 0) |
| | | pageViewController.didMove(toParent: self) |
| | | |
| | | // pageViewController.view.frame = CGRect(x: 0, y: 0, width: view_pages.jq_width, height: view_pages.jq_height) |
| | | pageViewController.view.snp.makeConstraints { make in |
| | | make.edges.equalToSuperview() |
| | | } |
| | | pageViewController.delegate = self |
| | | // pageViewController.view.frame = CGRect(x: 0, y: 0, width: view_pages.jq_width, height: view_pages.jq_height) |
| | | pageViewController.view.snp.makeConstraints { make in |
| | | make.edges.equalToSuperview() |
| | | } |
| | | pageViewController.delegate = self |
| | | |
| | | btn_fullYard.spacingBetweenImageAndTitle = 13 |
| | | btn_halfYard.spacingBetweenImageAndTitle = 13 |
| | |
| | | view_selectYardType.isHidden = true |
| | | |
| | | scrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 75, right: 0) |
| | | } |
| | | } |
| | | |
| | | /// 查询优惠券 |
| | | private func queryCoupon(price:Double){ |
| | | Services.querySiteCouponList(price: price, siteId: siteDetailModel.id).subscribe(onNext: {[weak self] data in |
| | | if let models = data.data{ |
| | | self?.view_coupon.isHidden = models.count == 0 |
| | | self?.coupons = models |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | /// 查询优惠券 |
| | | private func queryCoupon(price:Double){ |
| | | Services.querySiteCouponList(price: price, siteId: siteDetailModel.id).subscribe(onNext: {[weak self] data in |
| | | if let models = data.data{ |
| | | self?.view_coupon.isHidden = models.count == 0 |
| | | self?.coupons = models |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | private func changePrice(cashPrice:Double,coin:Int,typeName:String){ |
| | | let att = AttributedStringbuilder.build() |
| | | att.add(string: "\(cashPrice.currency())/", withFont: UIFont.systemFont(ofSize: 18, weight: .medium), withColor: UIColor(hexStr: "#EC0808")) |
| | | if typeName == "智慧场地"{ |
| | | att.add(string: "15分钟", withFont: UIFont.systemFont(ofSize: 14, weight: .medium), withColor: UIColor(hexStr: "#535353")) |
| | | }else{ |
| | | att.add(string: "半小时", withFont: UIFont.systemFont(ofSize: 14, weight: .medium), withColor: UIColor(hexStr: "#535353")) |
| | | } |
| | | label_cashPrice.attributedText = att.mutableAttributedString |
| | | |
| | | let att1 = AttributedStringbuilder.build() |
| | | att1.add(string: "\(coin)币/", withFont: UIFont.systemFont(ofSize: 18, weight: .medium), withColor: UIColor(hexStr: "#EC0808")) |
| | | if typeName == "智慧场地"{ |
| | | att1.add(string: "15分钟", withFont: UIFont.systemFont(ofSize: 14, weight: .medium), withColor: UIColor(hexStr: "#535353")) |
| | | }else{ |
| | | att1.add(string: "半小时", withFont: UIFont.systemFont(ofSize: 14, weight: .medium), withColor: UIColor(hexStr: "#535353")) |
| | | } |
| | | label_coinPrice.attributedText = att1.mutableAttributedString |
| | | } |
| | | |
| | | @IBAction func halfYardTypeAction(_ sender: QMUIButton) { |
| | | btn_fullYard.isSelected = sender.tag == 200 |
| | |
| | | |
| | | if btn_fullYard.isSelected{ |
| | | halfIndex = nil |
| | | collection_halfYard.reloadData() |
| | | // changePrice(cashPrice: siteDetailModel.cashPrice, coin: siteDetailModel.playPaiCoin, typeName: siteDetailModel.typeName) |
| | | }else{ |
| | | halfIndex = 0 |
| | | // changePrice(cashPrice: siteDetailModel.cashPriceOne, coin: siteDetailModel.playPaiCoinOne, typeName: siteDetailModel.typeName) |
| | | } |
| | | |
| | | collection_halfYard.reloadData() |
| | | |
| | | UIView.animate(withDuration: 0.5) { |
| | | self.view_halfYard.isHidden = self.btn_fullYard.isSelected |
| | | self.view_halfYard.alpha = (self.view_halfYard.isHidden ? 0:1) |
| | | } |
| | | |
| | | //为了计算价格 【半场/全场】切换 |
| | | var val = YardDetailDateManager.shared().dates.value |
| | | val.removeAll() |
| | | YardDetailDateManager.shared().dates.accept(val) |
| | | |
| | | if let currentVC = pageViewController.currentController as? YardDetailDateTimeVC{ |
| | | currentVC.clearALL() |
| | | } |
| | | } |
| | | |
| | | |
| | | @IBAction func callPhoneAction(_ sender: UIButton) { |
| | | UIApplication.shared.open(URL(string: "tel://\(siteDetailModel.storePhone)")!) |
| | | } |
| | | |
| | | @IBAction func couponAction(_ sender: UIButton) { |
| | | CouponChooseView.show(coupons, defaultModel: selectCouponModel) { [weak self] m in |
| | | self?.selectCouponModel = m |
| | | @IBAction func callPhoneAction(_ sender: UIButton) { |
| | | UIApplication.shared.open(URL(string: "tel://\(siteDetailModel.storePhone)")!) |
| | | } |
| | | |
| | | @IBAction func couponAction(_ sender: UIButton) { |
| | | CouponChooseView.show(coupons, defaultModel: selectCouponModel) { [weak self] m in |
| | | self?.selectCouponModel = m |
| | | let string = m == nil ? "去选择":"-\(m!.favorable.currency())" |
| | | self?.btn_coupon.setTitle(string, for: .normal) |
| | | } |
| | | } |
| | | self?.btn_coupon.setTitle(string, for: .normal) |
| | | } |
| | | } |
| | | |
| | | @IBAction func calendarAction(_ sender: QMUIButton) { |
| | | CalendarPickerView.show(selectDate: currentDate) { [weak self] date in |
| | | let offsetDay = Date.jq_CalByDays(startDate: Date().jq_clearTimes(), endDate: date) |
| | | self?.pageViewController.scroll(toPage: offsetDay, animation: true) |
| | | self?.collectionView.reloadData() |
| | | } |
| | | } |
| | | @IBAction func calendarAction(_ sender: QMUIButton) { |
| | | CalendarPickerView.show(selectDate: currentDate) { [weak self] date in |
| | | let offsetDay = Date.jq_CalByDays(startDate: Date().jq_clearTimes(), endDate: date) |
| | | self?.pageViewController.scroll(toPage: offsetDay, animation: true) |
| | | self?.collectionView.reloadData() |
| | | } |
| | | } |
| | | |
| | | @IBAction func bookingAction(_ sender: UIButton) { |
| | | @IBAction func bookingAction(_ sender: UIButton) { |
| | | |
| | | guard !YardDetailDateManager.shared().dates.value.isEmpty else {alertError(msg: "请选择预约时间");return} |
| | | guard !tf_person.isEmpty else {alertError(msg: "请输入预约人");return} |
| | | guard !tf_phone.isEmpty else {alertError(msg: "请输入联系方式");return} |
| | | guard tf_phone.text!.jq_isPhone else {alertError(msg: "请输入正确的联系方式");return} |
| | | guard !tf_person.isEmpty else {alertError(msg: "请输入预约人");return} |
| | | guard !tf_phone.isEmpty else {alertError(msg: "请输入联系方式");return} |
| | | guard tf_phone.text!.jq_isPhone else {alertError(msg: "请输入正确的联系方式");return} |
| | | if btn_halfYard.isSelected && halfIndex == nil{ |
| | | alert(msg: "请选择半场");return |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | StoresInfoView.show(siteDetailModel) { [weak self] status in |
| | | guard let weakSelf = self else { return } |
| | | if status{ |
| | | let a = YardDetailDateManager.shared().dates.value.values.first! |
| | | let price = Double(a.count) * weakSelf.siteDetailModel.cashPrice |
| | | let coin = a.count * weakSelf.siteDetailModel.playPaiCoin |
| | | StoresInfoView.show(siteDetailModel) { [weak self] status in |
| | | guard let weakSelf = self else { return } |
| | | if status{ |
| | | let a = YardDetailDateManager.shared().dates.value.values.first! |
| | | let price = Double(a.count) * weakSelf.siteDetailModel.cashPrice |
| | | let coin = a.count * weakSelf.siteDetailModel.playPaiCoin |
| | | |
| | | var datetimes = [String]() |
| | | let key = YardDetailDateManager.shared().dates.value.keys.first! |
| | |
| | | } |
| | | |
| | | |
| | | PaymentView.show(money: (ali:price,wx:price,coin:coin,course:nil)) { [weak self] type in |
| | | guard let weakSelf = self else { return } |
| | | PaymentView.show(money: (ali:price,wx:price,coin:coin,course:nil,integral:nil)) { [weak self] type in |
| | | guard let weakSelf = self else { return } |
| | | Services.reservationSite(booker: weakSelf.tf_person.text!, couponId: weakSelf.selectCouponModel?.id, id: weakSelf.siteDetailModel.id, payType: type, phone: weakSelf.tf_phone.text!, times: datetimes.joined(separator: ";"),halfName:halfName,isHalf:isHalf,nextName:nextName).subscribe(onNext: { data in |
| | | if let m = data.data{ |
| | | switch type { |
| | | case .aliPay: |
| | | YYPaymentManager.shared.sendPaymentRequest(YYAlipayRequest(orderString: m.orderString)) { result in |
| | | switch result { |
| | | case .success: |
| | | let vc = PaymentResultVC(result: .success, objType: .yard,handleVC: weakSelf) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | case .cancel: |
| | | alert(msg: "交易取消") |
| | | case .failure(let error): |
| | | let vc = PaymentResultVC(result: .fail(error.localizedDescription), objType: .yard,handleVC: weakSelf) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | } |
| | | } |
| | | if let m = data.data{ |
| | | switch type { |
| | | case .aliPay: |
| | | YYPaymentManager.shared.sendPaymentRequest(YYAlipayRequest(orderString: m.orderString)) { result in |
| | | switch result { |
| | | case .success: |
| | | let vc = PaymentResultVC(result: .success, objType: .yard,handleVC: nil) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | case .cancel: |
| | | alert(msg: "交易取消") |
| | | case .failure(let error): |
| | | let vc = PaymentResultVC(result: .fail(error.localizedDescription), objType: .yard,handleVC: nil) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | } |
| | | } |
| | | |
| | | case .wechat:break |
| | | case .coin: |
| | | let vc = PaymentResultVC(result: .success, objType: .yard,handleVC: weakSelf) |
| | | case .wechat,.integral:break |
| | | case .coin: |
| | | let vc = PaymentResultVC(result: .success, objType: .yard,handleVC: nil) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | case .courseNum:break |
| | | } |
| | | } |
| | | case .courseNum:break |
| | | } |
| | | } |
| | | |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | },onError: { error in |
| | | if let er = error as? NetworkRequest.NetRequestError{ |
| | | switch er { |
| | | case .Other(_,let string): |
| | | let vc = PaymentResultVC(result: .fail(string), objType: .yard,handleVC: nil) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | default: |
| | | let vc = PaymentResultVC(result: .fail("支付失败"), objType: .yard,handleVC: nil) |
| | | vc.modalPresentationStyle = .fullScreen |
| | | weakSelf.present(vc, animated: true) |
| | | } |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | }else{ |
| | | weakSelf.navigationController?.popToRootViewController(animated: true) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | deinit{ |
| | | YardDetailDateManager.destroy() |
| | | } |
| | | deinit{ |
| | | YardDetailDateManager.destroy() |
| | | } |
| | | } |
| | | |
| | | extension YardDetailVC:FFPageViewControllerDelegate{ |
| | | |
| | | func pageViewController(_ pageViewController: FFPageViewController, currentPageChanged currentPage: Int) { |
| | | if let vc = pageViewController.currentController as? YardDetailDateTimeVC{ |
| | | currentDate = vc.date |
| | | label_datetime.text = vc.date.jq_format("yyyy年MM月dd日") |
| | | cons_pagesHei.constant = vc.innerHeight |
| | | UIView.animate(withDuration: 0.5) { |
| | | self.view.layoutIfNeeded() |
| | | } |
| | | } |
| | | } |
| | | func pageViewController(_ pageViewController: FFPageViewController, currentPageChanged currentPage: Int) { |
| | | if let vc = pageViewController.currentController as? YardDetailDateTimeVC{ |
| | | currentDate = vc.date |
| | | label_datetime.text = vc.date.jq_format("yyyy年MM月dd日") |
| | | cons_pagesHei.constant = vc.innerHeight |
| | | UIView.animate(withDuration: 0.5) { |
| | | self.view.layoutIfNeeded() |
| | | } |
| | | } |
| | | } |
| | | |
| | | func totalPagesOfpageViewController(_ pageViewConteoller: FFPageViewController) -> UInt { |
| | | return 11 |
| | | } |
| | | func totalPagesOfpageViewController(_ pageViewConteoller: FFPageViewController) -> UInt { |
| | | return 11 |
| | | } |
| | | |
| | | func pageViewController(_ pageViewConteoller: FFPageViewController, controllerForPage page: Int) -> UIViewController { |
| | | let date = Date().jq_add(day: page) |
| | | let vc = YardDetailDateTimeVC(id:id,date: date!,currentPage: page) |
| | | vc.updateInnerHeight { [weak self] (height, currentPage) in |
| | | if currentPage == self?.pageViewController.currentPage{ |
| | | self?.cons_pagesHei.constant = height |
| | | UIView.animate(withDuration: 0.3) { |
| | | self?.view.layoutIfNeeded() |
| | | } |
| | | } |
| | | } |
| | | return vc |
| | | } |
| | | func pageViewController(_ pageViewConteoller: FFPageViewController, controllerForPage page: Int) -> UIViewController { |
| | | let date = Date().jq_add(day: page) |
| | | let vc = YardDetailDateTimeVC(id:id,date: date!,currentPage: page) |
| | | vc.updateInnerHeight { [weak self] (height, currentPage) in |
| | | if currentPage == self?.pageViewController.currentPage{ |
| | | self?.cons_pagesHei.constant = height |
| | | UIView.animate(withDuration: 0.3) { |
| | | self?.view.layoutIfNeeded() |
| | | } |
| | | } |
| | | } |
| | | return vc |
| | | } |
| | | } |
| | | |
| | | |
| | | extension YardDetailVC:UICollectionViewDataSource{ |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | |
| | | if self.collectionView == collectionView{ |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_CalendarItemCCell", for: indexPath) as! CalendarItemCCell |
| | |
| | | return cell |
| | | } |
| | | |
| | | //选择半场: |
| | | //选择半场: |
| | | if collection_halfYard == collectionView{ |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_Common_1_CCell", for: indexPath) as! Common_1_CCell |
| | | cell.label_content.text = siteDetailModel.halfName[indexPath.row] |
| | |
| | | return cell |
| | | } |
| | | return UICollectionViewCell() |
| | | } |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | |
| | | if self.collectionView == collectionView{ |
| | | return weeklys.count |
| | |
| | | } |
| | | |
| | | return 0 |
| | | } |
| | | } |
| | | } |
| | | |
| | | extension YardDetailVC:UICollectionViewDelegate{ |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | |
| | | if self.collectionView == collectionView{ |
| | | let date = weeklys[indexPath.row] |
| | |
| | | } |
| | | |
| | | if self.collection_yardType == collectionView{ |
| | | if let currentVC = pageViewController.currentController as? YardDetailDateTimeVC{ |
| | | currentVC.clearALL() |
| | | } |
| | | |
| | | yardIndex = indexPath.row |
| | | collectionView.reloadData() |
| | | } |
| | | |
| | | if self.collection_halfYard == collectionView{ |
| | | if let currentVC = pageViewController.currentController as? YardDetailDateTimeVC{ |
| | | currentVC.clearALL() |
| | | } |
| | | halfIndex = indexPath.row |
| | | collectionView.reloadData() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | extension YardDetailVC:UICollectionViewDelegateFlowLayout{ |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
| | | |
| | | if self.collectionView == collectionView{ |
| | | return CGSize(width: cellW, height: 50) |
| | | } |
| | | |
| | | return CGSize(width: yardCellW, height: yardCellW * 0.439) |
| | | } |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { |
| | | if self.collectionView == collectionView{ |
| | | return 0 |
| | | } |
| | | return 21 |
| | | } |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { |
| | | if self.collectionView == collectionView{ |
| | | return 0 |
| | | } |
| | | return 21 |
| | | } |
| | | } |
| | | } |