younger_times
2023-07-14 ca2a4ce89064be715e90ae60dc305c26e7dd5719
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()
    }
}